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 | 95 | #define SCTP_GET_ASSOC_ID_LIST 29 /* Read only */ |
| 96 | 96 | #define SCTP_AUTO_ASCONF 30 |
| 97 | 97 | #define SCTP_PEER_ADDR_THLDS 31 |
| 98 | +#define SCTP_RECVRCVINFO 32 | |
| 98 | 99 | |
| 99 | 100 | /* Internal Socket Options. Some of the sctp library functions are |
| 100 | 101 | * implemented using these socket options. |
| @@ -110,8 +111,7 @@ typedef __s32 sctp_assoc_t; · 9 unmodified lines | ||
| 110 | 111 | #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ |
| 111 | 112 | #define SCTP_GET_ASSOC_STATS 112 /* Read only */ |
| 112 | 113 | |
| 113 | −/* | |
| 114 | − * 5.2.1 SCTP Initiation Structure (SCTP_INIT) | |
| 114 | +/* 5.3.1 SCTP Initiation Structure (SCTP_INIT) | |
| 115 | 115 | * |
| 116 | 116 | * This cmsghdr structure provides information for initializing new |
| 117 | 117 | * SCTP associations with sendmsg(). The SCTP_INITMSG socket option |
| @@ -121,7 +121,6 @@ typedef __s32 sctp_assoc_t; · 3 unmodified lines | ||
| 121 | 121 | * cmsg_level cmsg_type cmsg_data[] |
| 122 | 122 | * ------------ ------------ ---------------------- |
| 123 | 123 | * IPPROTO_SCTP SCTP_INIT struct sctp_initmsg |
| 124 | − * | |
| 125 | 124 | */ |
| 126 | 125 | struct sctp_initmsg { |
| 127 | 126 | __u16 sinit_num_ostreams; |
| @@ -130,8 +129,7 @@ struct sctp_initmsg { · 2 unmodified lines | ||
| 130 | 129 | __u16 sinit_max_init_timeo; |
| 131 | 130 | }; |
| 132 | 131 | |
| 133 | −/* | |
| 134 | − * 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV) | |
| 132 | +/* 5.3.2 SCTP Header Information Structure (SCTP_SNDRCV) | |
| 135 | 133 | * |
| 136 | 134 | * This cmsghdr structure specifies SCTP options for sendmsg() and |
| 137 | 135 | * describes SCTP header information about a received message through |
| @@ -140,7 +138,6 @@ struct sctp_initmsg { · 2 unmodified lines | ||
| 140 | 138 | * cmsg_level cmsg_type cmsg_data[] |
| 141 | 139 | * ------------ ------------ ---------------------- |
| 142 | 140 | * IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo |
| 143 | − * | |
| 144 | 141 | */ |
| 145 | 142 | struct sctp_sndrcvinfo { |
| 146 | 143 | __u16 sinfo_stream; |
| @@ -170,13 +167,32 @@ struct sctp_sndinfo { · 23 unmodified lines | ||
| 170 | 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 | 191 | * sinfo_flags: 16 bits (unsigned integer) |
| 175 | 192 | * |
| 176 | 193 | * This field may contain any of the following flags and is composed of |
| 177 | 194 | * a bitwise OR of these values. |
| 178 | 195 | */ |
| 179 | − | |
| 180 | 196 | enum sctp_sinfo_flags { |
| 181 | 197 | SCTP_UNORDERED = 1, /* Send/receive message unordered. */ |
| 182 | 198 | SCTP_ADDR_OVER = 2, /* Override the primary destination. */ |
| @@ -199,6 +215,8 @@ typedef enum sctp_cmsg_type { · 16 unmodified lines | ||
| 199 | 215 | #define SCTP_SNDRCV SCTP_SNDRCV |
| 200 | 216 | SCTP_SNDINFO, /* 5.3.4 SCTP Send Information Structure */ |
| 201 | 217 | #define SCTP_SNDINFO SCTP_SNDINFO |
| 218 | + SCTP_RCVINFO, /* 5.3.5 SCTP Receive Information Structure */ | |
| 219 | +#define SCTP_RCVINFO SCTP_RCVINFO | |
| 202 | 220 | } sctp_cmsg_t; |
| 203 | 221 | |
| 204 | 222 | /* |