Skip to contentSkip to conversation

A step closer to RFC 6458 compliancy

PATCH In review Geir Ola Vaagland 3 participants 16 messages Jun 17, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover A step closer to RFC 6458 compliancy

Geir Ola Vaagland (6):
Support for SCTP_RECVRCVINFO socket option Support for SCTP_RCVINFO ancillary data Support for SCTP_SNDINFO ancillary data Support for SCTP_NXTINFO socket option Support for receiving SCTP_NXTINFO ancillary data Support for SCTP_DEFAULT_SNDINFO socket option

 include/net/sctp/structs.h  |  11 +-
 include/net/sctp/ulpevent.h |   4 +
 include/uapi/linux/sctp.h   |  46 ++++++++
 net/sctp/socket.c           | 260 ++++++++++++++++++++++++++++++++++++++++++--
 net/sctp/ulpevent.c         | 158 +++++++++++++++++++++++++++
 5 files changed, 470 insertions(+), 9 deletions(-)
#1 lore raw

PATCH 1/6 Support for SCTP_RECVRCVINFO socket option

---
 include/net/sctp/structs.h |  1 +
 include/uapi/linux/sctp.h  |  2 ++
 net/sctp/socket.c          | 48 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
include/net/sctp/structs.h +1 -0
index 0a248b3..75c598a 100644
@@ -216,6 +216,7 @@ struct sctp_sock {
 	__u8 frag_interleave;
 	__u32 adaptation_ind;
 	__u32 pd_point;
+	__u8 recvrcvinfo;
 
 	atomic_t pd_mode;
 	/* Receive to here while partial delivery is in effect. */
include/uapi/linux/sctp.h +2 -0
index ca451e9..a7db3b3 100644
@@ -97,6 +97,8 @@ typedef __s32 sctp_assoc_t;
 #define SCTP_AUTO_ASCONF       30
 #define SCTP_PEER_ADDR_THLDS	31
 
+#define SCTP_RECVRCVINFO 32
+
 /* Internal Socket Options. Some of the sctp library functions are
  * implemented using these socket options.
  */
net/sctp/socket.c +48 -0

78 lines not on this page · raw message

#2 lore raw

RE: [PATCH net-next 1/6] Support for SCTP_RECVRCVINFO socket option

From: Geir Ola Vaagland

include/net/sctp/structs.h struct sctp_sock { · line 219

Quoted 9 lines
include/net/sctp/structs.h +1 -0
index 0a248b3..75c598a 100644
@@ -216,6 +216,7 @@ struct sctp_sock {
 	__u8 frag_interleave;
 	__u32 adaptation_ind;
 	__u32 pd_point;
+	__u8 recvrcvinfo;

This adds a lot of padding.
Possibly it should also be a 'bool'

...

include/net/sctp/structs.h struct sctp_sock {

Quoted 12 lines
include/net/sctp/structs.h +12 -0
+static int sctp_setsockopt_recvrcvinfo(struct sock *sk,
+		char __user *optval,
+		unsigned int optlen){
+
+	int val;
+
+	if(optlen < sizeof(int))
+		return -EINVAL;
+
+	if(get_user(val, (int __user*)optval)){
+		return -EFAULT;
+	}

I suspect the above code is quite common, and should be put into a separate function.

include/net/sctp/structs.h

Quoted 1 line
include/net/sctp/structs.h +1 -0
+	sctp_sk(sk)->recvrcvinfo = (val = 0) ? 0 : 1;

See 'bool'

...

Quoted 6 lines
include/net/sctp/structs.h +6 -0
+static int sctp_getsockopt_recvrcvinfo(struct sock *sk,
+		int len,
+		char __user *optval,
+		int __user *optlen){
+
+	int val;

include/net/sctp/structs.h

Quoted 10 lines
include/net/sctp/structs.h +10 -0
+
+	if (len < sizeof(int))
+		return -EINVAL;
+
+	len = sizeof(int);
+	val = (sctp_sk(sk)->recvrcvinfo = 1);
+	if (put_user(len, optlen))
+		return -EFAULT;
+	if (copy_to_user(optval, &val, len))
+		return -EFAULT;

This wants factoring out as well.

...
David

#3 lore raw

Re: [PATCH net-next 1/6] Support for SCTP_RECVRCVINFO socket option

In reply to Geir Ola Vaagland

On 06/17/2014 07:57 AM, Geir Ola Vaagland wrote:

Again, some description and a pointer to RFC/Section for what this patch is implementing.

Quoted 25 lines
---
 include/net/sctp/structs.h |  1 +
 include/uapi/linux/sctp.h  |  2 ++
 net/sctp/socket.c          | 48 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
include/net/sctp/structs.h +1 -0
index 0a248b3..75c598a 100644
@@ -216,6 +216,7 @@ struct sctp_sock {
 	__u8 frag_interleave;
 	__u32 adaptation_ind;
 	__u32 pd_point;
+	__u8 recvrcvinfo;
 
 	atomic_t pd_mode;
 	/* Receive to here while partial delivery is in effect. */
include/uapi/linux/sctp.h +0 -0
index ca451e9..a7db3b3 100644

include/uapi/linux/sctp.h typedef __s32 sctp_assoc_t; · line 101

Quoted 5 lines
include/uapi/linux/sctp.h +2 -0
@@ -97,6 +97,8 @@ typedef __s32 sctp_assoc_t;
 #define SCTP_AUTO_ASCONF       30
 #define SCTP_PEER_ADDR_THLDS	31
 
+#define SCTP_RECVRCVINFO 32
+

The above probably shouldn't have an empty line between options 31 and 32.

Quoted 8 lines
include/uapi/linux/sctp.h +0 -0
 /* Internal Socket Options. Some of the sctp library functions are
  * implemented using these socket options.
  */
net/sctp/socket.c +0 -0
index 146b35d..1f3281b 100644

net/sctp/socket.c static int sctp_setsockopt_paddr_thresholds(struct sock *sk, · line 3571

Quoted 6 lines
net/sctp/socket.c +3 -0
@@ -3566,6 +3566,24 @@ static int sctp_setsockopt_paddr_thresholds(struct sock *sk,
 	return 0;
 }
 
+static int sctp_setsockopt_recvrcvinfo(struct sock *sk,
+		char __user *optval,
+		unsigned int optlen){

Coding style. Please put a space between ) and {. Also, please align definitions with above 'struct sock'. As in:
+static int sctp_setsockopt_recvrcvinfo(struct sock *sk,
+ char __user *optval,
+ unsigned int optlen) {

For more info on coding style see Documentation/CodingStyle in the kernel tree.

Quoted 39 lines
net/sctp/socket.c +21 -0
+
+	int val;
+
+	if(optlen < sizeof(int))
+		return -EINVAL;
+
+	if(get_user(val, (int __user*)optval)){
+		return -EFAULT;
+	}
+	sctp_sk(sk)->recvrcvinfo = (val = 0) ? 0 : 1;
+	return 0;
+}
+
+
+
 /* API 6.2 setsockopt(), getsockopt()
  *
  * Applications use setsockopt() and getsockopt() to set or retrieve
@@ -3717,6 +3735,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
 	case SCTP_PEER_ADDR_THLDS:
 		retval = sctp_setsockopt_paddr_thresholds(sk, optval, optlen);
 		break;
+	case SCTP_RECVRCVINFO:
+		retval = sctp_setsockopt_recvrcvinfo(sk, optval, optlen);
+		break;
 	default:
 		retval = -ENOPROTOOPT;
 		break;
@@ -3963,6 +3984,9 @@ static int sctp_init_sock(struct sock *sk)
 	/* Enable Nagle algorithm by default.  */
 	sp->nodelay           = 0;
 
+	/* No SCTP_RECVRCVINFO by default. */
+	sp->recvrcvinfo = 0;
+
 	/* Enable by default. */
 	sp->v4mapped          = 1;
 

net/sctp/socket.c static int sctp_getsockopt_assoc_stats(struct sock *sk, int len, · line 5765

Quoted 8 lines
net/sctp/socket.c +5 -0
@@ -5734,6 +5758,27 @@ static int sctp_getsockopt_assoc_stats(struct sock *sk, int len,
 	return 0;
 }
 
+static int sctp_getsockopt_recvrcvinfo(struct sock *sk,
+		int len,
+		char __user *optval,
+		int __user *optlen){
+

Indent issue.

-vlad

Quoted 30 lines
net/sctp/socket.c +19 -0
+	int val;
+
+	if (len < sizeof(int))
+		return -EINVAL;
+
+	len = sizeof(int);
+	val = (sctp_sk(sk)->recvrcvinfo = 1);
+	if (put_user(len, optlen))
+		return -EFAULT;
+	if (copy_to_user(optval, &val, len))
+		return -EFAULT;
+	return 0;
+}
+
+
+
 static int sctp_getsockopt(struct sock *sk, int level, int optname,
 			   char __user *optval, int __user *optlen)
 {
@@ -5877,6 +5922,9 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname,
 	case SCTP_GET_ASSOC_STATS:
 		retval = sctp_getsockopt_assoc_stats(sk, len, optval, optlen);
 		break;
+	case SCTP_RECVRCVINFO:
+		retval = sctp_getsockopt_recvrcvinfo(sk, len, optval, optlen);
+		break;
 	default:
 		retval = -ENOPROTOOPT;
 		break;
#4 lore raw

PATCH 2/6 Support for SCTP_RCVINFO ancillary data

In reply to Geir Ola Vaagland
---
 include/net/sctp/ulpevent.h |  2 +
 include/uapi/linux/sctp.h   | 23 ++++++++++++
 net/sctp/socket.c           |  6 +++
 net/sctp/ulpevent.c         | 91 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 122 insertions(+)
include/net/sctp/ulpevent.h +2 -0
index 27b9f5c..2f42831 100644
@@ -131,6 +131,8 @@ struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event(
 
 void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
 	struct msghdr *);
+void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
+	struct msghdr *);
 __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
 
 /* Is this event type enabled? */
include/uapi/linux/sctp.h +23 -0
index a7db3b3..7e8736b 100644
@@ -158,6 +158,27 @@ struct sctp_sndrcvinfo {
 };
 
 /*
+ *  5.3.5 SCTP Receive Information Structure (SCTP_RCVINFO)
+ *
+ *   This cmsghdr structure specifies SCTP options for sendmsg().
+ *
+ *   cmsg_level    cmsg_type      cmsg_data[]
+ *   ------------  ------------   -------------------
+ *   IPPROTO_SCTP  SCTP_RCVINFO   struct sctp_rcvinfo
+ *
+ */
+struct sctp_rcvinfo {
+	__u16 rcv_sid;
+	__u16 rcv_ssn;
+	__u16 rcv_flags;
+	__u32 rcv_ppid;
+	__u32 rcv_tsn;
+	__u32 rcv_cumtsn;
+	__u32 rcv_context;
+	sctp_assoc_t rcv_assoc_id;
+};
+
+/*
  *  sinfo_flags: 16 bits (unsigned integer)
  *
  *   This field may contain any of the following flags and is composed of
@@ -184,6 +205,8 @@ typedef enum sctp_cmsg_type {
 #define SCTP_INIT	SCTP_INIT
 	SCTP_SNDRCV,            /* 5.2.2 SCTP Header Information Structure */
 #define SCTP_SNDRCV	SCTP_SNDRCV
+	SCTP_RCVINFO,
+#define SCTP_RCVINFO SCTP_RCVINFO
 } sctp_cmsg_t;
 
 /*
net/sctp/socket.c +6 -0
index 1f3281b..aee161b 100644
@@ -2094,6 +2094,12 @@ static int sctp_recvmsg(struct kiocb *iocb, struct sock *sk,
 		sp->pf->skb_msgname(skb, msg->msg_name, addr_len);
 	}
 
+
+	/* Check if SCTP_RCVINFO should be included */
+	if(sp->recvrcvinfo){
+		sctp_ulpevent_read_rcvinfo(event, msg);
+	}
+
 	/* Check if we allow SCTP_SNDRCVINFO. */
 	if (sp->subscribe.sctp_data_io_event)
 		sctp_ulpevent_read_sndrcvinfo(event, msg);
net/sctp/ulpevent.c +91 -0

97 lines not on this page · raw message

#5 lore raw

RE: [PATCH net-next 2/6] Support for SCTP_RCVINFO ancillary data

From: Geir Ola Vaagland
...

include/uapi/linux/sctp.h struct sctp_sndrcvinfo { · line 179

Quoted 10 lines
include/uapi/linux/sctp.h +10 -0
+struct sctp_rcvinfo {
+	__u16 rcv_sid;
+	__u16 rcv_ssn;
+	__u16 rcv_flags;
+	__u32 rcv_ppid;
+	__u32 rcv_tsn;
+	__u32 rcv_cumtsn;
+	__u32 rcv_context;
+	sctp_assoc_t rcv_assoc_id;
+};

There are two pad bytes in the middle of the above. You leak kernel data to userspace.

...
David

#6 lore raw

Re: [PATCH net-next 2/6] Support for SCTP_RCVINFO ancillary data

In reply to Geir Ola Vaagland
Quoted 14 lines · Geir Ola Vaagland
---
 include/net/sctp/ulpevent.h |  2 +
 include/uapi/linux/sctp.h   | 23 ++++++++++++
 net/sctp/socket.c           |  6 +++
 net/sctp/ulpevent.c         | 91 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 122 insertions(+)
include/net/sctp/ulpevent.h +0 -0
index 27b9f5c..2f42831 100644

include/net/sctp/ulpevent.h struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event( · line 135

Quoted 5 lines
include/net/sctp/ulpevent.h +2 -0
@@ -131,6 +131,8 @@ struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event(
 
 void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
 	struct msghdr *);
+void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
+	struct msghdr *);

Gah... This whole file doesn't conform to coding style. :(

Please make this change conform to style standards, and we can clean up the file later.

Quoted 68 lines
include/net/sctp/ulpevent.h +0 -0
 __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
 
 /* Is this event type enabled? */
include/uapi/linux/sctp.h +23 -0
index a7db3b3..7e8736b 100644
@@ -158,6 +158,27 @@ struct sctp_sndrcvinfo {
 };
 
 /*
+ *  5.3.5 SCTP Receive Information Structure (SCTP_RCVINFO)
+ *
+ *   This cmsghdr structure specifies SCTP options for sendmsg().
+ *
+ *   cmsg_level    cmsg_type      cmsg_data[]
+ *   ------------  ------------   -------------------
+ *   IPPROTO_SCTP  SCTP_RCVINFO   struct sctp_rcvinfo
+ *
+ */
+struct sctp_rcvinfo {
+	__u16 rcv_sid;
+	__u16 rcv_ssn;
+	__u16 rcv_flags;
+	__u32 rcv_ppid;
+	__u32 rcv_tsn;
+	__u32 rcv_cumtsn;
+	__u32 rcv_context;
+	sctp_assoc_t rcv_assoc_id;
+};
+
+/*
  *  sinfo_flags: 16 bits (unsigned integer)
  *
  *   This field may contain any of the following flags and is composed of
@@ -184,6 +205,8 @@ typedef enum sctp_cmsg_type {
 #define SCTP_INIT	SCTP_INIT
 	SCTP_SNDRCV,            /* 5.2.2 SCTP Header Information Structure */
 #define SCTP_SNDRCV	SCTP_SNDRCV
+	SCTP_RCVINFO,
+#define SCTP_RCVINFO SCTP_RCVINFO
 } sctp_cmsg_t;
 
 /*
net/sctp/socket.c +6 -0
index 1f3281b..aee161b 100644
@@ -2094,6 +2094,12 @@ static int sctp_recvmsg(struct kiocb *iocb, struct sock *sk,
 		sp->pf->skb_msgname(skb, msg->msg_name, addr_len);
 	}
 
+
+	/* Check if SCTP_RCVINFO should be included */
+	if(sp->recvrcvinfo){
+		sctp_ulpevent_read_rcvinfo(event, msg);
+	}
+
 	/* Check if we allow SCTP_SNDRCVINFO. */
 	if (sp->subscribe.sctp_data_io_event)
 		sctp_ulpevent_read_sndrcvinfo(event, msg);
net/sctp/ulpevent.c +0 -0
index 81089ed..d1b9a02 100644
@@ -900,6 +900,97 @@ __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event)
 	return notification->sn_header.sn_type;
 }

net/sctp/ulpevent.c __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event) · line 911

Quoted 10 lines
net/sctp/ulpevent.c +9 -0
 
+void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
+		struct msghdr *msghdr)
+{
+	struct sctp_rcvinfo rinfo;
+
+	if (sctp_ulpevent_is_notification(event)){
+		return;
+	}
+

As David Laight mentioned, the spec defines sctp_rcvinfo with a hole in it. To prevent passing kernel stack data to user space, you need to zero-out the data first.

-vlad

Quoted 86 lines
net/sctp/ulpevent.c +82 -0
+	/* Sockets API Extensions for SCTP
+	 * Section 5.3.5 SCTP Receive Information Structure (SCTP_SNDRCV)
+	 *
+	 * rcv_sid: 16 bits (unsigned integer)
+	 *
+	 * The SCTP stack places the message's stream number in this
+	 * value.
+	 */
+	rinfo.rcv_sid = event->stream;
+
+	/* rcv_ssn: 16 bits (unsigned integer)
+	 * This value contains the stream sequence number that the
+	 * remote endpoint placed in the DATA chunk.  For fragmented
+	 * messages, this is the same number for all deliveries of the
+	 * message (if more than one recvmsg() is needed to read
+	 * the message)
+	 */
+	rinfo.rcv_ssn = event->ssn;
+
+
+	/* rcv_ppid: 32 bits (unsigned integer)
+	 *
+	 * This value is the same information that was passed by the
+	 * upper layer in the peer application.  Please note that the SCTP
+	 * stack performs no byte order modification of this field.
+	 * For example, if the DATA chunk has to contain a given
+	 * value in network byte order, the SCTP user has to perform the
+	 * ntohl() computation.
+	 */
+	rinfo.rcv_ppid = event->ppid;
+
+	/* rcv_flags: 16 bits (unsigned integer)
+	 *
+	 * This field may contain any of the following flags and is composed of
+	 * a bitwise OR of these values.
+	 *
+	 * recvmsg() flags:
+	 *
+	 * SCTP_UNORDERED - This flag is present when the message was sent
+	 *                 non-ordered.
+	 */
+
+	rinfo.rcv_flags = event->flags;
+
+	/* rcv_tsn: 32 bits (unsigned integer)
+	 *
+	 * This field holds a TSN that was assigned to one of the SCTP
+	 * DATA chunks.
+	 */
+	rinfo.rcv_tsn = event->tsn;
+
+	/* rcv_cumtsn: 32 bits (unsigned integer)
+	 *
+	 * This field will hold the current cumulative TSN as known
+	 * by the underlying SCTP layer.
+	 */
+	rinfo.rcv_cumtsn = event->cumtsn;
+
+	/* rcv_assoc_id: sizeof (sctp_assoc_t)
+	 *
+	 * The association handle field, sinfo_assoc_id, holds the identifier
+	 * for the association announced in the COMMUNICATION_UP notification.
+	 * All notifications for a given association have the same identifier.
+	 * Ignored for one-to-one style sockets.
+	 */
+	rinfo.rcv_assoc_id = sctp_assoc2id(event->asoc);
+
+	/* rcv_context: 32 bits (unsigned integer)
+	 *
+	 * This value is an opaque 32-bit context datum that was
+	 * set by the user with the SCTP_CONTEXT socket option.  This
+	 * value is passed back to the upper layer if an error occurs on
+	 * the send of a message and is retrieved with each undelivered
+	 * message.
+	 */
+	rinfo.rcv_context = event->asoc->default_rcv_context;
+
+	put_cmsg(msghdr, IPPROTO_SCTP, SCTP_RCVINFO,
+			sizeof(struct sctp_rcvinfo), (void *)&rinfo);
+}
+
+
 /* Copy out the sndrcvinfo into a msghdr.  */
 void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
 				   struct msghdr *msghdr)
#7 lore raw

PATCH 3/6 Support for SCTP_SNDINFO ancillary data

In reply to Geir Ola Vaagland
---
 include/net/sctp/structs.h |  9 +++++++-
 include/uapi/linux/sctp.h  | 19 +++++++++++++++++
 net/sctp/socket.c          | 53 +++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 75 insertions(+), 6 deletions(-)
include/net/sctp/structs.h +8 -1
index 75c598a..5ed8a3c 100644
@@ -1921,9 +1921,16 @@ struct sctp_chunk *sctp_get_ecne_prepend(struct sctp_association *asoc);
 /* A convenience structure to parse out SCTP specific CMSGs. */
 typedef struct sctp_cmsgs {
 	struct sctp_initmsg *init;
-	struct sctp_sndrcvinfo *info;
+	union {
+		struct sctp_sndrcvinfo *srinfo;
+		struct sctp_sndinfo *sinfo;
+	} info;
+	sctp_cmsg_t cmsg_type;
 } sctp_cmsgs_t;
 
+#define sr_info info.srinfo
+#define s_info info.sinfo
+
 /* Structure for tracking memory objects */
 typedef struct {
 	char *label;
include/uapi/linux/sctp.h +19 -0
index 7e8736b..d725e30 100644
@@ -156,6 +156,23 @@ struct sctp_sndrcvinfo {
 	__u32 sinfo_cumtsn;
 	sctp_assoc_t sinfo_assoc_id;
 };
+/*
+ * 5.3.4 SCTP Send Information Structure (SCTP_SNDINFO)
+ *
+ *   This cmsghdr structure specifies SCTP options for sendmsg().
+ *
+ *   cmsg_level    cmsg_type      cmsg_data[]
+ *   ------------  ------------   -------------------
+ *   IPPROTO_SCTP  SCTP_SNDINFO   struct sctp_sndinfo
+ *
+ */
+struct sctp_sndinfo {
+	__u16 snd_sid;
+	__u16 snd_flags;
+	__u32 snd_ppid;
+	__u32 snd_context;
+	sctp_assoc_t snd_assoc_id;
+};
 
 /*
  *  5.3.5 SCTP Receive Information Structure (SCTP_RCVINFO)
@@ -207,6 +224,8 @@ typedef enum sctp_cmsg_type {
 #define SCTP_SNDRCV	SCTP_SNDRCV
 	SCTP_RCVINFO,
 #define SCTP_RCVINFO SCTP_RCVINFO
+	SCTP_SNDINFO,
+#define SCTP_SNDINFO SCTP_SNDINFO
 } sctp_cmsg_t;
 
 /*
net/sctp/socket.c +46 -5

84 lines not on this page · raw message

#8 lore raw

RE: [PATCH net-next 3/6] Support for SCTP_SNDINFO ancillary data

From: Geir Ola Vaagland
...

net/sctp/socket.c static int sctp_msghdr_parse(const struct msghdr *msg, sctp_cmsgs_t *cmsgs) · line 6503

Quoted 7 lines
net/sctp/socket.c +7 -0
+		case SCTP_SNDINFO:
+			/* SCTP Socket API Extension
+			 * 5.3.4 SCTP Send Information Structure (SCTP_SNDINFO)
+			 *
+			 * This cmsghdr structure specifies SCTP options for
+			 * sendmsg(). This structure and SCTP_RCVINFO replaces
+			 * SCTP_SNDRCV which has been depleted.

What do you mean by 'depleted'?
Support for it cannot be removed because it will break existing applications.

David

#9 lore raw

Re: [PATCH net-next 3/6] Support for SCTP_SNDINFO ancillary data

Quoted 11 lines · David Laight

From: Geir Ola Vaagland
...

net/sctp/socket.c static int sctp_msghdr_parse(const struct msghdr *msg, sctp_cmsgs_t *cmsgs) · line 6503

Quoted 7 lines
net/sctp/socket.c +7 -0
+		case SCTP_SNDINFO:
+			/* SCTP Socket API Extension
+			 * 5.3.4 SCTP Send Information Structure (SCTP_SNDINFO)
+			 *
+			 * This cmsghdr structure specifies SCTP options for
+			 * sendmsg(). This structure and SCTP_RCVINFO replaces
+			 * SCTP_SNDRCV which has been depleted.

What do you mean by 'depleted'?

I think he meant deprecated.

-vlad

Quoted 7 lines

Support for it cannot be removed because it will break existing applications.

David

#10 lore raw

RE: [PATCH net-next 3/6] Support for SCTP_SNDINFO ancillary data

From: Vlad Yasevich

Quoted 13 lines · David Laight
Quoted 11 lines

From: Geir Ola Vaagland
...

net/sctp/socket.c static int sctp_msghdr_parse(const struct msghdr *msg, sctp_cmsgs_t *cmsgs) · line 6503

Quoted 7 lines
net/sctp/socket.c +7 -0
+		case SCTP_SNDINFO:
+			/* SCTP Socket API Extension
+			 * 5.3.4 SCTP Send Information Structure (SCTP_SNDINFO)
+			 *
+			 * This cmsghdr structure specifies SCTP options for
+			 * sendmsg(). This structure and SCTP_RCVINFO replaces
+			 * SCTP_SNDRCV which has been depleted.

What do you mean by 'depleted'?

Quoted 1 line

I think he meant deprecated.

Hmm.... that isn't going to work well, is it!

I presume the 'standard' only requires that the structure contain the required fields?
Which probably means it could contain the required padding to make it binary compatible with the existing 'struct sctp_sndrcvinfo' (which also contains pad bytes!)

David

#11 lore raw

PATCH 4/6 Support for SCTP_NXTINFO socket option

In reply to Geir Ola Vaagland
---
 include/net/sctp/structs.h |  1 +
 include/uapi/linux/sctp.h  |  1 +
 net/sctp/socket.c          | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+)
include/net/sctp/structs.h +1 -0
index 5ed8a3c..06585b8 100644
@@ -217,6 +217,7 @@ struct sctp_sock {
 	__u32 adaptation_ind;
 	__u32 pd_point;
 	__u8 recvrcvinfo;
+	__u8 recvnxtinfo;
 
 	atomic_t pd_mode;
 	/* Receive to here while partial delivery is in effect. */
include/uapi/linux/sctp.h +1 -0
index d725e30..986563e 100644
@@ -98,6 +98,7 @@ typedef __s32 sctp_assoc_t;
 #define SCTP_PEER_ADDR_THLDS	31
 
 #define SCTP_RECVRCVINFO 32
+#define SCTP_RECVNXTINFO 33
 
 /* Internal Socket Options. Some of the sctp library functions are
  * implemented using these socket options.
net/sctp/socket.c +43 -0

73 lines not on this page · raw message

#12 lore raw

PATCH 5/6 Support for receiving SCTP_NXTINFO ancillary data

In reply to Geir Ola Vaagland
---
 include/net/sctp/ulpevent.h |  2 ++
 net/sctp/socket.c           | 16 +++++++++--
 net/sctp/ulpevent.c         | 67 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 3 deletions(-)
include/net/sctp/ulpevent.h +2 -0
index 2f42831..d15b835 100644
@@ -133,6 +133,8 @@ void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
 	struct msghdr *);
 void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
 	struct msghdr *);
+void sctp_ulpevent_read_nxtinfo(const struct sctp_ulpevent *event,
+	struct msghdr *, struct sk_buff *);
 __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
 
 /* Is this event type enabled? */
net/sctp/socket.c +13 -3
index 10e12da..57106e8 100644
@@ -2061,11 +2061,11 @@ static int sctp_recvmsg(struct kiocb *iocb, struct sock *sk,
 			struct msghdr *msg, size_t len, int noblock,
 			int flags, int *addr_len)
 {
-	struct sctp_ulpevent *event = NULL;
+	struct sctp_ulpevent *event = NULL, *nxt_event = NULL;
 	struct sctp_sock *sp = sctp_sk(sk);
-	struct sk_buff *skb;
+	struct sk_buff *skb, *nxtskb = NULL;
 	int copied;
-	int err = 0;
+	int err = 0, err2 = 0;
 	int skb_len;
 
 	pr_debug("%s: sk:%p, msghdr:%p, len:%zd, noblock:%d, flags:0x%x, "
@@ -2113,6 +2113,14 @@ static int sctp_recvmsg(struct kiocb *iocb, struct sock *sk,
 		sctp_ulpevent_read_rcvinfo(event, msg);
 	}
 
+	if(sp->recvnxtinfo){
+		nxtskb = sctp_skb_recv_datagram(sk, MSG_PEEK, 1, &err2);
+		if(nxtskb && nxtskb->len){
+			nxt_event = sctp_skb2event(nxtskb);
+			sctp_ulpevent_read_nxtinfo(nxt_event, msg, nxtskb);
+		}
+	}
+
 	/* Check if we allow SCTP_SNDRCVINFO. */
 	if (sp->subscribe.sctp_data_io_event)
 		sctp_ulpevent_read_sndrcvinfo(event, msg);
@@ -2162,6 +2170,8 @@ out_free:
 		sctp_ulpevent_free(event);
 	}
 out:
+	if(nxtskb)
+		kfree_skb(nxtskb);
 	sctp_release_sock(sk);
 	return err;
 }
net/sctp/ulpevent.c +67 -0

73 lines not on this page · raw message

#13 lore raw

PATCH 6/6 Support for SCTP_DEFAULT_SNDINFO socket option

In reply to Geir Ola Vaagland
---
 include/uapi/linux/sctp.h |  1 +
 net/sctp/socket.c         | 94 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)
include/uapi/linux/sctp.h +1 -0
index 986563e..133df4e 100644
@@ -99,6 +99,7 @@ typedef __s32 sctp_assoc_t;
 
 #define SCTP_RECVRCVINFO 32
 #define SCTP_RECVNXTINFO 33
+#define SCTP_DEFAULT_SNDINFO 34
 
 /* Internal Socket Options. Some of the sctp library functions are
  * implemented using these socket options.
net/sctp/socket.c +94 -0

118 lines not on this page · raw message

#14 lore raw
In reply to Geir Ola Vaagland

From: Geir Ola Vaagland

Quoted 8 lines

Geir Ola Vaagland (6):
Support for SCTP_RECVRCVINFO socket option Support for SCTP_RCVINFO ancillary data Support for SCTP_SNDINFO ancillary data Support for SCTP_NXTINFO socket option Support for receiving SCTP_NXTINFO ancillary data Support for SCTP_DEFAULT_SNDINFO socket option

Quoted 6 lines
 include/net/sctp/structs.h  |  11 +-
 include/net/sctp/ulpevent.h |   4 +
 include/uapi/linux/sctp.h   |  46 ++++++++
 net/sctp/socket.c           | 260 ++++++++++++++++++++++++++++++++++++++++++--
 net/sctp/ulpevent.c         | 158 +++++++++++++++++++++++++++
 5 files changed, 470 insertions(+), 9 deletions(-)

You need to make your C match the expected layout for kernel code. In particular the whitespace rules.

David

#15 lore raw
In reply to Geir Ola Vaagland

On 06/17/2014 07:57 AM, Geir Ola Vaagland wrote:

Hi Geir

Please provide a bit more description for the those who are not familiar with the series.

Thanks
-vlad

Quoted 20 lines

Geir Ola Vaagland (6):
Support for SCTP_RECVRCVINFO socket option Support for SCTP_RCVINFO ancillary data Support for SCTP_SNDINFO ancillary data Support for SCTP_NXTINFO socket option Support for receiving SCTP_NXTINFO ancillary data Support for SCTP_DEFAULT_SNDINFO socket option

 include/net/sctp/structs.h  |  11 +-
 include/net/sctp/ulpevent.h |   4 +
 include/uapi/linux/sctp.h   |  46 ++++++++
 net/sctp/socket.c           | 260 ++++++++++++++++++++++++++++++++++++++++++--
 net/sctp/ulpevent.c         | 158 +++++++++++++++++++++++++++
 5 files changed, 470 insertions(+), 9 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html