aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-04-09 01:54:01 -0400
committerDavid S. Miller <davem@davemloft.net>2013-04-09 13:19:39 -0400
commit1b8664341100716202c29d67f24d67094a82971e (patch)
tree6420508b2e4053927f2ec6df4a516366da31691f
parent3d4a1316286d037c29a36a8451a9612f60404ef7 (diff)
net: sctp: introduce uapi header for sctp
This patch introduces an UAPI header for the SCTP protocol, so that we can facilitate the maintenance and development of user land applications or libraries, in particular in terms of header synchronization. To not break compatibility, some fragments from lksctp-tools' netinet/sctp.h have been carefully included, while taking care that neither kernel nor user land breaks, so both compile fine with this change (for lksctp-tools I tested with the old netinet/sctp.h header and with a newly adapted one that includes the uapi sctp header). lksctp-tools smoke test run through successfully as well in both cases. Suggested-by: Neil Horman <nhorman@tuxdriver.com> Cc: Neil Horman <nhorman@tuxdriver.com> Cc: Vlad Yasevich <vyasevich@gmail.com> Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--fs/dlm/lowcomms.c2
-rw-r--r--include/linux/sctp.h6
-rw-r--r--include/net/sctp/constants.h1
-rw-r--r--include/uapi/linux/Kbuild1
-rw-r--r--include/uapi/linux/sctp.h (renamed from include/net/sctp/user.h)84
5 files changed, 78 insertions, 16 deletions
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 4f5ad246582f..d0ccd2fd79eb 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -52,8 +52,8 @@
52#include <linux/mutex.h> 52#include <linux/mutex.h>
53#include <linux/sctp.h> 53#include <linux/sctp.h>
54#include <linux/slab.h> 54#include <linux/slab.h>
55#include <linux/sctp.h>
55#include <net/sctp/sctp.h> 56#include <net/sctp/sctp.h>
56#include <net/sctp/user.h>
57#include <net/ipv6.h> 57#include <net/ipv6.h>
58 58
59#include "dlm_internal.h" 59#include "dlm_internal.h"
diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index c11a28706fa4..3bfe8d6ee248 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -53,7 +53,9 @@
53 53
54#include <linux/in.h> /* We need in_addr. */ 54#include <linux/in.h> /* We need in_addr. */
55#include <linux/in6.h> /* We need in6_addr. */ 55#include <linux/in6.h> /* We need in6_addr. */
56#include <linux/skbuff.h>
56 57
58#include <uapi/linux/sctp.h>
57 59
58/* Section 3.1. SCTP Common Header Format */ 60/* Section 3.1. SCTP Common Header Format */
59typedef struct sctphdr { 61typedef struct sctphdr {
@@ -63,14 +65,10 @@ typedef struct sctphdr {
63 __le32 checksum; 65 __le32 checksum;
64} __packed sctp_sctphdr_t; 66} __packed sctp_sctphdr_t;
65 67
66#ifdef __KERNEL__
67#include <linux/skbuff.h>
68
69static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb) 68static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb)
70{ 69{
71 return (struct sctphdr *)skb_transport_header(skb); 70 return (struct sctphdr *)skb_transport_header(skb);
72} 71}
73#endif
74 72
75/* Section 3.2. Chunk Field Descriptions. */ 73/* Section 3.2. Chunk Field Descriptions. */
76typedef struct sctp_chunkhdr { 74typedef struct sctp_chunkhdr {
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index a7dd5c50df79..ca50e0751e47 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -49,7 +49,6 @@
49 49
50#include <linux/sctp.h> 50#include <linux/sctp.h>
51#include <linux/ipv6.h> /* For ipv6hdr. */ 51#include <linux/ipv6.h> /* For ipv6hdr. */
52#include <net/sctp/user.h>
53#include <net/tcp_states.h> /* For TCP states used in sctp_sock_state_t */ 52#include <net/tcp_states.h> /* For TCP states used in sctp_sock_state_t */
54 53
55/* Value used for stream negotiation. */ 54/* Value used for stream negotiation. */
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index 5c8a1d25e21c..7df190525337 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -331,6 +331,7 @@ header-y += rtnetlink.h
331header-y += scc.h 331header-y += scc.h
332header-y += sched.h 332header-y += sched.h
333header-y += screen_info.h 333header-y += screen_info.h
334header-y += sctp.h
334header-y += sdla.h 335header-y += sdla.h
335header-y += seccomp.h 336header-y += seccomp.h
336header-y += securebits.h 337header-y += securebits.h
diff --git a/include/net/sctp/user.h b/include/uapi/linux/sctp.h
index 9a0ae091366d..66b466e4ca08 100644
--- a/include/net/sctp/user.h
+++ b/include/uapi/linux/sctp.h
@@ -42,15 +42,17 @@
42 * Jon Grimm <jgrimm@us.ibm.com> 42 * Jon Grimm <jgrimm@us.ibm.com>
43 * Daisy Chang <daisyc@us.ibm.com> 43 * Daisy Chang <daisyc@us.ibm.com>
44 * Ryan Layer <rmlayer@us.ibm.com> 44 * Ryan Layer <rmlayer@us.ibm.com>
45 * Ardelle Fan <ardelle.fan@intel.com> 45 * Ardelle Fan <ardelle.fan@intel.com>
46 * Sridhar Samudrala <sri@us.ibm.com> 46 * Sridhar Samudrala <sri@us.ibm.com>
47 * Inaky Perez-Gonzalez <inaky.gonzalez@intel.com>
48 * Vlad Yasevich <vladislav.yasevich@hp.com>
47 * 49 *
48 * Any bugs reported given to us we will try to fix... any fixes shared will 50 * Any bugs reported given to us we will try to fix... any fixes shared will
49 * be incorporated into the next SCTP release. 51 * be incorporated into the next SCTP release.
50 */ 52 */
51 53
52#ifndef __net_sctp_user_h__ 54#ifndef _UAPI_SCTP_H
53#define __net_sctp_user_h__ 55#define _UAPI_SCTP_H
54 56
55#include <linux/types.h> 57#include <linux/types.h>
56#include <linux/socket.h> 58#include <linux/socket.h>
@@ -165,17 +167,23 @@ enum sctp_sinfo_flags {
165 SCTP_ADDR_OVER = 2, /* Override the primary destination. */ 167 SCTP_ADDR_OVER = 2, /* Override the primary destination. */
166 SCTP_ABORT=4, /* Send an ABORT message to the peer. */ 168 SCTP_ABORT=4, /* Send an ABORT message to the peer. */
167 SCTP_SACK_IMMEDIATELY = 8, /* SACK should be sent without delay */ 169 SCTP_SACK_IMMEDIATELY = 8, /* SACK should be sent without delay */
168 SCTP_EOF=MSG_FIN, /* Initiate graceful shutdown process. */ 170 SCTP_EOF=MSG_FIN, /* Initiate graceful shutdown process. */
169}; 171};
170 172
173typedef union {
174 __u8 raw;
175 struct sctp_initmsg init;
176 struct sctp_sndrcvinfo sndrcv;
177} sctp_cmsg_data_t;
171 178
172/* These are cmsg_types. */ 179/* These are cmsg_types. */
173typedef enum sctp_cmsg_type { 180typedef enum sctp_cmsg_type {
174 SCTP_INIT, /* 5.2.1 SCTP Initiation Structure */ 181 SCTP_INIT, /* 5.2.1 SCTP Initiation Structure */
182#define SCTP_INIT SCTP_INIT
175 SCTP_SNDRCV, /* 5.2.2 SCTP Header Information Structure */ 183 SCTP_SNDRCV, /* 5.2.2 SCTP Header Information Structure */
184#define SCTP_SNDRCV SCTP_SNDRCV
176} sctp_cmsg_t; 185} sctp_cmsg_t;
177 186
178
179/* 187/*
180 * 5.3.1.1 SCTP_ASSOC_CHANGE 188 * 5.3.1.1 SCTP_ASSOC_CHANGE
181 * 189 *
@@ -345,6 +353,12 @@ struct sctp_pdapi_event {
345 353
346enum { SCTP_PARTIAL_DELIVERY_ABORTED=0, }; 354enum { SCTP_PARTIAL_DELIVERY_ABORTED=0, };
347 355
356/*
357 * 5.3.1.8. SCTP_AUTHENTICATION_EVENT
358 *
359 * When a receiver is using authentication this message will provide
360 * notifications regarding new keys being made active as well as errors.
361 */
348struct sctp_authkey_event { 362struct sctp_authkey_event {
349 __u16 auth_type; 363 __u16 auth_type;
350 __u16 auth_flags; 364 __u16 auth_flags;
@@ -421,15 +435,23 @@ union sctp_notification {
421enum sctp_sn_type { 435enum sctp_sn_type {
422 SCTP_SN_TYPE_BASE = (1<<15), 436 SCTP_SN_TYPE_BASE = (1<<15),
423 SCTP_ASSOC_CHANGE, 437 SCTP_ASSOC_CHANGE,
438#define SCTP_ASSOC_CHANGE SCTP_ASSOC_CHANGE
424 SCTP_PEER_ADDR_CHANGE, 439 SCTP_PEER_ADDR_CHANGE,
440#define SCTP_PEER_ADDR_CHANGE SCTP_PEER_ADDR_CHANGE
425 SCTP_SEND_FAILED, 441 SCTP_SEND_FAILED,
442#define SCTP_SEND_FAILED SCTP_SEND_FAILED
426 SCTP_REMOTE_ERROR, 443 SCTP_REMOTE_ERROR,
444#define SCTP_REMOTE_ERROR SCTP_REMOTE_ERROR
427 SCTP_SHUTDOWN_EVENT, 445 SCTP_SHUTDOWN_EVENT,
446#define SCTP_SHUTDOWN_EVENT SCTP_SHUTDOWN_EVENT
428 SCTP_PARTIAL_DELIVERY_EVENT, 447 SCTP_PARTIAL_DELIVERY_EVENT,
448#define SCTP_PARTIAL_DELIVERY_EVENT SCTP_PARTIAL_DELIVERY_EVENT
429 SCTP_ADAPTATION_INDICATION, 449 SCTP_ADAPTATION_INDICATION,
450#define SCTP_ADAPTATION_INDICATION SCTP_ADAPTATION_INDICATION
430 SCTP_AUTHENTICATION_EVENT, 451 SCTP_AUTHENTICATION_EVENT,
431#define SCTP_AUTHENTICATION_INDICATION SCTP_AUTHENTICATION_EVENT 452#define SCTP_AUTHENTICATION_INDICATION SCTP_AUTHENTICATION_EVENT
432 SCTP_SENDER_DRY_EVENT, 453 SCTP_SENDER_DRY_EVENT,
454#define SCTP_SENDER_DRY_EVENT SCTP_SENDER_DRY_EVENT
433}; 455};
434 456
435/* Notification error codes used to fill up the error fields in some 457/* Notification error codes used to fill up the error fields in some
@@ -454,7 +476,7 @@ typedef enum sctp_sn_error {
454 * 476 *
455 * The protocol parameters used to initialize and bound retransmission 477 * The protocol parameters used to initialize and bound retransmission
456 * timeout (RTO) are tunable. See [SCTP] for more information on how 478 * timeout (RTO) are tunable. See [SCTP] for more information on how
457 * these parameters are used in RTO calculation. 479 * these parameters are used in RTO calculation.
458 */ 480 */
459struct sctp_rtoinfo { 481struct sctp_rtoinfo {
460 sctp_assoc_t srto_assoc_id; 482 sctp_assoc_t srto_assoc_id;
@@ -504,6 +526,9 @@ struct sctp_prim {
504 struct sockaddr_storage ssp_addr; 526 struct sockaddr_storage ssp_addr;
505} __attribute__((packed, aligned(4))); 527} __attribute__((packed, aligned(4)));
506 528
529/* For backward compatibility use, define the old name too */
530#define sctp_setprim sctp_prim
531
507/* 532/*
508 * 7.1.11 Set Adaptation Layer Indicator (SCTP_ADAPTATION_LAYER) 533 * 7.1.11 Set Adaptation Layer Indicator (SCTP_ADAPTATION_LAYER)
509 * 534 *
@@ -564,12 +589,27 @@ struct sctp_authchunk {
564 * 589 *
565 * This option gets or sets the list of HMAC algorithms that the local 590 * This option gets or sets the list of HMAC algorithms that the local
566 * endpoint requires the peer to use. 591 * endpoint requires the peer to use.
567*/ 592 */
593#ifndef __KERNEL__
594/* This here is only used by user space as is. It might not be a good idea
595 * to export/reveal the whole structure with reserved fields etc.
596 */
597enum {
598 SCTP_AUTH_HMAC_ID_SHA1 = 1,
599 SCTP_AUTH_HMAC_ID_SHA256 = 3,
600};
601#endif
602
568struct sctp_hmacalgo { 603struct sctp_hmacalgo {
569 __u32 shmac_num_idents; 604 __u32 shmac_num_idents;
570 __u16 shmac_idents[]; 605 __u16 shmac_idents[];
571}; 606};
572 607
608/* Sadly, user and kernel space have different names for
609 * this structure member, so this is to not break anything.
610 */
611#define shmac_number_of_idents shmac_num_idents
612
573/* 613/*
574 * 7.1.20. Set a shared key (SCTP_AUTH_KEY) 614 * 7.1.20. Set a shared key (SCTP_AUTH_KEY)
575 * 615 *
@@ -691,6 +731,24 @@ struct sctp_authchunks {
691 uint8_t gauth_chunks[]; 731 uint8_t gauth_chunks[];
692}; 732};
693 733
734/* The broken spelling has been released already in lksctp-tools header,
735 * so don't break anyone, now that it's fixed.
736 */
737#define guth_number_of_chunks gauth_number_of_chunks
738
739/* Association states. */
740enum sctp_sstat_state {
741 SCTP_EMPTY = 0,
742 SCTP_CLOSED = 1,
743 SCTP_COOKIE_WAIT = 2,
744 SCTP_COOKIE_ECHOED = 3,
745 SCTP_ESTABLISHED = 4,
746 SCTP_SHUTDOWN_PENDING = 5,
747 SCTP_SHUTDOWN_SENT = 6,
748 SCTP_SHUTDOWN_RECEIVED = 7,
749 SCTP_SHUTDOWN_ACK_SENT = 8,
750};
751
694/* 752/*
695 * 8.2.6. Get the Current Identifiers of Associations 753 * 8.2.6. Get the Current Identifiers of Associations
696 * (SCTP_GET_ASSOC_ID_LIST) 754 * (SCTP_GET_ASSOC_ID_LIST)
@@ -705,15 +763,20 @@ struct sctp_assoc_ids {
705 763
706/* 764/*
707 * 8.3, 8.5 get all peer/local addresses in an association. 765 * 8.3, 8.5 get all peer/local addresses in an association.
708 * This parameter struct is used by SCTP_GET_PEER_ADDRS and 766 * This parameter struct is used by SCTP_GET_PEER_ADDRS and
709 * SCTP_GET_LOCAL_ADDRS socket options used internally to implement 767 * SCTP_GET_LOCAL_ADDRS socket options used internally to implement
710 * sctp_getpaddrs() and sctp_getladdrs() API. 768 * sctp_getpaddrs() and sctp_getladdrs() API.
711 */ 769 */
712struct sctp_getaddrs_old { 770struct sctp_getaddrs_old {
713 sctp_assoc_t assoc_id; 771 sctp_assoc_t assoc_id;
714 int addr_num; 772 int addr_num;
773#ifdef __KERNEL__
715 struct sockaddr __user *addrs; 774 struct sockaddr __user *addrs;
775#else
776 struct sockaddr *addrs;
777#endif
716}; 778};
779
717struct sctp_getaddrs { 780struct sctp_getaddrs {
718 sctp_assoc_t assoc_id; /*input*/ 781 sctp_assoc_t assoc_id; /*input*/
719 __u32 addr_num; /*output*/ 782 __u32 addr_num; /*output*/
@@ -779,4 +842,5 @@ struct sctp_paddrthlds {
779 __u16 spt_pathmaxrxt; 842 __u16 spt_pathmaxrxt;
780 __u16 spt_pathpfthld; 843 __u16 spt_pathpfthld;
781}; 844};
782#endif /* __net_sctp_user_h__ */ 845
846#endif /* _UAPI_SCTP_H */