diff options
| author | Geir Ola Vaagland <geirola@gmail.com> | 2014-07-12 14:30:38 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2014-07-16 17:40:03 -0400 |
| commit | 2347c80ff127b94ddaa675e2b78ab4cef46dc905 (patch) | |
| tree | 5fe57c8b7814f629cb773bbea0c1a9f8eba035d0 /include/uapi/linux | |
| parent | 0d3a421d284812d07970b4ccee74d4fa38737e4d (diff) | |
net: sctp: implement rfc6458, 5.3.6. SCTP_NXTINFO cmsg support
This patch implements section 5.3.6. of RFC6458, that is, support
for 'SCTP Next Receive Information Structure' (SCTP_NXTINFO) which
is placed into ancillary data cmsghdr structure for each recvmsg()
call, if this information is already available when delivering the
current message.
This option can be enabled/disabled via setsockopt(2) on SOL_SCTP
level by setting an int value with 1/0 for SCTP_RECVNXTINFO in
user space applications as per RFC6458, section 8.1.30.
The sctp_nxtinfo structure is defined as per RFC as below ...
struct sctp_nxtinfo {
uint16_t nxt_sid;
uint16_t nxt_flags;
uint32_t nxt_ppid;
uint32_t nxt_length;
sctp_assoc_t nxt_assoc_id;
};
... and provided under cmsg_level IPPROTO_SCTP, cmsg_type
SCTP_NXTINFO, while cmsg_data[] contains struct sctp_nxtinfo.
Joint work with Daniel Borkmann.
Signed-off-by: Geir Ola Vaagland <geirola@gmail.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/uapi/linux')
| -rw-r--r-- | include/uapi/linux/sctp.h | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h index 29b81bbfc53d..222f82ffeca4 100644 --- a/include/uapi/linux/sctp.h +++ b/include/uapi/linux/sctp.h | |||
| @@ -96,6 +96,7 @@ typedef __s32 sctp_assoc_t; | |||
| 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 | #define SCTP_RECVRCVINFO 32 |
| 99 | #define SCTP_RECVNXTINFO 33 | ||
| 99 | 100 | ||
| 100 | /* Internal Socket Options. Some of the sctp library functions are | 101 | /* Internal Socket Options. Some of the sctp library functions are |
| 101 | * implemented using these socket options. | 102 | * implemented using these socket options. |
| @@ -111,6 +112,13 @@ typedef __s32 sctp_assoc_t; | |||
| 111 | #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ | 112 | #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ |
| 112 | #define SCTP_GET_ASSOC_STATS 112 /* Read only */ | 113 | #define SCTP_GET_ASSOC_STATS 112 /* Read only */ |
| 113 | 114 | ||
| 115 | /* These are bit fields for msghdr->msg_flags. See section 5.1. */ | ||
| 116 | /* On user space Linux, these live in <bits/socket.h> as an enum. */ | ||
| 117 | enum sctp_msg_flags { | ||
| 118 | MSG_NOTIFICATION = 0x8000, | ||
| 119 | #define MSG_NOTIFICATION MSG_NOTIFICATION | ||
| 120 | }; | ||
| 121 | |||
| 114 | /* 5.3.1 SCTP Initiation Structure (SCTP_INIT) | 122 | /* 5.3.1 SCTP Initiation Structure (SCTP_INIT) |
| 115 | * | 123 | * |
| 116 | * This cmsghdr structure provides information for initializing new | 124 | * This cmsghdr structure provides information for initializing new |
| @@ -187,6 +195,25 @@ struct sctp_rcvinfo { | |||
| 187 | sctp_assoc_t rcv_assoc_id; | 195 | sctp_assoc_t rcv_assoc_id; |
| 188 | }; | 196 | }; |
| 189 | 197 | ||
| 198 | /* 5.3.6 SCTP Next Receive Information Structure (SCTP_NXTINFO) | ||
| 199 | * | ||
| 200 | * This cmsghdr structure describes SCTP receive information | ||
| 201 | * of the next message that will be delivered through recvmsg() | ||
| 202 | * if this information is already available when delivering | ||
| 203 | * the current message. | ||
| 204 | * | ||
| 205 | * cmsg_level cmsg_type cmsg_data[] | ||
| 206 | * ------------ ------------ ------------------- | ||
| 207 | * IPPROTO_SCTP SCTP_NXTINFO struct sctp_nxtinfo | ||
| 208 | */ | ||
| 209 | struct sctp_nxtinfo { | ||
| 210 | __u16 nxt_sid; | ||
| 211 | __u16 nxt_flags; | ||
| 212 | __u32 nxt_ppid; | ||
| 213 | __u32 nxt_length; | ||
| 214 | sctp_assoc_t nxt_assoc_id; | ||
| 215 | }; | ||
| 216 | |||
| 190 | /* | 217 | /* |
| 191 | * sinfo_flags: 16 bits (unsigned integer) | 218 | * sinfo_flags: 16 bits (unsigned integer) |
| 192 | * | 219 | * |
| @@ -194,11 +221,12 @@ struct sctp_rcvinfo { | |||
| 194 | * a bitwise OR of these values. | 221 | * a bitwise OR of these values. |
| 195 | */ | 222 | */ |
| 196 | enum sctp_sinfo_flags { | 223 | enum sctp_sinfo_flags { |
| 197 | SCTP_UNORDERED = 1, /* Send/receive message unordered. */ | 224 | SCTP_UNORDERED = (1 << 0), /* Send/receive message unordered. */ |
| 198 | SCTP_ADDR_OVER = 2, /* Override the primary destination. */ | 225 | SCTP_ADDR_OVER = (1 << 1), /* Override the primary destination. */ |
| 199 | SCTP_ABORT=4, /* Send an ABORT message to the peer. */ | 226 | SCTP_ABORT = (1 << 2), /* Send an ABORT message to the peer. */ |
| 200 | SCTP_SACK_IMMEDIATELY = 8, /* SACK should be sent without delay */ | 227 | SCTP_SACK_IMMEDIATELY = (1 << 3), /* SACK should be sent without delay. */ |
| 201 | SCTP_EOF=MSG_FIN, /* Initiate graceful shutdown process. */ | 228 | SCTP_NOTIFICATION = MSG_NOTIFICATION, /* Next message is not user msg but notification. */ |
| 229 | SCTP_EOF = MSG_FIN, /* Initiate graceful shutdown process. */ | ||
| 202 | }; | 230 | }; |
| 203 | 231 | ||
| 204 | typedef union { | 232 | typedef union { |
| @@ -217,6 +245,8 @@ typedef enum sctp_cmsg_type { | |||
| 217 | #define SCTP_SNDINFO SCTP_SNDINFO | 245 | #define SCTP_SNDINFO SCTP_SNDINFO |
| 218 | SCTP_RCVINFO, /* 5.3.5 SCTP Receive Information Structure */ | 246 | SCTP_RCVINFO, /* 5.3.5 SCTP Receive Information Structure */ |
| 219 | #define SCTP_RCVINFO SCTP_RCVINFO | 247 | #define SCTP_RCVINFO SCTP_RCVINFO |
| 248 | SCTP_NXTINFO, /* 5.3.6 SCTP Next Receive Information Structure */ | ||
| 249 | #define SCTP_NXTINFO SCTP_NXTINFO | ||
| 220 | } sctp_cmsg_t; | 250 | } sctp_cmsg_t; |
| 221 | 251 | ||
| 222 | /* | 252 | /* |
| @@ -844,13 +874,6 @@ struct sctp_assoc_stats { | |||
| 844 | __u64 sas_ictrlchunks; /* Control chunks received */ | 874 | __u64 sas_ictrlchunks; /* Control chunks received */ |
| 845 | }; | 875 | }; |
| 846 | 876 | ||
| 847 | /* These are bit fields for msghdr->msg_flags. See section 5.1. */ | ||
| 848 | /* On user space Linux, these live in <bits/socket.h> as an enum. */ | ||
| 849 | enum sctp_msg_flags { | ||
| 850 | MSG_NOTIFICATION = 0x8000, | ||
| 851 | #define MSG_NOTIFICATION MSG_NOTIFICATION | ||
| 852 | }; | ||
| 853 | |||
| 854 | /* | 877 | /* |
| 855 | * 8.1 sctp_bindx() | 878 | * 8.1 sctp_bindx() |
| 856 | * | 879 | * |
