This patch implements section 5.3.5. of RFC6458, that is, support for 'SCTP Receive Information Structure' (SCTP_RCVINFO) which is placed into ancillary data cmsghdr structure for each recvmsg() call. This option can be enabled/disabled via setsockopt(2) on SOL_SCTP level by setting an int value with 1/0 for SCTP_RECVRCVINFO in user space applications as per RFC6458, section 8.1.29. The sctp_rcvinfo structure is defined as per RFC as below ... struct sctp_rcvinfo { uint16_t rcv_sid; uint16_t rcv_ssn; uint16_t rcv_flags; <-- 2 bytes hole --> uint32_t rcv_ppid; uint32_t rcv_tsn; uint32_t rcv_cumtsn; uint32_t rcv_context; sctp_assoc_t rcv_assoc_id; }; ... and provided under cmsg_level IPPROTO_SCTP, cmsg_type SCTP_RCVINFO, while cmsg_data[] contains struct sctp_rcvinfo. An sctp_rcvinfo item always corresponds to the data in msg_iov. Joint work with Daniel Borkmann.
Showing the changes to include/uapi/linux (1 of 5 files). Show all
Unified · Split
| @@ -95,6 +95,7 @@ typedef __s32 sctp_assoc_t; · 94 unmodified lines | |||
| 95 | #define SCTP_GET_ASSOC_ID_LIST 29 /* Read only */ | 95 | #define SCTP_GET_ASSOC_ID_LIST 29 /* Read only */ |
| 96 | #define SCTP_AUTO_ASCONF 30 | 96 | #define SCTP_AUTO_ASCONF 30 |
| 97 | #define SCTP_PEER_ADDR_THLDS 31 | 97 | #define SCTP_PEER_ADDR_THLDS 31 |
| 98 | #define SCTP_RECVRCVINFO 32 | ||
| 98 | 99 | ||
| 99 | /* Internal Socket Options. Some of the sctp library functions are | 100 | /* Internal Socket Options. Some of the sctp library functions are |
| 100 | * implemented using these socket options. | 101 | * implemented using these socket options. |
| @@ -110,8 +111,7 @@ typedef __s32 sctp_assoc_t; · 9 unmodified lines | |||
| 110 | #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ | 111 | #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ |
| 111 | #define SCTP_GET_ASSOC_STATS 112 /* Read only */ | 112 | #define SCTP_GET_ASSOC_STATS 112 /* Read only */ |
| 112 | 113 | ||
| 113 | /* | 114 | /* 5.3.1 SCTP Initiation Structure (SCTP_INIT) |
| 114 | * 5.2.1 SCTP Initiation Structure (SCTP_INIT) | ||
| 115 | * | 115 | * |
| 116 | * This cmsghdr structure provides information for initializing new | 116 | * This cmsghdr structure provides information for initializing new |
| 117 | * SCTP associations with sendmsg(). The SCTP_INITMSG socket option | 117 | * SCTP associations with sendmsg(). The SCTP_INITMSG socket option |
| @@ -121,7 +121,6 @@ typedef __s32 sctp_assoc_t; · 3 unmodified lines | |||
| 121 | * cmsg_level cmsg_type cmsg_data[] | 121 | * cmsg_level cmsg_type cmsg_data[] |
| 122 | * ------------ ------------ ---------------------- | 122 | * ------------ ------------ ---------------------- |
| 123 | * IPPROTO_SCTP SCTP_INIT struct sctp_initmsg | 123 | * IPPROTO_SCTP SCTP_INIT struct sctp_initmsg |
| 124 | * | ||
| 125 | */ | 124 | */ |
| 126 | struct sctp_initmsg { | 125 | struct sctp_initmsg { |
| 127 | __u16 sinit_num_ostreams; | 126 | __u16 sinit_num_ostreams; |
| @@ -130,8 +129,7 @@ struct sctp_initmsg { · 2 unmodified lines | |||
| 130 | __u16 sinit_max_init_timeo; | 129 | __u16 sinit_max_init_timeo; |
| 131 | }; | 130 | }; |
| 132 | 131 | ||
| 133 | /* | 132 | /* 5.3.2 SCTP Header Information Structure (SCTP_SNDRCV) |
| 134 | * 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV) | ||
| 135 | * | 133 | * |
| 136 | * This cmsghdr structure specifies SCTP options for sendmsg() and | 134 | * This cmsghdr structure specifies SCTP options for sendmsg() and |
| 137 | * describes SCTP header information about a received message through | 135 | * describes SCTP header information about a received message through |
| @@ -140,7 +138,6 @@ struct sctp_initmsg { · 2 unmodified lines | |||
| 140 | * cmsg_level cmsg_type cmsg_data[] | 138 | * cmsg_level cmsg_type cmsg_data[] |
| 141 | * ------------ ------------ ---------------------- | 139 | * ------------ ------------ ---------------------- |
| 142 | * IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo | 140 | * IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo |
| 143 | * | ||
| 144 | */ | 141 | */ |
| 145 | struct sctp_sndrcvinfo { | 142 | struct sctp_sndrcvinfo { |
| 146 | __u16 sinfo_stream; | 143 | __u16 sinfo_stream; |
| @@ -170,13 +167,32 @@ struct sctp_sndinfo { · 23 unmodified lines | |||
| 170 | sctp_assoc_t snd_assoc_id; | 167 | sctp_assoc_t snd_assoc_id; |
| 171 | }; | 168 | }; |
| 172 | 169 | ||
| 170 | /* 5.3.5 SCTP Receive Information Structure (SCTP_RCVINFO) | ||
| 171 | * | ||
| 172 | * This cmsghdr structure describes SCTP receive information | ||
| 173 | * about a received message through recvmsg(). | ||
| 174 | * | ||
| 175 | * cmsg_level cmsg_type cmsg_data[] | ||
| 176 | * ------------ ------------ ------------------- | ||
| 177 | * IPPROTO_SCTP SCTP_RCVINFO struct sctp_rcvinfo | ||
| 178 | */ | ||
| 179 | struct sctp_rcvinfo { | ||
| 180 | __u16 rcv_sid; | ||
| 181 | __u16 rcv_ssn; | ||
| 182 | __u16 rcv_flags; | ||
| 183 | __u32 rcv_ppid; | ||
| 184 | __u32 rcv_tsn; | ||
| 185 | __u32 rcv_cumtsn; | ||
| 186 | __u32 rcv_context; | ||
| 187 | sctp_assoc_t rcv_assoc_id; | ||
| 188 | }; | ||
| 189 | |||
| 173 | /* | 190 | /* |
| 174 | * sinfo_flags: 16 bits (unsigned integer) | 191 | * sinfo_flags: 16 bits (unsigned integer) |
| 175 | * | 192 | * |
| 176 | * This field may contain any of the following flags and is composed of | 193 | * This field may contain any of the following flags and is composed of |
| 177 | * a bitwise OR of these values. | 194 | * a bitwise OR of these values. |
| 178 | */ | 195 | */ |
| 179 | |||
| 180 | enum sctp_sinfo_flags { | 196 | enum sctp_sinfo_flags { |
| 181 | SCTP_UNORDERED = 1, /* Send/receive message unordered. */ | 197 | SCTP_UNORDERED = 1, /* Send/receive message unordered. */ |
| 182 | SCTP_ADDR_OVER = 2, /* Override the primary destination. */ | 198 | SCTP_ADDR_OVER = 2, /* Override the primary destination. */ |
| @@ -199,6 +215,8 @@ typedef enum sctp_cmsg_type { · 16 unmodified lines | |||
| 199 | #define SCTP_SNDRCV SCTP_SNDRCV | 215 | #define SCTP_SNDRCV SCTP_SNDRCV |
| 200 | SCTP_SNDINFO, /* 5.3.4 SCTP Send Information Structure */ | 216 | SCTP_SNDINFO, /* 5.3.4 SCTP Send Information Structure */ |
| 201 | #define SCTP_SNDINFO SCTP_SNDINFO | 217 | #define SCTP_SNDINFO SCTP_SNDINFO |
| 218 | SCTP_RCVINFO, /* 5.3.5 SCTP Receive Information Structure */ | ||
| 219 | #define SCTP_RCVINFO SCTP_RCVINFO | ||
| 202 | } sctp_cmsg_t; | 220 | } sctp_cmsg_t; |
| 203 | 221 | ||
| 204 | /* | 222 | /* |