18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* SCTP kernel implementation 38c2ecf20Sopenharmony_ci * (C) Copyright IBM Corp. 2001, 2004 48c2ecf20Sopenharmony_ci * Copyright (c) 1999-2000 Cisco, Inc. 58c2ecf20Sopenharmony_ci * Copyright (c) 1999-2001 Motorola, Inc. 68c2ecf20Sopenharmony_ci * Copyright (c) 2001-2003 Intel Corp. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * This file is part of the SCTP kernel implementation 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * The base lksctp header. 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * Please send any bug reports or fixes you make to the 138c2ecf20Sopenharmony_ci * email address(es): 148c2ecf20Sopenharmony_ci * lksctp developers <linux-sctp@vger.kernel.org> 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * Written or modified by: 178c2ecf20Sopenharmony_ci * La Monte H.P. Yarroll <piggy@acm.org> 188c2ecf20Sopenharmony_ci * Xingang Guo <xingang.guo@intel.com> 198c2ecf20Sopenharmony_ci * Jon Grimm <jgrimm@us.ibm.com> 208c2ecf20Sopenharmony_ci * Daisy Chang <daisyc@us.ibm.com> 218c2ecf20Sopenharmony_ci * Sridhar Samudrala <sri@us.ibm.com> 228c2ecf20Sopenharmony_ci * Ardelle Fan <ardelle.fan@intel.com> 238c2ecf20Sopenharmony_ci * Ryan Layer <rmlayer@us.ibm.com> 248c2ecf20Sopenharmony_ci * Kevin Gao <kevin.gao@intel.com> 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#ifndef __net_sctp_h__ 288c2ecf20Sopenharmony_ci#define __net_sctp_h__ 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* Header Strategy. 318c2ecf20Sopenharmony_ci * Start getting some control over the header file depencies: 328c2ecf20Sopenharmony_ci * includes 338c2ecf20Sopenharmony_ci * constants 348c2ecf20Sopenharmony_ci * structs 358c2ecf20Sopenharmony_ci * prototypes 368c2ecf20Sopenharmony_ci * macros, externs, and inlines 378c2ecf20Sopenharmony_ci * 388c2ecf20Sopenharmony_ci * Move test_frame specific items out of the kernel headers 398c2ecf20Sopenharmony_ci * and into the test frame headers. This is not perfect in any sense 408c2ecf20Sopenharmony_ci * and will continue to evolve. 418c2ecf20Sopenharmony_ci */ 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#include <linux/types.h> 448c2ecf20Sopenharmony_ci#include <linux/slab.h> 458c2ecf20Sopenharmony_ci#include <linux/in.h> 468c2ecf20Sopenharmony_ci#include <linux/tty.h> 478c2ecf20Sopenharmony_ci#include <linux/proc_fs.h> 488c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 498c2ecf20Sopenharmony_ci#include <linux/jiffies.h> 508c2ecf20Sopenharmony_ci#include <linux/idr.h> 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_IPV6) 538c2ecf20Sopenharmony_ci#include <net/ipv6.h> 548c2ecf20Sopenharmony_ci#include <net/ip6_route.h> 558c2ecf20Sopenharmony_ci#endif 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#include <linux/uaccess.h> 588c2ecf20Sopenharmony_ci#include <asm/page.h> 598c2ecf20Sopenharmony_ci#include <net/sock.h> 608c2ecf20Sopenharmony_ci#include <net/snmp.h> 618c2ecf20Sopenharmony_ci#include <net/sctp/structs.h> 628c2ecf20Sopenharmony_ci#include <net/sctp/constants.h> 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#ifdef CONFIG_IP_SCTP_MODULE 658c2ecf20Sopenharmony_ci#define SCTP_PROTOSW_FLAG 0 668c2ecf20Sopenharmony_ci#else /* static! */ 678c2ecf20Sopenharmony_ci#define SCTP_PROTOSW_FLAG INET_PROTOSW_PERMANENT 688c2ecf20Sopenharmony_ci#endif 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/* Round an int up to the next multiple of 4. */ 718c2ecf20Sopenharmony_ci#define SCTP_PAD4(s) (((s)+3)&~3) 728c2ecf20Sopenharmony_ci/* Truncate to the previous multiple of 4. */ 738c2ecf20Sopenharmony_ci#define SCTP_TRUNC4(s) ((s)&~3) 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* 768c2ecf20Sopenharmony_ci * Function declarations. 778c2ecf20Sopenharmony_ci */ 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* 808c2ecf20Sopenharmony_ci * sctp/protocol.c 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_ciint sctp_copy_local_addr_list(struct net *net, struct sctp_bind_addr *addr, 838c2ecf20Sopenharmony_ci enum sctp_scope, gfp_t gfp, int flags); 848c2ecf20Sopenharmony_cistruct sctp_pf *sctp_get_pf_specific(sa_family_t family); 858c2ecf20Sopenharmony_ciint sctp_register_pf(struct sctp_pf *, sa_family_t); 868c2ecf20Sopenharmony_civoid sctp_addr_wq_mgmt(struct net *, struct sctp_sockaddr_entry *, int); 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* 898c2ecf20Sopenharmony_ci * sctp/socket.c 908c2ecf20Sopenharmony_ci */ 918c2ecf20Sopenharmony_ciint sctp_inet_connect(struct socket *sock, struct sockaddr *uaddr, 928c2ecf20Sopenharmony_ci int addr_len, int flags); 938c2ecf20Sopenharmony_ciint sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb); 948c2ecf20Sopenharmony_ciint sctp_inet_listen(struct socket *sock, int backlog); 958c2ecf20Sopenharmony_civoid sctp_write_space(struct sock *sk); 968c2ecf20Sopenharmony_civoid sctp_data_ready(struct sock *sk); 978c2ecf20Sopenharmony_ci__poll_t sctp_poll(struct file *file, struct socket *sock, 988c2ecf20Sopenharmony_ci poll_table *wait); 998c2ecf20Sopenharmony_civoid sctp_sock_rfree(struct sk_buff *skb); 1008c2ecf20Sopenharmony_civoid sctp_copy_sock(struct sock *newsk, struct sock *sk, 1018c2ecf20Sopenharmony_ci struct sctp_association *asoc); 1028c2ecf20Sopenharmony_ciextern struct percpu_counter sctp_sockets_allocated; 1038c2ecf20Sopenharmony_ciint sctp_asconf_mgmt(struct sctp_sock *, struct sctp_sockaddr_entry *); 1048c2ecf20Sopenharmony_cistruct sk_buff *sctp_skb_recv_datagram(struct sock *, int, int, int *); 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_citypedef int (*sctp_callback_t)(struct sctp_endpoint *, struct sctp_transport *, void *); 1078c2ecf20Sopenharmony_civoid sctp_transport_walk_start(struct rhashtable_iter *iter); 1088c2ecf20Sopenharmony_civoid sctp_transport_walk_stop(struct rhashtable_iter *iter); 1098c2ecf20Sopenharmony_cistruct sctp_transport *sctp_transport_get_next(struct net *net, 1108c2ecf20Sopenharmony_ci struct rhashtable_iter *iter); 1118c2ecf20Sopenharmony_cistruct sctp_transport *sctp_transport_get_idx(struct net *net, 1128c2ecf20Sopenharmony_ci struct rhashtable_iter *iter, int pos); 1138c2ecf20Sopenharmony_ciint sctp_transport_lookup_process(int (*cb)(struct sctp_transport *, void *), 1148c2ecf20Sopenharmony_ci struct net *net, 1158c2ecf20Sopenharmony_ci const union sctp_addr *laddr, 1168c2ecf20Sopenharmony_ci const union sctp_addr *paddr, void *p); 1178c2ecf20Sopenharmony_ciint sctp_transport_traverse_process(sctp_callback_t cb, sctp_callback_t cb_done, 1188c2ecf20Sopenharmony_ci struct net *net, int *pos, void *p); 1198c2ecf20Sopenharmony_ciint sctp_for_each_endpoint(int (*cb)(struct sctp_endpoint *, void *), void *p); 1208c2ecf20Sopenharmony_ciint sctp_get_sctp_info(struct sock *sk, struct sctp_association *asoc, 1218c2ecf20Sopenharmony_ci struct sctp_info *info); 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci/* 1248c2ecf20Sopenharmony_ci * sctp/primitive.c 1258c2ecf20Sopenharmony_ci */ 1268c2ecf20Sopenharmony_ciint sctp_primitive_ASSOCIATE(struct net *, struct sctp_association *, void *arg); 1278c2ecf20Sopenharmony_ciint sctp_primitive_SHUTDOWN(struct net *, struct sctp_association *, void *arg); 1288c2ecf20Sopenharmony_ciint sctp_primitive_ABORT(struct net *, struct sctp_association *, void *arg); 1298c2ecf20Sopenharmony_ciint sctp_primitive_SEND(struct net *, struct sctp_association *, void *arg); 1308c2ecf20Sopenharmony_ciint sctp_primitive_REQUESTHEARTBEAT(struct net *, struct sctp_association *, void *arg); 1318c2ecf20Sopenharmony_ciint sctp_primitive_ASCONF(struct net *, struct sctp_association *, void *arg); 1328c2ecf20Sopenharmony_ciint sctp_primitive_RECONF(struct net *net, struct sctp_association *asoc, 1338c2ecf20Sopenharmony_ci void *arg); 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci/* 1368c2ecf20Sopenharmony_ci * sctp/input.c 1378c2ecf20Sopenharmony_ci */ 1388c2ecf20Sopenharmony_ciint sctp_rcv(struct sk_buff *skb); 1398c2ecf20Sopenharmony_ciint sctp_v4_err(struct sk_buff *skb, u32 info); 1408c2ecf20Sopenharmony_ciint sctp_hash_endpoint(struct sctp_endpoint *ep); 1418c2ecf20Sopenharmony_civoid sctp_unhash_endpoint(struct sctp_endpoint *); 1428c2ecf20Sopenharmony_cistruct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *, 1438c2ecf20Sopenharmony_ci struct sctphdr *, struct sctp_association **, 1448c2ecf20Sopenharmony_ci struct sctp_transport **); 1458c2ecf20Sopenharmony_civoid sctp_err_finish(struct sock *, struct sctp_transport *); 1468c2ecf20Sopenharmony_civoid sctp_icmp_frag_needed(struct sock *, struct sctp_association *, 1478c2ecf20Sopenharmony_ci struct sctp_transport *t, __u32 pmtu); 1488c2ecf20Sopenharmony_civoid sctp_icmp_redirect(struct sock *, struct sctp_transport *, 1498c2ecf20Sopenharmony_ci struct sk_buff *); 1508c2ecf20Sopenharmony_civoid sctp_icmp_proto_unreachable(struct sock *sk, 1518c2ecf20Sopenharmony_ci struct sctp_association *asoc, 1528c2ecf20Sopenharmony_ci struct sctp_transport *t); 1538c2ecf20Sopenharmony_civoid sctp_backlog_migrate(struct sctp_association *assoc, 1548c2ecf20Sopenharmony_ci struct sock *oldsk, struct sock *newsk); 1558c2ecf20Sopenharmony_ciint sctp_transport_hashtable_init(void); 1568c2ecf20Sopenharmony_civoid sctp_transport_hashtable_destroy(void); 1578c2ecf20Sopenharmony_ciint sctp_hash_transport(struct sctp_transport *t); 1588c2ecf20Sopenharmony_civoid sctp_unhash_transport(struct sctp_transport *t); 1598c2ecf20Sopenharmony_cistruct sctp_transport *sctp_addrs_lookup_transport( 1608c2ecf20Sopenharmony_ci struct net *net, 1618c2ecf20Sopenharmony_ci const union sctp_addr *laddr, 1628c2ecf20Sopenharmony_ci const union sctp_addr *paddr); 1638c2ecf20Sopenharmony_cistruct sctp_transport *sctp_epaddr_lookup_transport( 1648c2ecf20Sopenharmony_ci const struct sctp_endpoint *ep, 1658c2ecf20Sopenharmony_ci const union sctp_addr *paddr); 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci/* 1688c2ecf20Sopenharmony_ci * sctp/proc.c 1698c2ecf20Sopenharmony_ci */ 1708c2ecf20Sopenharmony_ciint __net_init sctp_proc_init(struct net *net); 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci/* 1738c2ecf20Sopenharmony_ci * sctp/offload.c 1748c2ecf20Sopenharmony_ci */ 1758c2ecf20Sopenharmony_ciint sctp_offload_init(void); 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci/* 1788c2ecf20Sopenharmony_ci * sctp/stream_sched.c 1798c2ecf20Sopenharmony_ci */ 1808c2ecf20Sopenharmony_civoid sctp_sched_ops_init(void); 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci/* 1838c2ecf20Sopenharmony_ci * sctp/stream.c 1848c2ecf20Sopenharmony_ci */ 1858c2ecf20Sopenharmony_ciint sctp_send_reset_streams(struct sctp_association *asoc, 1868c2ecf20Sopenharmony_ci struct sctp_reset_streams *params); 1878c2ecf20Sopenharmony_ciint sctp_send_reset_assoc(struct sctp_association *asoc); 1888c2ecf20Sopenharmony_ciint sctp_send_add_streams(struct sctp_association *asoc, 1898c2ecf20Sopenharmony_ci struct sctp_add_streams *params); 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci/* 1928c2ecf20Sopenharmony_ci * Module global variables 1938c2ecf20Sopenharmony_ci */ 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci /* 1968c2ecf20Sopenharmony_ci * sctp/protocol.c 1978c2ecf20Sopenharmony_ci */ 1988c2ecf20Sopenharmony_ciextern struct kmem_cache *sctp_chunk_cachep __read_mostly; 1998c2ecf20Sopenharmony_ciextern struct kmem_cache *sctp_bucket_cachep __read_mostly; 2008c2ecf20Sopenharmony_ciextern long sysctl_sctp_mem[3]; 2018c2ecf20Sopenharmony_ciextern int sysctl_sctp_rmem[3]; 2028c2ecf20Sopenharmony_ciextern int sysctl_sctp_wmem[3]; 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci/* 2058c2ecf20Sopenharmony_ci * Section: Macros, externs, and inlines 2068c2ecf20Sopenharmony_ci */ 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci/* SCTP SNMP MIB stats handlers */ 2098c2ecf20Sopenharmony_ci#define SCTP_INC_STATS(net, field) SNMP_INC_STATS((net)->sctp.sctp_statistics, field) 2108c2ecf20Sopenharmony_ci#define __SCTP_INC_STATS(net, field) __SNMP_INC_STATS((net)->sctp.sctp_statistics, field) 2118c2ecf20Sopenharmony_ci#define SCTP_DEC_STATS(net, field) SNMP_DEC_STATS((net)->sctp.sctp_statistics, field) 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci/* sctp mib definitions */ 2148c2ecf20Sopenharmony_cienum { 2158c2ecf20Sopenharmony_ci SCTP_MIB_NUM = 0, 2168c2ecf20Sopenharmony_ci SCTP_MIB_CURRESTAB, /* CurrEstab */ 2178c2ecf20Sopenharmony_ci SCTP_MIB_ACTIVEESTABS, /* ActiveEstabs */ 2188c2ecf20Sopenharmony_ci SCTP_MIB_PASSIVEESTABS, /* PassiveEstabs */ 2198c2ecf20Sopenharmony_ci SCTP_MIB_ABORTEDS, /* Aborteds */ 2208c2ecf20Sopenharmony_ci SCTP_MIB_SHUTDOWNS, /* Shutdowns */ 2218c2ecf20Sopenharmony_ci SCTP_MIB_OUTOFBLUES, /* OutOfBlues */ 2228c2ecf20Sopenharmony_ci SCTP_MIB_CHECKSUMERRORS, /* ChecksumErrors */ 2238c2ecf20Sopenharmony_ci SCTP_MIB_OUTCTRLCHUNKS, /* OutCtrlChunks */ 2248c2ecf20Sopenharmony_ci SCTP_MIB_OUTORDERCHUNKS, /* OutOrderChunks */ 2258c2ecf20Sopenharmony_ci SCTP_MIB_OUTUNORDERCHUNKS, /* OutUnorderChunks */ 2268c2ecf20Sopenharmony_ci SCTP_MIB_INCTRLCHUNKS, /* InCtrlChunks */ 2278c2ecf20Sopenharmony_ci SCTP_MIB_INORDERCHUNKS, /* InOrderChunks */ 2288c2ecf20Sopenharmony_ci SCTP_MIB_INUNORDERCHUNKS, /* InUnorderChunks */ 2298c2ecf20Sopenharmony_ci SCTP_MIB_FRAGUSRMSGS, /* FragUsrMsgs */ 2308c2ecf20Sopenharmony_ci SCTP_MIB_REASMUSRMSGS, /* ReasmUsrMsgs */ 2318c2ecf20Sopenharmony_ci SCTP_MIB_OUTSCTPPACKS, /* OutSCTPPacks */ 2328c2ecf20Sopenharmony_ci SCTP_MIB_INSCTPPACKS, /* InSCTPPacks */ 2338c2ecf20Sopenharmony_ci SCTP_MIB_T1_INIT_EXPIREDS, 2348c2ecf20Sopenharmony_ci SCTP_MIB_T1_COOKIE_EXPIREDS, 2358c2ecf20Sopenharmony_ci SCTP_MIB_T2_SHUTDOWN_EXPIREDS, 2368c2ecf20Sopenharmony_ci SCTP_MIB_T3_RTX_EXPIREDS, 2378c2ecf20Sopenharmony_ci SCTP_MIB_T4_RTO_EXPIREDS, 2388c2ecf20Sopenharmony_ci SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS, 2398c2ecf20Sopenharmony_ci SCTP_MIB_DELAY_SACK_EXPIREDS, 2408c2ecf20Sopenharmony_ci SCTP_MIB_AUTOCLOSE_EXPIREDS, 2418c2ecf20Sopenharmony_ci SCTP_MIB_T1_RETRANSMITS, 2428c2ecf20Sopenharmony_ci SCTP_MIB_T3_RETRANSMITS, 2438c2ecf20Sopenharmony_ci SCTP_MIB_PMTUD_RETRANSMITS, 2448c2ecf20Sopenharmony_ci SCTP_MIB_FAST_RETRANSMITS, 2458c2ecf20Sopenharmony_ci SCTP_MIB_IN_PKT_SOFTIRQ, 2468c2ecf20Sopenharmony_ci SCTP_MIB_IN_PKT_BACKLOG, 2478c2ecf20Sopenharmony_ci SCTP_MIB_IN_PKT_DISCARDS, 2488c2ecf20Sopenharmony_ci SCTP_MIB_IN_DATA_CHUNK_DISCARDS, 2498c2ecf20Sopenharmony_ci __SCTP_MIB_MAX 2508c2ecf20Sopenharmony_ci}; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci#define SCTP_MIB_MAX __SCTP_MIB_MAX 2538c2ecf20Sopenharmony_cistruct sctp_mib { 2548c2ecf20Sopenharmony_ci unsigned long mibs[SCTP_MIB_MAX]; 2558c2ecf20Sopenharmony_ci}; 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci/* helper function to track stats about max rto and related transport */ 2588c2ecf20Sopenharmony_cistatic inline void sctp_max_rto(struct sctp_association *asoc, 2598c2ecf20Sopenharmony_ci struct sctp_transport *trans) 2608c2ecf20Sopenharmony_ci{ 2618c2ecf20Sopenharmony_ci if (asoc->stats.max_obs_rto < (__u64)trans->rto) { 2628c2ecf20Sopenharmony_ci asoc->stats.max_obs_rto = trans->rto; 2638c2ecf20Sopenharmony_ci memset(&asoc->stats.obs_rto_ipaddr, 0, 2648c2ecf20Sopenharmony_ci sizeof(struct sockaddr_storage)); 2658c2ecf20Sopenharmony_ci memcpy(&asoc->stats.obs_rto_ipaddr, &trans->ipaddr, 2668c2ecf20Sopenharmony_ci trans->af_specific->sockaddr_len); 2678c2ecf20Sopenharmony_ci } 2688c2ecf20Sopenharmony_ci} 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci/* 2718c2ecf20Sopenharmony_ci * Macros for keeping a global reference of object allocations. 2728c2ecf20Sopenharmony_ci */ 2738c2ecf20Sopenharmony_ci#ifdef CONFIG_SCTP_DBG_OBJCNT 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ciextern atomic_t sctp_dbg_objcnt_sock; 2768c2ecf20Sopenharmony_ciextern atomic_t sctp_dbg_objcnt_ep; 2778c2ecf20Sopenharmony_ciextern atomic_t sctp_dbg_objcnt_assoc; 2788c2ecf20Sopenharmony_ciextern atomic_t sctp_dbg_objcnt_transport; 2798c2ecf20Sopenharmony_ciextern atomic_t sctp_dbg_objcnt_chunk; 2808c2ecf20Sopenharmony_ciextern atomic_t sctp_dbg_objcnt_bind_addr; 2818c2ecf20Sopenharmony_ciextern atomic_t sctp_dbg_objcnt_bind_bucket; 2828c2ecf20Sopenharmony_ciextern atomic_t sctp_dbg_objcnt_addr; 2838c2ecf20Sopenharmony_ciextern atomic_t sctp_dbg_objcnt_datamsg; 2848c2ecf20Sopenharmony_ciextern atomic_t sctp_dbg_objcnt_keys; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci/* Macros to atomically increment/decrement objcnt counters. */ 2878c2ecf20Sopenharmony_ci#define SCTP_DBG_OBJCNT_INC(name) \ 2888c2ecf20Sopenharmony_ciatomic_inc(&sctp_dbg_objcnt_## name) 2898c2ecf20Sopenharmony_ci#define SCTP_DBG_OBJCNT_DEC(name) \ 2908c2ecf20Sopenharmony_ciatomic_dec(&sctp_dbg_objcnt_## name) 2918c2ecf20Sopenharmony_ci#define SCTP_DBG_OBJCNT(name) \ 2928c2ecf20Sopenharmony_ciatomic_t sctp_dbg_objcnt_## name = ATOMIC_INIT(0) 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci/* Macro to help create new entries in the global array of 2958c2ecf20Sopenharmony_ci * objcnt counters. 2968c2ecf20Sopenharmony_ci */ 2978c2ecf20Sopenharmony_ci#define SCTP_DBG_OBJCNT_ENTRY(name) \ 2988c2ecf20Sopenharmony_ci{.label= #name, .counter= &sctp_dbg_objcnt_## name} 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_civoid sctp_dbg_objcnt_init(struct net *); 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci#else 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci#define SCTP_DBG_OBJCNT_INC(name) 3058c2ecf20Sopenharmony_ci#define SCTP_DBG_OBJCNT_DEC(name) 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_cistatic inline void sctp_dbg_objcnt_init(struct net *net) { return; } 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci#endif /* CONFIG_SCTP_DBG_OBJCOUNT */ 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci#if defined CONFIG_SYSCTL 3128c2ecf20Sopenharmony_civoid sctp_sysctl_register(void); 3138c2ecf20Sopenharmony_civoid sctp_sysctl_unregister(void); 3148c2ecf20Sopenharmony_ciint sctp_sysctl_net_register(struct net *net); 3158c2ecf20Sopenharmony_civoid sctp_sysctl_net_unregister(struct net *net); 3168c2ecf20Sopenharmony_ci#else 3178c2ecf20Sopenharmony_cistatic inline void sctp_sysctl_register(void) { return; } 3188c2ecf20Sopenharmony_cistatic inline void sctp_sysctl_unregister(void) { return; } 3198c2ecf20Sopenharmony_cistatic inline int sctp_sysctl_net_register(struct net *net) { return 0; } 3208c2ecf20Sopenharmony_cistatic inline void sctp_sysctl_net_unregister(struct net *net) { return; } 3218c2ecf20Sopenharmony_ci#endif 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci/* Size of Supported Address Parameter for 'x' address types. */ 3248c2ecf20Sopenharmony_ci#define SCTP_SAT_LEN(x) (sizeof(struct sctp_paramhdr) + (x) * sizeof(__u16)) 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_IPV6) 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_civoid sctp_v6_pf_init(void); 3298c2ecf20Sopenharmony_civoid sctp_v6_pf_exit(void); 3308c2ecf20Sopenharmony_ciint sctp_v6_protosw_init(void); 3318c2ecf20Sopenharmony_civoid sctp_v6_protosw_exit(void); 3328c2ecf20Sopenharmony_ciint sctp_v6_add_protocol(void); 3338c2ecf20Sopenharmony_civoid sctp_v6_del_protocol(void); 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci#else /* #ifdef defined(CONFIG_IPV6) */ 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_cistatic inline void sctp_v6_pf_init(void) { return; } 3388c2ecf20Sopenharmony_cistatic inline void sctp_v6_pf_exit(void) { return; } 3398c2ecf20Sopenharmony_cistatic inline int sctp_v6_protosw_init(void) { return 0; } 3408c2ecf20Sopenharmony_cistatic inline void sctp_v6_protosw_exit(void) { return; } 3418c2ecf20Sopenharmony_cistatic inline int sctp_v6_add_protocol(void) { return 0; } 3428c2ecf20Sopenharmony_cistatic inline void sctp_v6_del_protocol(void) { return; } 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci#endif /* #if defined(CONFIG_IPV6) */ 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_ci/* Map an association to an assoc_id. */ 3488c2ecf20Sopenharmony_cistatic inline sctp_assoc_t sctp_assoc2id(const struct sctp_association *asoc) 3498c2ecf20Sopenharmony_ci{ 3508c2ecf20Sopenharmony_ci return asoc ? asoc->assoc_id : 0; 3518c2ecf20Sopenharmony_ci} 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_cistatic inline enum sctp_sstat_state 3548c2ecf20Sopenharmony_cisctp_assoc_to_state(const struct sctp_association *asoc) 3558c2ecf20Sopenharmony_ci{ 3568c2ecf20Sopenharmony_ci /* SCTP's uapi always had SCTP_EMPTY(=0) as a dummy state, but we 3578c2ecf20Sopenharmony_ci * got rid of it in kernel space. Therefore SCTP_CLOSED et al 3588c2ecf20Sopenharmony_ci * start at =1 in user space, but actually as =0 in kernel space. 3598c2ecf20Sopenharmony_ci * Now that we can not break user space and SCTP_EMPTY is exposed 3608c2ecf20Sopenharmony_ci * there, we need to fix it up with an ugly offset not to break 3618c2ecf20Sopenharmony_ci * applications. :( 3628c2ecf20Sopenharmony_ci */ 3638c2ecf20Sopenharmony_ci return asoc->state + 1; 3648c2ecf20Sopenharmony_ci} 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci/* Look up the association by its id. */ 3678c2ecf20Sopenharmony_cistruct sctp_association *sctp_id2assoc(struct sock *sk, sctp_assoc_t id); 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ciint sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp); 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci/* A macro to walk a list of skbs. */ 3728c2ecf20Sopenharmony_ci#define sctp_skb_for_each(pos, head, tmp) \ 3738c2ecf20Sopenharmony_ci skb_queue_walk_safe(head, pos, tmp) 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci/** 3768c2ecf20Sopenharmony_ci * sctp_list_dequeue - remove from the head of the queue 3778c2ecf20Sopenharmony_ci * @list: list to dequeue from 3788c2ecf20Sopenharmony_ci * 3798c2ecf20Sopenharmony_ci * Remove the head of the list. The head item is 3808c2ecf20Sopenharmony_ci * returned or %NULL if the list is empty. 3818c2ecf20Sopenharmony_ci */ 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_cistatic inline struct list_head *sctp_list_dequeue(struct list_head *list) 3848c2ecf20Sopenharmony_ci{ 3858c2ecf20Sopenharmony_ci struct list_head *result = NULL; 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ci if (!list_empty(list)) { 3888c2ecf20Sopenharmony_ci result = list->next; 3898c2ecf20Sopenharmony_ci list_del_init(result); 3908c2ecf20Sopenharmony_ci } 3918c2ecf20Sopenharmony_ci return result; 3928c2ecf20Sopenharmony_ci} 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci/* SCTP version of skb_set_owner_r. We need this one because 3958c2ecf20Sopenharmony_ci * of the way we have to do receive buffer accounting on bundled 3968c2ecf20Sopenharmony_ci * chunks. 3978c2ecf20Sopenharmony_ci */ 3988c2ecf20Sopenharmony_cistatic inline void sctp_skb_set_owner_r(struct sk_buff *skb, struct sock *sk) 3998c2ecf20Sopenharmony_ci{ 4008c2ecf20Sopenharmony_ci struct sctp_ulpevent *event = sctp_skb2event(skb); 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ci skb_orphan(skb); 4038c2ecf20Sopenharmony_ci skb->sk = sk; 4048c2ecf20Sopenharmony_ci skb->destructor = sctp_sock_rfree; 4058c2ecf20Sopenharmony_ci atomic_add(event->rmem_len, &sk->sk_rmem_alloc); 4068c2ecf20Sopenharmony_ci /* 4078c2ecf20Sopenharmony_ci * This mimics the behavior of skb_set_owner_r 4088c2ecf20Sopenharmony_ci */ 4098c2ecf20Sopenharmony_ci sk_mem_charge(sk, event->rmem_len); 4108c2ecf20Sopenharmony_ci} 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci/* Tests if the list has one and only one entry. */ 4138c2ecf20Sopenharmony_cistatic inline int sctp_list_single_entry(struct list_head *head) 4148c2ecf20Sopenharmony_ci{ 4158c2ecf20Sopenharmony_ci return list_is_singular(head); 4168c2ecf20Sopenharmony_ci} 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_cistatic inline bool sctp_chunk_pending(const struct sctp_chunk *chunk) 4198c2ecf20Sopenharmony_ci{ 4208c2ecf20Sopenharmony_ci return !list_empty(&chunk->list); 4218c2ecf20Sopenharmony_ci} 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ci/* Walk through a list of TLV parameters. Don't trust the 4248c2ecf20Sopenharmony_ci * individual parameter lengths and instead depend on 4258c2ecf20Sopenharmony_ci * the chunk length to indicate when to stop. Make sure 4268c2ecf20Sopenharmony_ci * there is room for a param header too. 4278c2ecf20Sopenharmony_ci */ 4288c2ecf20Sopenharmony_ci#define sctp_walk_params(pos, chunk, member)\ 4298c2ecf20Sopenharmony_ci_sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member) 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ci#define _sctp_walk_params(pos, chunk, end, member)\ 4328c2ecf20Sopenharmony_cifor (pos.v = chunk->member;\ 4338c2ecf20Sopenharmony_ci (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <=\ 4348c2ecf20Sopenharmony_ci (void *)chunk + end) &&\ 4358c2ecf20Sopenharmony_ci pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\ 4368c2ecf20Sopenharmony_ci ntohs(pos.p->length) >= sizeof(struct sctp_paramhdr);\ 4378c2ecf20Sopenharmony_ci pos.v += SCTP_PAD4(ntohs(pos.p->length))) 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci#define sctp_walk_errors(err, chunk_hdr)\ 4408c2ecf20Sopenharmony_ci_sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length)) 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_ci#define _sctp_walk_errors(err, chunk_hdr, end)\ 4438c2ecf20Sopenharmony_cifor (err = (struct sctp_errhdr *)((void *)chunk_hdr + \ 4448c2ecf20Sopenharmony_ci sizeof(struct sctp_chunkhdr));\ 4458c2ecf20Sopenharmony_ci ((void *)err + offsetof(struct sctp_errhdr, length) + sizeof(err->length) <=\ 4468c2ecf20Sopenharmony_ci (void *)chunk_hdr + end) &&\ 4478c2ecf20Sopenharmony_ci (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\ 4488c2ecf20Sopenharmony_ci ntohs(err->length) >= sizeof(struct sctp_errhdr); \ 4498c2ecf20Sopenharmony_ci err = (struct sctp_errhdr *)((void *)err + SCTP_PAD4(ntohs(err->length)))) 4508c2ecf20Sopenharmony_ci 4518c2ecf20Sopenharmony_ci#define sctp_walk_fwdtsn(pos, chunk)\ 4528c2ecf20Sopenharmony_ci_sctp_walk_fwdtsn((pos), (chunk), ntohs((chunk)->chunk_hdr->length) - sizeof(struct sctp_fwdtsn_chunk)) 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci#define _sctp_walk_fwdtsn(pos, chunk, end)\ 4558c2ecf20Sopenharmony_cifor (pos = chunk->subh.fwdtsn_hdr->skip;\ 4568c2ecf20Sopenharmony_ci (void *)pos <= (void *)chunk->subh.fwdtsn_hdr->skip + end - sizeof(struct sctp_fwdtsn_skip);\ 4578c2ecf20Sopenharmony_ci pos++) 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_ci/* External references. */ 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_ciextern struct proto sctp_prot; 4628c2ecf20Sopenharmony_ciextern struct proto sctpv6_prot; 4638c2ecf20Sopenharmony_civoid sctp_put_port(struct sock *sk); 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_ciextern struct idr sctp_assocs_id; 4668c2ecf20Sopenharmony_ciextern spinlock_t sctp_assocs_id_lock; 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_ci/* Static inline functions. */ 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci/* Convert from an IP version number to an Address Family symbol. */ 4718c2ecf20Sopenharmony_cistatic inline int ipver2af(__u8 ipver) 4728c2ecf20Sopenharmony_ci{ 4738c2ecf20Sopenharmony_ci switch (ipver) { 4748c2ecf20Sopenharmony_ci case 4: 4758c2ecf20Sopenharmony_ci return AF_INET; 4768c2ecf20Sopenharmony_ci case 6: 4778c2ecf20Sopenharmony_ci return AF_INET6; 4788c2ecf20Sopenharmony_ci default: 4798c2ecf20Sopenharmony_ci return 0; 4808c2ecf20Sopenharmony_ci } 4818c2ecf20Sopenharmony_ci} 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_ci/* Convert from an address parameter type to an address family. */ 4848c2ecf20Sopenharmony_cistatic inline int param_type2af(__be16 type) 4858c2ecf20Sopenharmony_ci{ 4868c2ecf20Sopenharmony_ci switch (type) { 4878c2ecf20Sopenharmony_ci case SCTP_PARAM_IPV4_ADDRESS: 4888c2ecf20Sopenharmony_ci return AF_INET; 4898c2ecf20Sopenharmony_ci case SCTP_PARAM_IPV6_ADDRESS: 4908c2ecf20Sopenharmony_ci return AF_INET6; 4918c2ecf20Sopenharmony_ci default: 4928c2ecf20Sopenharmony_ci return 0; 4938c2ecf20Sopenharmony_ci } 4948c2ecf20Sopenharmony_ci} 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci/* Warning: The following hash functions assume a power of two 'size'. */ 4978c2ecf20Sopenharmony_ci/* This is the hash function for the SCTP port hash table. */ 4988c2ecf20Sopenharmony_cistatic inline int sctp_phashfn(struct net *net, __u16 lport) 4998c2ecf20Sopenharmony_ci{ 5008c2ecf20Sopenharmony_ci return (net_hash_mix(net) + lport) & (sctp_port_hashsize - 1); 5018c2ecf20Sopenharmony_ci} 5028c2ecf20Sopenharmony_ci 5038c2ecf20Sopenharmony_ci/* This is the hash function for the endpoint hash table. */ 5048c2ecf20Sopenharmony_cistatic inline int sctp_ep_hashfn(struct net *net, __u16 lport) 5058c2ecf20Sopenharmony_ci{ 5068c2ecf20Sopenharmony_ci return (net_hash_mix(net) + lport) & (sctp_ep_hashsize - 1); 5078c2ecf20Sopenharmony_ci} 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci#define sctp_for_each_hentry(epb, head) \ 5108c2ecf20Sopenharmony_ci hlist_for_each_entry(epb, head, node) 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_ci/* Is a socket of this style? */ 5138c2ecf20Sopenharmony_ci#define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style)) 5148c2ecf20Sopenharmony_cistatic inline int __sctp_style(const struct sock *sk, 5158c2ecf20Sopenharmony_ci enum sctp_socket_type style) 5168c2ecf20Sopenharmony_ci{ 5178c2ecf20Sopenharmony_ci return sctp_sk(sk)->type == style; 5188c2ecf20Sopenharmony_ci} 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci/* Is the association in this state? */ 5218c2ecf20Sopenharmony_ci#define sctp_state(asoc, state) __sctp_state((asoc), (SCTP_STATE_##state)) 5228c2ecf20Sopenharmony_cistatic inline int __sctp_state(const struct sctp_association *asoc, 5238c2ecf20Sopenharmony_ci enum sctp_state state) 5248c2ecf20Sopenharmony_ci{ 5258c2ecf20Sopenharmony_ci return asoc->state == state; 5268c2ecf20Sopenharmony_ci} 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_ci/* Is the socket in this state? */ 5298c2ecf20Sopenharmony_ci#define sctp_sstate(sk, state) __sctp_sstate((sk), (SCTP_SS_##state)) 5308c2ecf20Sopenharmony_cistatic inline int __sctp_sstate(const struct sock *sk, 5318c2ecf20Sopenharmony_ci enum sctp_sock_state state) 5328c2ecf20Sopenharmony_ci{ 5338c2ecf20Sopenharmony_ci return sk->sk_state == state; 5348c2ecf20Sopenharmony_ci} 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_ci/* Map v4-mapped v6 address back to v4 address */ 5378c2ecf20Sopenharmony_cistatic inline void sctp_v6_map_v4(union sctp_addr *addr) 5388c2ecf20Sopenharmony_ci{ 5398c2ecf20Sopenharmony_ci addr->v4.sin_family = AF_INET; 5408c2ecf20Sopenharmony_ci addr->v4.sin_port = addr->v6.sin6_port; 5418c2ecf20Sopenharmony_ci addr->v4.sin_addr.s_addr = addr->v6.sin6_addr.s6_addr32[3]; 5428c2ecf20Sopenharmony_ci} 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci/* Map v4 address to v4-mapped v6 address */ 5458c2ecf20Sopenharmony_cistatic inline void sctp_v4_map_v6(union sctp_addr *addr) 5468c2ecf20Sopenharmony_ci{ 5478c2ecf20Sopenharmony_ci __be16 port; 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_ci port = addr->v4.sin_port; 5508c2ecf20Sopenharmony_ci addr->v6.sin6_addr.s6_addr32[3] = addr->v4.sin_addr.s_addr; 5518c2ecf20Sopenharmony_ci addr->v6.sin6_port = port; 5528c2ecf20Sopenharmony_ci addr->v6.sin6_family = AF_INET6; 5538c2ecf20Sopenharmony_ci addr->v6.sin6_flowinfo = 0; 5548c2ecf20Sopenharmony_ci addr->v6.sin6_scope_id = 0; 5558c2ecf20Sopenharmony_ci addr->v6.sin6_addr.s6_addr32[0] = 0; 5568c2ecf20Sopenharmony_ci addr->v6.sin6_addr.s6_addr32[1] = 0; 5578c2ecf20Sopenharmony_ci addr->v6.sin6_addr.s6_addr32[2] = htonl(0x0000ffff); 5588c2ecf20Sopenharmony_ci} 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci/* The cookie is always 0 since this is how it's used in the 5618c2ecf20Sopenharmony_ci * pmtu code. 5628c2ecf20Sopenharmony_ci */ 5638c2ecf20Sopenharmony_cistatic inline struct dst_entry *sctp_transport_dst_check(struct sctp_transport *t) 5648c2ecf20Sopenharmony_ci{ 5658c2ecf20Sopenharmony_ci if (t->dst && !dst_check(t->dst, t->dst_cookie)) 5668c2ecf20Sopenharmony_ci sctp_transport_dst_release(t); 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci return t->dst; 5698c2ecf20Sopenharmony_ci} 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_ci/* Calculate max payload size given a MTU, or the total overhead if 5728c2ecf20Sopenharmony_ci * given MTU is zero 5738c2ecf20Sopenharmony_ci */ 5748c2ecf20Sopenharmony_cistatic inline __u32 sctp_mtu_payload(const struct sctp_sock *sp, 5758c2ecf20Sopenharmony_ci __u32 mtu, __u32 extra) 5768c2ecf20Sopenharmony_ci{ 5778c2ecf20Sopenharmony_ci __u32 overhead = sizeof(struct sctphdr) + extra; 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci if (sp) 5808c2ecf20Sopenharmony_ci overhead += sp->pf->af->net_header_len; 5818c2ecf20Sopenharmony_ci else 5828c2ecf20Sopenharmony_ci overhead += sizeof(struct ipv6hdr); 5838c2ecf20Sopenharmony_ci 5848c2ecf20Sopenharmony_ci if (WARN_ON_ONCE(mtu && mtu <= overhead)) 5858c2ecf20Sopenharmony_ci mtu = overhead; 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_ci return mtu ? mtu - overhead : overhead; 5888c2ecf20Sopenharmony_ci} 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_cistatic inline __u32 sctp_dst_mtu(const struct dst_entry *dst) 5918c2ecf20Sopenharmony_ci{ 5928c2ecf20Sopenharmony_ci return SCTP_TRUNC4(max_t(__u32, dst_mtu(dst), 5938c2ecf20Sopenharmony_ci SCTP_DEFAULT_MINSEGMENT)); 5948c2ecf20Sopenharmony_ci} 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_cistatic inline bool sctp_transport_pmtu_check(struct sctp_transport *t) 5978c2ecf20Sopenharmony_ci{ 5988c2ecf20Sopenharmony_ci __u32 pmtu = sctp_dst_mtu(t->dst); 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ci if (t->pathmtu == pmtu) 6018c2ecf20Sopenharmony_ci return true; 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_ci t->pathmtu = pmtu; 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci return false; 6068c2ecf20Sopenharmony_ci} 6078c2ecf20Sopenharmony_ci 6088c2ecf20Sopenharmony_cistatic inline __u32 sctp_min_frag_point(struct sctp_sock *sp, __u16 datasize) 6098c2ecf20Sopenharmony_ci{ 6108c2ecf20Sopenharmony_ci return sctp_mtu_payload(sp, SCTP_DEFAULT_MINSEGMENT, datasize); 6118c2ecf20Sopenharmony_ci} 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_cistatic inline bool sctp_newsk_ready(const struct sock *sk) 6148c2ecf20Sopenharmony_ci{ 6158c2ecf20Sopenharmony_ci return sock_flag(sk, SOCK_DEAD) || sk->sk_socket; 6168c2ecf20Sopenharmony_ci} 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_cistatic inline void sctp_sock_set_nodelay(struct sock *sk) 6198c2ecf20Sopenharmony_ci{ 6208c2ecf20Sopenharmony_ci lock_sock(sk); 6218c2ecf20Sopenharmony_ci sctp_sk(sk)->nodelay = true; 6228c2ecf20Sopenharmony_ci release_sock(sk); 6238c2ecf20Sopenharmony_ci} 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_ci#endif /* __net_sctp_h__ */ 626