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 Intel Corp. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * This file is part of the SCTP kernel implementation 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Please send any bug reports or fixes you make to the 118c2ecf20Sopenharmony_ci * email addresses: 128c2ecf20Sopenharmony_ci * lksctp developers <linux-sctp@vger.kernel.org> 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * Written or modified by: 158c2ecf20Sopenharmony_ci * Randall Stewart <randall@sctp.chicago.il.us> 168c2ecf20Sopenharmony_ci * Ken Morneau <kmorneau@cisco.com> 178c2ecf20Sopenharmony_ci * Qiaobing Xie <qxie1@email.mot.com> 188c2ecf20Sopenharmony_ci * La Monte H.P. Yarroll <piggy@acm.org> 198c2ecf20Sopenharmony_ci * Karl Knutson <karl@athena.chicago.il.us> 208c2ecf20Sopenharmony_ci * Jon Grimm <jgrimm@us.ibm.com> 218c2ecf20Sopenharmony_ci * Xingang Guo <xingang.guo@intel.com> 228c2ecf20Sopenharmony_ci * Hui Huang <hui.huang@nokia.com> 238c2ecf20Sopenharmony_ci * Sridhar Samudrala <sri@us.ibm.com> 248c2ecf20Sopenharmony_ci * Daisy Chang <daisyc@us.ibm.com> 258c2ecf20Sopenharmony_ci * Dajiang Zhang <dajiang.zhang@nokia.com> 268c2ecf20Sopenharmony_ci * Ardelle Fan <ardelle.fan@intel.com> 278c2ecf20Sopenharmony_ci * Ryan Layer <rmlayer@us.ibm.com> 288c2ecf20Sopenharmony_ci * Anup Pemmaiah <pemmaiah@cc.usu.edu> 298c2ecf20Sopenharmony_ci * Kevin Gao <kevin.gao@intel.com> 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#ifndef __sctp_structs_h__ 338c2ecf20Sopenharmony_ci#define __sctp_structs_h__ 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#include <linux/ktime.h> 368c2ecf20Sopenharmony_ci#include <linux/generic-radix-tree.h> 378c2ecf20Sopenharmony_ci#include <linux/rhashtable-types.h> 388c2ecf20Sopenharmony_ci#include <linux/socket.h> /* linux/in.h needs this!! */ 398c2ecf20Sopenharmony_ci#include <linux/in.h> /* We get struct sockaddr_in. */ 408c2ecf20Sopenharmony_ci#include <linux/in6.h> /* We get struct in6_addr */ 418c2ecf20Sopenharmony_ci#include <linux/ipv6.h> 428c2ecf20Sopenharmony_ci#include <asm/param.h> /* We get MAXHOSTNAMELEN. */ 438c2ecf20Sopenharmony_ci#include <linux/atomic.h> /* This gets us atomic counters. */ 448c2ecf20Sopenharmony_ci#include <linux/skbuff.h> /* We need sk_buff_head. */ 458c2ecf20Sopenharmony_ci#include <linux/workqueue.h> /* We need tq_struct. */ 468c2ecf20Sopenharmony_ci#include <linux/sctp.h> /* We need sctp* header structs. */ 478c2ecf20Sopenharmony_ci#include <net/sctp/auth.h> /* We need auth specific structs */ 488c2ecf20Sopenharmony_ci#include <net/ip.h> /* For inet_skb_parm */ 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* A convenience structure for handling sockaddr structures. 518c2ecf20Sopenharmony_ci * We should wean ourselves off this. 528c2ecf20Sopenharmony_ci */ 538c2ecf20Sopenharmony_ciunion sctp_addr { 548c2ecf20Sopenharmony_ci struct sockaddr_in v4; 558c2ecf20Sopenharmony_ci struct sockaddr_in6 v6; 568c2ecf20Sopenharmony_ci struct sockaddr sa; 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci/* Forward declarations for data structures. */ 608c2ecf20Sopenharmony_cistruct sctp_globals; 618c2ecf20Sopenharmony_cistruct sctp_endpoint; 628c2ecf20Sopenharmony_cistruct sctp_association; 638c2ecf20Sopenharmony_cistruct sctp_transport; 648c2ecf20Sopenharmony_cistruct sctp_packet; 658c2ecf20Sopenharmony_cistruct sctp_chunk; 668c2ecf20Sopenharmony_cistruct sctp_inq; 678c2ecf20Sopenharmony_cistruct sctp_outq; 688c2ecf20Sopenharmony_cistruct sctp_bind_addr; 698c2ecf20Sopenharmony_cistruct sctp_ulpq; 708c2ecf20Sopenharmony_cistruct sctp_ep_common; 718c2ecf20Sopenharmony_cistruct crypto_shash; 728c2ecf20Sopenharmony_cistruct sctp_stream; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#include <net/sctp/tsnmap.h> 768c2ecf20Sopenharmony_ci#include <net/sctp/ulpevent.h> 778c2ecf20Sopenharmony_ci#include <net/sctp/ulpqueue.h> 788c2ecf20Sopenharmony_ci#include <net/sctp/stream_interleave.h> 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci/* Structures useful for managing bind/connect. */ 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cistruct sctp_bind_bucket { 838c2ecf20Sopenharmony_ci unsigned short port; 848c2ecf20Sopenharmony_ci signed char fastreuse; 858c2ecf20Sopenharmony_ci signed char fastreuseport; 868c2ecf20Sopenharmony_ci kuid_t fastuid; 878c2ecf20Sopenharmony_ci struct hlist_node node; 888c2ecf20Sopenharmony_ci struct hlist_head owner; 898c2ecf20Sopenharmony_ci struct net *net; 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistruct sctp_bind_hashbucket { 938c2ecf20Sopenharmony_ci spinlock_t lock; 948c2ecf20Sopenharmony_ci struct hlist_head chain; 958c2ecf20Sopenharmony_ci}; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci/* Used for hashing all associations. */ 988c2ecf20Sopenharmony_cistruct sctp_hashbucket { 998c2ecf20Sopenharmony_ci rwlock_t lock; 1008c2ecf20Sopenharmony_ci struct hlist_head chain; 1018c2ecf20Sopenharmony_ci} __attribute__((__aligned__(8))); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* The SCTP globals structure. */ 1058c2ecf20Sopenharmony_ciextern struct sctp_globals { 1068c2ecf20Sopenharmony_ci /* This is a list of groups of functions for each address 1078c2ecf20Sopenharmony_ci * family that we support. 1088c2ecf20Sopenharmony_ci */ 1098c2ecf20Sopenharmony_ci struct list_head address_families; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci /* This is the hash of all endpoints. */ 1128c2ecf20Sopenharmony_ci struct sctp_hashbucket *ep_hashtable; 1138c2ecf20Sopenharmony_ci /* This is the sctp port control hash. */ 1148c2ecf20Sopenharmony_ci struct sctp_bind_hashbucket *port_hashtable; 1158c2ecf20Sopenharmony_ci /* This is the hash of all transports. */ 1168c2ecf20Sopenharmony_ci struct rhltable transport_hashtable; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci /* Sizes of above hashtables. */ 1198c2ecf20Sopenharmony_ci int ep_hashsize; 1208c2ecf20Sopenharmony_ci int port_hashsize; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci /* Default initialization values to be applied to new associations. */ 1238c2ecf20Sopenharmony_ci __u16 max_instreams; 1248c2ecf20Sopenharmony_ci __u16 max_outstreams; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci /* Flag to indicate whether computing and verifying checksum 1278c2ecf20Sopenharmony_ci * is disabled. */ 1288c2ecf20Sopenharmony_ci bool checksum_disable; 1298c2ecf20Sopenharmony_ci} sctp_globals; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci#define sctp_max_instreams (sctp_globals.max_instreams) 1328c2ecf20Sopenharmony_ci#define sctp_max_outstreams (sctp_globals.max_outstreams) 1338c2ecf20Sopenharmony_ci#define sctp_address_families (sctp_globals.address_families) 1348c2ecf20Sopenharmony_ci#define sctp_ep_hashsize (sctp_globals.ep_hashsize) 1358c2ecf20Sopenharmony_ci#define sctp_ep_hashtable (sctp_globals.ep_hashtable) 1368c2ecf20Sopenharmony_ci#define sctp_port_hashsize (sctp_globals.port_hashsize) 1378c2ecf20Sopenharmony_ci#define sctp_port_hashtable (sctp_globals.port_hashtable) 1388c2ecf20Sopenharmony_ci#define sctp_transport_hashtable (sctp_globals.transport_hashtable) 1398c2ecf20Sopenharmony_ci#define sctp_checksum_disable (sctp_globals.checksum_disable) 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/* SCTP Socket type: UDP or TCP style. */ 1428c2ecf20Sopenharmony_cienum sctp_socket_type { 1438c2ecf20Sopenharmony_ci SCTP_SOCKET_UDP = 0, 1448c2ecf20Sopenharmony_ci SCTP_SOCKET_UDP_HIGH_BANDWIDTH, 1458c2ecf20Sopenharmony_ci SCTP_SOCKET_TCP 1468c2ecf20Sopenharmony_ci}; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci/* Per socket SCTP information. */ 1498c2ecf20Sopenharmony_cistruct sctp_sock { 1508c2ecf20Sopenharmony_ci /* inet_sock has to be the first member of sctp_sock */ 1518c2ecf20Sopenharmony_ci struct inet_sock inet; 1528c2ecf20Sopenharmony_ci /* What kind of a socket is this? */ 1538c2ecf20Sopenharmony_ci enum sctp_socket_type type; 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci /* PF_ family specific functions. */ 1568c2ecf20Sopenharmony_ci struct sctp_pf *pf; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci /* Access to HMAC transform. */ 1598c2ecf20Sopenharmony_ci struct crypto_shash *hmac; 1608c2ecf20Sopenharmony_ci char *sctp_hmac_alg; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci /* What is our base endpointer? */ 1638c2ecf20Sopenharmony_ci struct sctp_endpoint *ep; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci struct sctp_bind_bucket *bind_hash; 1668c2ecf20Sopenharmony_ci /* Various Socket Options. */ 1678c2ecf20Sopenharmony_ci __u16 default_stream; 1688c2ecf20Sopenharmony_ci __u32 default_ppid; 1698c2ecf20Sopenharmony_ci __u16 default_flags; 1708c2ecf20Sopenharmony_ci __u32 default_context; 1718c2ecf20Sopenharmony_ci __u32 default_timetolive; 1728c2ecf20Sopenharmony_ci __u32 default_rcv_context; 1738c2ecf20Sopenharmony_ci int max_burst; 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to 1768c2ecf20Sopenharmony_ci * the destination address every heartbeat interval. This value 1778c2ecf20Sopenharmony_ci * will be inherited by all new associations. 1788c2ecf20Sopenharmony_ci */ 1798c2ecf20Sopenharmony_ci __u32 hbinterval; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci /* This is the max_retrans value for new associations. */ 1828c2ecf20Sopenharmony_ci __u16 pathmaxrxt; 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci __u32 flowlabel; 1858c2ecf20Sopenharmony_ci __u8 dscp; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci __u16 pf_retrans; 1888c2ecf20Sopenharmony_ci __u16 ps_retrans; 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci /* The initial Path MTU to use for new associations. */ 1918c2ecf20Sopenharmony_ci __u32 pathmtu; 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci /* The default SACK delay timeout for new associations. */ 1948c2ecf20Sopenharmony_ci __u32 sackdelay; 1958c2ecf20Sopenharmony_ci __u32 sackfreq; 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci /* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */ 1988c2ecf20Sopenharmony_ci __u32 param_flags; 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci __u32 default_ss; 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci struct sctp_rtoinfo rtoinfo; 2038c2ecf20Sopenharmony_ci struct sctp_paddrparams paddrparam; 2048c2ecf20Sopenharmony_ci struct sctp_assocparams assocparams; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci /* 2078c2ecf20Sopenharmony_ci * These two structures must be grouped together for the usercopy 2088c2ecf20Sopenharmony_ci * whitelist region. 2098c2ecf20Sopenharmony_ci */ 2108c2ecf20Sopenharmony_ci __u16 subscribe; 2118c2ecf20Sopenharmony_ci struct sctp_initmsg initmsg; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci int user_frag; 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci __u32 autoclose; 2168c2ecf20Sopenharmony_ci __u32 adaptation_ind; 2178c2ecf20Sopenharmony_ci __u32 pd_point; 2188c2ecf20Sopenharmony_ci __u16 nodelay:1, 2198c2ecf20Sopenharmony_ci pf_expose:2, 2208c2ecf20Sopenharmony_ci reuse:1, 2218c2ecf20Sopenharmony_ci disable_fragments:1, 2228c2ecf20Sopenharmony_ci v4mapped:1, 2238c2ecf20Sopenharmony_ci frag_interleave:1, 2248c2ecf20Sopenharmony_ci recvrcvinfo:1, 2258c2ecf20Sopenharmony_ci recvnxtinfo:1, 2268c2ecf20Sopenharmony_ci data_ready_signalled:1; 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci atomic_t pd_mode; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci /* Fields after this point will be skipped on copies, like on accept 2318c2ecf20Sopenharmony_ci * and peeloff operations 2328c2ecf20Sopenharmony_ci */ 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci /* Receive to here while partial delivery is in effect. */ 2358c2ecf20Sopenharmony_ci struct sk_buff_head pd_lobby; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci struct list_head auto_asconf_list; 2388c2ecf20Sopenharmony_ci int do_auto_asconf; 2398c2ecf20Sopenharmony_ci}; 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_cistatic inline struct sctp_sock *sctp_sk(const struct sock *sk) 2428c2ecf20Sopenharmony_ci{ 2438c2ecf20Sopenharmony_ci return (struct sctp_sock *)sk; 2448c2ecf20Sopenharmony_ci} 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_cistatic inline struct sock *sctp_opt2sk(const struct sctp_sock *sp) 2478c2ecf20Sopenharmony_ci{ 2488c2ecf20Sopenharmony_ci return (struct sock *)sp; 2498c2ecf20Sopenharmony_ci} 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_IPV6) 2528c2ecf20Sopenharmony_cistruct sctp6_sock { 2538c2ecf20Sopenharmony_ci struct sctp_sock sctp; 2548c2ecf20Sopenharmony_ci struct ipv6_pinfo inet6; 2558c2ecf20Sopenharmony_ci}; 2568c2ecf20Sopenharmony_ci#endif /* CONFIG_IPV6 */ 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci/* This is our APPLICATION-SPECIFIC state cookie. 2608c2ecf20Sopenharmony_ci * THIS IS NOT DICTATED BY THE SPECIFICATION. 2618c2ecf20Sopenharmony_ci */ 2628c2ecf20Sopenharmony_ci/* These are the parts of an association which we send in the cookie. 2638c2ecf20Sopenharmony_ci * Most of these are straight out of: 2648c2ecf20Sopenharmony_ci * RFC2960 12.2 Parameters necessary per association (i.e. the TCB) 2658c2ecf20Sopenharmony_ci * 2668c2ecf20Sopenharmony_ci */ 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_cistruct sctp_cookie { 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci /* My : Tag expected in every inbound packet and sent 2718c2ecf20Sopenharmony_ci * Verification: in the INIT or INIT ACK chunk. 2728c2ecf20Sopenharmony_ci * Tag : 2738c2ecf20Sopenharmony_ci */ 2748c2ecf20Sopenharmony_ci __u32 my_vtag; 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci /* Peer's : Tag expected in every outbound packet except 2778c2ecf20Sopenharmony_ci * Verification: in the INIT chunk. 2788c2ecf20Sopenharmony_ci * Tag : 2798c2ecf20Sopenharmony_ci */ 2808c2ecf20Sopenharmony_ci __u32 peer_vtag; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci /* The rest of these are not from the spec, but really need to 2838c2ecf20Sopenharmony_ci * be in the cookie. 2848c2ecf20Sopenharmony_ci */ 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci /* My Tie Tag : Assist in discovering a restarting association. */ 2878c2ecf20Sopenharmony_ci __u32 my_ttag; 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci /* Peer's Tie Tag: Assist in discovering a restarting association. */ 2908c2ecf20Sopenharmony_ci __u32 peer_ttag; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci /* When does this cookie expire? */ 2938c2ecf20Sopenharmony_ci ktime_t expiration; 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci /* Number of inbound/outbound streams which are set 2968c2ecf20Sopenharmony_ci * and negotiated during the INIT process. 2978c2ecf20Sopenharmony_ci */ 2988c2ecf20Sopenharmony_ci __u16 sinit_num_ostreams; 2998c2ecf20Sopenharmony_ci __u16 sinit_max_instreams; 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci /* This is the first sequence number I used. */ 3028c2ecf20Sopenharmony_ci __u32 initial_tsn; 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci /* This holds the originating address of the INIT packet. */ 3058c2ecf20Sopenharmony_ci union sctp_addr peer_addr; 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci /* IG Section 2.35.3 3088c2ecf20Sopenharmony_ci * Include the source port of the INIT-ACK 3098c2ecf20Sopenharmony_ci */ 3108c2ecf20Sopenharmony_ci __u16 my_port; 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci __u8 prsctp_capable; 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci /* Padding for future use */ 3158c2ecf20Sopenharmony_ci __u8 padding; 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci __u32 adaptation_ind; 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci __u8 auth_random[sizeof(struct sctp_paramhdr) + 3208c2ecf20Sopenharmony_ci SCTP_AUTH_RANDOM_LENGTH]; 3218c2ecf20Sopenharmony_ci __u8 auth_hmacs[SCTP_AUTH_NUM_HMACS * sizeof(__u16) + 2]; 3228c2ecf20Sopenharmony_ci __u8 auth_chunks[sizeof(struct sctp_paramhdr) + SCTP_AUTH_MAX_CHUNKS]; 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_ci /* This is a shim for my peer's INIT packet, followed by 3258c2ecf20Sopenharmony_ci * a copy of the raw address list of the association. 3268c2ecf20Sopenharmony_ci * The length of the raw address list is saved in the 3278c2ecf20Sopenharmony_ci * raw_addr_list_len field, which will be used at the time when 3288c2ecf20Sopenharmony_ci * the association TCB is re-constructed from the cookie. 3298c2ecf20Sopenharmony_ci */ 3308c2ecf20Sopenharmony_ci __u32 raw_addr_list_len; 3318c2ecf20Sopenharmony_ci struct sctp_init_chunk peer_init[]; 3328c2ecf20Sopenharmony_ci}; 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci/* The format of our cookie that we send to our peer. */ 3368c2ecf20Sopenharmony_cistruct sctp_signed_cookie { 3378c2ecf20Sopenharmony_ci __u8 signature[SCTP_SECRET_SIZE]; 3388c2ecf20Sopenharmony_ci __u32 __pad; /* force sctp_cookie alignment to 64 bits */ 3398c2ecf20Sopenharmony_ci struct sctp_cookie c; 3408c2ecf20Sopenharmony_ci} __packed; 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ci/* This is another convenience type to allocate memory for address 3438c2ecf20Sopenharmony_ci * params for the maximum size and pass such structures around 3448c2ecf20Sopenharmony_ci * internally. 3458c2ecf20Sopenharmony_ci */ 3468c2ecf20Sopenharmony_ciunion sctp_addr_param { 3478c2ecf20Sopenharmony_ci struct sctp_paramhdr p; 3488c2ecf20Sopenharmony_ci struct sctp_ipv4addr_param v4; 3498c2ecf20Sopenharmony_ci struct sctp_ipv6addr_param v6; 3508c2ecf20Sopenharmony_ci}; 3518c2ecf20Sopenharmony_ci 3528c2ecf20Sopenharmony_ci/* A convenience type to allow walking through the various 3538c2ecf20Sopenharmony_ci * parameters and avoid casting all over the place. 3548c2ecf20Sopenharmony_ci */ 3558c2ecf20Sopenharmony_ciunion sctp_params { 3568c2ecf20Sopenharmony_ci void *v; 3578c2ecf20Sopenharmony_ci struct sctp_paramhdr *p; 3588c2ecf20Sopenharmony_ci struct sctp_cookie_preserve_param *life; 3598c2ecf20Sopenharmony_ci struct sctp_hostname_param *dns; 3608c2ecf20Sopenharmony_ci struct sctp_cookie_param *cookie; 3618c2ecf20Sopenharmony_ci struct sctp_supported_addrs_param *sat; 3628c2ecf20Sopenharmony_ci struct sctp_ipv4addr_param *v4; 3638c2ecf20Sopenharmony_ci struct sctp_ipv6addr_param *v6; 3648c2ecf20Sopenharmony_ci union sctp_addr_param *addr; 3658c2ecf20Sopenharmony_ci struct sctp_adaptation_ind_param *aind; 3668c2ecf20Sopenharmony_ci struct sctp_supported_ext_param *ext; 3678c2ecf20Sopenharmony_ci struct sctp_random_param *random; 3688c2ecf20Sopenharmony_ci struct sctp_chunks_param *chunks; 3698c2ecf20Sopenharmony_ci struct sctp_hmac_algo_param *hmac_algo; 3708c2ecf20Sopenharmony_ci struct sctp_addip_param *addip; 3718c2ecf20Sopenharmony_ci}; 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci/* RFC 2960. Section 3.3.5 Heartbeat. 3748c2ecf20Sopenharmony_ci * Heartbeat Information: variable length 3758c2ecf20Sopenharmony_ci * The Sender-specific Heartbeat Info field should normally include 3768c2ecf20Sopenharmony_ci * information about the sender's current time when this HEARTBEAT 3778c2ecf20Sopenharmony_ci * chunk is sent and the destination transport address to which this 3788c2ecf20Sopenharmony_ci * HEARTBEAT is sent (see Section 8.3). 3798c2ecf20Sopenharmony_ci */ 3808c2ecf20Sopenharmony_cistruct sctp_sender_hb_info { 3818c2ecf20Sopenharmony_ci struct sctp_paramhdr param_hdr; 3828c2ecf20Sopenharmony_ci union sctp_addr daddr; 3838c2ecf20Sopenharmony_ci unsigned long sent_at; 3848c2ecf20Sopenharmony_ci __u64 hb_nonce; 3858c2ecf20Sopenharmony_ci}; 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ciint sctp_stream_init(struct sctp_stream *stream, __u16 outcnt, __u16 incnt, 3888c2ecf20Sopenharmony_ci gfp_t gfp); 3898c2ecf20Sopenharmony_ciint sctp_stream_init_ext(struct sctp_stream *stream, __u16 sid); 3908c2ecf20Sopenharmony_civoid sctp_stream_free(struct sctp_stream *stream); 3918c2ecf20Sopenharmony_civoid sctp_stream_clear(struct sctp_stream *stream); 3928c2ecf20Sopenharmony_civoid sctp_stream_update(struct sctp_stream *stream, struct sctp_stream *new); 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci/* What is the current SSN number for this stream? */ 3958c2ecf20Sopenharmony_ci#define sctp_ssn_peek(stream, type, sid) \ 3968c2ecf20Sopenharmony_ci (sctp_stream_##type((stream), (sid))->ssn) 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ci/* Return the next SSN number for this stream. */ 3998c2ecf20Sopenharmony_ci#define sctp_ssn_next(stream, type, sid) \ 4008c2ecf20Sopenharmony_ci (sctp_stream_##type((stream), (sid))->ssn++) 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ci/* Skip over this ssn and all below. */ 4038c2ecf20Sopenharmony_ci#define sctp_ssn_skip(stream, type, sid, ssn) \ 4048c2ecf20Sopenharmony_ci (sctp_stream_##type((stream), (sid))->ssn = ssn + 1) 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci/* What is the current MID number for this stream? */ 4078c2ecf20Sopenharmony_ci#define sctp_mid_peek(stream, type, sid) \ 4088c2ecf20Sopenharmony_ci (sctp_stream_##type((stream), (sid))->mid) 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci/* Return the next MID number for this stream. */ 4118c2ecf20Sopenharmony_ci#define sctp_mid_next(stream, type, sid) \ 4128c2ecf20Sopenharmony_ci (sctp_stream_##type((stream), (sid))->mid++) 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci/* Skip over this mid and all below. */ 4158c2ecf20Sopenharmony_ci#define sctp_mid_skip(stream, type, sid, mid) \ 4168c2ecf20Sopenharmony_ci (sctp_stream_##type((stream), (sid))->mid = mid + 1) 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci/* What is the current MID_uo number for this stream? */ 4198c2ecf20Sopenharmony_ci#define sctp_mid_uo_peek(stream, type, sid) \ 4208c2ecf20Sopenharmony_ci (sctp_stream_##type((stream), (sid))->mid_uo) 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci/* Return the next MID_uo number for this stream. */ 4238c2ecf20Sopenharmony_ci#define sctp_mid_uo_next(stream, type, sid) \ 4248c2ecf20Sopenharmony_ci (sctp_stream_##type((stream), (sid))->mid_uo++) 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ci/* 4278c2ecf20Sopenharmony_ci * Pointers to address related SCTP functions. 4288c2ecf20Sopenharmony_ci * (i.e. things that depend on the address family.) 4298c2ecf20Sopenharmony_ci */ 4308c2ecf20Sopenharmony_cistruct sctp_af { 4318c2ecf20Sopenharmony_ci int (*sctp_xmit) (struct sk_buff *skb, 4328c2ecf20Sopenharmony_ci struct sctp_transport *); 4338c2ecf20Sopenharmony_ci int (*setsockopt) (struct sock *sk, 4348c2ecf20Sopenharmony_ci int level, 4358c2ecf20Sopenharmony_ci int optname, 4368c2ecf20Sopenharmony_ci sockptr_t optval, 4378c2ecf20Sopenharmony_ci unsigned int optlen); 4388c2ecf20Sopenharmony_ci int (*getsockopt) (struct sock *sk, 4398c2ecf20Sopenharmony_ci int level, 4408c2ecf20Sopenharmony_ci int optname, 4418c2ecf20Sopenharmony_ci char __user *optval, 4428c2ecf20Sopenharmony_ci int __user *optlen); 4438c2ecf20Sopenharmony_ci void (*get_dst) (struct sctp_transport *t, 4448c2ecf20Sopenharmony_ci union sctp_addr *saddr, 4458c2ecf20Sopenharmony_ci struct flowi *fl, 4468c2ecf20Sopenharmony_ci struct sock *sk); 4478c2ecf20Sopenharmony_ci void (*get_saddr) (struct sctp_sock *sk, 4488c2ecf20Sopenharmony_ci struct sctp_transport *t, 4498c2ecf20Sopenharmony_ci struct flowi *fl); 4508c2ecf20Sopenharmony_ci void (*copy_addrlist) (struct list_head *, 4518c2ecf20Sopenharmony_ci struct net_device *); 4528c2ecf20Sopenharmony_ci int (*cmp_addr) (const union sctp_addr *addr1, 4538c2ecf20Sopenharmony_ci const union sctp_addr *addr2); 4548c2ecf20Sopenharmony_ci void (*addr_copy) (union sctp_addr *dst, 4558c2ecf20Sopenharmony_ci union sctp_addr *src); 4568c2ecf20Sopenharmony_ci void (*from_skb) (union sctp_addr *, 4578c2ecf20Sopenharmony_ci struct sk_buff *skb, 4588c2ecf20Sopenharmony_ci int saddr); 4598c2ecf20Sopenharmony_ci void (*from_sk) (union sctp_addr *, 4608c2ecf20Sopenharmony_ci struct sock *sk); 4618c2ecf20Sopenharmony_ci bool (*from_addr_param) (union sctp_addr *, 4628c2ecf20Sopenharmony_ci union sctp_addr_param *, 4638c2ecf20Sopenharmony_ci __be16 port, int iif); 4648c2ecf20Sopenharmony_ci int (*to_addr_param) (const union sctp_addr *, 4658c2ecf20Sopenharmony_ci union sctp_addr_param *); 4668c2ecf20Sopenharmony_ci int (*addr_valid) (union sctp_addr *, 4678c2ecf20Sopenharmony_ci struct sctp_sock *, 4688c2ecf20Sopenharmony_ci const struct sk_buff *); 4698c2ecf20Sopenharmony_ci enum sctp_scope (*scope)(union sctp_addr *); 4708c2ecf20Sopenharmony_ci void (*inaddr_any) (union sctp_addr *, __be16); 4718c2ecf20Sopenharmony_ci int (*is_any) (const union sctp_addr *); 4728c2ecf20Sopenharmony_ci int (*available) (union sctp_addr *, 4738c2ecf20Sopenharmony_ci struct sctp_sock *); 4748c2ecf20Sopenharmony_ci int (*skb_iif) (const struct sk_buff *sk); 4758c2ecf20Sopenharmony_ci int (*is_ce) (const struct sk_buff *sk); 4768c2ecf20Sopenharmony_ci void (*seq_dump_addr)(struct seq_file *seq, 4778c2ecf20Sopenharmony_ci union sctp_addr *addr); 4788c2ecf20Sopenharmony_ci void (*ecn_capable)(struct sock *sk); 4798c2ecf20Sopenharmony_ci __u16 net_header_len; 4808c2ecf20Sopenharmony_ci int sockaddr_len; 4818c2ecf20Sopenharmony_ci int (*ip_options_len)(struct sock *sk); 4828c2ecf20Sopenharmony_ci sa_family_t sa_family; 4838c2ecf20Sopenharmony_ci struct list_head list; 4848c2ecf20Sopenharmony_ci}; 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_cistruct sctp_af *sctp_get_af_specific(sa_family_t); 4878c2ecf20Sopenharmony_ciint sctp_register_af(struct sctp_af *); 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_ci/* Protocol family functions. */ 4908c2ecf20Sopenharmony_cistruct sctp_pf { 4918c2ecf20Sopenharmony_ci void (*event_msgname)(struct sctp_ulpevent *, char *, int *); 4928c2ecf20Sopenharmony_ci void (*skb_msgname) (struct sk_buff *, char *, int *); 4938c2ecf20Sopenharmony_ci int (*af_supported) (sa_family_t, struct sctp_sock *); 4948c2ecf20Sopenharmony_ci int (*cmp_addr) (const union sctp_addr *, 4958c2ecf20Sopenharmony_ci const union sctp_addr *, 4968c2ecf20Sopenharmony_ci struct sctp_sock *); 4978c2ecf20Sopenharmony_ci int (*bind_verify) (struct sctp_sock *, union sctp_addr *); 4988c2ecf20Sopenharmony_ci int (*send_verify) (struct sctp_sock *, union sctp_addr *); 4998c2ecf20Sopenharmony_ci int (*supported_addrs)(const struct sctp_sock *, __be16 *); 5008c2ecf20Sopenharmony_ci struct sock *(*create_accept_sk) (struct sock *sk, 5018c2ecf20Sopenharmony_ci struct sctp_association *asoc, 5028c2ecf20Sopenharmony_ci bool kern); 5038c2ecf20Sopenharmony_ci int (*addr_to_user)(struct sctp_sock *sk, union sctp_addr *addr); 5048c2ecf20Sopenharmony_ci void (*to_sk_saddr)(union sctp_addr *, struct sock *sk); 5058c2ecf20Sopenharmony_ci void (*to_sk_daddr)(union sctp_addr *, struct sock *sk); 5068c2ecf20Sopenharmony_ci void (*copy_ip_options)(struct sock *sk, struct sock *newsk); 5078c2ecf20Sopenharmony_ci struct sctp_af *af; 5088c2ecf20Sopenharmony_ci}; 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci/* Structure to track chunk fragments that have been acked, but peer 5128c2ecf20Sopenharmony_ci * fragments of the same message have not. 5138c2ecf20Sopenharmony_ci */ 5148c2ecf20Sopenharmony_cistruct sctp_datamsg { 5158c2ecf20Sopenharmony_ci /* Chunks waiting to be submitted to lower layer. */ 5168c2ecf20Sopenharmony_ci struct list_head chunks; 5178c2ecf20Sopenharmony_ci /* Reference counting. */ 5188c2ecf20Sopenharmony_ci refcount_t refcnt; 5198c2ecf20Sopenharmony_ci /* When is this message no longer interesting to the peer? */ 5208c2ecf20Sopenharmony_ci unsigned long expires_at; 5218c2ecf20Sopenharmony_ci /* Did the messenge fail to send? */ 5228c2ecf20Sopenharmony_ci int send_error; 5238c2ecf20Sopenharmony_ci u8 send_failed:1, 5248c2ecf20Sopenharmony_ci can_delay:1, /* should this message be Nagle delayed */ 5258c2ecf20Sopenharmony_ci abandoned:1; /* should this message be abandoned */ 5268c2ecf20Sopenharmony_ci}; 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_cistruct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *, 5298c2ecf20Sopenharmony_ci struct sctp_sndrcvinfo *, 5308c2ecf20Sopenharmony_ci struct iov_iter *); 5318c2ecf20Sopenharmony_civoid sctp_datamsg_free(struct sctp_datamsg *); 5328c2ecf20Sopenharmony_civoid sctp_datamsg_put(struct sctp_datamsg *); 5338c2ecf20Sopenharmony_civoid sctp_chunk_fail(struct sctp_chunk *, int error); 5348c2ecf20Sopenharmony_ciint sctp_chunk_abandoned(struct sctp_chunk *); 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_ci/* RFC2960 1.4 Key Terms 5378c2ecf20Sopenharmony_ci * 5388c2ecf20Sopenharmony_ci * o Chunk: A unit of information within an SCTP packet, consisting of 5398c2ecf20Sopenharmony_ci * a chunk header and chunk-specific content. 5408c2ecf20Sopenharmony_ci * 5418c2ecf20Sopenharmony_ci * As a matter of convenience, we remember the SCTP common header for 5428c2ecf20Sopenharmony_ci * each chunk as well as a few other header pointers... 5438c2ecf20Sopenharmony_ci */ 5448c2ecf20Sopenharmony_cistruct sctp_chunk { 5458c2ecf20Sopenharmony_ci struct list_head list; 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci refcount_t refcnt; 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_ci /* How many times this chunk have been sent, for prsctp RTX policy */ 5508c2ecf20Sopenharmony_ci int sent_count; 5518c2ecf20Sopenharmony_ci 5528c2ecf20Sopenharmony_ci union { 5538c2ecf20Sopenharmony_ci /* This is our link to the per-transport transmitted list. */ 5548c2ecf20Sopenharmony_ci struct list_head transmitted_list; 5558c2ecf20Sopenharmony_ci /* List in specific stream outq */ 5568c2ecf20Sopenharmony_ci struct list_head stream_list; 5578c2ecf20Sopenharmony_ci }; 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci /* This field is used by chunks that hold fragmented data. 5608c2ecf20Sopenharmony_ci * For the first fragment this is the list that holds the rest of 5618c2ecf20Sopenharmony_ci * fragments. For the remaining fragments, this is the link to the 5628c2ecf20Sopenharmony_ci * frag_list maintained in the first fragment. 5638c2ecf20Sopenharmony_ci */ 5648c2ecf20Sopenharmony_ci struct list_head frag_list; 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci /* This points to the sk_buff containing the actual data. */ 5678c2ecf20Sopenharmony_ci struct sk_buff *skb; 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci union { 5708c2ecf20Sopenharmony_ci /* In case of GSO packets, this will store the head one */ 5718c2ecf20Sopenharmony_ci struct sk_buff *head_skb; 5728c2ecf20Sopenharmony_ci /* In case of auth enabled, this will point to the shkey */ 5738c2ecf20Sopenharmony_ci struct sctp_shared_key *shkey; 5748c2ecf20Sopenharmony_ci }; 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_ci /* These are the SCTP headers by reverse order in a packet. 5778c2ecf20Sopenharmony_ci * Note that some of these may happen more than once. In that 5788c2ecf20Sopenharmony_ci * case, we point at the "current" one, whatever that means 5798c2ecf20Sopenharmony_ci * for that level of header. 5808c2ecf20Sopenharmony_ci */ 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci /* We point this at the FIRST TLV parameter to chunk_hdr. */ 5838c2ecf20Sopenharmony_ci union sctp_params param_hdr; 5848c2ecf20Sopenharmony_ci union { 5858c2ecf20Sopenharmony_ci __u8 *v; 5868c2ecf20Sopenharmony_ci struct sctp_datahdr *data_hdr; 5878c2ecf20Sopenharmony_ci struct sctp_inithdr *init_hdr; 5888c2ecf20Sopenharmony_ci struct sctp_sackhdr *sack_hdr; 5898c2ecf20Sopenharmony_ci struct sctp_heartbeathdr *hb_hdr; 5908c2ecf20Sopenharmony_ci struct sctp_sender_hb_info *hbs_hdr; 5918c2ecf20Sopenharmony_ci struct sctp_shutdownhdr *shutdown_hdr; 5928c2ecf20Sopenharmony_ci struct sctp_signed_cookie *cookie_hdr; 5938c2ecf20Sopenharmony_ci struct sctp_ecnehdr *ecne_hdr; 5948c2ecf20Sopenharmony_ci struct sctp_cwrhdr *ecn_cwr_hdr; 5958c2ecf20Sopenharmony_ci struct sctp_errhdr *err_hdr; 5968c2ecf20Sopenharmony_ci struct sctp_addiphdr *addip_hdr; 5978c2ecf20Sopenharmony_ci struct sctp_fwdtsn_hdr *fwdtsn_hdr; 5988c2ecf20Sopenharmony_ci struct sctp_authhdr *auth_hdr; 5998c2ecf20Sopenharmony_ci struct sctp_idatahdr *idata_hdr; 6008c2ecf20Sopenharmony_ci struct sctp_ifwdtsn_hdr *ifwdtsn_hdr; 6018c2ecf20Sopenharmony_ci } subh; 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_ci __u8 *chunk_end; 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci struct sctp_chunkhdr *chunk_hdr; 6068c2ecf20Sopenharmony_ci struct sctphdr *sctp_hdr; 6078c2ecf20Sopenharmony_ci 6088c2ecf20Sopenharmony_ci /* This needs to be recoverable for SCTP_SEND_FAILED events. */ 6098c2ecf20Sopenharmony_ci struct sctp_sndrcvinfo sinfo; 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci /* Which association does this belong to? */ 6128c2ecf20Sopenharmony_ci struct sctp_association *asoc; 6138c2ecf20Sopenharmony_ci 6148c2ecf20Sopenharmony_ci /* What endpoint received this chunk? */ 6158c2ecf20Sopenharmony_ci struct sctp_ep_common *rcvr; 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci /* We fill this in if we are calculating RTT. */ 6188c2ecf20Sopenharmony_ci unsigned long sent_at; 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_ci /* What is the origin IP address for this chunk? */ 6218c2ecf20Sopenharmony_ci union sctp_addr source; 6228c2ecf20Sopenharmony_ci /* Destination address for this chunk. */ 6238c2ecf20Sopenharmony_ci union sctp_addr dest; 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_ci /* For outbound message, track all fragments for SEND_FAILED. */ 6268c2ecf20Sopenharmony_ci struct sctp_datamsg *msg; 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_ci /* For an inbound chunk, this tells us where it came from. 6298c2ecf20Sopenharmony_ci * For an outbound chunk, it tells us where we'd like it to 6308c2ecf20Sopenharmony_ci * go. It is NULL if we have no preference. 6318c2ecf20Sopenharmony_ci */ 6328c2ecf20Sopenharmony_ci struct sctp_transport *transport; 6338c2ecf20Sopenharmony_ci 6348c2ecf20Sopenharmony_ci /* SCTP-AUTH: For the special case inbound processing of COOKIE-ECHO 6358c2ecf20Sopenharmony_ci * we need save a pointer to the AUTH chunk, since the SCTP-AUTH 6368c2ecf20Sopenharmony_ci * spec violates the principle premis that all chunks are processed 6378c2ecf20Sopenharmony_ci * in order. 6388c2ecf20Sopenharmony_ci */ 6398c2ecf20Sopenharmony_ci struct sk_buff *auth_chunk; 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_ci#define SCTP_CAN_FRTX 0x0 6428c2ecf20Sopenharmony_ci#define SCTP_NEED_FRTX 0x1 6438c2ecf20Sopenharmony_ci#define SCTP_DONT_FRTX 0x2 6448c2ecf20Sopenharmony_ci __u16 rtt_in_progress:1, /* This chunk used for RTT calc? */ 6458c2ecf20Sopenharmony_ci has_tsn:1, /* Does this chunk have a TSN yet? */ 6468c2ecf20Sopenharmony_ci has_ssn:1, /* Does this chunk have a SSN yet? */ 6478c2ecf20Sopenharmony_ci#define has_mid has_ssn 6488c2ecf20Sopenharmony_ci singleton:1, /* Only chunk in the packet? */ 6498c2ecf20Sopenharmony_ci end_of_packet:1, /* Last chunk in the packet? */ 6508c2ecf20Sopenharmony_ci ecn_ce_done:1, /* Have we processed the ECN CE bit? */ 6518c2ecf20Sopenharmony_ci pdiscard:1, /* Discard the whole packet now? */ 6528c2ecf20Sopenharmony_ci tsn_gap_acked:1, /* Is this chunk acked by a GAP ACK? */ 6538c2ecf20Sopenharmony_ci data_accepted:1, /* At least 1 chunk accepted */ 6548c2ecf20Sopenharmony_ci auth:1, /* IN: was auth'ed | OUT: needs auth */ 6558c2ecf20Sopenharmony_ci has_asconf:1, /* IN: have seen an asconf before */ 6568c2ecf20Sopenharmony_ci tsn_missing_report:2, /* Data chunk missing counter. */ 6578c2ecf20Sopenharmony_ci fast_retransmit:2; /* Is this chunk fast retransmitted? */ 6588c2ecf20Sopenharmony_ci}; 6598c2ecf20Sopenharmony_ci 6608c2ecf20Sopenharmony_ci#define sctp_chunk_retransmitted(chunk) (chunk->sent_count > 1) 6618c2ecf20Sopenharmony_civoid sctp_chunk_hold(struct sctp_chunk *); 6628c2ecf20Sopenharmony_civoid sctp_chunk_put(struct sctp_chunk *); 6638c2ecf20Sopenharmony_ciint sctp_user_addto_chunk(struct sctp_chunk *chunk, int len, 6648c2ecf20Sopenharmony_ci struct iov_iter *from); 6658c2ecf20Sopenharmony_civoid sctp_chunk_free(struct sctp_chunk *); 6668c2ecf20Sopenharmony_civoid *sctp_addto_chunk(struct sctp_chunk *, int len, const void *data); 6678c2ecf20Sopenharmony_cistruct sctp_chunk *sctp_chunkify(struct sk_buff *, 6688c2ecf20Sopenharmony_ci const struct sctp_association *, 6698c2ecf20Sopenharmony_ci struct sock *, gfp_t gfp); 6708c2ecf20Sopenharmony_civoid sctp_init_addrs(struct sctp_chunk *, union sctp_addr *, 6718c2ecf20Sopenharmony_ci union sctp_addr *); 6728c2ecf20Sopenharmony_ciconst union sctp_addr *sctp_source(const struct sctp_chunk *chunk); 6738c2ecf20Sopenharmony_ci 6748c2ecf20Sopenharmony_cistatic inline __u16 sctp_chunk_stream_no(struct sctp_chunk *ch) 6758c2ecf20Sopenharmony_ci{ 6768c2ecf20Sopenharmony_ci return ntohs(ch->subh.data_hdr->stream); 6778c2ecf20Sopenharmony_ci} 6788c2ecf20Sopenharmony_ci 6798c2ecf20Sopenharmony_cienum { 6808c2ecf20Sopenharmony_ci SCTP_ADDR_NEW, /* new address added to assoc/ep */ 6818c2ecf20Sopenharmony_ci SCTP_ADDR_SRC, /* address can be used as source */ 6828c2ecf20Sopenharmony_ci SCTP_ADDR_DEL, /* address about to be deleted */ 6838c2ecf20Sopenharmony_ci}; 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_ci/* This is a structure for holding either an IPv6 or an IPv4 address. */ 6868c2ecf20Sopenharmony_cistruct sctp_sockaddr_entry { 6878c2ecf20Sopenharmony_ci struct list_head list; 6888c2ecf20Sopenharmony_ci struct rcu_head rcu; 6898c2ecf20Sopenharmony_ci union sctp_addr a; 6908c2ecf20Sopenharmony_ci __u8 state; 6918c2ecf20Sopenharmony_ci __u8 valid; 6928c2ecf20Sopenharmony_ci}; 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci#define SCTP_ADDRESS_TICK_DELAY 500 6958c2ecf20Sopenharmony_ci 6968c2ecf20Sopenharmony_ci/* This structure holds lists of chunks as we are assembling for 6978c2ecf20Sopenharmony_ci * transmission. 6988c2ecf20Sopenharmony_ci */ 6998c2ecf20Sopenharmony_cistruct sctp_packet { 7008c2ecf20Sopenharmony_ci /* These are the SCTP header values (host order) for the packet. */ 7018c2ecf20Sopenharmony_ci __u16 source_port; 7028c2ecf20Sopenharmony_ci __u16 destination_port; 7038c2ecf20Sopenharmony_ci __u32 vtag; 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ci /* This contains the payload chunks. */ 7068c2ecf20Sopenharmony_ci struct list_head chunk_list; 7078c2ecf20Sopenharmony_ci 7088c2ecf20Sopenharmony_ci /* This is the overhead of the sctp and ip headers. */ 7098c2ecf20Sopenharmony_ci size_t overhead; 7108c2ecf20Sopenharmony_ci /* This is the total size of all chunks INCLUDING padding. */ 7118c2ecf20Sopenharmony_ci size_t size; 7128c2ecf20Sopenharmony_ci /* This is the maximum size this packet may have */ 7138c2ecf20Sopenharmony_ci size_t max_size; 7148c2ecf20Sopenharmony_ci 7158c2ecf20Sopenharmony_ci /* The packet is destined for this transport address. 7168c2ecf20Sopenharmony_ci * The function we finally use to pass down to the next lower 7178c2ecf20Sopenharmony_ci * layer lives in the transport structure. 7188c2ecf20Sopenharmony_ci */ 7198c2ecf20Sopenharmony_ci struct sctp_transport *transport; 7208c2ecf20Sopenharmony_ci 7218c2ecf20Sopenharmony_ci /* pointer to the auth chunk for this packet */ 7228c2ecf20Sopenharmony_ci struct sctp_chunk *auth; 7238c2ecf20Sopenharmony_ci 7248c2ecf20Sopenharmony_ci u8 has_cookie_echo:1, /* This packet contains a COOKIE-ECHO chunk. */ 7258c2ecf20Sopenharmony_ci has_sack:1, /* This packet contains a SACK chunk. */ 7268c2ecf20Sopenharmony_ci has_auth:1, /* This packet contains an AUTH chunk */ 7278c2ecf20Sopenharmony_ci has_data:1, /* This packet contains at least 1 DATA chunk */ 7288c2ecf20Sopenharmony_ci ipfragok:1; /* So let ip fragment this packet */ 7298c2ecf20Sopenharmony_ci}; 7308c2ecf20Sopenharmony_ci 7318c2ecf20Sopenharmony_civoid sctp_packet_init(struct sctp_packet *, struct sctp_transport *, 7328c2ecf20Sopenharmony_ci __u16 sport, __u16 dport); 7338c2ecf20Sopenharmony_civoid sctp_packet_config(struct sctp_packet *, __u32 vtag, int); 7348c2ecf20Sopenharmony_cienum sctp_xmit sctp_packet_transmit_chunk(struct sctp_packet *packet, 7358c2ecf20Sopenharmony_ci struct sctp_chunk *chunk, 7368c2ecf20Sopenharmony_ci int one_packet, gfp_t gfp); 7378c2ecf20Sopenharmony_cienum sctp_xmit sctp_packet_append_chunk(struct sctp_packet *packet, 7388c2ecf20Sopenharmony_ci struct sctp_chunk *chunk); 7398c2ecf20Sopenharmony_ciint sctp_packet_transmit(struct sctp_packet *, gfp_t); 7408c2ecf20Sopenharmony_civoid sctp_packet_free(struct sctp_packet *); 7418c2ecf20Sopenharmony_ci 7428c2ecf20Sopenharmony_cistatic inline int sctp_packet_empty(struct sctp_packet *packet) 7438c2ecf20Sopenharmony_ci{ 7448c2ecf20Sopenharmony_ci return packet->size == packet->overhead; 7458c2ecf20Sopenharmony_ci} 7468c2ecf20Sopenharmony_ci 7478c2ecf20Sopenharmony_ci/* This represents a remote transport address. 7488c2ecf20Sopenharmony_ci * For local transport addresses, we just use union sctp_addr. 7498c2ecf20Sopenharmony_ci * 7508c2ecf20Sopenharmony_ci * RFC2960 Section 1.4 Key Terms 7518c2ecf20Sopenharmony_ci * 7528c2ecf20Sopenharmony_ci * o Transport address: A Transport Address is traditionally defined 7538c2ecf20Sopenharmony_ci * by Network Layer address, Transport Layer protocol and Transport 7548c2ecf20Sopenharmony_ci * Layer port number. In the case of SCTP running over IP, a 7558c2ecf20Sopenharmony_ci * transport address is defined by the combination of an IP address 7568c2ecf20Sopenharmony_ci * and an SCTP port number (where SCTP is the Transport protocol). 7578c2ecf20Sopenharmony_ci * 7588c2ecf20Sopenharmony_ci * RFC2960 Section 7.1 SCTP Differences from TCP Congestion control 7598c2ecf20Sopenharmony_ci * 7608c2ecf20Sopenharmony_ci * o The sender keeps a separate congestion control parameter set for 7618c2ecf20Sopenharmony_ci * each of the destination addresses it can send to (not each 7628c2ecf20Sopenharmony_ci * source-destination pair but for each destination). The parameters 7638c2ecf20Sopenharmony_ci * should decay if the address is not used for a long enough time 7648c2ecf20Sopenharmony_ci * period. 7658c2ecf20Sopenharmony_ci * 7668c2ecf20Sopenharmony_ci */ 7678c2ecf20Sopenharmony_cistruct sctp_transport { 7688c2ecf20Sopenharmony_ci /* A list of transports. */ 7698c2ecf20Sopenharmony_ci struct list_head transports; 7708c2ecf20Sopenharmony_ci struct rhlist_head node; 7718c2ecf20Sopenharmony_ci 7728c2ecf20Sopenharmony_ci /* Reference counting. */ 7738c2ecf20Sopenharmony_ci refcount_t refcnt; 7748c2ecf20Sopenharmony_ci /* RTO-Pending : A flag used to track if one of the DATA 7758c2ecf20Sopenharmony_ci * chunks sent to this address is currently being 7768c2ecf20Sopenharmony_ci * used to compute a RTT. If this flag is 0, 7778c2ecf20Sopenharmony_ci * the next DATA chunk sent to this destination 7788c2ecf20Sopenharmony_ci * should be used to compute a RTT and this flag 7798c2ecf20Sopenharmony_ci * should be set. Every time the RTT 7808c2ecf20Sopenharmony_ci * calculation completes (i.e. the DATA chunk 7818c2ecf20Sopenharmony_ci * is SACK'd) clear this flag. 7828c2ecf20Sopenharmony_ci */ 7838c2ecf20Sopenharmony_ci __u32 rto_pending:1, 7848c2ecf20Sopenharmony_ci 7858c2ecf20Sopenharmony_ci /* 7868c2ecf20Sopenharmony_ci * hb_sent : a flag that signals that we have a pending 7878c2ecf20Sopenharmony_ci * heartbeat. 7888c2ecf20Sopenharmony_ci */ 7898c2ecf20Sopenharmony_ci hb_sent:1, 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci /* Is the Path MTU update pending on this tranport */ 7928c2ecf20Sopenharmony_ci pmtu_pending:1, 7938c2ecf20Sopenharmony_ci 7948c2ecf20Sopenharmony_ci dst_pending_confirm:1, /* need to confirm neighbour */ 7958c2ecf20Sopenharmony_ci 7968c2ecf20Sopenharmony_ci /* Has this transport moved the ctsn since we last sacked */ 7978c2ecf20Sopenharmony_ci sack_generation:1; 7988c2ecf20Sopenharmony_ci u32 dst_cookie; 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_ci struct flowi fl; 8018c2ecf20Sopenharmony_ci 8028c2ecf20Sopenharmony_ci /* This is the peer's IP address and port. */ 8038c2ecf20Sopenharmony_ci union sctp_addr ipaddr; 8048c2ecf20Sopenharmony_ci 8058c2ecf20Sopenharmony_ci /* These are the functions we call to handle LLP stuff. */ 8068c2ecf20Sopenharmony_ci struct sctp_af *af_specific; 8078c2ecf20Sopenharmony_ci 8088c2ecf20Sopenharmony_ci /* Which association do we belong to? */ 8098c2ecf20Sopenharmony_ci struct sctp_association *asoc; 8108c2ecf20Sopenharmony_ci 8118c2ecf20Sopenharmony_ci /* RFC2960 8128c2ecf20Sopenharmony_ci * 8138c2ecf20Sopenharmony_ci * 12.3 Per Transport Address Data 8148c2ecf20Sopenharmony_ci * 8158c2ecf20Sopenharmony_ci * For each destination transport address in the peer's 8168c2ecf20Sopenharmony_ci * address list derived from the INIT or INIT ACK chunk, a 8178c2ecf20Sopenharmony_ci * number of data elements needs to be maintained including: 8188c2ecf20Sopenharmony_ci */ 8198c2ecf20Sopenharmony_ci /* RTO : The current retransmission timeout value. */ 8208c2ecf20Sopenharmony_ci unsigned long rto; 8218c2ecf20Sopenharmony_ci 8228c2ecf20Sopenharmony_ci __u32 rtt; /* This is the most recent RTT. */ 8238c2ecf20Sopenharmony_ci 8248c2ecf20Sopenharmony_ci /* RTTVAR : The current RTT variation. */ 8258c2ecf20Sopenharmony_ci __u32 rttvar; 8268c2ecf20Sopenharmony_ci 8278c2ecf20Sopenharmony_ci /* SRTT : The current smoothed round trip time. */ 8288c2ecf20Sopenharmony_ci __u32 srtt; 8298c2ecf20Sopenharmony_ci 8308c2ecf20Sopenharmony_ci /* 8318c2ecf20Sopenharmony_ci * These are the congestion stats. 8328c2ecf20Sopenharmony_ci */ 8338c2ecf20Sopenharmony_ci /* cwnd : The current congestion window. */ 8348c2ecf20Sopenharmony_ci __u32 cwnd; /* This is the actual cwnd. */ 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_ci /* ssthresh : The current slow start threshold value. */ 8378c2ecf20Sopenharmony_ci __u32 ssthresh; 8388c2ecf20Sopenharmony_ci 8398c2ecf20Sopenharmony_ci /* partial : The tracking method for increase of cwnd when in 8408c2ecf20Sopenharmony_ci * bytes acked : congestion avoidance mode (see Section 6.2.2) 8418c2ecf20Sopenharmony_ci */ 8428c2ecf20Sopenharmony_ci __u32 partial_bytes_acked; 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_ci /* Data that has been sent, but not acknowledged. */ 8458c2ecf20Sopenharmony_ci __u32 flight_size; 8468c2ecf20Sopenharmony_ci 8478c2ecf20Sopenharmony_ci __u32 burst_limited; /* Holds old cwnd when max.burst is applied */ 8488c2ecf20Sopenharmony_ci 8498c2ecf20Sopenharmony_ci /* Destination */ 8508c2ecf20Sopenharmony_ci struct dst_entry *dst; 8518c2ecf20Sopenharmony_ci /* Source address. */ 8528c2ecf20Sopenharmony_ci union sctp_addr saddr; 8538c2ecf20Sopenharmony_ci 8548c2ecf20Sopenharmony_ci /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to 8558c2ecf20Sopenharmony_ci * the destination address every heartbeat interval. 8568c2ecf20Sopenharmony_ci */ 8578c2ecf20Sopenharmony_ci unsigned long hbinterval; 8588c2ecf20Sopenharmony_ci 8598c2ecf20Sopenharmony_ci /* SACK delay timeout */ 8608c2ecf20Sopenharmony_ci unsigned long sackdelay; 8618c2ecf20Sopenharmony_ci __u32 sackfreq; 8628c2ecf20Sopenharmony_ci 8638c2ecf20Sopenharmony_ci atomic_t mtu_info; 8648c2ecf20Sopenharmony_ci 8658c2ecf20Sopenharmony_ci /* When was the last time that we heard from this transport? We use 8668c2ecf20Sopenharmony_ci * this to pick new active and retran paths. 8678c2ecf20Sopenharmony_ci */ 8688c2ecf20Sopenharmony_ci ktime_t last_time_heard; 8698c2ecf20Sopenharmony_ci 8708c2ecf20Sopenharmony_ci /* When was the last time that we sent a chunk using this 8718c2ecf20Sopenharmony_ci * transport? We use this to check for idle transports 8728c2ecf20Sopenharmony_ci */ 8738c2ecf20Sopenharmony_ci unsigned long last_time_sent; 8748c2ecf20Sopenharmony_ci 8758c2ecf20Sopenharmony_ci /* Last time(in jiffies) when cwnd is reduced due to the congestion 8768c2ecf20Sopenharmony_ci * indication based on ECNE chunk. 8778c2ecf20Sopenharmony_ci */ 8788c2ecf20Sopenharmony_ci unsigned long last_time_ecne_reduced; 8798c2ecf20Sopenharmony_ci 8808c2ecf20Sopenharmony_ci /* This is the max_retrans value for the transport and will 8818c2ecf20Sopenharmony_ci * be initialized from the assocs value. This can be changed 8828c2ecf20Sopenharmony_ci * using the SCTP_SET_PEER_ADDR_PARAMS socket option. 8838c2ecf20Sopenharmony_ci */ 8848c2ecf20Sopenharmony_ci __u16 pathmaxrxt; 8858c2ecf20Sopenharmony_ci 8868c2ecf20Sopenharmony_ci __u32 flowlabel; 8878c2ecf20Sopenharmony_ci __u8 dscp; 8888c2ecf20Sopenharmony_ci 8898c2ecf20Sopenharmony_ci /* This is the partially failed retrans value for the transport 8908c2ecf20Sopenharmony_ci * and will be initialized from the assocs value. This can be changed 8918c2ecf20Sopenharmony_ci * using the SCTP_PEER_ADDR_THLDS socket option 8928c2ecf20Sopenharmony_ci */ 8938c2ecf20Sopenharmony_ci __u16 pf_retrans; 8948c2ecf20Sopenharmony_ci /* Used for primary path switchover. */ 8958c2ecf20Sopenharmony_ci __u16 ps_retrans; 8968c2ecf20Sopenharmony_ci /* PMTU : The current known path MTU. */ 8978c2ecf20Sopenharmony_ci __u32 pathmtu; 8988c2ecf20Sopenharmony_ci 8998c2ecf20Sopenharmony_ci /* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */ 9008c2ecf20Sopenharmony_ci __u32 param_flags; 9018c2ecf20Sopenharmony_ci 9028c2ecf20Sopenharmony_ci /* The number of times INIT has been sent on this transport. */ 9038c2ecf20Sopenharmony_ci int init_sent_count; 9048c2ecf20Sopenharmony_ci 9058c2ecf20Sopenharmony_ci /* state : The current state of this destination, 9068c2ecf20Sopenharmony_ci * : i.e. SCTP_ACTIVE, SCTP_INACTIVE, SCTP_UNKNOWN. 9078c2ecf20Sopenharmony_ci */ 9088c2ecf20Sopenharmony_ci int state; 9098c2ecf20Sopenharmony_ci 9108c2ecf20Sopenharmony_ci /* These are the error stats for this destination. */ 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci /* Error count : The current error count for this destination. */ 9138c2ecf20Sopenharmony_ci unsigned short error_count; 9148c2ecf20Sopenharmony_ci 9158c2ecf20Sopenharmony_ci /* Per : A timer used by each destination. 9168c2ecf20Sopenharmony_ci * Destination : 9178c2ecf20Sopenharmony_ci * Timer : 9188c2ecf20Sopenharmony_ci * 9198c2ecf20Sopenharmony_ci * [Everywhere else in the text this is called T3-rtx. -ed] 9208c2ecf20Sopenharmony_ci */ 9218c2ecf20Sopenharmony_ci struct timer_list T3_rtx_timer; 9228c2ecf20Sopenharmony_ci 9238c2ecf20Sopenharmony_ci /* Heartbeat timer is per destination. */ 9248c2ecf20Sopenharmony_ci struct timer_list hb_timer; 9258c2ecf20Sopenharmony_ci 9268c2ecf20Sopenharmony_ci /* Timer to handle ICMP proto unreachable envets */ 9278c2ecf20Sopenharmony_ci struct timer_list proto_unreach_timer; 9288c2ecf20Sopenharmony_ci 9298c2ecf20Sopenharmony_ci /* Timer to handler reconf chunk rtx */ 9308c2ecf20Sopenharmony_ci struct timer_list reconf_timer; 9318c2ecf20Sopenharmony_ci 9328c2ecf20Sopenharmony_ci /* Since we're using per-destination retransmission timers 9338c2ecf20Sopenharmony_ci * (see above), we're also using per-destination "transmitted" 9348c2ecf20Sopenharmony_ci * queues. This probably ought to be a private struct 9358c2ecf20Sopenharmony_ci * accessible only within the outqueue, but it's not, yet. 9368c2ecf20Sopenharmony_ci */ 9378c2ecf20Sopenharmony_ci struct list_head transmitted; 9388c2ecf20Sopenharmony_ci 9398c2ecf20Sopenharmony_ci /* We build bundle-able packets for this transport here. */ 9408c2ecf20Sopenharmony_ci struct sctp_packet packet; 9418c2ecf20Sopenharmony_ci 9428c2ecf20Sopenharmony_ci /* This is the list of transports that have chunks to send. */ 9438c2ecf20Sopenharmony_ci struct list_head send_ready; 9448c2ecf20Sopenharmony_ci 9458c2ecf20Sopenharmony_ci /* State information saved for SFR_CACC algorithm. The key 9468c2ecf20Sopenharmony_ci * idea in SFR_CACC is to maintain state at the sender on a 9478c2ecf20Sopenharmony_ci * per-destination basis when a changeover happens. 9488c2ecf20Sopenharmony_ci * char changeover_active; 9498c2ecf20Sopenharmony_ci * char cycling_changeover; 9508c2ecf20Sopenharmony_ci * __u32 next_tsn_at_change; 9518c2ecf20Sopenharmony_ci * char cacc_saw_newack; 9528c2ecf20Sopenharmony_ci */ 9538c2ecf20Sopenharmony_ci struct { 9548c2ecf20Sopenharmony_ci /* An unsigned integer, which stores the next TSN to be 9558c2ecf20Sopenharmony_ci * used by the sender, at the moment of changeover. 9568c2ecf20Sopenharmony_ci */ 9578c2ecf20Sopenharmony_ci __u32 next_tsn_at_change; 9588c2ecf20Sopenharmony_ci 9598c2ecf20Sopenharmony_ci /* A flag which indicates the occurrence of a changeover */ 9608c2ecf20Sopenharmony_ci char changeover_active; 9618c2ecf20Sopenharmony_ci 9628c2ecf20Sopenharmony_ci /* A flag which indicates whether the change of primary is 9638c2ecf20Sopenharmony_ci * the first switch to this destination address during an 9648c2ecf20Sopenharmony_ci * active switch. 9658c2ecf20Sopenharmony_ci */ 9668c2ecf20Sopenharmony_ci char cycling_changeover; 9678c2ecf20Sopenharmony_ci 9688c2ecf20Sopenharmony_ci /* A temporary flag, which is used during the processing of 9698c2ecf20Sopenharmony_ci * a SACK to estimate the causative TSN(s)'s group. 9708c2ecf20Sopenharmony_ci */ 9718c2ecf20Sopenharmony_ci char cacc_saw_newack; 9728c2ecf20Sopenharmony_ci } cacc; 9738c2ecf20Sopenharmony_ci 9748c2ecf20Sopenharmony_ci /* 64-bit random number sent with heartbeat. */ 9758c2ecf20Sopenharmony_ci __u64 hb_nonce; 9768c2ecf20Sopenharmony_ci 9778c2ecf20Sopenharmony_ci struct rcu_head rcu; 9788c2ecf20Sopenharmony_ci}; 9798c2ecf20Sopenharmony_ci 9808c2ecf20Sopenharmony_cistruct sctp_transport *sctp_transport_new(struct net *, const union sctp_addr *, 9818c2ecf20Sopenharmony_ci gfp_t); 9828c2ecf20Sopenharmony_civoid sctp_transport_set_owner(struct sctp_transport *, 9838c2ecf20Sopenharmony_ci struct sctp_association *); 9848c2ecf20Sopenharmony_civoid sctp_transport_route(struct sctp_transport *, union sctp_addr *, 9858c2ecf20Sopenharmony_ci struct sctp_sock *); 9868c2ecf20Sopenharmony_civoid sctp_transport_pmtu(struct sctp_transport *, struct sock *sk); 9878c2ecf20Sopenharmony_civoid sctp_transport_free(struct sctp_transport *); 9888c2ecf20Sopenharmony_civoid sctp_transport_reset_t3_rtx(struct sctp_transport *); 9898c2ecf20Sopenharmony_civoid sctp_transport_reset_hb_timer(struct sctp_transport *); 9908c2ecf20Sopenharmony_civoid sctp_transport_reset_reconf_timer(struct sctp_transport *transport); 9918c2ecf20Sopenharmony_ciint sctp_transport_hold(struct sctp_transport *); 9928c2ecf20Sopenharmony_civoid sctp_transport_put(struct sctp_transport *); 9938c2ecf20Sopenharmony_civoid sctp_transport_update_rto(struct sctp_transport *, __u32); 9948c2ecf20Sopenharmony_civoid sctp_transport_raise_cwnd(struct sctp_transport *, __u32, __u32); 9958c2ecf20Sopenharmony_civoid sctp_transport_lower_cwnd(struct sctp_transport *t, 9968c2ecf20Sopenharmony_ci enum sctp_lower_cwnd reason); 9978c2ecf20Sopenharmony_civoid sctp_transport_burst_limited(struct sctp_transport *); 9988c2ecf20Sopenharmony_civoid sctp_transport_burst_reset(struct sctp_transport *); 9998c2ecf20Sopenharmony_ciunsigned long sctp_transport_timeout(struct sctp_transport *); 10008c2ecf20Sopenharmony_civoid sctp_transport_reset(struct sctp_transport *t); 10018c2ecf20Sopenharmony_cibool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu); 10028c2ecf20Sopenharmony_civoid sctp_transport_immediate_rtx(struct sctp_transport *); 10038c2ecf20Sopenharmony_civoid sctp_transport_dst_release(struct sctp_transport *t); 10048c2ecf20Sopenharmony_civoid sctp_transport_dst_confirm(struct sctp_transport *t); 10058c2ecf20Sopenharmony_ci 10068c2ecf20Sopenharmony_ci 10078c2ecf20Sopenharmony_ci/* This is the structure we use to queue packets as they come into 10088c2ecf20Sopenharmony_ci * SCTP. We write packets to it and read chunks from it. 10098c2ecf20Sopenharmony_ci */ 10108c2ecf20Sopenharmony_cistruct sctp_inq { 10118c2ecf20Sopenharmony_ci /* This is actually a queue of sctp_chunk each 10128c2ecf20Sopenharmony_ci * containing a partially decoded packet. 10138c2ecf20Sopenharmony_ci */ 10148c2ecf20Sopenharmony_ci struct list_head in_chunk_list; 10158c2ecf20Sopenharmony_ci /* This is the packet which is currently off the in queue and is 10168c2ecf20Sopenharmony_ci * being worked on through the inbound chunk processing. 10178c2ecf20Sopenharmony_ci */ 10188c2ecf20Sopenharmony_ci struct sctp_chunk *in_progress; 10198c2ecf20Sopenharmony_ci 10208c2ecf20Sopenharmony_ci /* This is the delayed task to finish delivering inbound 10218c2ecf20Sopenharmony_ci * messages. 10228c2ecf20Sopenharmony_ci */ 10238c2ecf20Sopenharmony_ci struct work_struct immediate; 10248c2ecf20Sopenharmony_ci}; 10258c2ecf20Sopenharmony_ci 10268c2ecf20Sopenharmony_civoid sctp_inq_init(struct sctp_inq *); 10278c2ecf20Sopenharmony_civoid sctp_inq_free(struct sctp_inq *); 10288c2ecf20Sopenharmony_civoid sctp_inq_push(struct sctp_inq *, struct sctp_chunk *packet); 10298c2ecf20Sopenharmony_cistruct sctp_chunk *sctp_inq_pop(struct sctp_inq *); 10308c2ecf20Sopenharmony_cistruct sctp_chunkhdr *sctp_inq_peek(struct sctp_inq *); 10318c2ecf20Sopenharmony_civoid sctp_inq_set_th_handler(struct sctp_inq *, work_func_t); 10328c2ecf20Sopenharmony_ci 10338c2ecf20Sopenharmony_ci/* This is the structure we use to hold outbound chunks. You push 10348c2ecf20Sopenharmony_ci * chunks in and they automatically pop out the other end as bundled 10358c2ecf20Sopenharmony_ci * packets (it calls (*output_handler)()). 10368c2ecf20Sopenharmony_ci * 10378c2ecf20Sopenharmony_ci * This structure covers sections 6.3, 6.4, 6.7, 6.8, 6.10, 7., 8.1, 10388c2ecf20Sopenharmony_ci * and 8.2 of the v13 draft. 10398c2ecf20Sopenharmony_ci * 10408c2ecf20Sopenharmony_ci * It handles retransmissions. The connection to the timeout portion 10418c2ecf20Sopenharmony_ci * of the state machine is through sctp_..._timeout() and timeout_handler. 10428c2ecf20Sopenharmony_ci * 10438c2ecf20Sopenharmony_ci * If you feed it SACKs, it will eat them. 10448c2ecf20Sopenharmony_ci * 10458c2ecf20Sopenharmony_ci * If you give it big chunks, it will fragment them. 10468c2ecf20Sopenharmony_ci * 10478c2ecf20Sopenharmony_ci * It assigns TSN's to data chunks. This happens at the last possible 10488c2ecf20Sopenharmony_ci * instant before transmission. 10498c2ecf20Sopenharmony_ci * 10508c2ecf20Sopenharmony_ci * When free()'d, it empties itself out via output_handler(). 10518c2ecf20Sopenharmony_ci */ 10528c2ecf20Sopenharmony_cistruct sctp_outq { 10538c2ecf20Sopenharmony_ci struct sctp_association *asoc; 10548c2ecf20Sopenharmony_ci 10558c2ecf20Sopenharmony_ci /* Data pending that has never been transmitted. */ 10568c2ecf20Sopenharmony_ci struct list_head out_chunk_list; 10578c2ecf20Sopenharmony_ci 10588c2ecf20Sopenharmony_ci /* Stream scheduler being used */ 10598c2ecf20Sopenharmony_ci struct sctp_sched_ops *sched; 10608c2ecf20Sopenharmony_ci 10618c2ecf20Sopenharmony_ci unsigned int out_qlen; /* Total length of queued data chunks. */ 10628c2ecf20Sopenharmony_ci 10638c2ecf20Sopenharmony_ci /* Error of send failed, may used in SCTP_SEND_FAILED event. */ 10648c2ecf20Sopenharmony_ci unsigned int error; 10658c2ecf20Sopenharmony_ci 10668c2ecf20Sopenharmony_ci /* These are control chunks we want to send. */ 10678c2ecf20Sopenharmony_ci struct list_head control_chunk_list; 10688c2ecf20Sopenharmony_ci 10698c2ecf20Sopenharmony_ci /* These are chunks that have been sacked but are above the 10708c2ecf20Sopenharmony_ci * CTSN, or cumulative tsn ack point. 10718c2ecf20Sopenharmony_ci */ 10728c2ecf20Sopenharmony_ci struct list_head sacked; 10738c2ecf20Sopenharmony_ci 10748c2ecf20Sopenharmony_ci /* Put chunks on this list to schedule them for 10758c2ecf20Sopenharmony_ci * retransmission. 10768c2ecf20Sopenharmony_ci */ 10778c2ecf20Sopenharmony_ci struct list_head retransmit; 10788c2ecf20Sopenharmony_ci 10798c2ecf20Sopenharmony_ci /* Put chunks on this list to save them for FWD TSN processing as 10808c2ecf20Sopenharmony_ci * they were abandoned. 10818c2ecf20Sopenharmony_ci */ 10828c2ecf20Sopenharmony_ci struct list_head abandoned; 10838c2ecf20Sopenharmony_ci 10848c2ecf20Sopenharmony_ci /* How many unackd bytes do we have in-flight? */ 10858c2ecf20Sopenharmony_ci __u32 outstanding_bytes; 10868c2ecf20Sopenharmony_ci 10878c2ecf20Sopenharmony_ci /* Are we doing fast-rtx on this queue */ 10888c2ecf20Sopenharmony_ci char fast_rtx; 10898c2ecf20Sopenharmony_ci 10908c2ecf20Sopenharmony_ci /* Corked? */ 10918c2ecf20Sopenharmony_ci char cork; 10928c2ecf20Sopenharmony_ci}; 10938c2ecf20Sopenharmony_ci 10948c2ecf20Sopenharmony_civoid sctp_outq_init(struct sctp_association *, struct sctp_outq *); 10958c2ecf20Sopenharmony_civoid sctp_outq_teardown(struct sctp_outq *); 10968c2ecf20Sopenharmony_civoid sctp_outq_free(struct sctp_outq*); 10978c2ecf20Sopenharmony_civoid sctp_outq_tail(struct sctp_outq *, struct sctp_chunk *chunk, gfp_t); 10988c2ecf20Sopenharmony_ciint sctp_outq_sack(struct sctp_outq *, struct sctp_chunk *); 10998c2ecf20Sopenharmony_ciint sctp_outq_is_empty(const struct sctp_outq *); 11008c2ecf20Sopenharmony_civoid sctp_outq_restart(struct sctp_outq *); 11018c2ecf20Sopenharmony_ci 11028c2ecf20Sopenharmony_civoid sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport, 11038c2ecf20Sopenharmony_ci enum sctp_retransmit_reason reason); 11048c2ecf20Sopenharmony_civoid sctp_retransmit_mark(struct sctp_outq *, struct sctp_transport *, __u8); 11058c2ecf20Sopenharmony_civoid sctp_outq_uncork(struct sctp_outq *, gfp_t gfp); 11068c2ecf20Sopenharmony_civoid sctp_prsctp_prune(struct sctp_association *asoc, 11078c2ecf20Sopenharmony_ci struct sctp_sndrcvinfo *sinfo, int msg_len); 11088c2ecf20Sopenharmony_civoid sctp_generate_fwdtsn(struct sctp_outq *q, __u32 sack_ctsn); 11098c2ecf20Sopenharmony_ci/* Uncork and flush an outqueue. */ 11108c2ecf20Sopenharmony_cistatic inline void sctp_outq_cork(struct sctp_outq *q) 11118c2ecf20Sopenharmony_ci{ 11128c2ecf20Sopenharmony_ci q->cork = 1; 11138c2ecf20Sopenharmony_ci} 11148c2ecf20Sopenharmony_ci 11158c2ecf20Sopenharmony_ci/* SCTP skb control block. 11168c2ecf20Sopenharmony_ci * sctp_input_cb is currently used on rx and sock rx queue 11178c2ecf20Sopenharmony_ci */ 11188c2ecf20Sopenharmony_cistruct sctp_input_cb { 11198c2ecf20Sopenharmony_ci union { 11208c2ecf20Sopenharmony_ci struct inet_skb_parm h4; 11218c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_IPV6) 11228c2ecf20Sopenharmony_ci struct inet6_skb_parm h6; 11238c2ecf20Sopenharmony_ci#endif 11248c2ecf20Sopenharmony_ci } header; 11258c2ecf20Sopenharmony_ci struct sctp_chunk *chunk; 11268c2ecf20Sopenharmony_ci struct sctp_af *af; 11278c2ecf20Sopenharmony_ci}; 11288c2ecf20Sopenharmony_ci#define SCTP_INPUT_CB(__skb) ((struct sctp_input_cb *)&((__skb)->cb[0])) 11298c2ecf20Sopenharmony_ci 11308c2ecf20Sopenharmony_cistruct sctp_output_cb { 11318c2ecf20Sopenharmony_ci struct sk_buff *last; 11328c2ecf20Sopenharmony_ci}; 11338c2ecf20Sopenharmony_ci#define SCTP_OUTPUT_CB(__skb) ((struct sctp_output_cb *)&((__skb)->cb[0])) 11348c2ecf20Sopenharmony_ci 11358c2ecf20Sopenharmony_cistatic inline const struct sk_buff *sctp_gso_headskb(const struct sk_buff *skb) 11368c2ecf20Sopenharmony_ci{ 11378c2ecf20Sopenharmony_ci const struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk; 11388c2ecf20Sopenharmony_ci 11398c2ecf20Sopenharmony_ci return chunk->head_skb ? : skb; 11408c2ecf20Sopenharmony_ci} 11418c2ecf20Sopenharmony_ci 11428c2ecf20Sopenharmony_ci/* These bind address data fields common between endpoints and associations */ 11438c2ecf20Sopenharmony_cistruct sctp_bind_addr { 11448c2ecf20Sopenharmony_ci 11458c2ecf20Sopenharmony_ci /* RFC 2960 12.1 Parameters necessary for the SCTP instance 11468c2ecf20Sopenharmony_ci * 11478c2ecf20Sopenharmony_ci * SCTP Port: The local SCTP port number the endpoint is 11488c2ecf20Sopenharmony_ci * bound to. 11498c2ecf20Sopenharmony_ci */ 11508c2ecf20Sopenharmony_ci __u16 port; 11518c2ecf20Sopenharmony_ci 11528c2ecf20Sopenharmony_ci /* RFC 2960 12.1 Parameters necessary for the SCTP instance 11538c2ecf20Sopenharmony_ci * 11548c2ecf20Sopenharmony_ci * Address List: The list of IP addresses that this instance 11558c2ecf20Sopenharmony_ci * has bound. This information is passed to one's 11568c2ecf20Sopenharmony_ci * peer(s) in INIT and INIT ACK chunks. 11578c2ecf20Sopenharmony_ci */ 11588c2ecf20Sopenharmony_ci struct list_head address_list; 11598c2ecf20Sopenharmony_ci}; 11608c2ecf20Sopenharmony_ci 11618c2ecf20Sopenharmony_civoid sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port); 11628c2ecf20Sopenharmony_civoid sctp_bind_addr_free(struct sctp_bind_addr *); 11638c2ecf20Sopenharmony_ciint sctp_bind_addr_copy(struct net *net, struct sctp_bind_addr *dest, 11648c2ecf20Sopenharmony_ci const struct sctp_bind_addr *src, 11658c2ecf20Sopenharmony_ci enum sctp_scope scope, gfp_t gfp, 11668c2ecf20Sopenharmony_ci int flags); 11678c2ecf20Sopenharmony_ciint sctp_bind_addr_dup(struct sctp_bind_addr *dest, 11688c2ecf20Sopenharmony_ci const struct sctp_bind_addr *src, 11698c2ecf20Sopenharmony_ci gfp_t gfp); 11708c2ecf20Sopenharmony_ciint sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *, 11718c2ecf20Sopenharmony_ci int new_size, __u8 addr_state, gfp_t gfp); 11728c2ecf20Sopenharmony_ciint sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *); 11738c2ecf20Sopenharmony_ciint sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *, 11748c2ecf20Sopenharmony_ci struct sctp_sock *); 11758c2ecf20Sopenharmony_ciint sctp_bind_addr_conflict(struct sctp_bind_addr *, const union sctp_addr *, 11768c2ecf20Sopenharmony_ci struct sctp_sock *, struct sctp_sock *); 11778c2ecf20Sopenharmony_ciint sctp_bind_addr_state(const struct sctp_bind_addr *bp, 11788c2ecf20Sopenharmony_ci const union sctp_addr *addr); 11798c2ecf20Sopenharmony_ciint sctp_bind_addrs_check(struct sctp_sock *sp, 11808c2ecf20Sopenharmony_ci struct sctp_sock *sp2, int cnt2); 11818c2ecf20Sopenharmony_ciunion sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp, 11828c2ecf20Sopenharmony_ci const union sctp_addr *addrs, 11838c2ecf20Sopenharmony_ci int addrcnt, 11848c2ecf20Sopenharmony_ci struct sctp_sock *opt); 11858c2ecf20Sopenharmony_ciunion sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp, 11868c2ecf20Sopenharmony_ci int *addrs_len, 11878c2ecf20Sopenharmony_ci gfp_t gfp); 11888c2ecf20Sopenharmony_ciint sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len, 11898c2ecf20Sopenharmony_ci __u16 port, gfp_t gfp); 11908c2ecf20Sopenharmony_ci 11918c2ecf20Sopenharmony_cienum sctp_scope sctp_scope(const union sctp_addr *addr); 11928c2ecf20Sopenharmony_ciint sctp_in_scope(struct net *net, const union sctp_addr *addr, 11938c2ecf20Sopenharmony_ci const enum sctp_scope scope); 11948c2ecf20Sopenharmony_ciint sctp_is_any(struct sock *sk, const union sctp_addr *addr); 11958c2ecf20Sopenharmony_ciint sctp_is_ep_boundall(struct sock *sk); 11968c2ecf20Sopenharmony_ci 11978c2ecf20Sopenharmony_ci 11988c2ecf20Sopenharmony_ci/* What type of endpoint? */ 11998c2ecf20Sopenharmony_cienum sctp_endpoint_type { 12008c2ecf20Sopenharmony_ci SCTP_EP_TYPE_SOCKET, 12018c2ecf20Sopenharmony_ci SCTP_EP_TYPE_ASSOCIATION, 12028c2ecf20Sopenharmony_ci}; 12038c2ecf20Sopenharmony_ci 12048c2ecf20Sopenharmony_ci/* 12058c2ecf20Sopenharmony_ci * A common base class to bridge the implmentation view of a 12068c2ecf20Sopenharmony_ci * socket (usually listening) endpoint versus an association's 12078c2ecf20Sopenharmony_ci * local endpoint. 12088c2ecf20Sopenharmony_ci * This common structure is useful for several purposes: 12098c2ecf20Sopenharmony_ci * 1) Common interface for lookup routines. 12108c2ecf20Sopenharmony_ci * a) Subfunctions work for either endpoint or association 12118c2ecf20Sopenharmony_ci * b) Single interface to lookup allows hiding the lookup lock rather 12128c2ecf20Sopenharmony_ci * than acquiring it externally. 12138c2ecf20Sopenharmony_ci * 2) Common interface for the inbound chunk handling/state machine. 12148c2ecf20Sopenharmony_ci * 3) Common object handling routines for reference counting, etc. 12158c2ecf20Sopenharmony_ci * 4) Disentangle association lookup from endpoint lookup, where we 12168c2ecf20Sopenharmony_ci * do not have to find our endpoint to find our association. 12178c2ecf20Sopenharmony_ci * 12188c2ecf20Sopenharmony_ci */ 12198c2ecf20Sopenharmony_ci 12208c2ecf20Sopenharmony_cistruct sctp_ep_common { 12218c2ecf20Sopenharmony_ci /* Fields to help us manage our entries in the hash tables. */ 12228c2ecf20Sopenharmony_ci struct hlist_node node; 12238c2ecf20Sopenharmony_ci int hashent; 12248c2ecf20Sopenharmony_ci 12258c2ecf20Sopenharmony_ci /* Runtime type information. What kind of endpoint is this? */ 12268c2ecf20Sopenharmony_ci enum sctp_endpoint_type type; 12278c2ecf20Sopenharmony_ci 12288c2ecf20Sopenharmony_ci /* Some fields to help us manage this object. 12298c2ecf20Sopenharmony_ci * refcnt - Reference count access to this object. 12308c2ecf20Sopenharmony_ci * dead - Do not attempt to use this object. 12318c2ecf20Sopenharmony_ci */ 12328c2ecf20Sopenharmony_ci refcount_t refcnt; 12338c2ecf20Sopenharmony_ci bool dead; 12348c2ecf20Sopenharmony_ci 12358c2ecf20Sopenharmony_ci /* What socket does this endpoint belong to? */ 12368c2ecf20Sopenharmony_ci struct sock *sk; 12378c2ecf20Sopenharmony_ci 12388c2ecf20Sopenharmony_ci /* Cache netns and it won't change once set */ 12398c2ecf20Sopenharmony_ci struct net *net; 12408c2ecf20Sopenharmony_ci 12418c2ecf20Sopenharmony_ci /* This is where we receive inbound chunks. */ 12428c2ecf20Sopenharmony_ci struct sctp_inq inqueue; 12438c2ecf20Sopenharmony_ci 12448c2ecf20Sopenharmony_ci /* This substructure includes the defining parameters of the 12458c2ecf20Sopenharmony_ci * endpoint: 12468c2ecf20Sopenharmony_ci * bind_addr.port is our shared port number. 12478c2ecf20Sopenharmony_ci * bind_addr.address_list is our set of local IP addresses. 12488c2ecf20Sopenharmony_ci */ 12498c2ecf20Sopenharmony_ci struct sctp_bind_addr bind_addr; 12508c2ecf20Sopenharmony_ci}; 12518c2ecf20Sopenharmony_ci 12528c2ecf20Sopenharmony_ci 12538c2ecf20Sopenharmony_ci/* RFC Section 1.4 Key Terms 12548c2ecf20Sopenharmony_ci * 12558c2ecf20Sopenharmony_ci * o SCTP endpoint: The logical sender/receiver of SCTP packets. On a 12568c2ecf20Sopenharmony_ci * multi-homed host, an SCTP endpoint is represented to its peers as a 12578c2ecf20Sopenharmony_ci * combination of a set of eligible destination transport addresses to 12588c2ecf20Sopenharmony_ci * which SCTP packets can be sent and a set of eligible source 12598c2ecf20Sopenharmony_ci * transport addresses from which SCTP packets can be received. 12608c2ecf20Sopenharmony_ci * All transport addresses used by an SCTP endpoint must use the 12618c2ecf20Sopenharmony_ci * same port number, but can use multiple IP addresses. A transport 12628c2ecf20Sopenharmony_ci * address used by an SCTP endpoint must not be used by another 12638c2ecf20Sopenharmony_ci * SCTP endpoint. In other words, a transport address is unique 12648c2ecf20Sopenharmony_ci * to an SCTP endpoint. 12658c2ecf20Sopenharmony_ci * 12668c2ecf20Sopenharmony_ci * From an implementation perspective, each socket has one of these. 12678c2ecf20Sopenharmony_ci * A TCP-style socket will have exactly one association on one of 12688c2ecf20Sopenharmony_ci * these. An UDP-style socket will have multiple associations hanging 12698c2ecf20Sopenharmony_ci * off one of these. 12708c2ecf20Sopenharmony_ci */ 12718c2ecf20Sopenharmony_ci 12728c2ecf20Sopenharmony_cistruct sctp_endpoint { 12738c2ecf20Sopenharmony_ci /* Common substructure for endpoint and association. */ 12748c2ecf20Sopenharmony_ci struct sctp_ep_common base; 12758c2ecf20Sopenharmony_ci 12768c2ecf20Sopenharmony_ci /* Associations: A list of current associations and mappings 12778c2ecf20Sopenharmony_ci * to the data consumers for each association. This 12788c2ecf20Sopenharmony_ci * may be in the form of a hash table or other 12798c2ecf20Sopenharmony_ci * implementation dependent structure. The data 12808c2ecf20Sopenharmony_ci * consumers may be process identification 12818c2ecf20Sopenharmony_ci * information such as file descriptors, named pipe 12828c2ecf20Sopenharmony_ci * pointer, or table pointers dependent on how SCTP 12838c2ecf20Sopenharmony_ci * is implemented. 12848c2ecf20Sopenharmony_ci */ 12858c2ecf20Sopenharmony_ci /* This is really a list of struct sctp_association entries. */ 12868c2ecf20Sopenharmony_ci struct list_head asocs; 12878c2ecf20Sopenharmony_ci 12888c2ecf20Sopenharmony_ci /* Secret Key: A secret key used by this endpoint to compute 12898c2ecf20Sopenharmony_ci * the MAC. This SHOULD be a cryptographic quality 12908c2ecf20Sopenharmony_ci * random number with a sufficient length. 12918c2ecf20Sopenharmony_ci * Discussion in [RFC1750] can be helpful in 12928c2ecf20Sopenharmony_ci * selection of the key. 12938c2ecf20Sopenharmony_ci */ 12948c2ecf20Sopenharmony_ci __u8 secret_key[SCTP_SECRET_SIZE]; 12958c2ecf20Sopenharmony_ci 12968c2ecf20Sopenharmony_ci /* digest: This is a digest of the sctp cookie. This field is 12978c2ecf20Sopenharmony_ci * only used on the receive path when we try to validate 12988c2ecf20Sopenharmony_ci * that the cookie has not been tampered with. We put 12998c2ecf20Sopenharmony_ci * this here so we pre-allocate this once and can re-use 13008c2ecf20Sopenharmony_ci * on every receive. 13018c2ecf20Sopenharmony_ci */ 13028c2ecf20Sopenharmony_ci __u8 *digest; 13038c2ecf20Sopenharmony_ci 13048c2ecf20Sopenharmony_ci /* sendbuf acct. policy. */ 13058c2ecf20Sopenharmony_ci __u32 sndbuf_policy; 13068c2ecf20Sopenharmony_ci 13078c2ecf20Sopenharmony_ci /* rcvbuf acct. policy. */ 13088c2ecf20Sopenharmony_ci __u32 rcvbuf_policy; 13098c2ecf20Sopenharmony_ci 13108c2ecf20Sopenharmony_ci /* SCTP AUTH: array of the HMACs that will be allocated 13118c2ecf20Sopenharmony_ci * we need this per association so that we don't serialize 13128c2ecf20Sopenharmony_ci */ 13138c2ecf20Sopenharmony_ci struct crypto_shash **auth_hmacs; 13148c2ecf20Sopenharmony_ci 13158c2ecf20Sopenharmony_ci /* SCTP-AUTH: hmacs for the endpoint encoded into parameter */ 13168c2ecf20Sopenharmony_ci struct sctp_hmac_algo_param *auth_hmacs_list; 13178c2ecf20Sopenharmony_ci 13188c2ecf20Sopenharmony_ci /* SCTP-AUTH: chunks to authenticate encoded into parameter */ 13198c2ecf20Sopenharmony_ci struct sctp_chunks_param *auth_chunk_list; 13208c2ecf20Sopenharmony_ci 13218c2ecf20Sopenharmony_ci /* SCTP-AUTH: endpoint shared keys */ 13228c2ecf20Sopenharmony_ci struct list_head endpoint_shared_keys; 13238c2ecf20Sopenharmony_ci __u16 active_key_id; 13248c2ecf20Sopenharmony_ci __u8 ecn_enable:1, 13258c2ecf20Sopenharmony_ci auth_enable:1, 13268c2ecf20Sopenharmony_ci intl_enable:1, 13278c2ecf20Sopenharmony_ci prsctp_enable:1, 13288c2ecf20Sopenharmony_ci asconf_enable:1, 13298c2ecf20Sopenharmony_ci reconf_enable:1; 13308c2ecf20Sopenharmony_ci 13318c2ecf20Sopenharmony_ci __u8 strreset_enable; 13328c2ecf20Sopenharmony_ci 13338c2ecf20Sopenharmony_ci /* Security identifiers from incoming (INIT). These are set by 13348c2ecf20Sopenharmony_ci * security_sctp_assoc_request(). These will only be used by 13358c2ecf20Sopenharmony_ci * SCTP TCP type sockets and peeled off connections as they 13368c2ecf20Sopenharmony_ci * cause a new socket to be generated. security_sctp_sk_clone() 13378c2ecf20Sopenharmony_ci * will then plug these into the new socket. 13388c2ecf20Sopenharmony_ci */ 13398c2ecf20Sopenharmony_ci 13408c2ecf20Sopenharmony_ci u32 secid; 13418c2ecf20Sopenharmony_ci u32 peer_secid; 13428c2ecf20Sopenharmony_ci struct rcu_head rcu; 13438c2ecf20Sopenharmony_ci}; 13448c2ecf20Sopenharmony_ci 13458c2ecf20Sopenharmony_ci/* Recover the outter endpoint structure. */ 13468c2ecf20Sopenharmony_cistatic inline struct sctp_endpoint *sctp_ep(struct sctp_ep_common *base) 13478c2ecf20Sopenharmony_ci{ 13488c2ecf20Sopenharmony_ci struct sctp_endpoint *ep; 13498c2ecf20Sopenharmony_ci 13508c2ecf20Sopenharmony_ci ep = container_of(base, struct sctp_endpoint, base); 13518c2ecf20Sopenharmony_ci return ep; 13528c2ecf20Sopenharmony_ci} 13538c2ecf20Sopenharmony_ci 13548c2ecf20Sopenharmony_ci/* These are function signatures for manipulating endpoints. */ 13558c2ecf20Sopenharmony_cistruct sctp_endpoint *sctp_endpoint_new(struct sock *, gfp_t); 13568c2ecf20Sopenharmony_civoid sctp_endpoint_free(struct sctp_endpoint *); 13578c2ecf20Sopenharmony_civoid sctp_endpoint_put(struct sctp_endpoint *); 13588c2ecf20Sopenharmony_ciint sctp_endpoint_hold(struct sctp_endpoint *ep); 13598c2ecf20Sopenharmony_civoid sctp_endpoint_add_asoc(struct sctp_endpoint *, struct sctp_association *); 13608c2ecf20Sopenharmony_cistruct sctp_association *sctp_endpoint_lookup_assoc( 13618c2ecf20Sopenharmony_ci const struct sctp_endpoint *ep, 13628c2ecf20Sopenharmony_ci const union sctp_addr *paddr, 13638c2ecf20Sopenharmony_ci struct sctp_transport **); 13648c2ecf20Sopenharmony_cibool sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep, 13658c2ecf20Sopenharmony_ci const union sctp_addr *paddr); 13668c2ecf20Sopenharmony_cistruct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *, 13678c2ecf20Sopenharmony_ci struct net *, const union sctp_addr *); 13688c2ecf20Sopenharmony_cibool sctp_has_association(struct net *net, const union sctp_addr *laddr, 13698c2ecf20Sopenharmony_ci const union sctp_addr *paddr); 13708c2ecf20Sopenharmony_ci 13718c2ecf20Sopenharmony_ciint sctp_verify_init(struct net *net, const struct sctp_endpoint *ep, 13728c2ecf20Sopenharmony_ci const struct sctp_association *asoc, 13738c2ecf20Sopenharmony_ci enum sctp_cid cid, struct sctp_init_chunk *peer_init, 13748c2ecf20Sopenharmony_ci struct sctp_chunk *chunk, struct sctp_chunk **err_chunk); 13758c2ecf20Sopenharmony_ciint sctp_process_init(struct sctp_association *, struct sctp_chunk *chunk, 13768c2ecf20Sopenharmony_ci const union sctp_addr *peer, 13778c2ecf20Sopenharmony_ci struct sctp_init_chunk *init, gfp_t gfp); 13788c2ecf20Sopenharmony_ci__u32 sctp_generate_tag(const struct sctp_endpoint *); 13798c2ecf20Sopenharmony_ci__u32 sctp_generate_tsn(const struct sctp_endpoint *); 13808c2ecf20Sopenharmony_ci 13818c2ecf20Sopenharmony_cistruct sctp_inithdr_host { 13828c2ecf20Sopenharmony_ci __u32 init_tag; 13838c2ecf20Sopenharmony_ci __u32 a_rwnd; 13848c2ecf20Sopenharmony_ci __u16 num_outbound_streams; 13858c2ecf20Sopenharmony_ci __u16 num_inbound_streams; 13868c2ecf20Sopenharmony_ci __u32 initial_tsn; 13878c2ecf20Sopenharmony_ci}; 13888c2ecf20Sopenharmony_ci 13898c2ecf20Sopenharmony_cistruct sctp_stream_priorities { 13908c2ecf20Sopenharmony_ci /* List of priorities scheduled */ 13918c2ecf20Sopenharmony_ci struct list_head prio_sched; 13928c2ecf20Sopenharmony_ci /* List of streams scheduled */ 13938c2ecf20Sopenharmony_ci struct list_head active; 13948c2ecf20Sopenharmony_ci /* The next stream in line */ 13958c2ecf20Sopenharmony_ci struct sctp_stream_out_ext *next; 13968c2ecf20Sopenharmony_ci __u16 prio; 13978c2ecf20Sopenharmony_ci __u16 users; 13988c2ecf20Sopenharmony_ci}; 13998c2ecf20Sopenharmony_ci 14008c2ecf20Sopenharmony_cistruct sctp_stream_out_ext { 14018c2ecf20Sopenharmony_ci __u64 abandoned_unsent[SCTP_PR_INDEX(MAX) + 1]; 14028c2ecf20Sopenharmony_ci __u64 abandoned_sent[SCTP_PR_INDEX(MAX) + 1]; 14038c2ecf20Sopenharmony_ci struct list_head outq; /* chunks enqueued by this stream */ 14048c2ecf20Sopenharmony_ci union { 14058c2ecf20Sopenharmony_ci struct { 14068c2ecf20Sopenharmony_ci /* Scheduled streams list */ 14078c2ecf20Sopenharmony_ci struct list_head prio_list; 14088c2ecf20Sopenharmony_ci struct sctp_stream_priorities *prio_head; 14098c2ecf20Sopenharmony_ci }; 14108c2ecf20Sopenharmony_ci /* Fields used by RR scheduler */ 14118c2ecf20Sopenharmony_ci struct { 14128c2ecf20Sopenharmony_ci struct list_head rr_list; 14138c2ecf20Sopenharmony_ci }; 14148c2ecf20Sopenharmony_ci }; 14158c2ecf20Sopenharmony_ci}; 14168c2ecf20Sopenharmony_ci 14178c2ecf20Sopenharmony_cistruct sctp_stream_out { 14188c2ecf20Sopenharmony_ci union { 14198c2ecf20Sopenharmony_ci __u32 mid; 14208c2ecf20Sopenharmony_ci __u16 ssn; 14218c2ecf20Sopenharmony_ci }; 14228c2ecf20Sopenharmony_ci __u32 mid_uo; 14238c2ecf20Sopenharmony_ci struct sctp_stream_out_ext *ext; 14248c2ecf20Sopenharmony_ci __u8 state; 14258c2ecf20Sopenharmony_ci}; 14268c2ecf20Sopenharmony_ci 14278c2ecf20Sopenharmony_cistruct sctp_stream_in { 14288c2ecf20Sopenharmony_ci union { 14298c2ecf20Sopenharmony_ci __u32 mid; 14308c2ecf20Sopenharmony_ci __u16 ssn; 14318c2ecf20Sopenharmony_ci }; 14328c2ecf20Sopenharmony_ci __u32 mid_uo; 14338c2ecf20Sopenharmony_ci __u32 fsn; 14348c2ecf20Sopenharmony_ci __u32 fsn_uo; 14358c2ecf20Sopenharmony_ci char pd_mode; 14368c2ecf20Sopenharmony_ci char pd_mode_uo; 14378c2ecf20Sopenharmony_ci}; 14388c2ecf20Sopenharmony_ci 14398c2ecf20Sopenharmony_cistruct sctp_stream { 14408c2ecf20Sopenharmony_ci GENRADIX(struct sctp_stream_out) out; 14418c2ecf20Sopenharmony_ci GENRADIX(struct sctp_stream_in) in; 14428c2ecf20Sopenharmony_ci 14438c2ecf20Sopenharmony_ci __u16 outcnt; 14448c2ecf20Sopenharmony_ci __u16 incnt; 14458c2ecf20Sopenharmony_ci /* Current stream being sent, if any */ 14468c2ecf20Sopenharmony_ci struct sctp_stream_out *out_curr; 14478c2ecf20Sopenharmony_ci union { 14488c2ecf20Sopenharmony_ci /* Fields used by priority scheduler */ 14498c2ecf20Sopenharmony_ci struct { 14508c2ecf20Sopenharmony_ci /* List of priorities scheduled */ 14518c2ecf20Sopenharmony_ci struct list_head prio_list; 14528c2ecf20Sopenharmony_ci }; 14538c2ecf20Sopenharmony_ci /* Fields used by RR scheduler */ 14548c2ecf20Sopenharmony_ci struct { 14558c2ecf20Sopenharmony_ci /* List of streams scheduled */ 14568c2ecf20Sopenharmony_ci struct list_head rr_list; 14578c2ecf20Sopenharmony_ci /* The next stream in line */ 14588c2ecf20Sopenharmony_ci struct sctp_stream_out_ext *rr_next; 14598c2ecf20Sopenharmony_ci }; 14608c2ecf20Sopenharmony_ci }; 14618c2ecf20Sopenharmony_ci struct sctp_stream_interleave *si; 14628c2ecf20Sopenharmony_ci}; 14638c2ecf20Sopenharmony_ci 14648c2ecf20Sopenharmony_cistatic inline struct sctp_stream_out *sctp_stream_out( 14658c2ecf20Sopenharmony_ci struct sctp_stream *stream, 14668c2ecf20Sopenharmony_ci __u16 sid) 14678c2ecf20Sopenharmony_ci{ 14688c2ecf20Sopenharmony_ci return genradix_ptr(&stream->out, sid); 14698c2ecf20Sopenharmony_ci} 14708c2ecf20Sopenharmony_ci 14718c2ecf20Sopenharmony_cistatic inline struct sctp_stream_in *sctp_stream_in( 14728c2ecf20Sopenharmony_ci struct sctp_stream *stream, 14738c2ecf20Sopenharmony_ci __u16 sid) 14748c2ecf20Sopenharmony_ci{ 14758c2ecf20Sopenharmony_ci return genradix_ptr(&stream->in, sid); 14768c2ecf20Sopenharmony_ci} 14778c2ecf20Sopenharmony_ci 14788c2ecf20Sopenharmony_ci#define SCTP_SO(s, i) sctp_stream_out((s), (i)) 14798c2ecf20Sopenharmony_ci#define SCTP_SI(s, i) sctp_stream_in((s), (i)) 14808c2ecf20Sopenharmony_ci 14818c2ecf20Sopenharmony_ci#define SCTP_STREAM_CLOSED 0x00 14828c2ecf20Sopenharmony_ci#define SCTP_STREAM_OPEN 0x01 14838c2ecf20Sopenharmony_ci 14848c2ecf20Sopenharmony_cistatic inline __u16 sctp_datachk_len(const struct sctp_stream *stream) 14858c2ecf20Sopenharmony_ci{ 14868c2ecf20Sopenharmony_ci return stream->si->data_chunk_len; 14878c2ecf20Sopenharmony_ci} 14888c2ecf20Sopenharmony_ci 14898c2ecf20Sopenharmony_cistatic inline __u16 sctp_datahdr_len(const struct sctp_stream *stream) 14908c2ecf20Sopenharmony_ci{ 14918c2ecf20Sopenharmony_ci return stream->si->data_chunk_len - sizeof(struct sctp_chunkhdr); 14928c2ecf20Sopenharmony_ci} 14938c2ecf20Sopenharmony_ci 14948c2ecf20Sopenharmony_cistatic inline __u16 sctp_ftsnchk_len(const struct sctp_stream *stream) 14958c2ecf20Sopenharmony_ci{ 14968c2ecf20Sopenharmony_ci return stream->si->ftsn_chunk_len; 14978c2ecf20Sopenharmony_ci} 14988c2ecf20Sopenharmony_ci 14998c2ecf20Sopenharmony_cistatic inline __u16 sctp_ftsnhdr_len(const struct sctp_stream *stream) 15008c2ecf20Sopenharmony_ci{ 15018c2ecf20Sopenharmony_ci return stream->si->ftsn_chunk_len - sizeof(struct sctp_chunkhdr); 15028c2ecf20Sopenharmony_ci} 15038c2ecf20Sopenharmony_ci 15048c2ecf20Sopenharmony_ci/* SCTP_GET_ASSOC_STATS counters */ 15058c2ecf20Sopenharmony_cistruct sctp_priv_assoc_stats { 15068c2ecf20Sopenharmony_ci /* Maximum observed rto in the association during subsequent 15078c2ecf20Sopenharmony_ci * observations. Value is set to 0 if no RTO measurement took place 15088c2ecf20Sopenharmony_ci * The transport where the max_rto was observed is returned in 15098c2ecf20Sopenharmony_ci * obs_rto_ipaddr 15108c2ecf20Sopenharmony_ci */ 15118c2ecf20Sopenharmony_ci struct sockaddr_storage obs_rto_ipaddr; 15128c2ecf20Sopenharmony_ci __u64 max_obs_rto; 15138c2ecf20Sopenharmony_ci /* Total In and Out SACKs received and sent */ 15148c2ecf20Sopenharmony_ci __u64 isacks; 15158c2ecf20Sopenharmony_ci __u64 osacks; 15168c2ecf20Sopenharmony_ci /* Total In and Out packets received and sent */ 15178c2ecf20Sopenharmony_ci __u64 opackets; 15188c2ecf20Sopenharmony_ci __u64 ipackets; 15198c2ecf20Sopenharmony_ci /* Total retransmitted chunks */ 15208c2ecf20Sopenharmony_ci __u64 rtxchunks; 15218c2ecf20Sopenharmony_ci /* TSN received > next expected */ 15228c2ecf20Sopenharmony_ci __u64 outofseqtsns; 15238c2ecf20Sopenharmony_ci /* Duplicate Chunks received */ 15248c2ecf20Sopenharmony_ci __u64 idupchunks; 15258c2ecf20Sopenharmony_ci /* Gap Ack Blocks received */ 15268c2ecf20Sopenharmony_ci __u64 gapcnt; 15278c2ecf20Sopenharmony_ci /* Unordered data chunks sent and received */ 15288c2ecf20Sopenharmony_ci __u64 ouodchunks; 15298c2ecf20Sopenharmony_ci __u64 iuodchunks; 15308c2ecf20Sopenharmony_ci /* Ordered data chunks sent and received */ 15318c2ecf20Sopenharmony_ci __u64 oodchunks; 15328c2ecf20Sopenharmony_ci __u64 iodchunks; 15338c2ecf20Sopenharmony_ci /* Control chunks sent and received */ 15348c2ecf20Sopenharmony_ci __u64 octrlchunks; 15358c2ecf20Sopenharmony_ci __u64 ictrlchunks; 15368c2ecf20Sopenharmony_ci}; 15378c2ecf20Sopenharmony_ci 15388c2ecf20Sopenharmony_ci/* RFC2960 15398c2ecf20Sopenharmony_ci * 15408c2ecf20Sopenharmony_ci * 12. Recommended Transmission Control Block (TCB) Parameters 15418c2ecf20Sopenharmony_ci * 15428c2ecf20Sopenharmony_ci * This section details a recommended set of parameters that should 15438c2ecf20Sopenharmony_ci * be contained within the TCB for an implementation. This section is 15448c2ecf20Sopenharmony_ci * for illustrative purposes and should not be deemed as requirements 15458c2ecf20Sopenharmony_ci * on an implementation or as an exhaustive list of all parameters 15468c2ecf20Sopenharmony_ci * inside an SCTP TCB. Each implementation may need its own additional 15478c2ecf20Sopenharmony_ci * parameters for optimization. 15488c2ecf20Sopenharmony_ci */ 15498c2ecf20Sopenharmony_ci 15508c2ecf20Sopenharmony_ci 15518c2ecf20Sopenharmony_ci/* Here we have information about each individual association. */ 15528c2ecf20Sopenharmony_cistruct sctp_association { 15538c2ecf20Sopenharmony_ci 15548c2ecf20Sopenharmony_ci /* A base structure common to endpoint and association. 15558c2ecf20Sopenharmony_ci * In this context, it represents the associations's view 15568c2ecf20Sopenharmony_ci * of the local endpoint of the association. 15578c2ecf20Sopenharmony_ci */ 15588c2ecf20Sopenharmony_ci struct sctp_ep_common base; 15598c2ecf20Sopenharmony_ci 15608c2ecf20Sopenharmony_ci /* Associations on the same socket. */ 15618c2ecf20Sopenharmony_ci struct list_head asocs; 15628c2ecf20Sopenharmony_ci 15638c2ecf20Sopenharmony_ci /* association id. */ 15648c2ecf20Sopenharmony_ci sctp_assoc_t assoc_id; 15658c2ecf20Sopenharmony_ci 15668c2ecf20Sopenharmony_ci /* This is our parent endpoint. */ 15678c2ecf20Sopenharmony_ci struct sctp_endpoint *ep; 15688c2ecf20Sopenharmony_ci 15698c2ecf20Sopenharmony_ci /* These are those association elements needed in the cookie. */ 15708c2ecf20Sopenharmony_ci struct sctp_cookie c; 15718c2ecf20Sopenharmony_ci 15728c2ecf20Sopenharmony_ci /* This is all information about our peer. */ 15738c2ecf20Sopenharmony_ci struct { 15748c2ecf20Sopenharmony_ci /* transport_addr_list 15758c2ecf20Sopenharmony_ci * 15768c2ecf20Sopenharmony_ci * Peer : A list of SCTP transport addresses that the 15778c2ecf20Sopenharmony_ci * Transport : peer is bound to. This information is derived 15788c2ecf20Sopenharmony_ci * Address : from the INIT or INIT ACK and is used to 15798c2ecf20Sopenharmony_ci * List : associate an inbound packet with a given 15808c2ecf20Sopenharmony_ci * : association. Normally this information is 15818c2ecf20Sopenharmony_ci * : hashed or keyed for quick lookup and access 15828c2ecf20Sopenharmony_ci * : of the TCB. 15838c2ecf20Sopenharmony_ci * : The list is also initialized with the list 15848c2ecf20Sopenharmony_ci * : of addresses passed with the sctp_connectx() 15858c2ecf20Sopenharmony_ci * : call. 15868c2ecf20Sopenharmony_ci * 15878c2ecf20Sopenharmony_ci * It is a list of SCTP_transport's. 15888c2ecf20Sopenharmony_ci */ 15898c2ecf20Sopenharmony_ci struct list_head transport_addr_list; 15908c2ecf20Sopenharmony_ci 15918c2ecf20Sopenharmony_ci /* rwnd 15928c2ecf20Sopenharmony_ci * 15938c2ecf20Sopenharmony_ci * Peer Rwnd : Current calculated value of the peer's rwnd. 15948c2ecf20Sopenharmony_ci */ 15958c2ecf20Sopenharmony_ci __u32 rwnd; 15968c2ecf20Sopenharmony_ci 15978c2ecf20Sopenharmony_ci /* transport_count 15988c2ecf20Sopenharmony_ci * 15998c2ecf20Sopenharmony_ci * Peer : A count of the number of peer addresses 16008c2ecf20Sopenharmony_ci * Transport : in the Peer Transport Address List. 16018c2ecf20Sopenharmony_ci * Address : 16028c2ecf20Sopenharmony_ci * Count : 16038c2ecf20Sopenharmony_ci */ 16048c2ecf20Sopenharmony_ci __u16 transport_count; 16058c2ecf20Sopenharmony_ci 16068c2ecf20Sopenharmony_ci /* port 16078c2ecf20Sopenharmony_ci * The transport layer port number. 16088c2ecf20Sopenharmony_ci */ 16098c2ecf20Sopenharmony_ci __u16 port; 16108c2ecf20Sopenharmony_ci 16118c2ecf20Sopenharmony_ci /* primary_path 16128c2ecf20Sopenharmony_ci * 16138c2ecf20Sopenharmony_ci * Primary : This is the current primary destination 16148c2ecf20Sopenharmony_ci * Path : transport address of the peer endpoint. It 16158c2ecf20Sopenharmony_ci * : may also specify a source transport address 16168c2ecf20Sopenharmony_ci * : on this endpoint. 16178c2ecf20Sopenharmony_ci * 16188c2ecf20Sopenharmony_ci * All of these paths live on transport_addr_list. 16198c2ecf20Sopenharmony_ci * 16208c2ecf20Sopenharmony_ci * At the bakeoffs, we discovered that the intent of 16218c2ecf20Sopenharmony_ci * primaryPath is that it only changes when the ULP 16228c2ecf20Sopenharmony_ci * asks to have it changed. We add the activePath to 16238c2ecf20Sopenharmony_ci * designate the connection we are currently using to 16248c2ecf20Sopenharmony_ci * transmit new data and most control chunks. 16258c2ecf20Sopenharmony_ci */ 16268c2ecf20Sopenharmony_ci struct sctp_transport *primary_path; 16278c2ecf20Sopenharmony_ci 16288c2ecf20Sopenharmony_ci /* Cache the primary path address here, when we 16298c2ecf20Sopenharmony_ci * need a an address for msg_name. 16308c2ecf20Sopenharmony_ci */ 16318c2ecf20Sopenharmony_ci union sctp_addr primary_addr; 16328c2ecf20Sopenharmony_ci 16338c2ecf20Sopenharmony_ci /* active_path 16348c2ecf20Sopenharmony_ci * The path that we are currently using to 16358c2ecf20Sopenharmony_ci * transmit new data and most control chunks. 16368c2ecf20Sopenharmony_ci */ 16378c2ecf20Sopenharmony_ci struct sctp_transport *active_path; 16388c2ecf20Sopenharmony_ci 16398c2ecf20Sopenharmony_ci /* retran_path 16408c2ecf20Sopenharmony_ci * 16418c2ecf20Sopenharmony_ci * RFC2960 6.4 Multi-homed SCTP Endpoints 16428c2ecf20Sopenharmony_ci * ... 16438c2ecf20Sopenharmony_ci * Furthermore, when its peer is multi-homed, an 16448c2ecf20Sopenharmony_ci * endpoint SHOULD try to retransmit a chunk to an 16458c2ecf20Sopenharmony_ci * active destination transport address that is 16468c2ecf20Sopenharmony_ci * different from the last destination address to 16478c2ecf20Sopenharmony_ci * which the DATA chunk was sent. 16488c2ecf20Sopenharmony_ci */ 16498c2ecf20Sopenharmony_ci struct sctp_transport *retran_path; 16508c2ecf20Sopenharmony_ci 16518c2ecf20Sopenharmony_ci /* Pointer to last transport I have sent on. */ 16528c2ecf20Sopenharmony_ci struct sctp_transport *last_sent_to; 16538c2ecf20Sopenharmony_ci 16548c2ecf20Sopenharmony_ci /* This is the last transport I have received DATA on. */ 16558c2ecf20Sopenharmony_ci struct sctp_transport *last_data_from; 16568c2ecf20Sopenharmony_ci 16578c2ecf20Sopenharmony_ci /* 16588c2ecf20Sopenharmony_ci * Mapping An array of bits or bytes indicating which out of 16598c2ecf20Sopenharmony_ci * Array order TSN's have been received (relative to the 16608c2ecf20Sopenharmony_ci * Last Rcvd TSN). If no gaps exist, i.e. no out of 16618c2ecf20Sopenharmony_ci * order packets have been received, this array 16628c2ecf20Sopenharmony_ci * will be set to all zero. This structure may be 16638c2ecf20Sopenharmony_ci * in the form of a circular buffer or bit array. 16648c2ecf20Sopenharmony_ci * 16658c2ecf20Sopenharmony_ci * Last Rcvd : This is the last TSN received in 16668c2ecf20Sopenharmony_ci * TSN : sequence. This value is set initially by 16678c2ecf20Sopenharmony_ci * : taking the peer's Initial TSN, received in 16688c2ecf20Sopenharmony_ci * : the INIT or INIT ACK chunk, and subtracting 16698c2ecf20Sopenharmony_ci * : one from it. 16708c2ecf20Sopenharmony_ci * 16718c2ecf20Sopenharmony_ci * Throughout most of the specification this is called the 16728c2ecf20Sopenharmony_ci * "Cumulative TSN ACK Point". In this case, we 16738c2ecf20Sopenharmony_ci * ignore the advice in 12.2 in favour of the term 16748c2ecf20Sopenharmony_ci * used in the bulk of the text. This value is hidden 16758c2ecf20Sopenharmony_ci * in tsn_map--we get it by calling sctp_tsnmap_get_ctsn(). 16768c2ecf20Sopenharmony_ci */ 16778c2ecf20Sopenharmony_ci struct sctp_tsnmap tsn_map; 16788c2ecf20Sopenharmony_ci 16798c2ecf20Sopenharmony_ci /* This mask is used to disable sending the ASCONF chunk 16808c2ecf20Sopenharmony_ci * with specified parameter to peer. 16818c2ecf20Sopenharmony_ci */ 16828c2ecf20Sopenharmony_ci __be16 addip_disabled_mask; 16838c2ecf20Sopenharmony_ci 16848c2ecf20Sopenharmony_ci /* These are capabilities which our peer advertised. */ 16858c2ecf20Sopenharmony_ci __u16 ecn_capable:1, /* Can peer do ECN? */ 16868c2ecf20Sopenharmony_ci ipv4_address:1, /* Peer understands IPv4 addresses? */ 16878c2ecf20Sopenharmony_ci ipv6_address:1, /* Peer understands IPv6 addresses? */ 16888c2ecf20Sopenharmony_ci hostname_address:1, /* Peer understands DNS addresses? */ 16898c2ecf20Sopenharmony_ci asconf_capable:1, /* Does peer support ADDIP? */ 16908c2ecf20Sopenharmony_ci prsctp_capable:1, /* Can peer do PR-SCTP? */ 16918c2ecf20Sopenharmony_ci reconf_capable:1, /* Can peer do RE-CONFIG? */ 16928c2ecf20Sopenharmony_ci intl_capable:1, /* Can peer do INTERLEAVE */ 16938c2ecf20Sopenharmony_ci auth_capable:1, /* Is peer doing SCTP-AUTH? */ 16948c2ecf20Sopenharmony_ci /* sack_needed: 16958c2ecf20Sopenharmony_ci * This flag indicates if the next received 16968c2ecf20Sopenharmony_ci * packet is to be responded to with a 16978c2ecf20Sopenharmony_ci * SACK. This is initialized to 0. When a packet 16988c2ecf20Sopenharmony_ci * is received sack_cnt is incremented. If this value 16998c2ecf20Sopenharmony_ci * reaches 2 or more, a SACK is sent and the 17008c2ecf20Sopenharmony_ci * value is reset to 0. Note: This is used only 17018c2ecf20Sopenharmony_ci * when no DATA chunks are received out of 17028c2ecf20Sopenharmony_ci * order. When DATA chunks are out of order, 17038c2ecf20Sopenharmony_ci * SACK's are not delayed (see Section 6). 17048c2ecf20Sopenharmony_ci */ 17058c2ecf20Sopenharmony_ci sack_needed:1, /* Do we need to sack the peer? */ 17068c2ecf20Sopenharmony_ci sack_generation:1, 17078c2ecf20Sopenharmony_ci zero_window_announced:1; 17088c2ecf20Sopenharmony_ci 17098c2ecf20Sopenharmony_ci __u32 sack_cnt; 17108c2ecf20Sopenharmony_ci 17118c2ecf20Sopenharmony_ci __u32 adaptation_ind; /* Adaptation Code point. */ 17128c2ecf20Sopenharmony_ci 17138c2ecf20Sopenharmony_ci struct sctp_inithdr_host i; 17148c2ecf20Sopenharmony_ci void *cookie; 17158c2ecf20Sopenharmony_ci int cookie_len; 17168c2ecf20Sopenharmony_ci 17178c2ecf20Sopenharmony_ci /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk. 17188c2ecf20Sopenharmony_ci * C1) ... "Peer-Serial-Number'. This value MUST be initialized to the 17198c2ecf20Sopenharmony_ci * Initial TSN Value minus 1 17208c2ecf20Sopenharmony_ci */ 17218c2ecf20Sopenharmony_ci __u32 addip_serial; 17228c2ecf20Sopenharmony_ci 17238c2ecf20Sopenharmony_ci /* SCTP-AUTH: We need to know pears random number, hmac list 17248c2ecf20Sopenharmony_ci * and authenticated chunk list. All that is part of the 17258c2ecf20Sopenharmony_ci * cookie and these are just pointers to those locations 17268c2ecf20Sopenharmony_ci */ 17278c2ecf20Sopenharmony_ci struct sctp_random_param *peer_random; 17288c2ecf20Sopenharmony_ci struct sctp_chunks_param *peer_chunks; 17298c2ecf20Sopenharmony_ci struct sctp_hmac_algo_param *peer_hmacs; 17308c2ecf20Sopenharmony_ci } peer; 17318c2ecf20Sopenharmony_ci 17328c2ecf20Sopenharmony_ci /* State : A state variable indicating what state the 17338c2ecf20Sopenharmony_ci * : association is in, i.e. COOKIE-WAIT, 17348c2ecf20Sopenharmony_ci * : COOKIE-ECHOED, ESTABLISHED, SHUTDOWN-PENDING, 17358c2ecf20Sopenharmony_ci * : SHUTDOWN-SENT, SHUTDOWN-RECEIVED, SHUTDOWN-ACK-SENT. 17368c2ecf20Sopenharmony_ci * 17378c2ecf20Sopenharmony_ci * Note: No "CLOSED" state is illustrated since if a 17388c2ecf20Sopenharmony_ci * association is "CLOSED" its TCB SHOULD be removed. 17398c2ecf20Sopenharmony_ci * 17408c2ecf20Sopenharmony_ci * In this implementation we DO have a CLOSED 17418c2ecf20Sopenharmony_ci * state which is used during initiation and shutdown. 17428c2ecf20Sopenharmony_ci * 17438c2ecf20Sopenharmony_ci * State takes values from SCTP_STATE_*. 17448c2ecf20Sopenharmony_ci */ 17458c2ecf20Sopenharmony_ci enum sctp_state state; 17468c2ecf20Sopenharmony_ci 17478c2ecf20Sopenharmony_ci /* Overall : The overall association error count. 17488c2ecf20Sopenharmony_ci * Error Count : [Clear this any time I get something.] 17498c2ecf20Sopenharmony_ci */ 17508c2ecf20Sopenharmony_ci int overall_error_count; 17518c2ecf20Sopenharmony_ci 17528c2ecf20Sopenharmony_ci /* The cookie life I award for any cookie. */ 17538c2ecf20Sopenharmony_ci ktime_t cookie_life; 17548c2ecf20Sopenharmony_ci 17558c2ecf20Sopenharmony_ci /* These are the association's initial, max, and min RTO values. 17568c2ecf20Sopenharmony_ci * These values will be initialized by system defaults, but can 17578c2ecf20Sopenharmony_ci * be modified via the SCTP_RTOINFO socket option. 17588c2ecf20Sopenharmony_ci */ 17598c2ecf20Sopenharmony_ci unsigned long rto_initial; 17608c2ecf20Sopenharmony_ci unsigned long rto_max; 17618c2ecf20Sopenharmony_ci unsigned long rto_min; 17628c2ecf20Sopenharmony_ci 17638c2ecf20Sopenharmony_ci /* Maximum number of new data packets that can be sent in a burst. */ 17648c2ecf20Sopenharmony_ci int max_burst; 17658c2ecf20Sopenharmony_ci 17668c2ecf20Sopenharmony_ci /* This is the max_retrans value for the association. This value will 17678c2ecf20Sopenharmony_ci * be initialized from system defaults, but can be 17688c2ecf20Sopenharmony_ci * modified by the SCTP_ASSOCINFO socket option. 17698c2ecf20Sopenharmony_ci */ 17708c2ecf20Sopenharmony_ci int max_retrans; 17718c2ecf20Sopenharmony_ci 17728c2ecf20Sopenharmony_ci /* This is the partially failed retrans value for the transport 17738c2ecf20Sopenharmony_ci * and will be initialized from the assocs value. This can be 17748c2ecf20Sopenharmony_ci * changed using the SCTP_PEER_ADDR_THLDS socket option 17758c2ecf20Sopenharmony_ci */ 17768c2ecf20Sopenharmony_ci __u16 pf_retrans; 17778c2ecf20Sopenharmony_ci /* Used for primary path switchover. */ 17788c2ecf20Sopenharmony_ci __u16 ps_retrans; 17798c2ecf20Sopenharmony_ci 17808c2ecf20Sopenharmony_ci /* Maximum number of times the endpoint will retransmit INIT */ 17818c2ecf20Sopenharmony_ci __u16 max_init_attempts; 17828c2ecf20Sopenharmony_ci 17838c2ecf20Sopenharmony_ci /* How many times have we resent an INIT? */ 17848c2ecf20Sopenharmony_ci __u16 init_retries; 17858c2ecf20Sopenharmony_ci 17868c2ecf20Sopenharmony_ci /* The largest timeout or RTO value to use in attempting an INIT */ 17878c2ecf20Sopenharmony_ci unsigned long max_init_timeo; 17888c2ecf20Sopenharmony_ci 17898c2ecf20Sopenharmony_ci /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to 17908c2ecf20Sopenharmony_ci * the destination address every heartbeat interval. This value 17918c2ecf20Sopenharmony_ci * will be inherited by all new transports. 17928c2ecf20Sopenharmony_ci */ 17938c2ecf20Sopenharmony_ci unsigned long hbinterval; 17948c2ecf20Sopenharmony_ci 17958c2ecf20Sopenharmony_ci /* This is the max_retrans value for new transports in the 17968c2ecf20Sopenharmony_ci * association. 17978c2ecf20Sopenharmony_ci */ 17988c2ecf20Sopenharmony_ci __u16 pathmaxrxt; 17998c2ecf20Sopenharmony_ci 18008c2ecf20Sopenharmony_ci __u32 flowlabel; 18018c2ecf20Sopenharmony_ci __u8 dscp; 18028c2ecf20Sopenharmony_ci 18038c2ecf20Sopenharmony_ci /* Flag that path mtu update is pending */ 18048c2ecf20Sopenharmony_ci __u8 pmtu_pending; 18058c2ecf20Sopenharmony_ci 18068c2ecf20Sopenharmony_ci /* Association : The smallest PMTU discovered for all of the 18078c2ecf20Sopenharmony_ci * PMTU : peer's transport addresses. 18088c2ecf20Sopenharmony_ci */ 18098c2ecf20Sopenharmony_ci __u32 pathmtu; 18108c2ecf20Sopenharmony_ci 18118c2ecf20Sopenharmony_ci /* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */ 18128c2ecf20Sopenharmony_ci __u32 param_flags; 18138c2ecf20Sopenharmony_ci 18148c2ecf20Sopenharmony_ci __u32 sackfreq; 18158c2ecf20Sopenharmony_ci /* SACK delay timeout */ 18168c2ecf20Sopenharmony_ci unsigned long sackdelay; 18178c2ecf20Sopenharmony_ci 18188c2ecf20Sopenharmony_ci unsigned long timeouts[SCTP_NUM_TIMEOUT_TYPES]; 18198c2ecf20Sopenharmony_ci struct timer_list timers[SCTP_NUM_TIMEOUT_TYPES]; 18208c2ecf20Sopenharmony_ci 18218c2ecf20Sopenharmony_ci /* Transport to which SHUTDOWN chunk was last sent. */ 18228c2ecf20Sopenharmony_ci struct sctp_transport *shutdown_last_sent_to; 18238c2ecf20Sopenharmony_ci 18248c2ecf20Sopenharmony_ci /* Transport to which INIT chunk was last sent. */ 18258c2ecf20Sopenharmony_ci struct sctp_transport *init_last_sent_to; 18268c2ecf20Sopenharmony_ci 18278c2ecf20Sopenharmony_ci /* How many times have we resent a SHUTDOWN */ 18288c2ecf20Sopenharmony_ci int shutdown_retries; 18298c2ecf20Sopenharmony_ci 18308c2ecf20Sopenharmony_ci /* Next TSN : The next TSN number to be assigned to a new 18318c2ecf20Sopenharmony_ci * : DATA chunk. This is sent in the INIT or INIT 18328c2ecf20Sopenharmony_ci * : ACK chunk to the peer and incremented each 18338c2ecf20Sopenharmony_ci * : time a DATA chunk is assigned a TSN 18348c2ecf20Sopenharmony_ci * : (normally just prior to transmit or during 18358c2ecf20Sopenharmony_ci * : fragmentation). 18368c2ecf20Sopenharmony_ci */ 18378c2ecf20Sopenharmony_ci __u32 next_tsn; 18388c2ecf20Sopenharmony_ci 18398c2ecf20Sopenharmony_ci /* 18408c2ecf20Sopenharmony_ci * Last Rcvd : This is the last TSN received in sequence. This value 18418c2ecf20Sopenharmony_ci * TSN : is set initially by taking the peer's Initial TSN, 18428c2ecf20Sopenharmony_ci * : received in the INIT or INIT ACK chunk, and 18438c2ecf20Sopenharmony_ci * : subtracting one from it. 18448c2ecf20Sopenharmony_ci * 18458c2ecf20Sopenharmony_ci * Most of RFC 2960 refers to this as the Cumulative TSN Ack Point. 18468c2ecf20Sopenharmony_ci */ 18478c2ecf20Sopenharmony_ci 18488c2ecf20Sopenharmony_ci __u32 ctsn_ack_point; 18498c2ecf20Sopenharmony_ci 18508c2ecf20Sopenharmony_ci /* PR-SCTP Advanced.Peer.Ack.Point */ 18518c2ecf20Sopenharmony_ci __u32 adv_peer_ack_point; 18528c2ecf20Sopenharmony_ci 18538c2ecf20Sopenharmony_ci /* Highest TSN that is acknowledged by incoming SACKs. */ 18548c2ecf20Sopenharmony_ci __u32 highest_sacked; 18558c2ecf20Sopenharmony_ci 18568c2ecf20Sopenharmony_ci /* TSN marking the fast recovery exit point */ 18578c2ecf20Sopenharmony_ci __u32 fast_recovery_exit; 18588c2ecf20Sopenharmony_ci 18598c2ecf20Sopenharmony_ci /* Flag to track the current fast recovery state */ 18608c2ecf20Sopenharmony_ci __u8 fast_recovery; 18618c2ecf20Sopenharmony_ci 18628c2ecf20Sopenharmony_ci /* The number of unacknowledged data chunks. Reported through 18638c2ecf20Sopenharmony_ci * the SCTP_STATUS sockopt. 18648c2ecf20Sopenharmony_ci */ 18658c2ecf20Sopenharmony_ci __u16 unack_data; 18668c2ecf20Sopenharmony_ci 18678c2ecf20Sopenharmony_ci /* The total number of data chunks that we've had to retransmit 18688c2ecf20Sopenharmony_ci * as the result of a T3 timer expiration 18698c2ecf20Sopenharmony_ci */ 18708c2ecf20Sopenharmony_ci __u32 rtx_data_chunks; 18718c2ecf20Sopenharmony_ci 18728c2ecf20Sopenharmony_ci /* This is the association's receive buffer space. This value is used 18738c2ecf20Sopenharmony_ci * to set a_rwnd field in an INIT or a SACK chunk. 18748c2ecf20Sopenharmony_ci */ 18758c2ecf20Sopenharmony_ci __u32 rwnd; 18768c2ecf20Sopenharmony_ci 18778c2ecf20Sopenharmony_ci /* This is the last advertised value of rwnd over a SACK chunk. */ 18788c2ecf20Sopenharmony_ci __u32 a_rwnd; 18798c2ecf20Sopenharmony_ci 18808c2ecf20Sopenharmony_ci /* Number of bytes by which the rwnd has slopped. The rwnd is allowed 18818c2ecf20Sopenharmony_ci * to slop over a maximum of the association's frag_point. 18828c2ecf20Sopenharmony_ci */ 18838c2ecf20Sopenharmony_ci __u32 rwnd_over; 18848c2ecf20Sopenharmony_ci 18858c2ecf20Sopenharmony_ci /* Keeps treack of rwnd pressure. This happens when we have 18868c2ecf20Sopenharmony_ci * a window, but not recevie buffer (i.e small packets). This one 18878c2ecf20Sopenharmony_ci * is releases slowly (1 PMTU at a time ). 18888c2ecf20Sopenharmony_ci */ 18898c2ecf20Sopenharmony_ci __u32 rwnd_press; 18908c2ecf20Sopenharmony_ci 18918c2ecf20Sopenharmony_ci /* This is the sndbuf size in use for the association. 18928c2ecf20Sopenharmony_ci * This corresponds to the sndbuf size for the association, 18938c2ecf20Sopenharmony_ci * as specified in the sk->sndbuf. 18948c2ecf20Sopenharmony_ci */ 18958c2ecf20Sopenharmony_ci int sndbuf_used; 18968c2ecf20Sopenharmony_ci 18978c2ecf20Sopenharmony_ci /* This is the amount of memory that this association has allocated 18988c2ecf20Sopenharmony_ci * in the receive path at any given time. 18998c2ecf20Sopenharmony_ci */ 19008c2ecf20Sopenharmony_ci atomic_t rmem_alloc; 19018c2ecf20Sopenharmony_ci 19028c2ecf20Sopenharmony_ci /* This is the wait queue head for send requests waiting on 19038c2ecf20Sopenharmony_ci * the association sndbuf space. 19048c2ecf20Sopenharmony_ci */ 19058c2ecf20Sopenharmony_ci wait_queue_head_t wait; 19068c2ecf20Sopenharmony_ci 19078c2ecf20Sopenharmony_ci /* The message size at which SCTP fragmentation will occur. */ 19088c2ecf20Sopenharmony_ci __u32 frag_point; 19098c2ecf20Sopenharmony_ci __u32 user_frag; 19108c2ecf20Sopenharmony_ci 19118c2ecf20Sopenharmony_ci /* Counter used to count INIT errors. */ 19128c2ecf20Sopenharmony_ci int init_err_counter; 19138c2ecf20Sopenharmony_ci 19148c2ecf20Sopenharmony_ci /* Count the number of INIT cycles (for doubling timeout). */ 19158c2ecf20Sopenharmony_ci int init_cycle; 19168c2ecf20Sopenharmony_ci 19178c2ecf20Sopenharmony_ci /* Default send parameters. */ 19188c2ecf20Sopenharmony_ci __u16 default_stream; 19198c2ecf20Sopenharmony_ci __u16 default_flags; 19208c2ecf20Sopenharmony_ci __u32 default_ppid; 19218c2ecf20Sopenharmony_ci __u32 default_context; 19228c2ecf20Sopenharmony_ci __u32 default_timetolive; 19238c2ecf20Sopenharmony_ci 19248c2ecf20Sopenharmony_ci /* Default receive parameters */ 19258c2ecf20Sopenharmony_ci __u32 default_rcv_context; 19268c2ecf20Sopenharmony_ci 19278c2ecf20Sopenharmony_ci /* Stream arrays */ 19288c2ecf20Sopenharmony_ci struct sctp_stream stream; 19298c2ecf20Sopenharmony_ci 19308c2ecf20Sopenharmony_ci /* All outbound chunks go through this structure. */ 19318c2ecf20Sopenharmony_ci struct sctp_outq outqueue; 19328c2ecf20Sopenharmony_ci 19338c2ecf20Sopenharmony_ci /* A smart pipe that will handle reordering and fragmentation, 19348c2ecf20Sopenharmony_ci * as well as handle passing events up to the ULP. 19358c2ecf20Sopenharmony_ci */ 19368c2ecf20Sopenharmony_ci struct sctp_ulpq ulpq; 19378c2ecf20Sopenharmony_ci 19388c2ecf20Sopenharmony_ci /* Last TSN that caused an ECNE Chunk to be sent. */ 19398c2ecf20Sopenharmony_ci __u32 last_ecne_tsn; 19408c2ecf20Sopenharmony_ci 19418c2ecf20Sopenharmony_ci /* Last TSN that caused a CWR Chunk to be sent. */ 19428c2ecf20Sopenharmony_ci __u32 last_cwr_tsn; 19438c2ecf20Sopenharmony_ci 19448c2ecf20Sopenharmony_ci /* How many duplicated TSNs have we seen? */ 19458c2ecf20Sopenharmony_ci int numduptsns; 19468c2ecf20Sopenharmony_ci 19478c2ecf20Sopenharmony_ci /* These are to support 19488c2ecf20Sopenharmony_ci * "SCTP Extensions for Dynamic Reconfiguration of IP Addresses 19498c2ecf20Sopenharmony_ci * and Enforcement of Flow and Message Limits" 19508c2ecf20Sopenharmony_ci * <draft-ietf-tsvwg-addip-sctp-02.txt> 19518c2ecf20Sopenharmony_ci * or "ADDIP" for short. 19528c2ecf20Sopenharmony_ci */ 19538c2ecf20Sopenharmony_ci 19548c2ecf20Sopenharmony_ci 19558c2ecf20Sopenharmony_ci 19568c2ecf20Sopenharmony_ci /* ADDIP Section 4.1.1 Congestion Control of ASCONF Chunks 19578c2ecf20Sopenharmony_ci * 19588c2ecf20Sopenharmony_ci * R1) One and only one ASCONF Chunk MAY be in transit and 19598c2ecf20Sopenharmony_ci * unacknowledged at any one time. If a sender, after sending 19608c2ecf20Sopenharmony_ci * an ASCONF chunk, decides it needs to transfer another 19618c2ecf20Sopenharmony_ci * ASCONF Chunk, it MUST wait until the ASCONF-ACK Chunk 19628c2ecf20Sopenharmony_ci * returns from the previous ASCONF Chunk before sending a 19638c2ecf20Sopenharmony_ci * subsequent ASCONF. Note this restriction binds each side, 19648c2ecf20Sopenharmony_ci * so at any time two ASCONF may be in-transit on any given 19658c2ecf20Sopenharmony_ci * association (one sent from each endpoint). 19668c2ecf20Sopenharmony_ci * 19678c2ecf20Sopenharmony_ci * [This is our one-and-only-one ASCONF in flight. If we do 19688c2ecf20Sopenharmony_ci * not have an ASCONF in flight, this is NULL.] 19698c2ecf20Sopenharmony_ci */ 19708c2ecf20Sopenharmony_ci struct sctp_chunk *addip_last_asconf; 19718c2ecf20Sopenharmony_ci 19728c2ecf20Sopenharmony_ci /* ADDIP Section 5.2 Upon reception of an ASCONF Chunk. 19738c2ecf20Sopenharmony_ci * 19748c2ecf20Sopenharmony_ci * This is needed to implement itmes E1 - E4 of the updated 19758c2ecf20Sopenharmony_ci * spec. Here is the justification: 19768c2ecf20Sopenharmony_ci * 19778c2ecf20Sopenharmony_ci * Since the peer may bundle multiple ASCONF chunks toward us, 19788c2ecf20Sopenharmony_ci * we now need the ability to cache multiple ACKs. The section 19798c2ecf20Sopenharmony_ci * describes in detail how they are cached and cleaned up. 19808c2ecf20Sopenharmony_ci */ 19818c2ecf20Sopenharmony_ci struct list_head asconf_ack_list; 19828c2ecf20Sopenharmony_ci 19838c2ecf20Sopenharmony_ci /* These ASCONF chunks are waiting to be sent. 19848c2ecf20Sopenharmony_ci * 19858c2ecf20Sopenharmony_ci * These chunaks can't be pushed to outqueue until receiving 19868c2ecf20Sopenharmony_ci * ASCONF_ACK for the previous ASCONF indicated by 19878c2ecf20Sopenharmony_ci * addip_last_asconf, so as to guarantee that only one ASCONF 19888c2ecf20Sopenharmony_ci * is in flight at any time. 19898c2ecf20Sopenharmony_ci * 19908c2ecf20Sopenharmony_ci * ADDIP Section 4.1.1 Congestion Control of ASCONF Chunks 19918c2ecf20Sopenharmony_ci * 19928c2ecf20Sopenharmony_ci * In defining the ASCONF Chunk transfer procedures, it is 19938c2ecf20Sopenharmony_ci * essential that these transfers MUST NOT cause congestion 19948c2ecf20Sopenharmony_ci * within the network. To achieve this, we place these 19958c2ecf20Sopenharmony_ci * restrictions on the transfer of ASCONF Chunks: 19968c2ecf20Sopenharmony_ci * 19978c2ecf20Sopenharmony_ci * R1) One and only one ASCONF Chunk MAY be in transit and 19988c2ecf20Sopenharmony_ci * unacknowledged at any one time. If a sender, after sending 19998c2ecf20Sopenharmony_ci * an ASCONF chunk, decides it needs to transfer another 20008c2ecf20Sopenharmony_ci * ASCONF Chunk, it MUST wait until the ASCONF-ACK Chunk 20018c2ecf20Sopenharmony_ci * returns from the previous ASCONF Chunk before sending a 20028c2ecf20Sopenharmony_ci * subsequent ASCONF. Note this restriction binds each side, 20038c2ecf20Sopenharmony_ci * so at any time two ASCONF may be in-transit on any given 20048c2ecf20Sopenharmony_ci * association (one sent from each endpoint). 20058c2ecf20Sopenharmony_ci * 20068c2ecf20Sopenharmony_ci * 20078c2ecf20Sopenharmony_ci * [I really think this is EXACTLY the sort of intelligence 20088c2ecf20Sopenharmony_ci * which already resides in sctp_outq. Please move this 20098c2ecf20Sopenharmony_ci * queue and its supporting logic down there. --piggy] 20108c2ecf20Sopenharmony_ci */ 20118c2ecf20Sopenharmony_ci struct list_head addip_chunk_list; 20128c2ecf20Sopenharmony_ci 20138c2ecf20Sopenharmony_ci /* ADDIP Section 4.1 ASCONF Chunk Procedures 20148c2ecf20Sopenharmony_ci * 20158c2ecf20Sopenharmony_ci * A2) A serial number should be assigned to the Chunk. The 20168c2ecf20Sopenharmony_ci * serial number SHOULD be a monotonically increasing 20178c2ecf20Sopenharmony_ci * number. The serial number SHOULD be initialized at 20188c2ecf20Sopenharmony_ci * the start of the association to the same value as the 20198c2ecf20Sopenharmony_ci * Initial TSN and every time a new ASCONF chunk is created 20208c2ecf20Sopenharmony_ci * it is incremented by one after assigning the serial number 20218c2ecf20Sopenharmony_ci * to the newly created chunk. 20228c2ecf20Sopenharmony_ci * 20238c2ecf20Sopenharmony_ci * ADDIP 20248c2ecf20Sopenharmony_ci * 3.1.1 Address/Stream Configuration Change Chunk (ASCONF) 20258c2ecf20Sopenharmony_ci * 20268c2ecf20Sopenharmony_ci * Serial Number : 32 bits (unsigned integer) 20278c2ecf20Sopenharmony_ci * 20288c2ecf20Sopenharmony_ci * This value represents a Serial Number for the ASCONF 20298c2ecf20Sopenharmony_ci * Chunk. The valid range of Serial Number is from 0 to 20308c2ecf20Sopenharmony_ci * 4294967295 (2^32 - 1). Serial Numbers wrap back to 0 20318c2ecf20Sopenharmony_ci * after reaching 4294967295. 20328c2ecf20Sopenharmony_ci */ 20338c2ecf20Sopenharmony_ci __u32 addip_serial; 20348c2ecf20Sopenharmony_ci int src_out_of_asoc_ok; 20358c2ecf20Sopenharmony_ci union sctp_addr *asconf_addr_del_pending; 20368c2ecf20Sopenharmony_ci struct sctp_transport *new_transport; 20378c2ecf20Sopenharmony_ci 20388c2ecf20Sopenharmony_ci /* SCTP AUTH: list of the endpoint shared keys. These 20398c2ecf20Sopenharmony_ci * keys are provided out of band by the user applicaton 20408c2ecf20Sopenharmony_ci * and can't change during the lifetime of the association 20418c2ecf20Sopenharmony_ci */ 20428c2ecf20Sopenharmony_ci struct list_head endpoint_shared_keys; 20438c2ecf20Sopenharmony_ci 20448c2ecf20Sopenharmony_ci /* SCTP AUTH: 20458c2ecf20Sopenharmony_ci * The current generated assocaition shared key (secret) 20468c2ecf20Sopenharmony_ci */ 20478c2ecf20Sopenharmony_ci struct sctp_auth_bytes *asoc_shared_key; 20488c2ecf20Sopenharmony_ci struct sctp_shared_key *shkey; 20498c2ecf20Sopenharmony_ci 20508c2ecf20Sopenharmony_ci /* SCTP AUTH: hmac id of the first peer requested algorithm 20518c2ecf20Sopenharmony_ci * that we support. 20528c2ecf20Sopenharmony_ci */ 20538c2ecf20Sopenharmony_ci __u16 default_hmac_id; 20548c2ecf20Sopenharmony_ci 20558c2ecf20Sopenharmony_ci __u16 active_key_id; 20568c2ecf20Sopenharmony_ci 20578c2ecf20Sopenharmony_ci __u8 need_ecne:1, /* Need to send an ECNE Chunk? */ 20588c2ecf20Sopenharmony_ci temp:1, /* Is it a temporary association? */ 20598c2ecf20Sopenharmony_ci pf_expose:2, /* Expose pf state? */ 20608c2ecf20Sopenharmony_ci force_delay:1; 20618c2ecf20Sopenharmony_ci 20628c2ecf20Sopenharmony_ci __u8 strreset_enable; 20638c2ecf20Sopenharmony_ci __u8 strreset_outstanding; /* request param count on the fly */ 20648c2ecf20Sopenharmony_ci 20658c2ecf20Sopenharmony_ci __u32 strreset_outseq; /* Update after receiving response */ 20668c2ecf20Sopenharmony_ci __u32 strreset_inseq; /* Update after receiving request */ 20678c2ecf20Sopenharmony_ci __u32 strreset_result[2]; /* save the results of last 2 responses */ 20688c2ecf20Sopenharmony_ci 20698c2ecf20Sopenharmony_ci struct sctp_chunk *strreset_chunk; /* save request chunk */ 20708c2ecf20Sopenharmony_ci 20718c2ecf20Sopenharmony_ci struct sctp_priv_assoc_stats stats; 20728c2ecf20Sopenharmony_ci 20738c2ecf20Sopenharmony_ci int sent_cnt_removable; 20748c2ecf20Sopenharmony_ci 20758c2ecf20Sopenharmony_ci __u16 subscribe; 20768c2ecf20Sopenharmony_ci 20778c2ecf20Sopenharmony_ci __u64 abandoned_unsent[SCTP_PR_INDEX(MAX) + 1]; 20788c2ecf20Sopenharmony_ci __u64 abandoned_sent[SCTP_PR_INDEX(MAX) + 1]; 20798c2ecf20Sopenharmony_ci 20808c2ecf20Sopenharmony_ci struct rcu_head rcu; 20818c2ecf20Sopenharmony_ci}; 20828c2ecf20Sopenharmony_ci 20838c2ecf20Sopenharmony_ci 20848c2ecf20Sopenharmony_ci/* An eyecatcher for determining if we are really looking at an 20858c2ecf20Sopenharmony_ci * association data structure. 20868c2ecf20Sopenharmony_ci */ 20878c2ecf20Sopenharmony_cienum { 20888c2ecf20Sopenharmony_ci SCTP_ASSOC_EYECATCHER = 0xa550c123, 20898c2ecf20Sopenharmony_ci}; 20908c2ecf20Sopenharmony_ci 20918c2ecf20Sopenharmony_ci/* Recover the outter association structure. */ 20928c2ecf20Sopenharmony_cistatic inline struct sctp_association *sctp_assoc(struct sctp_ep_common *base) 20938c2ecf20Sopenharmony_ci{ 20948c2ecf20Sopenharmony_ci struct sctp_association *asoc; 20958c2ecf20Sopenharmony_ci 20968c2ecf20Sopenharmony_ci asoc = container_of(base, struct sctp_association, base); 20978c2ecf20Sopenharmony_ci return asoc; 20988c2ecf20Sopenharmony_ci} 20998c2ecf20Sopenharmony_ci 21008c2ecf20Sopenharmony_ci/* These are function signatures for manipulating associations. */ 21018c2ecf20Sopenharmony_ci 21028c2ecf20Sopenharmony_ci 21038c2ecf20Sopenharmony_cistruct sctp_association * 21048c2ecf20Sopenharmony_cisctp_association_new(const struct sctp_endpoint *ep, const struct sock *sk, 21058c2ecf20Sopenharmony_ci enum sctp_scope scope, gfp_t gfp); 21068c2ecf20Sopenharmony_civoid sctp_association_free(struct sctp_association *); 21078c2ecf20Sopenharmony_civoid sctp_association_put(struct sctp_association *); 21088c2ecf20Sopenharmony_civoid sctp_association_hold(struct sctp_association *); 21098c2ecf20Sopenharmony_ci 21108c2ecf20Sopenharmony_cistruct sctp_transport *sctp_assoc_choose_alter_transport( 21118c2ecf20Sopenharmony_ci struct sctp_association *, struct sctp_transport *); 21128c2ecf20Sopenharmony_civoid sctp_assoc_update_retran_path(struct sctp_association *); 21138c2ecf20Sopenharmony_cistruct sctp_transport *sctp_assoc_lookup_paddr(const struct sctp_association *, 21148c2ecf20Sopenharmony_ci const union sctp_addr *); 21158c2ecf20Sopenharmony_ciint sctp_assoc_lookup_laddr(struct sctp_association *asoc, 21168c2ecf20Sopenharmony_ci const union sctp_addr *laddr); 21178c2ecf20Sopenharmony_cistruct sctp_transport *sctp_assoc_add_peer(struct sctp_association *, 21188c2ecf20Sopenharmony_ci const union sctp_addr *address, 21198c2ecf20Sopenharmony_ci const gfp_t gfp, 21208c2ecf20Sopenharmony_ci const int peer_state); 21218c2ecf20Sopenharmony_civoid sctp_assoc_del_peer(struct sctp_association *asoc, 21228c2ecf20Sopenharmony_ci const union sctp_addr *addr); 21238c2ecf20Sopenharmony_civoid sctp_assoc_rm_peer(struct sctp_association *asoc, 21248c2ecf20Sopenharmony_ci struct sctp_transport *peer); 21258c2ecf20Sopenharmony_civoid sctp_assoc_control_transport(struct sctp_association *asoc, 21268c2ecf20Sopenharmony_ci struct sctp_transport *transport, 21278c2ecf20Sopenharmony_ci enum sctp_transport_cmd command, 21288c2ecf20Sopenharmony_ci sctp_sn_error_t error); 21298c2ecf20Sopenharmony_cistruct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *, __u32); 21308c2ecf20Sopenharmony_civoid sctp_assoc_migrate(struct sctp_association *, struct sock *); 21318c2ecf20Sopenharmony_ciint sctp_assoc_update(struct sctp_association *old, 21328c2ecf20Sopenharmony_ci struct sctp_association *new); 21338c2ecf20Sopenharmony_ci 21348c2ecf20Sopenharmony_ci__u32 sctp_association_get_next_tsn(struct sctp_association *); 21358c2ecf20Sopenharmony_ci 21368c2ecf20Sopenharmony_civoid sctp_assoc_update_frag_point(struct sctp_association *asoc); 21378c2ecf20Sopenharmony_civoid sctp_assoc_set_pmtu(struct sctp_association *asoc, __u32 pmtu); 21388c2ecf20Sopenharmony_civoid sctp_assoc_sync_pmtu(struct sctp_association *asoc); 21398c2ecf20Sopenharmony_civoid sctp_assoc_rwnd_increase(struct sctp_association *, unsigned int); 21408c2ecf20Sopenharmony_civoid sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned int); 21418c2ecf20Sopenharmony_civoid sctp_assoc_set_primary(struct sctp_association *, 21428c2ecf20Sopenharmony_ci struct sctp_transport *); 21438c2ecf20Sopenharmony_civoid sctp_assoc_del_nonprimary_peers(struct sctp_association *, 21448c2ecf20Sopenharmony_ci struct sctp_transport *); 21458c2ecf20Sopenharmony_ciint sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, 21468c2ecf20Sopenharmony_ci enum sctp_scope scope, gfp_t gfp); 21478c2ecf20Sopenharmony_ciint sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *, 21488c2ecf20Sopenharmony_ci struct sctp_cookie*, 21498c2ecf20Sopenharmony_ci gfp_t gfp); 21508c2ecf20Sopenharmony_ciint sctp_assoc_set_id(struct sctp_association *, gfp_t); 21518c2ecf20Sopenharmony_civoid sctp_assoc_clean_asconf_ack_cache(const struct sctp_association *asoc); 21528c2ecf20Sopenharmony_cistruct sctp_chunk *sctp_assoc_lookup_asconf_ack( 21538c2ecf20Sopenharmony_ci const struct sctp_association *asoc, 21548c2ecf20Sopenharmony_ci __be32 serial); 21558c2ecf20Sopenharmony_civoid sctp_asconf_queue_teardown(struct sctp_association *asoc); 21568c2ecf20Sopenharmony_ci 21578c2ecf20Sopenharmony_ciint sctp_cmp_addr_exact(const union sctp_addr *ss1, 21588c2ecf20Sopenharmony_ci const union sctp_addr *ss2); 21598c2ecf20Sopenharmony_cistruct sctp_chunk *sctp_get_ecne_prepend(struct sctp_association *asoc); 21608c2ecf20Sopenharmony_ci 21618c2ecf20Sopenharmony_ci/* A convenience structure to parse out SCTP specific CMSGs. */ 21628c2ecf20Sopenharmony_cistruct sctp_cmsgs { 21638c2ecf20Sopenharmony_ci struct sctp_initmsg *init; 21648c2ecf20Sopenharmony_ci struct sctp_sndrcvinfo *srinfo; 21658c2ecf20Sopenharmony_ci struct sctp_sndinfo *sinfo; 21668c2ecf20Sopenharmony_ci struct sctp_prinfo *prinfo; 21678c2ecf20Sopenharmony_ci struct sctp_authinfo *authinfo; 21688c2ecf20Sopenharmony_ci struct msghdr *addrs_msg; 21698c2ecf20Sopenharmony_ci}; 21708c2ecf20Sopenharmony_ci 21718c2ecf20Sopenharmony_ci/* Structure for tracking memory objects */ 21728c2ecf20Sopenharmony_cistruct sctp_dbg_objcnt_entry { 21738c2ecf20Sopenharmony_ci char *label; 21748c2ecf20Sopenharmony_ci atomic_t *counter; 21758c2ecf20Sopenharmony_ci}; 21768c2ecf20Sopenharmony_ci 21778c2ecf20Sopenharmony_ci#endif /* __sctp_structs_h__ */ 2178