.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* SCTP kernel implementation |
---|
2 | 3 | * (C) Copyright IBM Corp. 2001, 2004 |
---|
3 | 4 | * Copyright (c) 1999-2000 Cisco, Inc. |
---|
.. | .. |
---|
5 | 6 | * Copyright (c) 2001 Intel Corp. |
---|
6 | 7 | * |
---|
7 | 8 | * This file is part of the SCTP kernel implementation |
---|
8 | | - * |
---|
9 | | - * This SCTP implementation is free software; |
---|
10 | | - * you can redistribute it and/or modify it under the terms of |
---|
11 | | - * the GNU General Public License as published by |
---|
12 | | - * the Free Software Foundation; either version 2, or (at your option) |
---|
13 | | - * any later version. |
---|
14 | | - * |
---|
15 | | - * This SCTP implementation is distributed in the hope that it |
---|
16 | | - * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
---|
17 | | - * ************************ |
---|
18 | | - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
---|
19 | | - * See the GNU General Public License for more details. |
---|
20 | | - * |
---|
21 | | - * You should have received a copy of the GNU General Public License |
---|
22 | | - * along with GNU CC; see the file COPYING. If not, see |
---|
23 | | - * <http://www.gnu.org/licenses/>. |
---|
24 | 9 | * |
---|
25 | 10 | * Please send any bug reports or fixes you make to the |
---|
26 | 11 | * email addresses: |
---|
.. | .. |
---|
48 | 33 | #define __sctp_structs_h__ |
---|
49 | 34 | |
---|
50 | 35 | #include <linux/ktime.h> |
---|
| 36 | +#include <linux/generic-radix-tree.h> |
---|
51 | 37 | #include <linux/rhashtable-types.h> |
---|
52 | 38 | #include <linux/socket.h> /* linux/in.h needs this!! */ |
---|
53 | 39 | #include <linux/in.h> /* We get struct sockaddr_in. */ |
---|
.. | .. |
---|
57 | 43 | #include <linux/atomic.h> /* This gets us atomic counters. */ |
---|
58 | 44 | #include <linux/skbuff.h> /* We need sk_buff_head. */ |
---|
59 | 45 | #include <linux/workqueue.h> /* We need tq_struct. */ |
---|
60 | | -#include <linux/flex_array.h> /* We need flex_array. */ |
---|
61 | 46 | #include <linux/sctp.h> /* We need sctp* header structs. */ |
---|
62 | 47 | #include <net/sctp/auth.h> /* We need auth specific structs */ |
---|
63 | 48 | #include <net/ip.h> /* For inet_skb_parm */ |
---|
.. | .. |
---|
96 | 81 | |
---|
97 | 82 | struct sctp_bind_bucket { |
---|
98 | 83 | unsigned short port; |
---|
99 | | - unsigned short fastreuse; |
---|
| 84 | + signed char fastreuse; |
---|
| 85 | + signed char fastreuseport; |
---|
| 86 | + kuid_t fastuid; |
---|
100 | 87 | struct hlist_node node; |
---|
101 | 88 | struct hlist_head owner; |
---|
102 | 89 | struct net *net; |
---|
.. | .. |
---|
197 | 184 | __u32 flowlabel; |
---|
198 | 185 | __u8 dscp; |
---|
199 | 186 | |
---|
| 187 | + __u16 pf_retrans; |
---|
| 188 | + __u16 ps_retrans; |
---|
| 189 | + |
---|
200 | 190 | /* The initial Path MTU to use for new associations. */ |
---|
201 | 191 | __u32 pathmtu; |
---|
202 | 192 | |
---|
.. | .. |
---|
207 | 197 | /* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */ |
---|
208 | 198 | __u32 param_flags; |
---|
209 | 199 | |
---|
| 200 | + __u32 default_ss; |
---|
| 201 | + |
---|
210 | 202 | struct sctp_rtoinfo rtoinfo; |
---|
211 | 203 | struct sctp_paddrparams paddrparam; |
---|
212 | 204 | struct sctp_assocparams assocparams; |
---|
.. | .. |
---|
215 | 207 | * These two structures must be grouped together for the usercopy |
---|
216 | 208 | * whitelist region. |
---|
217 | 209 | */ |
---|
218 | | - struct sctp_event_subscribe subscribe; |
---|
| 210 | + __u16 subscribe; |
---|
219 | 211 | struct sctp_initmsg initmsg; |
---|
220 | 212 | |
---|
221 | 213 | int user_frag; |
---|
.. | .. |
---|
224 | 216 | __u32 adaptation_ind; |
---|
225 | 217 | __u32 pd_point; |
---|
226 | 218 | __u16 nodelay:1, |
---|
| 219 | + pf_expose:2, |
---|
227 | 220 | reuse:1, |
---|
228 | 221 | disable_fragments:1, |
---|
229 | 222 | v4mapped:1, |
---|
230 | 223 | frag_interleave:1, |
---|
231 | | - strm_interleave:1, |
---|
232 | 224 | recvrcvinfo:1, |
---|
233 | 225 | recvnxtinfo:1, |
---|
234 | 226 | data_ready_signalled:1; |
---|
235 | 227 | |
---|
236 | 228 | atomic_t pd_mode; |
---|
| 229 | + |
---|
| 230 | + /* Fields after this point will be skipped on copies, like on accept |
---|
| 231 | + * and peeloff operations |
---|
| 232 | + */ |
---|
| 233 | + |
---|
237 | 234 | /* Receive to here while partial delivery is in effect. */ |
---|
238 | 235 | struct sk_buff_head pd_lobby; |
---|
239 | 236 | |
---|
240 | | - /* These must be the last fields, as they will skipped on copies, |
---|
241 | | - * like on accept and peeloff operations |
---|
242 | | - */ |
---|
243 | 237 | struct list_head auto_asconf_list; |
---|
244 | 238 | int do_auto_asconf; |
---|
245 | 239 | }; |
---|
.. | .. |
---|
334 | 328 | * the association TCB is re-constructed from the cookie. |
---|
335 | 329 | */ |
---|
336 | 330 | __u32 raw_addr_list_len; |
---|
337 | | - struct sctp_init_chunk peer_init[0]; |
---|
| 331 | + struct sctp_init_chunk peer_init[]; |
---|
338 | 332 | }; |
---|
339 | 333 | |
---|
340 | 334 | |
---|
.. | .. |
---|
439 | 433 | int (*setsockopt) (struct sock *sk, |
---|
440 | 434 | int level, |
---|
441 | 435 | int optname, |
---|
442 | | - char __user *optval, |
---|
| 436 | + sockptr_t optval, |
---|
443 | 437 | unsigned int optlen); |
---|
444 | 438 | int (*getsockopt) (struct sock *sk, |
---|
445 | | - int level, |
---|
446 | | - int optname, |
---|
447 | | - char __user *optval, |
---|
448 | | - int __user *optlen); |
---|
449 | | - int (*compat_setsockopt) (struct sock *sk, |
---|
450 | | - int level, |
---|
451 | | - int optname, |
---|
452 | | - char __user *optval, |
---|
453 | | - unsigned int optlen); |
---|
454 | | - int (*compat_getsockopt) (struct sock *sk, |
---|
455 | 439 | int level, |
---|
456 | 440 | int optname, |
---|
457 | 441 | char __user *optval, |
---|
.. | .. |
---|
906 | 890 | * and will be initialized from the assocs value. This can be changed |
---|
907 | 891 | * using the SCTP_PEER_ADDR_THLDS socket option |
---|
908 | 892 | */ |
---|
909 | | - int pf_retrans; |
---|
| 893 | + __u16 pf_retrans; |
---|
| 894 | + /* Used for primary path switchover. */ |
---|
| 895 | + __u16 ps_retrans; |
---|
910 | 896 | /* PMTU : The current known path MTU. */ |
---|
911 | 897 | __u32 pathmtu; |
---|
912 | 898 | |
---|
.. | .. |
---|
1190 | 1176 | struct sctp_sock *, struct sctp_sock *); |
---|
1191 | 1177 | int sctp_bind_addr_state(const struct sctp_bind_addr *bp, |
---|
1192 | 1178 | const union sctp_addr *addr); |
---|
| 1179 | +int sctp_bind_addrs_check(struct sctp_sock *sp, |
---|
| 1180 | + struct sctp_sock *sp2, int cnt2); |
---|
1193 | 1181 | union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp, |
---|
1194 | 1182 | const union sctp_addr *addrs, |
---|
1195 | 1183 | int addrcnt, |
---|
.. | .. |
---|
1333 | 1321 | /* SCTP-AUTH: endpoint shared keys */ |
---|
1334 | 1322 | struct list_head endpoint_shared_keys; |
---|
1335 | 1323 | __u16 active_key_id; |
---|
1336 | | - __u8 auth_enable:1, |
---|
| 1324 | + __u8 ecn_enable:1, |
---|
| 1325 | + auth_enable:1, |
---|
| 1326 | + intl_enable:1, |
---|
1337 | 1327 | prsctp_enable:1, |
---|
| 1328 | + asconf_enable:1, |
---|
1338 | 1329 | reconf_enable:1; |
---|
1339 | 1330 | |
---|
1340 | 1331 | __u8 strreset_enable; |
---|
.. | .. |
---|
1400 | 1391 | struct list_head prio_sched; |
---|
1401 | 1392 | /* List of streams scheduled */ |
---|
1402 | 1393 | struct list_head active; |
---|
1403 | | - /* The next stream stream in line */ |
---|
| 1394 | + /* The next stream in line */ |
---|
1404 | 1395 | struct sctp_stream_out_ext *next; |
---|
1405 | 1396 | __u16 prio; |
---|
1406 | 1397 | }; |
---|
.. | .. |
---|
1445 | 1436 | }; |
---|
1446 | 1437 | |
---|
1447 | 1438 | struct sctp_stream { |
---|
1448 | | - struct flex_array *out; |
---|
1449 | | - struct flex_array *in; |
---|
| 1439 | + GENRADIX(struct sctp_stream_out) out; |
---|
| 1440 | + GENRADIX(struct sctp_stream_in) in; |
---|
| 1441 | + |
---|
1450 | 1442 | __u16 outcnt; |
---|
1451 | 1443 | __u16 incnt; |
---|
1452 | 1444 | /* Current stream being sent, if any */ |
---|
.. | .. |
---|
1461 | 1453 | struct { |
---|
1462 | 1454 | /* List of streams scheduled */ |
---|
1463 | 1455 | struct list_head rr_list; |
---|
1464 | | - /* The next stream stream in line */ |
---|
| 1456 | + /* The next stream in line */ |
---|
1465 | 1457 | struct sctp_stream_out_ext *rr_next; |
---|
1466 | 1458 | }; |
---|
1467 | 1459 | }; |
---|
.. | .. |
---|
1469 | 1461 | }; |
---|
1470 | 1462 | |
---|
1471 | 1463 | static inline struct sctp_stream_out *sctp_stream_out( |
---|
1472 | | - const struct sctp_stream *stream, |
---|
| 1464 | + struct sctp_stream *stream, |
---|
1473 | 1465 | __u16 sid) |
---|
1474 | 1466 | { |
---|
1475 | | - return flex_array_get(stream->out, sid); |
---|
| 1467 | + return genradix_ptr(&stream->out, sid); |
---|
1476 | 1468 | } |
---|
1477 | 1469 | |
---|
1478 | 1470 | static inline struct sctp_stream_in *sctp_stream_in( |
---|
1479 | | - const struct sctp_stream *stream, |
---|
| 1471 | + struct sctp_stream *stream, |
---|
1480 | 1472 | __u16 sid) |
---|
1481 | 1473 | { |
---|
1482 | | - return flex_array_get(stream->in, sid); |
---|
| 1474 | + return genradix_ptr(&stream->in, sid); |
---|
1483 | 1475 | } |
---|
1484 | 1476 | |
---|
1485 | 1477 | #define SCTP_SO(s, i) sctp_stream_out((s), (i)) |
---|
.. | .. |
---|
1689 | 1681 | __be16 addip_disabled_mask; |
---|
1690 | 1682 | |
---|
1691 | 1683 | /* These are capabilities which our peer advertised. */ |
---|
1692 | | - __u8 ecn_capable:1, /* Can peer do ECN? */ |
---|
| 1684 | + __u16 ecn_capable:1, /* Can peer do ECN? */ |
---|
1693 | 1685 | ipv4_address:1, /* Peer understands IPv4 addresses? */ |
---|
1694 | 1686 | ipv6_address:1, /* Peer understands IPv6 addresses? */ |
---|
1695 | 1687 | hostname_address:1, /* Peer understands DNS addresses? */ |
---|
1696 | 1688 | asconf_capable:1, /* Does peer support ADDIP? */ |
---|
1697 | 1689 | prsctp_capable:1, /* Can peer do PR-SCTP? */ |
---|
1698 | 1690 | reconf_capable:1, /* Can peer do RE-CONFIG? */ |
---|
1699 | | - auth_capable:1; /* Is peer doing SCTP-AUTH? */ |
---|
1700 | | - |
---|
1701 | | - /* sack_needed : This flag indicates if the next received |
---|
1702 | | - * : packet is to be responded to with a |
---|
1703 | | - * : SACK. This is initialized to 0. When a packet |
---|
1704 | | - * : is received sack_cnt is incremented. If this value |
---|
1705 | | - * : reaches 2 or more, a SACK is sent and the |
---|
1706 | | - * : value is reset to 0. Note: This is used only |
---|
1707 | | - * : when no DATA chunks are received out of |
---|
1708 | | - * : order. When DATA chunks are out of order, |
---|
1709 | | - * : SACK's are not delayed (see Section 6). |
---|
1710 | | - */ |
---|
1711 | | - __u8 sack_needed:1, /* Do we need to sack the peer? */ |
---|
| 1691 | + intl_capable:1, /* Can peer do INTERLEAVE */ |
---|
| 1692 | + auth_capable:1, /* Is peer doing SCTP-AUTH? */ |
---|
| 1693 | + /* sack_needed: |
---|
| 1694 | + * This flag indicates if the next received |
---|
| 1695 | + * packet is to be responded to with a |
---|
| 1696 | + * SACK. This is initialized to 0. When a packet |
---|
| 1697 | + * is received sack_cnt is incremented. If this value |
---|
| 1698 | + * reaches 2 or more, a SACK is sent and the |
---|
| 1699 | + * value is reset to 0. Note: This is used only |
---|
| 1700 | + * when no DATA chunks are received out of |
---|
| 1701 | + * order. When DATA chunks are out of order, |
---|
| 1702 | + * SACK's are not delayed (see Section 6). |
---|
| 1703 | + */ |
---|
| 1704 | + sack_needed:1, /* Do we need to sack the peer? */ |
---|
1712 | 1705 | sack_generation:1, |
---|
1713 | 1706 | zero_window_announced:1; |
---|
| 1707 | + |
---|
1714 | 1708 | __u32 sack_cnt; |
---|
1715 | 1709 | |
---|
1716 | 1710 | __u32 adaptation_ind; /* Adaptation Code point. */ |
---|
.. | .. |
---|
1769 | 1763 | int max_burst; |
---|
1770 | 1764 | |
---|
1771 | 1765 | /* This is the max_retrans value for the association. This value will |
---|
1772 | | - * be initialized initialized from system defaults, but can be |
---|
| 1766 | + * be initialized from system defaults, but can be |
---|
1773 | 1767 | * modified by the SCTP_ASSOCINFO socket option. |
---|
1774 | 1768 | */ |
---|
1775 | 1769 | int max_retrans; |
---|
.. | .. |
---|
1778 | 1772 | * and will be initialized from the assocs value. This can be |
---|
1779 | 1773 | * changed using the SCTP_PEER_ADDR_THLDS socket option |
---|
1780 | 1774 | */ |
---|
1781 | | - int pf_retrans; |
---|
| 1775 | + __u16 pf_retrans; |
---|
| 1776 | + /* Used for primary path switchover. */ |
---|
| 1777 | + __u16 ps_retrans; |
---|
1782 | 1778 | |
---|
1783 | 1779 | /* Maximum number of times the endpoint will retransmit INIT */ |
---|
1784 | 1780 | __u16 max_init_attempts; |
---|
.. | .. |
---|
2059 | 2055 | |
---|
2060 | 2056 | __u8 need_ecne:1, /* Need to send an ECNE Chunk? */ |
---|
2061 | 2057 | temp:1, /* Is it a temporary association? */ |
---|
2062 | | - force_delay:1, |
---|
2063 | | - intl_enable:1, |
---|
2064 | | - prsctp_enable:1, |
---|
2065 | | - reconf_enable:1; |
---|
| 2058 | + pf_expose:2, /* Expose pf state? */ |
---|
| 2059 | + force_delay:1; |
---|
2066 | 2060 | |
---|
2067 | 2061 | __u8 strreset_enable; |
---|
2068 | 2062 | __u8 strreset_outstanding; /* request param count on the fly */ |
---|
.. | .. |
---|
2077 | 2071 | |
---|
2078 | 2072 | int sent_cnt_removable; |
---|
2079 | 2073 | |
---|
| 2074 | + __u16 subscribe; |
---|
| 2075 | + |
---|
2080 | 2076 | __u64 abandoned_unsent[SCTP_PR_INDEX(MAX) + 1]; |
---|
2081 | 2077 | __u64 abandoned_sent[SCTP_PR_INDEX(MAX) + 1]; |
---|
2082 | 2078 | |
---|