| 1 |
|
| 2 | |
| 3 | * (C) Copyright IBM Corp. 2001, 2004
|
| 4 | * Copyright (c) 1999-2000 Cisco, Inc.
|
| 5 | * Copyright (c) 1999-2001 Motorola, Inc.
|
| 6 | * Copyright (c) 2001 Intel Corp.
|
| 7 | *
|
| 8 | * This file is part of the SCTP kernel implementation
|
| 9 | *
|
| 10 | * Please send any bug reports or fixes you make to the
|
| 11 | * email addresses:
|
| 12 | * lksctp developers <[email protected]>
|
| 13 | *
|
| 14 | * Written or modified by:
|
| 15 | * Randall Stewart <[email protected]>
|
| 16 | * Ken Morneau <[email protected]>
|
| 17 | * Qiaobing Xie <[email protected]>
|
| 18 | * La Monte H.P. Yarroll <[email protected]>
|
| 19 | * Karl Knutson <[email protected]>
|
| 20 | * Jon Grimm <[email protected]>
|
| 21 | * Xingang Guo <[email protected]>
|
| 22 | * Hui Huang <[email protected]>
|
| 23 | * Sridhar Samudrala <[email protected]>
|
| 24 | * Daisy Chang <[email protected]>
|
| 25 | * Dajiang Zhang <[email protected]>
|
| 26 | * Ardelle Fan <[email protected]>
|
| 27 | * Ryan Layer <[email protected]>
|
| 28 | * Anup Pemmaiah <[email protected]>
|
| 29 | * Kevin Gao <[email protected]>
|
| 30 |
|
| 31 |
|
| 32 | #ifndef __sctp_structs_h__
|
| 33 | #define __sctp_structs_h__
|
| 34 |
|
| 35 | #include <crypto/sha2.h>
|
| 36 | #include <linux/ktime.h>
|
| 37 | #include <linux/generic-radix-tree.h>
|
| 38 | #include <linux/rhashtable-types.h>
|
| 39 | #include <linux/socket.h>
|
| 40 | #include <linux/in.h>
|
| 41 | #include <linux/in6.h>
|
| 42 | #include <linux/ipv6.h>
|
| 43 | #include <asm/param.h>
|
| 44 | #include <linux/atomic.h>
|
| 45 | #include <linux/skbuff.h>
|
| 46 | #include <linux/workqueue.h>
|
| 47 | #include <linux/sctp.h>
|
| 48 | #include <net/sctp/auth.h>
|
| 49 | #include <net/ip.h>
|
| 50 |
|
| 51 | |
| 52 | * We should wean ourselves off this.
|
| 53 |
|
| 54 | union sctp_addr {
|
| 55 | struct sockaddr_inet sa;
|
| 56 | struct sockaddr_in v4;
|
| 57 | struct sockaddr_in6 v6;
|
| 58 | };
|
| 59 |
|
| 60 |
|
| 61 | struct sctp_globals;
|
| 62 | struct sctp_endpoint;
|
| 63 | struct sctp_association;
|
| 64 | struct sctp_transport;
|
| 65 | struct sctp_packet;
|
| 66 | struct sctp_chunk;
|
| 67 | struct sctp_inq;
|
| 68 | struct sctp_outq;
|
| 69 | struct sctp_bind_addr;
|
| 70 | struct sctp_ulpq;
|
| 71 | struct sctp_ep_common;
|
| 72 | struct sctp_stream;
|
| 73 |
|
| 74 |
|
| 75 | #include <net/sctp/tsnmap.h>
|
| 76 | #include <net/sctp/ulpevent.h>
|
| 77 | #include <net/sctp/ulpqueue.h>
|
| 78 | #include <net/sctp/stream_interleave.h>
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 | struct sctp_bind_bucket {
|
| 83 | unsigned short port;
|
| 84 | signed char fastreuse;
|
| 85 | signed char fastreuseport;
|
| 86 | kuid_t fastuid;
|
| 87 | struct hlist_node node;
|
| 88 | struct hlist_head owner;
|
| 89 | struct net *net;
|
| 90 | };
|
| 91 |
|
| 92 | struct sctp_bind_hashbucket {
|
| 93 | spinlock_t lock;
|
| 94 | struct hlist_head chain;
|
| 95 | };
|
| 96 |
|
| 97 |
|
| 98 | struct sctp_hashbucket {
|
| 99 | rwlock_t lock;
|
| 100 | struct hlist_head chain;
|
| 101 | } __attribute__((__aligned__(8)));
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 | extern struct sctp_globals {
|
| 106 | |
| 107 | * family that we support.
|
| 108 |
|
| 109 | struct list_head address_families;
|
| 110 |
|
| 111 |
|
| 112 | struct sctp_hashbucket *ep_hashtable;
|
| 113 |
|
| 114 | struct sctp_bind_hashbucket *port_hashtable;
|
| 115 |
|
| 116 | struct rhltable transport_hashtable;
|
| 117 |
|
| 118 |
|
| 119 | int ep_hashsize;
|
| 120 | int port_hashsize;
|
| 121 |
|
| 122 |
|
| 123 | __u16 max_instreams;
|
| 124 | __u16 max_outstreams;
|
| 125 |
|
| 126 | |
| 127 | * is disabled.
|
| 128 | bool checksum_disable;
|
| 129 | } sctp_globals;
|
| 130 |
|
| 131 | #define sctp_max_instreams (sctp_globals.max_instreams)
|
| 132 | #define sctp_max_outstreams (sctp_globals.max_outstreams)
|
| 133 | #define sctp_address_families (sctp_globals.address_families)
|
| 134 | #define sctp_ep_hashsize (sctp_globals.ep_hashsize)
|
| 135 | #define sctp_ep_hashtable (sctp_globals.ep_hashtable)
|
| 136 | #define sctp_port_hashsize (sctp_globals.port_hashsize)
|
| 137 | #define sctp_port_hashtable (sctp_globals.port_hashtable)
|
| 138 | #define sctp_transport_hashtable (sctp_globals.transport_hashtable)
|
| 139 | #define sctp_checksum_disable (sctp_globals.checksum_disable)
|
| 140 |
|
| 141 |
|
| 142 | enum sctp_socket_type {
|
| 143 | SCTP_SOCKET_UDP = 0,
|
| 144 | SCTP_SOCKET_UDP_HIGH_BANDWIDTH,
|
| 145 | SCTP_SOCKET_TCP
|
| 146 | };
|
| 147 |
|
| 148 |
|
| 149 | struct sctp_sock {
|
| 150 |
|
| 151 | struct inet_sock inet;
|
| 152 |
|
| 153 | enum sctp_socket_type type;
|
| 154 |
|
| 155 |
|
| 156 | struct sctp_pf *pf;
|
| 157 |
|
| 158 |
|
| 159 | struct sctp_endpoint *ep;
|
| 160 |
|
| 161 | struct sctp_bind_bucket *bind_hash;
|
| 162 |
|
| 163 | __u16 default_stream;
|
| 164 | __u32 default_ppid;
|
| 165 | __u16 default_flags;
|
| 166 | __u32 default_context;
|
| 167 | __u32 default_timetolive;
|
| 168 | __u32 default_rcv_context;
|
| 169 | int max_burst;
|
| 170 |
|
| 171 | |
| 172 | * the destination address every heartbeat interval. This value
|
| 173 | * will be inherited by all new associations.
|
| 174 |
|
| 175 | __u32 hbinterval;
|
| 176 | __u32 probe_interval;
|
| 177 |
|
| 178 | __be16 udp_port;
|
| 179 | __be16 encap_port;
|
| 180 |
|
| 181 |
|
| 182 | __u16 pathmaxrxt;
|
| 183 |
|
| 184 | __u32 flowlabel;
|
| 185 | __u8 dscp;
|
| 186 |
|
| 187 | __u16 pf_retrans;
|
| 188 | __u16 ps_retrans;
|
| 189 |
|
| 190 |
|
| 191 | __u32 pathmtu;
|
| 192 |
|
| 193 |
|
| 194 | __u32 sackdelay;
|
| 195 | __u32 sackfreq;
|
| 196 |
|
| 197 |
|
| 198 | __u32 param_flags;
|
| 199 |
|
| 200 | __u32 default_ss;
|
| 201 |
|
| 202 | struct sctp_rtoinfo rtoinfo;
|
| 203 | struct sctp_paddrparams paddrparam;
|
| 204 | struct sctp_assocparams assocparams;
|
| 205 |
|
| 206 | |
| 207 | * These two structures must be grouped together for the usercopy
|
| 208 | * whitelist region.
|
| 209 |
|
| 210 | __u16 subscribe;
|
| 211 | struct sctp_initmsg initmsg;
|
| 212 |
|
| 213 | int user_frag;
|
| 214 |
|
| 215 | __u32 autoclose;
|
| 216 | __u32 adaptation_ind;
|
| 217 | __u32 pd_point;
|
| 218 | __u16 nodelay:1,
|
| 219 | pf_expose:2,
|
| 220 | reuse:1,
|
| 221 | disable_fragments:1,
|
| 222 | v4mapped:1,
|
| 223 | frag_interleave:1,
|
| 224 | recvrcvinfo:1,
|
| 225 | recvnxtinfo:1,
|
| 226 | data_ready_signalled:1,
|
| 227 | cookie_auth_enable:1;
|
| 228 |
|
| 229 | atomic_t pd_mode;
|
| 230 |
|
| 231 |
|
| 232 | struct sk_buff_head pd_lobby;
|
| 233 |
|
| 234 | struct list_head auto_asconf_list;
|
| 235 | int do_auto_asconf;
|
| 236 | };
|
| 237 |
|
| 238 | #define sctp_sk(ptr) container_of_const(ptr, struct sctp_sock, inet.sk)
|
| 239 |
|
| 240 | static inline struct sock *sctp_opt2sk(const struct sctp_sock *sp)
|
| 241 | {
|
| 242 | return (struct sock *)sp;
|
| 243 | }
|
| 244 |
|
| 245 | #if IS_ENABLED(CONFIG_IPV6)
|
| 246 | struct sctp6_sock {
|
| 247 | struct sctp_sock sctp;
|
| 248 | struct ipv6_pinfo inet6;
|
| 249 | };
|
| 250 | #endif
|
| 251 |
|
| 252 |
|
| 253 | |
| 254 | * THIS IS NOT DICTATED BY THE SPECIFICATION.
|
| 255 |
|
| 256 | |
| 257 | * Most of these are straight out of:
|
| 258 | * RFC2960 12.2 Parameters necessary per association (i.e. the TCB)
|
| 259 | *
|
| 260 |
|
| 261 |
|
| 262 | struct sctp_cookie {
|
| 263 |
|
| 264 | |
| 265 | * Verification: in the INIT or INIT ACK chunk.
|
| 266 | * Tag :
|
| 267 |
|
| 268 | __u32 my_vtag;
|
| 269 |
|
| 270 | |
| 271 | * Verification: in the INIT chunk.
|
| 272 | * Tag :
|
| 273 |
|
| 274 | __u32 peer_vtag;
|
| 275 |
|
| 276 | |
| 277 | * be in the cookie.
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 | __u32 my_ttag;
|
| 282 |
|
| 283 |
|
| 284 | __u32 peer_ttag;
|
| 285 |
|
| 286 |
|
| 287 | ktime_t expiration;
|
| 288 |
|
| 289 | |
| 290 | * and negotiated during the INIT process.
|
| 291 |
|
| 292 | __u16 sinit_num_ostreams;
|
| 293 | __u16 sinit_max_instreams;
|
| 294 |
|
| 295 |
|
| 296 | __u32 initial_tsn;
|
| 297 |
|
| 298 |
|
| 299 | union sctp_addr peer_addr;
|
| 300 |
|
| 301 | |
| 302 | * Include the source port of the INIT-ACK
|
| 303 |
|
| 304 | __u16 my_port;
|
| 305 |
|
| 306 | __u8 prsctp_capable;
|
| 307 |
|
| 308 |
|
| 309 | __u8 padding;
|
| 310 |
|
| 311 | __u32 adaptation_ind;
|
| 312 |
|
| 313 | __u8 auth_random[sizeof(struct sctp_paramhdr) +
|
| 314 | SCTP_AUTH_RANDOM_LENGTH];
|
| 315 | __u8 auth_hmacs[sizeof(struct sctp_paramhdr) +
|
| 316 | SCTP_AUTH_NUM_HMACS * sizeof(__u16)];
|
| 317 | __u8 auth_chunks[sizeof(struct sctp_paramhdr) + SCTP_AUTH_MAX_CHUNKS];
|
| 318 |
|
| 319 | |
| 320 | * a copy of the raw address list of the association.
|
| 321 | * The length of the raw address list is saved in the
|
| 322 | * raw_addr_list_len field, which will be used at the time when
|
| 323 | * the association TCB is re-constructed from the cookie.
|
| 324 |
|
| 325 | __u32 raw_addr_list_len;
|
| 326 |
|
| 327 | };
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 | struct sctp_signed_cookie {
|
| 332 | __u8 mac[SCTP_COOKIE_MAC_SIZE];
|
| 333 | __u32 __pad;
|
| 334 | struct sctp_cookie c;
|
| 335 | } __packed;
|
| 336 |
|
| 337 | |
| 338 | * params for the maximum size and pass such structures around
|
| 339 | * internally.
|
| 340 |
|
| 341 | union sctp_addr_param {
|
| 342 | struct sctp_paramhdr p;
|
| 343 | struct sctp_ipv4addr_param v4;
|
| 344 | struct sctp_ipv6addr_param v6;
|
| 345 | };
|
| 346 |
|
| 347 | |
| 348 | * parameters and avoid casting all over the place.
|
| 349 |
|
| 350 | union sctp_params {
|
| 351 | void *v;
|
| 352 | struct sctp_paramhdr *p;
|
| 353 | struct sctp_cookie_preserve_param *life;
|
| 354 | struct sctp_hostname_param *dns;
|
| 355 | struct sctp_cookie_param *cookie;
|
| 356 | struct sctp_supported_addrs_param *sat;
|
| 357 | struct sctp_ipv4addr_param *v4;
|
| 358 | struct sctp_ipv6addr_param *v6;
|
| 359 | union sctp_addr_param *addr;
|
| 360 | struct sctp_adaptation_ind_param *aind;
|
| 361 | struct sctp_supported_ext_param *ext;
|
| 362 | struct sctp_random_param *random;
|
| 363 | struct sctp_chunks_param *chunks;
|
| 364 | struct sctp_hmac_algo_param *hmac_algo;
|
| 365 | struct sctp_addip_param *addip;
|
| 366 | };
|
| 367 |
|
| 368 | |
| 369 | * Heartbeat Information: variable length
|
| 370 | * The Sender-specific Heartbeat Info field should normally include
|
| 371 | * information about the sender's current time when this HEARTBEAT
|
| 372 | * chunk is sent and the destination transport address to which this
|
| 373 | * HEARTBEAT is sent (see Section 8.3).
|
| 374 |
|
| 375 | struct sctp_sender_hb_info {
|
| 376 | struct sctp_paramhdr param_hdr;
|
| 377 | union sctp_addr daddr;
|
| 378 | unsigned long sent_at;
|
| 379 | __u64 hb_nonce;
|
| 380 | __u32 probe_size;
|
| 381 | };
|
| 382 |
|
| 383 | int sctp_stream_init(struct sctp_stream *stream, __u16 outcnt, __u16 incnt,
|
| 384 | gfp_t gfp);
|
| 385 | int sctp_stream_init_ext(struct sctp_stream *stream, __u16 sid);
|
| 386 | void sctp_stream_free(struct sctp_stream *stream);
|
| 387 | void sctp_stream_clear(struct sctp_stream *stream);
|
| 388 | void sctp_stream_update(struct sctp_stream *stream, struct sctp_stream *new);
|
| 389 |
|
| 390 |
|
| 391 | #define sctp_ssn_peek(stream, type, sid) \
|
| 392 | (sctp_stream_##type((stream), (sid))->ssn)
|
| 393 |
|
| 394 |
|
| 395 | #define sctp_ssn_next(stream, type, sid) \
|
| 396 | (sctp_stream_##type((stream), (sid))->ssn++)
|
| 397 |
|
| 398 |
|
| 399 | #define sctp_ssn_skip(stream, type, sid, ssn) \
|
| 400 | (sctp_stream_##type((stream), (sid))->ssn = ssn + 1)
|
| 401 |
|
| 402 |
|
| 403 | #define sctp_mid_peek(stream, type, sid) \
|
| 404 | (sctp_stream_##type((stream), (sid))->mid)
|
| 405 |
|
| 406 |
|
| 407 | #define sctp_mid_next(stream, type, sid) \
|
| 408 | (sctp_stream_##type((stream), (sid))->mid++)
|
| 409 |
|
| 410 |
|
| 411 | #define sctp_mid_skip(stream, type, sid, mid) \
|
| 412 | (sctp_stream_##type((stream), (sid))->mid = mid + 1)
|
| 413 |
|
| 414 |
|
| 415 | #define sctp_mid_uo_peek(stream, type, sid) \
|
| 416 | (sctp_stream_##type((stream), (sid))->mid_uo)
|
| 417 |
|
| 418 |
|
| 419 | #define sctp_mid_uo_next(stream, type, sid) \
|
| 420 | (sctp_stream_##type((stream), (sid))->mid_uo++)
|
| 421 |
|
| 422 | |
| 423 | * Pointers to address related SCTP functions.
|
| 424 | * (i.e. things that depend on the address family.)
|
| 425 |
|
| 426 | struct sctp_af {
|
| 427 | int (*sctp_xmit) (struct sk_buff *skb,
|
| 428 | struct sctp_transport *);
|
| 429 | int (*setsockopt) (struct sock *sk,
|
| 430 | int level,
|
| 431 | int optname,
|
| 432 | sockptr_t optval,
|
| 433 | unsigned int optlen);
|
| 434 | int (*getsockopt) (struct sock *sk,
|
| 435 | int level,
|
| 436 | int optname,
|
| 437 | char __user *optval,
|
| 438 | int __user *optlen);
|
| 439 | void (*get_dst) (struct sctp_transport *t,
|
| 440 | union sctp_addr *saddr,
|
| 441 | struct flowi *fl,
|
| 442 | struct sock *sk);
|
| 443 | void (*get_saddr) (struct sctp_sock *sk,
|
| 444 | struct sctp_transport *t,
|
| 445 | struct flowi *fl);
|
| 446 | void (*copy_addrlist) (struct list_head *,
|
| 447 | struct net_device *);
|
| 448 | int (*cmp_addr) (const union sctp_addr *addr1,
|
| 449 | const union sctp_addr *addr2);
|
| 450 | void (*addr_copy) (union sctp_addr *dst,
|
| 451 | union sctp_addr *src);
|
| 452 | void (*from_skb) (union sctp_addr *,
|
| 453 | struct sk_buff *skb,
|
| 454 | int saddr);
|
| 455 | void (*from_sk) (union sctp_addr *,
|
| 456 | struct sock *sk);
|
| 457 | bool (*from_addr_param) (union sctp_addr *,
|
| 458 | union sctp_addr_param *,
|
| 459 | __be16 port, int iif);
|
| 460 | int (*to_addr_param) (const union sctp_addr *,
|
| 461 | union sctp_addr_param *);
|
| 462 | int (*addr_valid) (union sctp_addr *,
|
| 463 | struct sctp_sock *,
|
| 464 | const struct sk_buff *);
|
| 465 | enum sctp_scope (*scope)(union sctp_addr *);
|
| 466 | void (*inaddr_any) (union sctp_addr *, __be16);
|
| 467 | int (*is_any) (const union sctp_addr *);
|
| 468 | int (*available) (union sctp_addr *,
|
| 469 | struct sctp_sock *);
|
| 470 | int (*skb_iif) (const struct sk_buff *sk);
|
| 471 | int (*skb_sdif)(const struct sk_buff *sk);
|
| 472 | int (*is_ce) (const struct sk_buff *sk);
|
| 473 | void (*seq_dump_addr)(struct seq_file *seq,
|
| 474 | union sctp_addr *addr);
|
| 475 | void (*ecn_capable)(struct sock *sk);
|
| 476 | __u16 net_header_len;
|
| 477 | int sockaddr_len;
|
| 478 | int (*ip_options_len)(struct sock *sk);
|
| 479 | sa_family_t sa_family;
|
| 480 | struct list_head list;
|
| 481 | };
|
| 482 |
|
| 483 | struct sctp_af *sctp_get_af_specific(sa_family_t);
|
| 484 | int sctp_register_af(struct sctp_af *);
|
| 485 |
|
| 486 |
|
| 487 | struct sctp_pf {
|
| 488 | void (*event_msgname)(struct sctp_ulpevent *, char *, int *);
|
| 489 | void (*skb_msgname) (struct sk_buff *, char *, int *);
|
| 490 | int (*af_supported) (sa_family_t, struct sctp_sock *);
|
| 491 | int (*cmp_addr) (const union sctp_addr *,
|
| 492 | const union sctp_addr *,
|
| 493 | struct sctp_sock *);
|
| 494 | int (*bind_verify) (struct sctp_sock *, union sctp_addr *);
|
| 495 | int (*send_verify) (struct sctp_sock *, union sctp_addr *);
|
| 496 | int (*supported_addrs)(const struct sctp_sock *, __be16 *);
|
| 497 | int (*addr_to_user)(struct sctp_sock *sk, union sctp_addr *addr);
|
| 498 | void (*to_sk_saddr)(union sctp_addr *, struct sock *sk);
|
| 499 | void (*to_sk_daddr)(union sctp_addr *, struct sock *sk);
|
| 500 | void (*copy_ip_options)(struct sock *sk, struct sock *newsk);
|
| 501 | struct sctp_af *af;
|
| 502 | };
|
| 503 |
|
| 504 |
|
| 505 | |
| 506 | * fragments of the same message have not.
|
| 507 |
|
| 508 | struct sctp_datamsg {
|
| 509 |
|
| 510 | struct list_head chunks;
|
| 511 |
|
| 512 | refcount_t refcnt;
|
| 513 |
|
| 514 | unsigned long expires_at;
|
| 515 |
|
| 516 | int send_error;
|
| 517 | u8 send_failed:1,
|
| 518 | can_delay:1,
|
| 519 | abandoned:1;
|
| 520 | };
|
| 521 |
|
| 522 | struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *,
|
| 523 | struct sctp_sndrcvinfo *,
|
| 524 | struct iov_iter *);
|
| 525 | void sctp_datamsg_free(struct sctp_datamsg *);
|
| 526 | void sctp_datamsg_put(struct sctp_datamsg *);
|
| 527 | void sctp_chunk_fail(struct sctp_chunk *, int error);
|
| 528 | int sctp_chunk_abandoned(struct sctp_chunk *);
|
| 529 |
|
| 530 | |
| 531 | *
|
| 532 | * o Chunk: A unit of information within an SCTP packet, consisting of
|
| 533 | * a chunk header and chunk-specific content.
|
| 534 | *
|
| 535 | * As a matter of convenience, we remember the SCTP common header for
|
| 536 | * each chunk as well as a few other header pointers...
|
| 537 |
|
| 538 | struct sctp_chunk {
|
| 539 | struct list_head list;
|
| 540 |
|
| 541 | refcount_t refcnt;
|
| 542 |
|
| 543 |
|
| 544 | int sent_count;
|
| 545 |
|
| 546 | union {
|
| 547 |
|
| 548 | struct list_head transmitted_list;
|
| 549 |
|
| 550 | struct list_head stream_list;
|
| 551 | };
|
| 552 |
|
| 553 | |
| 554 | * For the first fragment this is the list that holds the rest of
|
| 555 | * fragments. For the remaining fragments, this is the link to the
|
| 556 | * frag_list maintained in the first fragment.
|
| 557 |
|
| 558 | struct list_head frag_list;
|
| 559 |
|
| 560 |
|
| 561 | struct sk_buff *skb;
|
| 562 |
|
| 563 | union {
|
| 564 |
|
| 565 | struct sk_buff *head_skb;
|
| 566 |
|
| 567 | struct sctp_shared_key *shkey;
|
| 568 | };
|
| 569 |
|
| 570 | |
| 571 | * Note that some of these may happen more than once. In that
|
| 572 | * case, we point at the "current" one, whatever that means
|
| 573 | * for that level of header.
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 | union sctp_params param_hdr;
|
| 578 | union {
|
| 579 | __u8 *v;
|
| 580 | struct sctp_datahdr *data_hdr;
|
| 581 | struct sctp_inithdr *init_hdr;
|
| 582 | struct sctp_sackhdr *sack_hdr;
|
| 583 | struct sctp_heartbeathdr *hb_hdr;
|
| 584 | struct sctp_sender_hb_info *hbs_hdr;
|
| 585 | struct sctp_shutdownhdr *shutdown_hdr;
|
| 586 | struct sctp_signed_cookie *cookie_hdr;
|
| 587 | struct sctp_ecnehdr *ecne_hdr;
|
| 588 | struct sctp_cwrhdr *ecn_cwr_hdr;
|
| 589 | struct sctp_errhdr *err_hdr;
|
| 590 | struct sctp_addiphdr *addip_hdr;
|
| 591 | struct sctp_fwdtsn_hdr *fwdtsn_hdr;
|
| 592 | struct sctp_authhdr *auth_hdr;
|
| 593 | struct sctp_idatahdr *idata_hdr;
|
| 594 | struct sctp_ifwdtsn_hdr *ifwdtsn_hdr;
|
| 595 | } subh;
|
| 596 |
|
| 597 | __u8 *chunk_end;
|
| 598 |
|
| 599 | struct sctp_chunkhdr *chunk_hdr;
|
| 600 | struct sctphdr *sctp_hdr;
|
| 601 |
|
| 602 |
|
| 603 | struct sctp_sndrcvinfo sinfo;
|
| 604 |
|
| 605 |
|
| 606 | struct sctp_association *asoc;
|
| 607 |
|
| 608 |
|
| 609 | struct sctp_ep_common *rcvr;
|
| 610 |
|
| 611 |
|
| 612 | unsigned long sent_at;
|
| 613 |
|
| 614 |
|
| 615 | union sctp_addr source;
|
| 616 |
|
| 617 | union sctp_addr dest;
|
| 618 |
|
| 619 |
|
| 620 | struct sctp_datamsg *msg;
|
| 621 |
|
| 622 | |
| 623 | * For an outbound chunk, it tells us where we'd like it to
|
| 624 | * go. It is NULL if we have no preference.
|
| 625 |
|
| 626 | struct sctp_transport *transport;
|
| 627 |
|
| 628 | |
| 629 | * we need save a pointer to the AUTH chunk, since the SCTP-AUTH
|
| 630 | * spec violates the principle premis that all chunks are processed
|
| 631 | * in order.
|
| 632 |
|
| 633 | struct sk_buff *auth_chunk;
|
| 634 |
|
| 635 | #define SCTP_CAN_FRTX 0x0
|
| 636 | #define SCTP_NEED_FRTX 0x1
|
| 637 | #define SCTP_DONT_FRTX 0x2
|
| 638 | __u16 rtt_in_progress:1,
|
| 639 | has_tsn:1,
|
| 640 | has_ssn:1,
|
| 641 | #define has_mid has_ssn
|
| 642 | singleton:1,
|
| 643 | end_of_packet:1,
|
| 644 | ecn_ce_done:1,
|
| 645 | pdiscard:1,
|
| 646 | tsn_gap_acked:1,
|
| 647 | data_accepted:1,
|
| 648 | auth:1,
|
| 649 | has_asconf:1,
|
| 650 | pmtu_probe:1,
|
| 651 | tsn_missing_report:2,
|
| 652 | fast_retransmit:2;
|
| 653 | };
|
| 654 |
|
| 655 | #define sctp_chunk_retransmitted(chunk) (chunk->sent_count > 1)
|
| 656 | void sctp_chunk_hold(struct sctp_chunk *);
|
| 657 | void sctp_chunk_put(struct sctp_chunk *);
|
| 658 | int sctp_user_addto_chunk(struct sctp_chunk *chunk, int len,
|
| 659 | struct iov_iter *from);
|
| 660 | void sctp_chunk_free(struct sctp_chunk *);
|
| 661 | void *sctp_addto_chunk(struct sctp_chunk *, int len, const void *data);
|
| 662 | struct sctp_chunk *sctp_chunkify(struct sk_buff *,
|
| 663 | const struct sctp_association *,
|
| 664 | struct sock *, gfp_t gfp);
|
| 665 | void sctp_init_addrs(struct sctp_chunk *, union sctp_addr *,
|
| 666 | union sctp_addr *);
|
| 667 | const union sctp_addr *sctp_source(const struct sctp_chunk *chunk);
|
| 668 |
|
| 669 | static inline __u16 sctp_chunk_stream_no(struct sctp_chunk *ch)
|
| 670 | {
|
| 671 | return ntohs(ch->subh.data_hdr->stream);
|
| 672 | }
|
| 673 |
|
| 674 | enum {
|
| 675 | SCTP_ADDR_NEW,
|
| 676 | SCTP_ADDR_SRC,
|
| 677 | SCTP_ADDR_DEL,
|
| 678 | };
|
| 679 |
|
| 680 |
|
| 681 | struct sctp_sockaddr_entry {
|
| 682 | struct list_head list;
|
| 683 | struct rcu_head rcu;
|
| 684 | union sctp_addr a;
|
| 685 | __u8 state;
|
| 686 | __u8 valid;
|
| 687 | };
|
| 688 |
|
| 689 | #define SCTP_ADDRESS_TICK_DELAY 500
|
| 690 |
|
| 691 | |
| 692 | * transmission.
|
| 693 |
|
| 694 | struct sctp_packet {
|
| 695 |
|
| 696 | __u16 source_port;
|
| 697 | __u16 destination_port;
|
| 698 | __u32 vtag;
|
| 699 |
|
| 700 |
|
| 701 | struct list_head chunk_list;
|
| 702 |
|
| 703 |
|
| 704 | size_t overhead;
|
| 705 |
|
| 706 | size_t size;
|
| 707 |
|
| 708 | size_t max_size;
|
| 709 |
|
| 710 | |
| 711 | * The function we finally use to pass down to the next lower
|
| 712 | * layer lives in the transport structure.
|
| 713 |
|
| 714 | struct sctp_transport *transport;
|
| 715 |
|
| 716 |
|
| 717 | struct sctp_chunk *auth;
|
| 718 |
|
| 719 | u8 has_cookie_echo:1,
|
| 720 | has_sack:1,
|
| 721 | has_auth:1,
|
| 722 | has_data:1,
|
| 723 | ipfragok:1;
|
| 724 | };
|
| 725 |
|
| 726 | void sctp_packet_init(struct sctp_packet *, struct sctp_transport *,
|
| 727 | __u16 sport, __u16 dport);
|
| 728 | void sctp_packet_config(struct sctp_packet *, __u32 vtag, int);
|
| 729 | enum sctp_xmit sctp_packet_transmit_chunk(struct sctp_packet *packet,
|
| 730 | struct sctp_chunk *chunk,
|
| 731 | int one_packet, gfp_t gfp);
|
| 732 | enum sctp_xmit sctp_packet_append_chunk(struct sctp_packet *packet,
|
| 733 | struct sctp_chunk *chunk);
|
| 734 | int sctp_packet_transmit(struct sctp_packet *, gfp_t);
|
| 735 | void sctp_packet_free(struct sctp_packet *);
|
| 736 |
|
| 737 | static inline int sctp_packet_empty(struct sctp_packet *packet)
|
| 738 | {
|
| 739 | return packet->size == packet->overhead;
|
| 740 | }
|
| 741 |
|
| 742 | |
| 743 | * For local transport addresses, we just use union sctp_addr.
|
| 744 | *
|
| 745 | * RFC2960 Section 1.4 Key Terms
|
| 746 | *
|
| 747 | * o Transport address: A Transport Address is traditionally defined
|
| 748 | * by Network Layer address, Transport Layer protocol and Transport
|
| 749 | * Layer port number. In the case of SCTP running over IP, a
|
| 750 | * transport address is defined by the combination of an IP address
|
| 751 | * and an SCTP port number (where SCTP is the Transport protocol).
|
| 752 | *
|
| 753 | * RFC2960 Section 7.1 SCTP Differences from TCP Congestion control
|
| 754 | *
|
| 755 | * o The sender keeps a separate congestion control parameter set for
|
| 756 | * each of the destination addresses it can send to (not each
|
| 757 | * source-destination pair but for each destination). The parameters
|
| 758 | * should decay if the address is not used for a long enough time
|
| 759 | * period.
|
| 760 | *
|
| 761 |
|
| 762 | struct sctp_transport {
|
| 763 |
|
| 764 | struct list_head transports;
|
| 765 | struct rhlist_head node;
|
| 766 |
|
| 767 |
|
| 768 | refcount_t refcnt;
|
| 769 | __u32 dead:1,
|
| 770 | |
| 771 | * chunks sent to this address is currently being
|
| 772 | * used to compute a RTT. If this flag is 0,
|
| 773 | * the next DATA chunk sent to this destination
|
| 774 | * should be used to compute a RTT and this flag
|
| 775 | * should be set. Every time the RTT
|
| 776 | * calculation completes (i.e. the DATA chunk
|
| 777 | * is SACK'd) clear this flag.
|
| 778 |
|
| 779 | rto_pending:1,
|
| 780 |
|
| 781 | |
| 782 | * hb_sent : a flag that signals that we have a pending
|
| 783 | * heartbeat.
|
| 784 |
|
| 785 | hb_sent:1,
|
| 786 |
|
| 787 |
|
| 788 | pmtu_pending:1,
|
| 789 |
|
| 790 | dst_pending_confirm:1,
|
| 791 |
|
| 792 |
|
| 793 | sack_generation:1;
|
| 794 | u32 dst_cookie;
|
| 795 |
|
| 796 | struct flowi fl;
|
| 797 |
|
| 798 |
|
| 799 | union sctp_addr ipaddr;
|
| 800 |
|
| 801 |
|
| 802 | struct sctp_af *af_specific;
|
| 803 |
|
| 804 |
|
| 805 | struct sctp_association *asoc;
|
| 806 |
|
| 807 | |
| 808 | *
|
| 809 | * 12.3 Per Transport Address Data
|
| 810 | *
|
| 811 | * For each destination transport address in the peer's
|
| 812 | * address list derived from the INIT or INIT ACK chunk, a
|
| 813 | * number of data elements needs to be maintained including:
|
| 814 |
|
| 815 |
|
| 816 | unsigned long rto;
|
| 817 |
|
| 818 | __u32 rtt;
|
| 819 |
|
| 820 |
|
| 821 | __u32 rttvar;
|
| 822 |
|
| 823 |
|
| 824 | __u32 srtt;
|
| 825 |
|
| 826 | |
| 827 | * These are the congestion stats.
|
| 828 |
|
| 829 |
|
| 830 | __u32 cwnd;
|
| 831 |
|
| 832 |
|
| 833 | __u32 ssthresh;
|
| 834 |
|
| 835 | |
| 836 | * bytes acked : congestion avoidance mode (see Section 6.2.2)
|
| 837 |
|
| 838 | __u32 partial_bytes_acked;
|
| 839 |
|
| 840 |
|
| 841 | __u32 flight_size;
|
| 842 |
|
| 843 | __u32 burst_limited;
|
| 844 |
|
| 845 |
|
| 846 | struct dst_entry *dst;
|
| 847 |
|
| 848 | union sctp_addr saddr;
|
| 849 |
|
| 850 | |
| 851 | * the destination address every heartbeat interval.
|
| 852 |
|
| 853 | unsigned long hbinterval;
|
| 854 | unsigned long probe_interval;
|
| 855 |
|
| 856 |
|
| 857 | unsigned long sackdelay;
|
| 858 | __u32 sackfreq;
|
| 859 |
|
| 860 | atomic_t mtu_info;
|
| 861 |
|
| 862 | |
| 863 | * this to pick new active and retran paths.
|
| 864 |
|
| 865 | ktime_t last_time_heard;
|
| 866 |
|
| 867 | |
| 868 | * transport? We use this to check for idle transports
|
| 869 |
|
| 870 | unsigned long last_time_sent;
|
| 871 |
|
| 872 | |
| 873 | * indication based on ECNE chunk.
|
| 874 |
|
| 875 | unsigned long last_time_ecne_reduced;
|
| 876 |
|
| 877 | __be16 encap_port;
|
| 878 |
|
| 879 | |
| 880 | * be initialized from the assocs value. This can be changed
|
| 881 | * using the SCTP_SET_PEER_ADDR_PARAMS socket option.
|
| 882 |
|
| 883 | __u16 pathmaxrxt;
|
| 884 |
|
| 885 | __u32 flowlabel;
|
| 886 | __u8 dscp;
|
| 887 |
|
| 888 | |
| 889 | * and will be initialized from the assocs value. This can be changed
|
| 890 | * using the SCTP_PEER_ADDR_THLDS socket option
|
| 891 |
|
| 892 | __u16 pf_retrans;
|
| 893 |
|
| 894 | __u16 ps_retrans;
|
| 895 |
|
| 896 | __u32 pathmtu;
|
| 897 |
|
| 898 |
|
| 899 | __u32 param_flags;
|
| 900 |
|
| 901 |
|
| 902 | int init_sent_count;
|
| 903 |
|
| 904 | |
| 905 | * : i.e. SCTP_ACTIVE, SCTP_INACTIVE, SCTP_UNKNOWN.
|
| 906 |
|
| 907 | int state;
|
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 | unsigned short error_count;
|
| 913 |
|
| 914 | |
| 915 | * Destination :
|
| 916 | * Timer :
|
| 917 | *
|
| 918 | * [Everywhere else in the text this is called T3-rtx. -ed]
|
| 919 |
|
| 920 | struct timer_list T3_rtx_timer;
|
| 921 |
|
| 922 |
|
| 923 | struct timer_list hb_timer;
|
| 924 |
|
| 925 |
|
| 926 | struct timer_list proto_unreach_timer;
|
| 927 |
|
| 928 |
|
| 929 | struct timer_list reconf_timer;
|
| 930 |
|
| 931 |
|
| 932 | struct timer_list probe_timer;
|
| 933 |
|
| 934 | |
| 935 | * (see above), we're also using per-destination "transmitted"
|
| 936 | * queues. This probably ought to be a private struct
|
| 937 | * accessible only within the outqueue, but it's not, yet.
|
| 938 |
|
| 939 | struct list_head transmitted;
|
| 940 |
|
| 941 |
|
| 942 | struct sctp_packet packet;
|
| 943 |
|
| 944 |
|
| 945 | struct list_head send_ready;
|
| 946 |
|
| 947 | |
| 948 | * idea in SFR_CACC is to maintain state at the sender on a
|
| 949 | * per-destination basis when a changeover happens.
|
| 950 | * char changeover_active;
|
| 951 | * char cycling_changeover;
|
| 952 | * __u32 next_tsn_at_change;
|
| 953 | * char cacc_saw_newack;
|
| 954 |
|
| 955 | struct {
|
| 956 | |
| 957 | * used by the sender, at the moment of changeover.
|
| 958 |
|
| 959 | __u32 next_tsn_at_change;
|
| 960 |
|
| 961 |
|
| 962 | char changeover_active;
|
| 963 |
|
| 964 | |
| 965 | * the first switch to this destination address during an
|
| 966 | * active switch.
|
| 967 |
|
| 968 | char cycling_changeover;
|
| 969 |
|
| 970 | |
| 971 | * a SACK to estimate the causative TSN(s)'s group.
|
| 972 |
|
| 973 | char cacc_saw_newack;
|
| 974 | } cacc;
|
| 975 |
|
| 976 | struct {
|
| 977 | __u16 pmtu;
|
| 978 | __u16 probe_size;
|
| 979 | __u16 probe_high;
|
| 980 | __u8 probe_count;
|
| 981 | __u8 state;
|
| 982 | } pl;
|
| 983 |
|
| 984 |
|
| 985 | __u64 hb_nonce;
|
| 986 |
|
| 987 | struct rcu_head rcu;
|
| 988 | };
|
| 989 |
|
| 990 | struct sctp_transport *sctp_transport_new(struct net *, const union sctp_addr *,
|
| 991 | gfp_t);
|
| 992 | void sctp_transport_set_owner(struct sctp_transport *,
|
| 993 | struct sctp_association *);
|
| 994 | void sctp_transport_route(struct sctp_transport *, union sctp_addr *,
|
| 995 | struct sctp_sock *);
|
| 996 | void sctp_transport_pmtu(struct sctp_transport *, struct sock *sk);
|
| 997 | void sctp_transport_free(struct sctp_transport *);
|
| 998 | void sctp_transport_reset_t3_rtx(struct sctp_transport *);
|
| 999 | void sctp_transport_reset_hb_timer(struct sctp_transport *);
|
| 1000 | void sctp_transport_reset_reconf_timer(struct sctp_transport *transport);
|
| 1001 | void sctp_transport_reset_probe_timer(struct sctp_transport *transport);
|
| 1002 | void sctp_transport_reset_raise_timer(struct sctp_transport *transport);
|
| 1003 | int sctp_transport_hold(struct sctp_transport *);
|
| 1004 | void sctp_transport_put(struct sctp_transport *);
|
| 1005 | void sctp_transport_update_rto(struct sctp_transport *, __u32);
|
| 1006 | void sctp_transport_raise_cwnd(struct sctp_transport *, __u32, __u32);
|
| 1007 | void sctp_transport_lower_cwnd(struct sctp_transport *t,
|
| 1008 | enum sctp_lower_cwnd reason);
|
| 1009 | void sctp_transport_burst_limited(struct sctp_transport *);
|
| 1010 | void sctp_transport_burst_reset(struct sctp_transport *);
|
| 1011 | unsigned long sctp_transport_timeout(struct sctp_transport *);
|
| 1012 | void sctp_transport_reset(struct sctp_transport *t);
|
| 1013 | bool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu);
|
| 1014 | void sctp_transport_immediate_rtx(struct sctp_transport *);
|
| 1015 | void sctp_transport_dst_release(struct sctp_transport *t);
|
| 1016 | void sctp_transport_dst_confirm(struct sctp_transport *t);
|
| 1017 | void sctp_transport_pl_send(struct sctp_transport *t);
|
| 1018 | bool sctp_transport_pl_recv(struct sctp_transport *t);
|
| 1019 |
|
| 1020 |
|
| 1021 | |
| 1022 | * SCTP. We write packets to it and read chunks from it.
|
| 1023 |
|
| 1024 | struct sctp_inq {
|
| 1025 | |
| 1026 | * containing a partially decoded packet.
|
| 1027 |
|
| 1028 | struct list_head in_chunk_list;
|
| 1029 | |
| 1030 | * being worked on through the inbound chunk processing.
|
| 1031 |
|
| 1032 | struct sctp_chunk *in_progress;
|
| 1033 |
|
| 1034 | |
| 1035 | * messages.
|
| 1036 |
|
| 1037 | struct work_struct immediate;
|
| 1038 | };
|
| 1039 |
|
| 1040 | void sctp_inq_init(struct sctp_inq *);
|
| 1041 | void sctp_inq_free(struct sctp_inq *);
|
| 1042 | void sctp_inq_push(struct sctp_inq *, struct sctp_chunk *packet);
|
| 1043 | struct sctp_chunk *sctp_inq_pop(struct sctp_inq *);
|
| 1044 | struct sctp_chunkhdr *sctp_inq_peek(struct sctp_inq *);
|
| 1045 | void sctp_inq_set_th_handler(struct sctp_inq *, work_func_t);
|
| 1046 |
|
| 1047 | |
| 1048 | * chunks in and they automatically pop out the other end as bundled
|
| 1049 | * packets (it calls (*output_handler)()).
|
| 1050 | *
|
| 1051 | * This structure covers sections 6.3, 6.4, 6.7, 6.8, 6.10, 7., 8.1,
|
| 1052 | * and 8.2 of the v13 draft.
|
| 1053 | *
|
| 1054 | * It handles retransmissions. The connection to the timeout portion
|
| 1055 | * of the state machine is through sctp_..._timeout() and timeout_handler.
|
| 1056 | *
|
| 1057 | * If you feed it SACKs, it will eat them.
|
| 1058 | *
|
| 1059 | * If you give it big chunks, it will fragment them.
|
| 1060 | *
|
| 1061 | * It assigns TSN's to data chunks. This happens at the last possible
|
| 1062 | * instant before transmission.
|
| 1063 | *
|
| 1064 | * When free()'d, it empties itself out via output_handler().
|
| 1065 |
|
| 1066 | struct sctp_outq {
|
| 1067 | struct sctp_association *asoc;
|
| 1068 |
|
| 1069 |
|
| 1070 | struct list_head out_chunk_list;
|
| 1071 |
|
| 1072 |
|
| 1073 | const struct sctp_sched_ops *sched;
|
| 1074 |
|
| 1075 | unsigned int out_qlen;
|
| 1076 |
|
| 1077 |
|
| 1078 | unsigned int error;
|
| 1079 |
|
| 1080 |
|
| 1081 | struct list_head control_chunk_list;
|
| 1082 |
|
| 1083 | |
| 1084 | * CTSN, or cumulative tsn ack point.
|
| 1085 |
|
| 1086 | struct list_head sacked;
|
| 1087 |
|
| 1088 | |
| 1089 | * retransmission.
|
| 1090 |
|
| 1091 | struct list_head retransmit;
|
| 1092 |
|
| 1093 | |
| 1094 | * they were abandoned.
|
| 1095 |
|
| 1096 | struct list_head abandoned;
|
| 1097 |
|
| 1098 |
|
| 1099 | __u32 outstanding_bytes;
|
| 1100 |
|
| 1101 |
|
| 1102 | char fast_rtx;
|
| 1103 |
|
| 1104 |
|
| 1105 | char cork;
|
| 1106 | };
|
| 1107 |
|
| 1108 | void sctp_outq_init(struct sctp_association *, struct sctp_outq *);
|
| 1109 | void sctp_outq_teardown(struct sctp_outq *);
|
| 1110 | void sctp_outq_free(struct sctp_outq*);
|
| 1111 | void sctp_outq_tail(struct sctp_outq *, struct sctp_chunk *chunk, gfp_t);
|
| 1112 | int sctp_outq_sack(struct sctp_outq *, struct sctp_chunk *);
|
| 1113 | int sctp_outq_is_empty(const struct sctp_outq *);
|
| 1114 | void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
|
| 1115 | enum sctp_retransmit_reason reason);
|
| 1116 | void sctp_retransmit_mark(struct sctp_outq *, struct sctp_transport *, __u8);
|
| 1117 | void sctp_outq_uncork(struct sctp_outq *, gfp_t gfp);
|
| 1118 | void sctp_prsctp_prune(struct sctp_association *asoc,
|
| 1119 | struct sctp_sndrcvinfo *sinfo, int msg_len);
|
| 1120 | void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 sack_ctsn);
|
| 1121 |
|
| 1122 | static inline void sctp_outq_cork(struct sctp_outq *q)
|
| 1123 | {
|
| 1124 | q->cork = 1;
|
| 1125 | }
|
| 1126 |
|
| 1127 | |
| 1128 | * sctp_input_cb is currently used on rx and sock rx queue
|
| 1129 |
|
| 1130 | struct sctp_input_cb {
|
| 1131 | union {
|
| 1132 | struct inet_skb_parm h4;
|
| 1133 | #if IS_ENABLED(CONFIG_IPV6)
|
| 1134 | struct inet6_skb_parm h6;
|
| 1135 | #endif
|
| 1136 | } header;
|
| 1137 | struct sctp_chunk *chunk;
|
| 1138 | struct sctp_af *af;
|
| 1139 | __be16 encap_port;
|
| 1140 | };
|
| 1141 | #define SCTP_INPUT_CB(__skb) ((struct sctp_input_cb *)&((__skb)->cb[0]))
|
| 1142 |
|
| 1143 | struct sctp_output_cb {
|
| 1144 | struct sk_buff *last;
|
| 1145 | };
|
| 1146 | #define SCTP_OUTPUT_CB(__skb) ((struct sctp_output_cb *)&((__skb)->cb[0]))
|
| 1147 |
|
| 1148 | static inline const struct sk_buff *sctp_gso_headskb(const struct sk_buff *skb)
|
| 1149 | {
|
| 1150 | const struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
|
| 1151 |
|
| 1152 | return chunk->head_skb ? : skb;
|
| 1153 | }
|
| 1154 |
|
| 1155 |
|
| 1156 | struct sctp_bind_addr {
|
| 1157 |
|
| 1158 | |
| 1159 | *
|
| 1160 | * SCTP Port: The local SCTP port number the endpoint is
|
| 1161 | * bound to.
|
| 1162 |
|
| 1163 | __u16 port;
|
| 1164 |
|
| 1165 | |
| 1166 | *
|
| 1167 | * Address List: The list of IP addresses that this instance
|
| 1168 | * has bound. This information is passed to one's
|
| 1169 | * peer(s) in INIT and INIT ACK chunks.
|
| 1170 |
|
| 1171 | struct list_head address_list;
|
| 1172 | };
|
| 1173 |
|
| 1174 | void sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port);
|
| 1175 | void sctp_bind_addr_free(struct sctp_bind_addr *);
|
| 1176 | int sctp_bind_addr_copy(struct net *net, struct sctp_bind_addr *dest,
|
| 1177 | const struct sctp_bind_addr *src,
|
| 1178 | enum sctp_scope scope, gfp_t gfp,
|
| 1179 | int flags);
|
| 1180 | int sctp_bind_addr_dup(struct sctp_bind_addr *dest,
|
| 1181 | const struct sctp_bind_addr *src,
|
| 1182 | gfp_t gfp);
|
| 1183 | int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *,
|
| 1184 | int new_size, __u8 addr_state, gfp_t gfp);
|
| 1185 | int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *);
|
| 1186 | int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *,
|
| 1187 | struct sctp_sock *);
|
| 1188 | int sctp_bind_addr_conflict(struct sctp_bind_addr *, const union sctp_addr *,
|
| 1189 | struct sctp_sock *, struct sctp_sock *);
|
| 1190 | int sctp_bind_addr_state(const struct sctp_bind_addr *bp,
|
| 1191 | const union sctp_addr *addr);
|
| 1192 | int sctp_bind_addrs_check(struct sctp_sock *sp,
|
| 1193 | struct sctp_sock *sp2, int cnt2);
|
| 1194 | union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp,
|
| 1195 | const union sctp_addr *addrs,
|
| 1196 | int addrcnt,
|
| 1197 | struct sctp_sock *opt);
|
| 1198 | union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,
|
| 1199 | int *addrs_len,
|
| 1200 | gfp_t gfp);
|
| 1201 | int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len,
|
| 1202 | __u16 port, gfp_t gfp);
|
| 1203 |
|
| 1204 | enum sctp_scope sctp_scope(const union sctp_addr *addr);
|
| 1205 | int sctp_in_scope(struct net *net, const union sctp_addr *addr,
|
| 1206 | const enum sctp_scope scope);
|
| 1207 | int sctp_is_any(struct sock *sk, const union sctp_addr *addr);
|
| 1208 | int sctp_is_ep_boundall(struct sock *sk);
|
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 | enum sctp_endpoint_type {
|
| 1213 | SCTP_EP_TYPE_SOCKET,
|
| 1214 | SCTP_EP_TYPE_ASSOCIATION,
|
| 1215 | };
|
| 1216 |
|
| 1217 | |
| 1218 | * A common base class to bridge the implementation view of a
|
| 1219 | * socket (usually listening) endpoint versus an association's
|
| 1220 | * local endpoint.
|
| 1221 | * This common structure is useful for several purposes:
|
| 1222 | * 1) Common interface for lookup routines.
|
| 1223 | * a) Subfunctions work for either endpoint or association
|
| 1224 | * b) Single interface to lookup allows hiding the lookup lock rather
|
| 1225 | * than acquiring it externally.
|
| 1226 | * 2) Common interface for the inbound chunk handling/state machine.
|
| 1227 | * 3) Common object handling routines for reference counting, etc.
|
| 1228 | * 4) Disentangle association lookup from endpoint lookup, where we
|
| 1229 | * do not have to find our endpoint to find our association.
|
| 1230 | *
|
| 1231 |
|
| 1232 |
|
| 1233 | struct sctp_ep_common {
|
| 1234 |
|
| 1235 | enum sctp_endpoint_type type;
|
| 1236 |
|
| 1237 | |
| 1238 | * refcnt - Reference count access to this object.
|
| 1239 | * dead - Do not attempt to use this object.
|
| 1240 |
|
| 1241 | refcount_t refcnt;
|
| 1242 | bool dead;
|
| 1243 |
|
| 1244 |
|
| 1245 | struct sock *sk;
|
| 1246 |
|
| 1247 |
|
| 1248 | struct net *net;
|
| 1249 |
|
| 1250 |
|
| 1251 | struct sctp_inq inqueue;
|
| 1252 |
|
| 1253 | |
| 1254 | * endpoint:
|
| 1255 | * bind_addr.port is our shared port number.
|
| 1256 | * bind_addr.address_list is our set of local IP addresses.
|
| 1257 |
|
| 1258 | struct sctp_bind_addr bind_addr;
|
| 1259 | };
|
| 1260 |
|
| 1261 |
|
| 1262 | |
| 1263 | *
|
| 1264 | * o SCTP endpoint: The logical sender/receiver of SCTP packets. On a
|
| 1265 | * multi-homed host, an SCTP endpoint is represented to its peers as a
|
| 1266 | * combination of a set of eligible destination transport addresses to
|
| 1267 | * which SCTP packets can be sent and a set of eligible source
|
| 1268 | * transport addresses from which SCTP packets can be received.
|
| 1269 | * All transport addresses used by an SCTP endpoint must use the
|
| 1270 | * same port number, but can use multiple IP addresses. A transport
|
| 1271 | * address used by an SCTP endpoint must not be used by another
|
| 1272 | * SCTP endpoint. In other words, a transport address is unique
|
| 1273 | * to an SCTP endpoint.
|
| 1274 | *
|
| 1275 | * From an implementation perspective, each socket has one of these.
|
| 1276 | * A TCP-style socket will have exactly one association on one of
|
| 1277 | * these. An UDP-style socket will have multiple associations hanging
|
| 1278 | * off one of these.
|
| 1279 |
|
| 1280 |
|
| 1281 | struct sctp_endpoint {
|
| 1282 |
|
| 1283 | struct sctp_ep_common base;
|
| 1284 |
|
| 1285 |
|
| 1286 | struct hlist_node node;
|
| 1287 | int hashent;
|
| 1288 |
|
| 1289 | |
| 1290 | * to the data consumers for each association. This
|
| 1291 | * may be in the form of a hash table or other
|
| 1292 | * implementation dependent structure. The data
|
| 1293 | * consumers may be process identification
|
| 1294 | * information such as file descriptors, named pipe
|
| 1295 | * pointer, or table pointers dependent on how SCTP
|
| 1296 | * is implemented.
|
| 1297 |
|
| 1298 |
|
| 1299 | struct list_head asocs;
|
| 1300 |
|
| 1301 |
|
| 1302 | struct hmac_sha256_key cookie_auth_key;
|
| 1303 |
|
| 1304 |
|
| 1305 | __u32 sndbuf_policy;
|
| 1306 |
|
| 1307 |
|
| 1308 | __u32 rcvbuf_policy;
|
| 1309 |
|
| 1310 |
|
| 1311 | struct sctp_hmac_algo_param *auth_hmacs_list;
|
| 1312 |
|
| 1313 |
|
| 1314 | struct sctp_chunks_param *auth_chunk_list;
|
| 1315 |
|
| 1316 |
|
| 1317 | struct list_head endpoint_shared_keys;
|
| 1318 | __u16 active_key_id;
|
| 1319 | __u8 ecn_enable:1,
|
| 1320 | auth_enable:1,
|
| 1321 | intl_enable:1,
|
| 1322 | prsctp_enable:1,
|
| 1323 | asconf_enable:1,
|
| 1324 | reconf_enable:1;
|
| 1325 |
|
| 1326 | __u8 strreset_enable;
|
| 1327 | struct rcu_head rcu;
|
| 1328 | };
|
| 1329 |
|
| 1330 |
|
| 1331 | static inline struct sctp_endpoint *sctp_ep(struct sctp_ep_common *base)
|
| 1332 | {
|
| 1333 | struct sctp_endpoint *ep;
|
| 1334 |
|
| 1335 | ep = container_of(base, struct sctp_endpoint, base);
|
| 1336 | return ep;
|
| 1337 | }
|
| 1338 |
|
| 1339 |
|
| 1340 | struct sctp_endpoint *sctp_endpoint_new(struct sock *, gfp_t);
|
| 1341 | void sctp_endpoint_free(struct sctp_endpoint *);
|
| 1342 | void sctp_endpoint_put(struct sctp_endpoint *);
|
| 1343 | int sctp_endpoint_hold(struct sctp_endpoint *ep);
|
| 1344 | void sctp_endpoint_add_asoc(struct sctp_endpoint *, struct sctp_association *);
|
| 1345 | struct sctp_association *sctp_endpoint_lookup_assoc(
|
| 1346 | const struct sctp_endpoint *ep,
|
| 1347 | const union sctp_addr *paddr,
|
| 1348 | struct sctp_transport **);
|
| 1349 | bool sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep,
|
| 1350 | const union sctp_addr *paddr);
|
| 1351 | struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep,
|
| 1352 | struct net *net,
|
| 1353 | const union sctp_addr *laddr,
|
| 1354 | int dif, int sdif);
|
| 1355 | bool sctp_has_association(struct net *net, const union sctp_addr *laddr,
|
| 1356 | const union sctp_addr *paddr, int dif, int sdif);
|
| 1357 |
|
| 1358 | int sctp_verify_init(struct net *net, const struct sctp_endpoint *ep,
|
| 1359 | const struct sctp_association *asoc,
|
| 1360 | enum sctp_cid cid, struct sctp_init_chunk *peer_init,
|
| 1361 | struct sctp_chunk *chunk, struct sctp_chunk **err_chunk);
|
| 1362 | int sctp_process_init(struct sctp_association *, struct sctp_chunk *chunk,
|
| 1363 | const union sctp_addr *peer,
|
| 1364 | struct sctp_init_chunk *init, gfp_t gfp);
|
| 1365 | __u32 sctp_generate_tag(const struct sctp_endpoint *);
|
| 1366 | __u32 sctp_generate_tsn(const struct sctp_endpoint *);
|
| 1367 |
|
| 1368 | struct sctp_inithdr_host {
|
| 1369 | __u32 init_tag;
|
| 1370 | __u32 a_rwnd;
|
| 1371 | __u16 num_outbound_streams;
|
| 1372 | __u16 num_inbound_streams;
|
| 1373 | __u32 initial_tsn;
|
| 1374 | };
|
| 1375 |
|
| 1376 | struct sctp_stream_priorities {
|
| 1377 |
|
| 1378 | struct list_head prio_sched;
|
| 1379 |
|
| 1380 | struct list_head active;
|
| 1381 |
|
| 1382 | struct sctp_stream_out_ext *next;
|
| 1383 | __u16 prio;
|
| 1384 | __u16 users;
|
| 1385 | };
|
| 1386 |
|
| 1387 | struct sctp_stream_out_ext {
|
| 1388 | __u64 abandoned_unsent[SCTP_PR_INDEX(MAX) + 1];
|
| 1389 | __u64 abandoned_sent[SCTP_PR_INDEX(MAX) + 1];
|
| 1390 | struct list_head outq;
|
| 1391 | union {
|
| 1392 | struct {
|
| 1393 |
|
| 1394 | struct list_head prio_list;
|
| 1395 | struct sctp_stream_priorities *prio_head;
|
| 1396 | };
|
| 1397 |
|
| 1398 | struct {
|
| 1399 | struct list_head rr_list;
|
| 1400 | };
|
| 1401 | struct {
|
| 1402 | struct list_head fc_list;
|
| 1403 | __u32 fc_length;
|
| 1404 | __u16 fc_weight;
|
| 1405 | };
|
| 1406 | };
|
| 1407 | };
|
| 1408 |
|
| 1409 | struct sctp_stream_out {
|
| 1410 | union {
|
| 1411 | __u32 mid;
|
| 1412 | __u16 ssn;
|
| 1413 | };
|
| 1414 | __u32 mid_uo;
|
| 1415 | struct sctp_stream_out_ext *ext;
|
| 1416 | __u8 state;
|
| 1417 | };
|
| 1418 |
|
| 1419 | struct sctp_stream_in {
|
| 1420 | union {
|
| 1421 | __u32 mid;
|
| 1422 | __u16 ssn;
|
| 1423 | };
|
| 1424 | __u32 mid_uo;
|
| 1425 | __u32 fsn;
|
| 1426 | __u32 fsn_uo;
|
| 1427 | char pd_mode;
|
| 1428 | char pd_mode_uo;
|
| 1429 | };
|
| 1430 |
|
| 1431 | struct sctp_stream {
|
| 1432 | GENRADIX(struct sctp_stream_out) out;
|
| 1433 | GENRADIX(struct sctp_stream_in) in;
|
| 1434 |
|
| 1435 | __u16 outcnt;
|
| 1436 | __u16 incnt;
|
| 1437 |
|
| 1438 | struct sctp_stream_out *out_curr;
|
| 1439 | union {
|
| 1440 |
|
| 1441 | struct {
|
| 1442 |
|
| 1443 | struct list_head prio_list;
|
| 1444 | };
|
| 1445 |
|
| 1446 | struct {
|
| 1447 |
|
| 1448 | struct list_head rr_list;
|
| 1449 |
|
| 1450 | struct sctp_stream_out_ext *rr_next;
|
| 1451 | };
|
| 1452 | struct {
|
| 1453 | struct list_head fc_list;
|
| 1454 | };
|
| 1455 | };
|
| 1456 | struct sctp_stream_interleave *si;
|
| 1457 | };
|
| 1458 |
|
| 1459 | static inline struct sctp_stream_out *sctp_stream_out(
|
| 1460 | struct sctp_stream *stream,
|
| 1461 | __u16 sid)
|
| 1462 | {
|
| 1463 | return genradix_ptr(&stream->out, sid);
|
| 1464 | }
|
| 1465 |
|
| 1466 | static inline struct sctp_stream_in *sctp_stream_in(
|
| 1467 | struct sctp_stream *stream,
|
| 1468 | __u16 sid)
|
| 1469 | {
|
| 1470 | return genradix_ptr(&stream->in, sid);
|
| 1471 | }
|
| 1472 |
|
| 1473 | #define SCTP_SO(s, i) sctp_stream_out((s), (i))
|
| 1474 | #define SCTP_SI(s, i) sctp_stream_in((s), (i))
|
| 1475 |
|
| 1476 | #define SCTP_STREAM_CLOSED 0x00
|
| 1477 | #define SCTP_STREAM_OPEN 0x01
|
| 1478 |
|
| 1479 | static inline __u16 sctp_datachk_len(const struct sctp_stream *stream)
|
| 1480 | {
|
| 1481 | return stream->si->data_chunk_len;
|
| 1482 | }
|
| 1483 |
|
| 1484 | static inline __u16 sctp_datahdr_len(const struct sctp_stream *stream)
|
| 1485 | {
|
| 1486 | return stream->si->data_chunk_len - sizeof(struct sctp_chunkhdr);
|
| 1487 | }
|
| 1488 |
|
| 1489 | static inline __u16 sctp_ftsnchk_len(const struct sctp_stream *stream)
|
| 1490 | {
|
| 1491 | return stream->si->ftsn_chunk_len;
|
| 1492 | }
|
| 1493 |
|
| 1494 | static inline __u16 sctp_ftsnhdr_len(const struct sctp_stream *stream)
|
| 1495 | {
|
| 1496 | return stream->si->ftsn_chunk_len - sizeof(struct sctp_chunkhdr);
|
| 1497 | }
|
| 1498 |
|
| 1499 |
|
| 1500 | struct sctp_priv_assoc_stats {
|
| 1501 | |
| 1502 | * observations. Value is set to 0 if no RTO measurement took place
|
| 1503 | * The transport where the max_rto was observed is returned in
|
| 1504 | * obs_rto_ipaddr
|
| 1505 |
|
| 1506 | struct sockaddr_storage obs_rto_ipaddr;
|
| 1507 | __u64 max_obs_rto;
|
| 1508 |
|
| 1509 | __u64 isacks;
|
| 1510 | __u64 osacks;
|
| 1511 |
|
| 1512 | __u64 opackets;
|
| 1513 | __u64 ipackets;
|
| 1514 |
|
| 1515 | __u64 rtxchunks;
|
| 1516 |
|
| 1517 | __u64 outofseqtsns;
|
| 1518 |
|
| 1519 | __u64 idupchunks;
|
| 1520 |
|
| 1521 | __u64 gapcnt;
|
| 1522 |
|
| 1523 | __u64 ouodchunks;
|
| 1524 | __u64 iuodchunks;
|
| 1525 |
|
| 1526 | __u64 oodchunks;
|
| 1527 | __u64 iodchunks;
|
| 1528 |
|
| 1529 | __u64 octrlchunks;
|
| 1530 | __u64 ictrlchunks;
|
| 1531 | };
|
| 1532 |
|
| 1533 | |
| 1534 | *
|
| 1535 | * 12. Recommended Transmission Control Block (TCB) Parameters
|
| 1536 | *
|
| 1537 | * This section details a recommended set of parameters that should
|
| 1538 | * be contained within the TCB for an implementation. This section is
|
| 1539 | * for illustrative purposes and should not be deemed as requirements
|
| 1540 | * on an implementation or as an exhaustive list of all parameters
|
| 1541 | * inside an SCTP TCB. Each implementation may need its own additional
|
| 1542 | * parameters for optimization.
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
|
| 1547 | struct sctp_association {
|
| 1548 |
|
| 1549 | |
| 1550 | * In this context, it represents the associations's view
|
| 1551 | * of the local endpoint of the association.
|
| 1552 |
|
| 1553 | struct sctp_ep_common base;
|
| 1554 |
|
| 1555 |
|
| 1556 | struct list_head asocs;
|
| 1557 |
|
| 1558 |
|
| 1559 | sctp_assoc_t assoc_id;
|
| 1560 |
|
| 1561 |
|
| 1562 | struct sctp_endpoint *ep;
|
| 1563 |
|
| 1564 |
|
| 1565 | struct sctp_cookie c;
|
| 1566 |
|
| 1567 |
|
| 1568 | struct {
|
| 1569 | |
| 1570 | *
|
| 1571 | * Peer : A list of SCTP transport addresses that the
|
| 1572 | * Transport : peer is bound to. This information is derived
|
| 1573 | * Address : from the INIT or INIT ACK and is used to
|
| 1574 | * List : associate an inbound packet with a given
|
| 1575 | * : association. Normally this information is
|
| 1576 | * : hashed or keyed for quick lookup and access
|
| 1577 | * : of the TCB.
|
| 1578 | * : The list is also initialized with the list
|
| 1579 | * : of addresses passed with the sctp_connectx()
|
| 1580 | * : call.
|
| 1581 | *
|
| 1582 | * It is a list of SCTP_transport's.
|
| 1583 |
|
| 1584 | struct list_head transport_addr_list;
|
| 1585 |
|
| 1586 | |
| 1587 | *
|
| 1588 | * Peer Rwnd : Current calculated value of the peer's rwnd.
|
| 1589 |
|
| 1590 | __u32 rwnd;
|
| 1591 |
|
| 1592 | |
| 1593 | *
|
| 1594 | * Peer : A count of the number of peer addresses
|
| 1595 | * Transport : in the Peer Transport Address List.
|
| 1596 | * Address :
|
| 1597 | * Count :
|
| 1598 |
|
| 1599 | __u16 transport_count;
|
| 1600 |
|
| 1601 | |
| 1602 | * The transport layer port number.
|
| 1603 |
|
| 1604 | __u16 port;
|
| 1605 |
|
| 1606 | |
| 1607 | *
|
| 1608 | * Primary : This is the current primary destination
|
| 1609 | * Path : transport address of the peer endpoint. It
|
| 1610 | * : may also specify a source transport address
|
| 1611 | * : on this endpoint.
|
| 1612 | *
|
| 1613 | * All of these paths live on transport_addr_list.
|
| 1614 | *
|
| 1615 | * At the bakeoffs, we discovered that the intent of
|
| 1616 | * primaryPath is that it only changes when the ULP
|
| 1617 | * asks to have it changed. We add the activePath to
|
| 1618 | * designate the connection we are currently using to
|
| 1619 | * transmit new data and most control chunks.
|
| 1620 |
|
| 1621 | struct sctp_transport *primary_path;
|
| 1622 |
|
| 1623 | |
| 1624 | * need a an address for msg_name.
|
| 1625 |
|
| 1626 | union sctp_addr primary_addr;
|
| 1627 |
|
| 1628 | |
| 1629 | * The path that we are currently using to
|
| 1630 | * transmit new data and most control chunks.
|
| 1631 |
|
| 1632 | struct sctp_transport *active_path;
|
| 1633 |
|
| 1634 | |
| 1635 | *
|
| 1636 | * RFC2960 6.4 Multi-homed SCTP Endpoints
|
| 1637 | * ...
|
| 1638 | * Furthermore, when its peer is multi-homed, an
|
| 1639 | * endpoint SHOULD try to retransmit a chunk to an
|
| 1640 | * active destination transport address that is
|
| 1641 | * different from the last destination address to
|
| 1642 | * which the DATA chunk was sent.
|
| 1643 |
|
| 1644 | struct sctp_transport *retran_path;
|
| 1645 |
|
| 1646 |
|
| 1647 | struct sctp_transport *last_sent_to;
|
| 1648 |
|
| 1649 |
|
| 1650 | struct sctp_transport *last_data_from;
|
| 1651 |
|
| 1652 | |
| 1653 | * Mapping An array of bits or bytes indicating which out of
|
| 1654 | * Array order TSN's have been received (relative to the
|
| 1655 | * Last Rcvd TSN). If no gaps exist, i.e. no out of
|
| 1656 | * order packets have been received, this array
|
| 1657 | * will be set to all zero. This structure may be
|
| 1658 | * in the form of a circular buffer or bit array.
|
| 1659 | *
|
| 1660 | * Last Rcvd : This is the last TSN received in
|
| 1661 | * TSN : sequence. This value is set initially by
|
| 1662 | * : taking the peer's Initial TSN, received in
|
| 1663 | * : the INIT or INIT ACK chunk, and subtracting
|
| 1664 | * : one from it.
|
| 1665 | *
|
| 1666 | * Throughout most of the specification this is called the
|
| 1667 | * "Cumulative TSN ACK Point". In this case, we
|
| 1668 | * ignore the advice in 12.2 in favour of the term
|
| 1669 | * used in the bulk of the text. This value is hidden
|
| 1670 | * in tsn_map--we get it by calling sctp_tsnmap_get_ctsn().
|
| 1671 |
|
| 1672 | struct sctp_tsnmap tsn_map;
|
| 1673 |
|
| 1674 | |
| 1675 | * with specified parameter to peer.
|
| 1676 |
|
| 1677 | __be16 addip_disabled_mask;
|
| 1678 |
|
| 1679 |
|
| 1680 | __u16 ecn_capable:1,
|
| 1681 | ipv4_address:1,
|
| 1682 | ipv6_address:1,
|
| 1683 | asconf_capable:1,
|
| 1684 | prsctp_capable:1,
|
| 1685 | reconf_capable:1,
|
| 1686 | intl_capable:1,
|
| 1687 | auth_capable:1,
|
| 1688 | |
| 1689 | * This flag indicates if the next received
|
| 1690 | * packet is to be responded to with a
|
| 1691 | * SACK. This is initialized to 0. When a packet
|
| 1692 | * is received sack_cnt is incremented. If this value
|
| 1693 | * reaches 2 or more, a SACK is sent and the
|
| 1694 | * value is reset to 0. Note: This is used only
|
| 1695 | * when no DATA chunks are received out of
|
| 1696 | * order. When DATA chunks are out of order,
|
| 1697 | * SACK's are not delayed (see Section 6).
|
| 1698 |
|
| 1699 | sack_needed:1,
|
| 1700 | sack_generation:1,
|
| 1701 | zero_window_announced:1;
|
| 1702 |
|
| 1703 | __u32 sack_cnt;
|
| 1704 |
|
| 1705 | __u32 adaptation_ind;
|
| 1706 |
|
| 1707 | struct sctp_inithdr_host i;
|
| 1708 | void *cookie;
|
| 1709 | int cookie_len;
|
| 1710 |
|
| 1711 | |
| 1712 | * C1) ... "Peer-Serial-Number'. This value MUST be initialized to the
|
| 1713 | * Initial TSN Value minus 1
|
| 1714 |
|
| 1715 | __u32 addip_serial;
|
| 1716 |
|
| 1717 | |
| 1718 | * and authenticated chunk list. All that is part of the
|
| 1719 | * cookie and these are just pointers to those locations
|
| 1720 |
|
| 1721 | struct sctp_random_param *peer_random;
|
| 1722 | struct sctp_chunks_param *peer_chunks;
|
| 1723 | struct sctp_hmac_algo_param *peer_hmacs;
|
| 1724 | } peer;
|
| 1725 |
|
| 1726 | |
| 1727 | * : association is in, i.e. COOKIE-WAIT,
|
| 1728 | * : COOKIE-ECHOED, ESTABLISHED, SHUTDOWN-PENDING,
|
| 1729 | * : SHUTDOWN-SENT, SHUTDOWN-RECEIVED, SHUTDOWN-ACK-SENT.
|
| 1730 | *
|
| 1731 | * Note: No "CLOSED" state is illustrated since if a
|
| 1732 | * association is "CLOSED" its TCB SHOULD be removed.
|
| 1733 | *
|
| 1734 | * In this implementation we DO have a CLOSED
|
| 1735 | * state which is used during initiation and shutdown.
|
| 1736 | *
|
| 1737 | * State takes values from SCTP_STATE_*.
|
| 1738 |
|
| 1739 | enum sctp_state state;
|
| 1740 |
|
| 1741 | |
| 1742 | * Error Count : [Clear this any time I get something.]
|
| 1743 |
|
| 1744 | int overall_error_count;
|
| 1745 |
|
| 1746 |
|
| 1747 | ktime_t cookie_life;
|
| 1748 |
|
| 1749 | |
| 1750 | * These values will be initialized by system defaults, but can
|
| 1751 | * be modified via the SCTP_RTOINFO socket option.
|
| 1752 |
|
| 1753 | unsigned long rto_initial;
|
| 1754 | unsigned long rto_max;
|
| 1755 | unsigned long rto_min;
|
| 1756 |
|
| 1757 |
|
| 1758 | int max_burst;
|
| 1759 |
|
| 1760 | |
| 1761 | * be initialized from system defaults, but can be
|
| 1762 | * modified by the SCTP_ASSOCINFO socket option.
|
| 1763 |
|
| 1764 | int max_retrans;
|
| 1765 |
|
| 1766 | |
| 1767 | * and will be initialized from the assocs value. This can be
|
| 1768 | * changed using the SCTP_PEER_ADDR_THLDS socket option
|
| 1769 |
|
| 1770 | __u16 pf_retrans;
|
| 1771 |
|
| 1772 | __u16 ps_retrans;
|
| 1773 |
|
| 1774 |
|
| 1775 | __u16 max_init_attempts;
|
| 1776 |
|
| 1777 |
|
| 1778 | __u16 init_retries;
|
| 1779 |
|
| 1780 |
|
| 1781 | unsigned long max_init_timeo;
|
| 1782 |
|
| 1783 | |
| 1784 | * the destination address every heartbeat interval. This value
|
| 1785 | * will be inherited by all new transports.
|
| 1786 |
|
| 1787 | unsigned long hbinterval;
|
| 1788 | unsigned long probe_interval;
|
| 1789 |
|
| 1790 | __be16 encap_port;
|
| 1791 |
|
| 1792 | |
| 1793 | * association.
|
| 1794 |
|
| 1795 | __u16 pathmaxrxt;
|
| 1796 |
|
| 1797 | __u32 flowlabel;
|
| 1798 | __u8 dscp;
|
| 1799 |
|
| 1800 |
|
| 1801 | __u8 pmtu_pending;
|
| 1802 |
|
| 1803 | |
| 1804 | * PMTU : peer's transport addresses.
|
| 1805 |
|
| 1806 | __u32 pathmtu;
|
| 1807 |
|
| 1808 |
|
| 1809 | __u32 param_flags;
|
| 1810 |
|
| 1811 | __u32 sackfreq;
|
| 1812 |
|
| 1813 | unsigned long sackdelay;
|
| 1814 |
|
| 1815 | unsigned long timeouts[SCTP_NUM_TIMEOUT_TYPES];
|
| 1816 | struct timer_list timers[SCTP_NUM_TIMEOUT_TYPES];
|
| 1817 |
|
| 1818 |
|
| 1819 | struct sctp_transport *shutdown_last_sent_to;
|
| 1820 |
|
| 1821 |
|
| 1822 | struct sctp_transport *init_last_sent_to;
|
| 1823 |
|
| 1824 |
|
| 1825 | int shutdown_retries;
|
| 1826 |
|
| 1827 | |
| 1828 | * : DATA chunk. This is sent in the INIT or INIT
|
| 1829 | * : ACK chunk to the peer and incremented each
|
| 1830 | * : time a DATA chunk is assigned a TSN
|
| 1831 | * : (normally just prior to transmit or during
|
| 1832 | * : fragmentation).
|
| 1833 |
|
| 1834 | __u32 next_tsn;
|
| 1835 |
|
| 1836 | |
| 1837 | * Last Rcvd : This is the last TSN received in sequence. This value
|
| 1838 | * TSN : is set initially by taking the peer's Initial TSN,
|
| 1839 | * : received in the INIT or INIT ACK chunk, and
|
| 1840 | * : subtracting one from it.
|
| 1841 | *
|
| 1842 | * Most of RFC 2960 refers to this as the Cumulative TSN Ack Point.
|
| 1843 |
|
| 1844 |
|
| 1845 | __u32 ctsn_ack_point;
|
| 1846 |
|
| 1847 |
|
| 1848 | __u32 adv_peer_ack_point;
|
| 1849 |
|
| 1850 |
|
| 1851 | __u32 highest_sacked;
|
| 1852 |
|
| 1853 |
|
| 1854 | __u32 fast_recovery_exit;
|
| 1855 |
|
| 1856 |
|
| 1857 | __u8 fast_recovery;
|
| 1858 |
|
| 1859 | |
| 1860 | * the SCTP_STATUS sockopt.
|
| 1861 |
|
| 1862 | __u16 unack_data;
|
| 1863 |
|
| 1864 | |
| 1865 | * as the result of a T3 timer expiration
|
| 1866 |
|
| 1867 | __u32 rtx_data_chunks;
|
| 1868 |
|
| 1869 | |
| 1870 | * to set a_rwnd field in an INIT or a SACK chunk.
|
| 1871 |
|
| 1872 | __u32 rwnd;
|
| 1873 |
|
| 1874 |
|
| 1875 | __u32 a_rwnd;
|
| 1876 |
|
| 1877 | |
| 1878 | * to slop over a maximum of the association's frag_point.
|
| 1879 |
|
| 1880 | __u32 rwnd_over;
|
| 1881 |
|
| 1882 | |
| 1883 | * a window, but not receive buffer (i.e small packets). This one
|
| 1884 | * is releases slowly (1 PMTU at a time ).
|
| 1885 |
|
| 1886 | __u32 rwnd_press;
|
| 1887 |
|
| 1888 | |
| 1889 | * This corresponds to the sndbuf size for the association,
|
| 1890 | * as specified in the sk->sndbuf.
|
| 1891 |
|
| 1892 | int sndbuf_used;
|
| 1893 |
|
| 1894 | |
| 1895 | * in the receive path at any given time.
|
| 1896 |
|
| 1897 | atomic_t rmem_alloc;
|
| 1898 |
|
| 1899 | |
| 1900 | * the association sndbuf space.
|
| 1901 |
|
| 1902 | wait_queue_head_t wait;
|
| 1903 |
|
| 1904 |
|
| 1905 | __u32 frag_point;
|
| 1906 | __u32 user_frag;
|
| 1907 |
|
| 1908 |
|
| 1909 | int init_err_counter;
|
| 1910 |
|
| 1911 |
|
| 1912 | int init_cycle;
|
| 1913 |
|
| 1914 |
|
| 1915 | __u16 default_stream;
|
| 1916 | __u16 default_flags;
|
| 1917 | __u32 default_ppid;
|
| 1918 | __u32 default_context;
|
| 1919 | __u32 default_timetolive;
|
| 1920 |
|
| 1921 |
|
| 1922 | __u32 default_rcv_context;
|
| 1923 |
|
| 1924 |
|
| 1925 | struct sctp_stream stream;
|
| 1926 |
|
| 1927 |
|
| 1928 | struct sctp_outq outqueue;
|
| 1929 |
|
| 1930 | |
| 1931 | * as well as handle passing events up to the ULP.
|
| 1932 |
|
| 1933 | struct sctp_ulpq ulpq;
|
| 1934 |
|
| 1935 |
|
| 1936 | __u32 last_ecne_tsn;
|
| 1937 |
|
| 1938 |
|
| 1939 | __u32 last_cwr_tsn;
|
| 1940 |
|
| 1941 |
|
| 1942 | int numduptsns;
|
| 1943 |
|
| 1944 | |
| 1945 | * "SCTP Extensions for Dynamic Reconfiguration of IP Addresses
|
| 1946 | * and Enforcement of Flow and Message Limits"
|
| 1947 | * <draft-ietf-tsvwg-addip-sctp-02.txt>
|
| 1948 | * or "ADDIP" for short.
|
| 1949 |
|
| 1950 |
|
| 1951 |
|
| 1952 |
|
| 1953 | |
| 1954 | *
|
| 1955 | * R1) One and only one ASCONF Chunk MAY be in transit and
|
| 1956 | * unacknowledged at any one time. If a sender, after sending
|
| 1957 | * an ASCONF chunk, decides it needs to transfer another
|
| 1958 | * ASCONF Chunk, it MUST wait until the ASCONF-ACK Chunk
|
| 1959 | * returns from the previous ASCONF Chunk before sending a
|
| 1960 | * subsequent ASCONF. Note this restriction binds each side,
|
| 1961 | * so at any time two ASCONF may be in-transit on any given
|
| 1962 | * association (one sent from each endpoint).
|
| 1963 | *
|
| 1964 | * [This is our one-and-only-one ASCONF in flight. If we do
|
| 1965 | * not have an ASCONF in flight, this is NULL.]
|
| 1966 |
|
| 1967 | struct sctp_chunk *addip_last_asconf;
|
| 1968 |
|
| 1969 | |
| 1970 | *
|
| 1971 | * This is needed to implement items E1 - E4 of the updated
|
| 1972 | * spec. Here is the justification:
|
| 1973 | *
|
| 1974 | * Since the peer may bundle multiple ASCONF chunks toward us,
|
| 1975 | * we now need the ability to cache multiple ACKs. The section
|
| 1976 | * describes in detail how they are cached and cleaned up.
|
| 1977 |
|
| 1978 | struct list_head asconf_ack_list;
|
| 1979 |
|
| 1980 | |
| 1981 | *
|
| 1982 | * These chunks can't be pushed to outqueue until receiving
|
| 1983 | * ASCONF_ACK for the previous ASCONF indicated by
|
| 1984 | * addip_last_asconf, so as to guarantee that only one ASCONF
|
| 1985 | * is in flight at any time.
|
| 1986 | *
|
| 1987 | * ADDIP Section 4.1.1 Congestion Control of ASCONF Chunks
|
| 1988 | *
|
| 1989 | * In defining the ASCONF Chunk transfer procedures, it is
|
| 1990 | * essential that these transfers MUST NOT cause congestion
|
| 1991 | * within the network. To achieve this, we place these
|
| 1992 | * restrictions on the transfer of ASCONF Chunks:
|
| 1993 | *
|
| 1994 | * R1) One and only one ASCONF Chunk MAY be in transit and
|
| 1995 | * unacknowledged at any one time. If a sender, after sending
|
| 1996 | * an ASCONF chunk, decides it needs to transfer another
|
| 1997 | * ASCONF Chunk, it MUST wait until the ASCONF-ACK Chunk
|
| 1998 | * returns from the previous ASCONF Chunk before sending a
|
| 1999 | * subsequent ASCONF. Note this restriction binds each side,
|
| 2000 | * so at any time two ASCONF may be in-transit on any given
|
| 2001 | * association (one sent from each endpoint).
|
| 2002 | *
|
| 2003 | *
|
| 2004 | * [I really think this is EXACTLY the sort of intelligence
|
| 2005 | * which already resides in sctp_outq. Please move this
|
| 2006 | * queue and its supporting logic down there. --piggy]
|
| 2007 |
|
| 2008 | struct list_head addip_chunk_list;
|
| 2009 |
|
| 2010 | |
| 2011 | *
|
| 2012 | * A2) A serial number should be assigned to the Chunk. The
|
| 2013 | * serial number SHOULD be a monotonically increasing
|
| 2014 | * number. The serial number SHOULD be initialized at
|
| 2015 | * the start of the association to the same value as the
|
| 2016 | * Initial TSN and every time a new ASCONF chunk is created
|
| 2017 | * it is incremented by one after assigning the serial number
|
| 2018 | * to the newly created chunk.
|
| 2019 | *
|
| 2020 | * ADDIP
|
| 2021 | * 3.1.1 Address/Stream Configuration Change Chunk (ASCONF)
|
| 2022 | *
|
| 2023 | * Serial Number : 32 bits (unsigned integer)
|
| 2024 | *
|
| 2025 | * This value represents a Serial Number for the ASCONF
|
| 2026 | * Chunk. The valid range of Serial Number is from 0 to
|
| 2027 | * 4294967295 (2^32 - 1). Serial Numbers wrap back to 0
|
| 2028 | * after reaching 4294967295.
|
| 2029 |
|
| 2030 | __u32 addip_serial;
|
| 2031 | int src_out_of_asoc_ok;
|
| 2032 | union sctp_addr *asconf_addr_del_pending;
|
| 2033 | struct sctp_transport *new_transport;
|
| 2034 |
|
| 2035 | |
| 2036 | * keys are provided out of band by the user application
|
| 2037 | * and can't change during the lifetime of the association
|
| 2038 |
|
| 2039 | struct list_head endpoint_shared_keys;
|
| 2040 |
|
| 2041 | |
| 2042 | * The current generated association shared key (secret)
|
| 2043 |
|
| 2044 | struct sctp_auth_bytes *asoc_shared_key;
|
| 2045 | struct sctp_shared_key *shkey;
|
| 2046 |
|
| 2047 | |
| 2048 | * that we support.
|
| 2049 |
|
| 2050 | __u16 default_hmac_id;
|
| 2051 |
|
| 2052 | __u16 active_key_id;
|
| 2053 |
|
| 2054 | __u8 need_ecne:1,
|
| 2055 | temp:1,
|
| 2056 | pf_expose:2,
|
| 2057 | force_delay:1;
|
| 2058 |
|
| 2059 | __u8 strreset_enable;
|
| 2060 | __u8 strreset_outstanding;
|
| 2061 |
|
| 2062 | __u32 strreset_outseq;
|
| 2063 | __u32 strreset_inseq;
|
| 2064 | __u32 strreset_result[2];
|
| 2065 |
|
| 2066 | struct sctp_chunk *strreset_chunk;
|
| 2067 |
|
| 2068 | struct sctp_priv_assoc_stats stats;
|
| 2069 |
|
| 2070 | int sent_cnt_removable;
|
| 2071 |
|
| 2072 | __u16 subscribe;
|
| 2073 |
|
| 2074 | __u64 abandoned_unsent[SCTP_PR_INDEX(MAX) + 1];
|
| 2075 | __u64 abandoned_sent[SCTP_PR_INDEX(MAX) + 1];
|
| 2076 |
|
| 2077 | |
| 2078 | * security_sctp_assoc_request(). These will only be used by
|
| 2079 | * SCTP TCP type sockets and peeled off connections as they
|
| 2080 | * cause a new socket to be generated. security_sctp_sk_clone()
|
| 2081 | * will then plug these into the new socket.
|
| 2082 |
|
| 2083 |
|
| 2084 | u32 secid;
|
| 2085 | u32 peer_secid;
|
| 2086 |
|
| 2087 | struct rcu_head rcu;
|
| 2088 | };
|
| 2089 |
|
| 2090 |
|
| 2091 | |
| 2092 | * association data structure.
|
| 2093 |
|
| 2094 | enum {
|
| 2095 | SCTP_ASSOC_EYECATCHER = 0xa550c123,
|
| 2096 | };
|
| 2097 |
|
| 2098 |
|
| 2099 | static inline struct sctp_association *sctp_assoc(struct sctp_ep_common *base)
|
| 2100 | {
|
| 2101 | struct sctp_association *asoc;
|
| 2102 |
|
| 2103 | asoc = container_of(base, struct sctp_association, base);
|
| 2104 | return asoc;
|
| 2105 | }
|
| 2106 |
|
| 2107 |
|
| 2108 |
|
| 2109 |
|
| 2110 | struct sctp_association *
|
| 2111 | sctp_association_new(const struct sctp_endpoint *ep, const struct sock *sk,
|
| 2112 | enum sctp_scope scope, gfp_t gfp);
|
| 2113 | void sctp_association_free(struct sctp_association *);
|
| 2114 | void sctp_association_put(struct sctp_association *);
|
| 2115 | void sctp_association_hold(struct sctp_association *);
|
| 2116 |
|
| 2117 | struct sctp_transport *sctp_assoc_choose_alter_transport(
|
| 2118 | struct sctp_association *, struct sctp_transport *);
|
| 2119 | void sctp_assoc_update_retran_path(struct sctp_association *);
|
| 2120 | struct sctp_transport *sctp_assoc_lookup_paddr(const struct sctp_association *,
|
| 2121 | const union sctp_addr *);
|
| 2122 | int sctp_assoc_lookup_laddr(struct sctp_association *asoc,
|
| 2123 | const union sctp_addr *laddr);
|
| 2124 | struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *,
|
| 2125 | const union sctp_addr *address,
|
| 2126 | const gfp_t gfp,
|
| 2127 | const int peer_state);
|
| 2128 | void sctp_assoc_rm_peer(struct sctp_association *asoc,
|
| 2129 | struct sctp_transport *peer);
|
| 2130 | void sctp_assoc_control_transport(struct sctp_association *asoc,
|
| 2131 | struct sctp_transport *transport,
|
| 2132 | enum sctp_transport_cmd command,
|
| 2133 | sctp_sn_error_t error);
|
| 2134 | struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *, __u32);
|
| 2135 | void sctp_assoc_migrate(struct sctp_association *, struct sock *);
|
| 2136 | int sctp_assoc_update(struct sctp_association *old,
|
| 2137 | struct sctp_association *new);
|
| 2138 |
|
| 2139 | __u32 sctp_association_get_next_tsn(struct sctp_association *);
|
| 2140 |
|
| 2141 | void sctp_assoc_update_frag_point(struct sctp_association *asoc);
|
| 2142 | void sctp_assoc_set_pmtu(struct sctp_association *asoc, __u32 pmtu);
|
| 2143 | void sctp_assoc_sync_pmtu(struct sctp_association *asoc);
|
| 2144 | void sctp_assoc_rwnd_increase(struct sctp_association *, unsigned int);
|
| 2145 | void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned int);
|
| 2146 | void sctp_assoc_set_primary(struct sctp_association *,
|
| 2147 | struct sctp_transport *);
|
| 2148 | void sctp_assoc_del_nonprimary_peers(struct sctp_association *,
|
| 2149 | struct sctp_transport *);
|
| 2150 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc,
|
| 2151 | enum sctp_scope scope, gfp_t gfp);
|
| 2152 | int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *,
|
| 2153 | struct sctp_cookie*,
|
| 2154 | gfp_t gfp);
|
| 2155 | int sctp_assoc_set_id(struct sctp_association *, gfp_t);
|
| 2156 | void sctp_assoc_clean_asconf_ack_cache(const struct sctp_association *asoc);
|
| 2157 | struct sctp_chunk *sctp_assoc_lookup_asconf_ack(
|
| 2158 | const struct sctp_association *asoc,
|
| 2159 | __be32 serial);
|
| 2160 | void sctp_asconf_queue_teardown(struct sctp_association *asoc);
|
| 2161 |
|
| 2162 | int sctp_cmp_addr_exact(const union sctp_addr *ss1,
|
| 2163 | const union sctp_addr *ss2);
|
| 2164 | struct sctp_chunk *sctp_get_ecne_prepend(struct sctp_association *asoc);
|
| 2165 |
|
| 2166 |
|
| 2167 | struct sctp_cmsgs {
|
| 2168 | struct sctp_initmsg *init;
|
| 2169 | struct sctp_sndrcvinfo *srinfo;
|
| 2170 | struct sctp_sndinfo *sinfo;
|
| 2171 | struct sctp_prinfo *prinfo;
|
| 2172 | struct sctp_authinfo *authinfo;
|
| 2173 | struct msghdr *addrs_msg;
|
| 2174 | };
|
| 2175 |
|
| 2176 |
|
| 2177 | struct sctp_dbg_objcnt_entry {
|
| 2178 | char *label;
|
| 2179 | atomic_t *counter;
|
| 2180 | };
|
| 2181 |
|
| 2182 | #endif
|