Skip to contentSkip to conversation

A step closer to RFC 6458 compliancy

PATCH In review Geir Ola Vaagland 5 participants 20 messages Jun 17, 2014 – Jun 18, 2014

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

cover A step closer to RFC 6458 compliancy

These patches are part of my master thesis project. I have been searching for discrepancies between the socket API specificiation in RFC 6458 and the current Linux SCTP implementation. The following patches are my humble attempts at getting somewhat closer to 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,5 +97,7 @@ 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

#3 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 +93 -0

97 lines not on this page · raw message

void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
struct msghdr *msghdr)

#5 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 +47 -5

85 lines not on this page · raw message

#6 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

#7 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

#8 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 +50 -0

55 lines not on this page · raw message

*
@@ -3724,6 +3773,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
retval = sctp_setsockopt_default_send_param(sk, optval,
optlen);
break;
+ case SCTP_DEFAULT_SNDINFO:
+ retval = sctp_setsockopt_default_sndinfo(sk, optval, optlen);
+ break;
case SCTP_PRIMARY_ADDR:
retval = sctp_setsockopt_primary_addr(sk, optval, optlen); break;
@@ -5063,6 +5115,45 @@ static int sctp_getsockopt_default_send_param(struct sock *sk,

return 0;
}
+static int sctp_getsockopt_default_sndinfo(struct sock *sk,
+ int len, char __user *optval,
+ int __user *optlen)
+{
+ struct sctp_sndinfo info;
+ struct sctp_association *asoc;
+ struct sctp_sock *sp = sctp_sk(sk);
+
+ if (len < sizeof(struct sctp_sndinfo))
+ return -EINVAL;
+
+ len = sizeof(struct sctp_sndinfo);
+
+ if (copy_from_user(&info, optval, len))
+ return -EFAULT;
+
+ asoc = sctp_id2assoc(sk, info.snd_assoc_id);
+ if (!asoc && info.snd_assoc_id && sctp_style(sk, UDP))
+ return -EINVAL;
+
+ if (asoc) {
+ info.snd_sid = asoc->default_stream;
+ info.snd_flags = asoc->default_flags;
+ info.snd_ppid = asoc->default_ppid;
+ info.snd_context = asoc->default_context;
+ } else {
+ info.snd_sid = sp->default_stream;
+ info.snd_flags = sp->default_flags;
+ info.snd_ppid = sp->default_ppid;
+ info.snd_context = sp->default_context;
+ }
+
+ if (put_user(len, optlen))
+ return -EFAULT;
+ if (copy_to_user(optval, &info, len))
+ return -EFAULT;
+
+ return 0;
+}

/*
*
@@ -5917,6 +6008,9 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname,
retval = sctp_getsockopt_default_send_param(sk, len,
optval, optlen);
break;
+ case SCTP_DEFAULT_SNDINFO:
+ retval = sctp_getsockopt_default_sndinfo(sk, len,
+ optval, optlen);
+ break;
case SCTP_PRIMARY_ADDR:
retval = sctp_getsockopt_primary_addr(sk, len, optval, optlen); break;

#10 lore raw
In reply to Geir Ola Vaagland

From: Geir Ola Vaagland

Quoted 3 lines

These patches are part of my master thesis project. I have been searching for discrepancies between the socket API specificiation in RFC 6458 and the current Linux SCTP implementation. The following patches are my humble attempts at getting somewhat closer to compliancy.

You should keep commit messages with 80 columns.
The message subject should say that this is 'v2'.
You still haven't fixed all the code style issues.
This email should include a list of the differences from the earlier version.

David

#11 lore raw
In reply to Geir Ola Vaagland

From: Of Geir Ola Vaagland

Quoted 3 lines

These patches are part of my master thesis project. I have been searching for discrepancies between the socket API specificiation in RFC 6458 and the current Linux SCTP implementation. The following patches are my humble attempts at getting somewhat closer to compliancy.

I've just been reading RFC 6458 - HTF did it get past the editors and then published in its current form?
Lots of the structures have implied padding.
There is an embedded 'struct sockaddr_storage' in the middle of one structure. In some OS this should never actually be instantiated.

Maybe the interface could have been changed in 2001, but not in 2011.

David

#12 lore raw
Quoted 10 lines · David Laight

From: Of Geir Ola Vaagland

Quoted 3 lines

These patches are part of my master thesis project. I have been searching for discrepancies between the socket API specificiation in RFC 6458 and the current Linux SCTP implementation. The following patches are my humble attempts at getting somewhat closer to compliancy.

I've just been reading RFC 6458 - HTF did it get past the editors and then published in its current form?
Lots of the structures have implied padding.
There is an embedded 'struct sockaddr_storage' in the middle of one structure. In some OS this should never actually be instantiated.

This particular horse has been beaten to death already. It has been around for so long that we couldn't really change it anymore.

I've argued the padding issue, but the editor stance is that it's implementation dependent.

-vlad

Quoted 12 lines

Maybe the interface could have been changed in 2001, but not in 2011.

David

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

#13 lore raw

From: Vlad Yasevich

Quoted 9 lines · David Laight
Quoted 8 lines

From: Of Geir Ola Vaagland

Quoted 3 lines

These patches are part of my master thesis project. I have been searching for discrepancies between the socket API specificiation in RFC 6458 and the current Linux SCTP implementation. The following patches are my humble attempts at getting somewhat closer to compliancy.

I've just been reading RFC 6458 - HTF did it get past the editors and then published in its current form?
Lots of the structures have implied padding.

...

Quoted 2 lines

I've argued the padding issue, but the editor stance is that it's implementation dependent.

It wouldn't be as bad if the RFC said that the structure contained the fields that followed (as is typical of the posix definitions), but instead it gives a definition of the structure.

That isn't implementation friendly at all.

David

#14 lore raw
Quoted 10 lines · David Laight

From: Vlad Yasevich

Quoted 9 lines · David Laight
Quoted 8 lines

From: Of Geir Ola Vaagland

Quoted 3 lines

These patches are part of my master thesis project. I have been searching for discrepancies between the socket API specificiation in RFC 6458 and the current Linux SCTP implementation. The following patches are my humble attempts at getting somewhat closer to compliancy.

I've just been reading RFC 6458 - HTF did it get past the editors and then published in its current form?
Lots of the structures have implied padding.

Quoted 7 lines

...

Quoted 2 lines

I've argued the padding issue, but the editor stance is that it's implementation dependent.

It wouldn't be as bad if the RFC said that the structure contained the fields that followed (as is typical of the posix definitions), but instead it gives a definition of the structure.

That would have been a possibility, but it was never suggested. As far as I know, C does not guarantee the memory layout for structs, except for the sequence of the components. So a compiler might add some padding at any place. When implementing this, you need to take care of this (and your job might be simpler, since you might only work with a specific set of compilers).
In FreeBSD we also added some padding to some structures since they "evolved" during the lifetime of of the internet draft and we wanted to preserve some compatibility.
I agree, that one must take care of the implied padding and I will double check how this is handled in FreeBSD. Not sure...

Best regards
Michael

Quoted 12 lines

That isn't implementation friendly at all.

David

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

#15 lore raw

From: Michael Tuexen [

Quoted 22 lines · David Laight
Quoted 5 lines

From: Vlad Yasevich

Quoted 3 lines · David Laight
Quoted 2 lines

From: Of Geir Ola Vaagland

Quoted 1 line

These patches are part of my master thesis project. I have been searching for discrepancies

between

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the socket API specificiation in RFC 6458 and the current Linux SCTP implementation. The

following

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

patches are my humble attempts at getting somewhat closer to compliancy.

I've just been reading RFC 6458 - HTF did it get past the editors and then published in its current form?
Lots of the structures have implied padding.

Quoted 7 lines

...

Quoted 2 lines

I've argued the padding issue, but the editor stance is that it's implementation dependent.

It wouldn't be as bad if the RFC said that the structure contained the fields that followed (as is typical of the posix definitions), but instead it gives a definition of the structure.

Quoted 11 lines

That would have been a possibility, but it was never suggested. As far as I know, C does not guarantee the memory layout for structs, except for the sequence of the components. So a compiler might add some padding at any place. When implementing this, you need to take care of this (and your job might be simpler, since you might only work with a specific set of compilers).
In FreeBSD we also added some padding to some structures since they "evolved" during the lifetime of of the internet draft and we wanted to preserve some compatibility.
I agree, that one must take care of the implied padding and I will double check how this is handled in FreeBSD. Not sure...

You need to add explicit named pad fields in order to zero them. (since you don't really want a memset())
That is against my reading of the RFC.

What does FreeBSD do about the 'sockaddr_storage'?
I'd have thought it had the same rules as NetBSD - where (IIRC) it should never be instantiated, but only exists as a pointer type for function parameters.

David

#16 lore raw
Quoted 35 lines · David Laight

From: Michael Tuexen [

Quoted 22 lines · David Laight
Quoted 5 lines

From: Vlad Yasevich

Quoted 3 lines · David Laight
Quoted 2 lines

From: Of Geir Ola Vaagland

Quoted 1 line

These patches are part of my master thesis project. I have been searching for discrepancies

between

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the socket API specificiation in RFC 6458 and the current Linux SCTP implementation. The

following

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

patches are my humble attempts at getting somewhat closer to compliancy.

I've just been reading RFC 6458 - HTF did it get past the editors and then published in its current form?
Lots of the structures have implied padding.

Quoted 7 lines

...

Quoted 2 lines

I've argued the padding issue, but the editor stance is that it's implementation dependent.

It wouldn't be as bad if the RFC said that the structure contained the fields that followed (as is typical of the posix definitions), but instead it gives a definition of the structure.

Quoted 11 lines

That would have been a possibility, but it was never suggested. As far as I know, C does not guarantee the memory layout for structs, except for the sequence of the components. So a compiler might add some padding at any place. When implementing this, you need to take care of this (and your job might be simpler, since you might only work with a specific set of compilers).
In FreeBSD we also added some padding to some structures since they "evolved" during the lifetime of of the internet draft and we wanted to preserve some compatibility.
I agree, that one must take care of the implied padding and I will double check how this is handled in FreeBSD. Not sure...

Quoted 3 lines

You need to add explicit named pad fields in order to zero them. (since you don't really want a memset())
That is against my reading of the RFC.

Well, you can have an additional field in the struct to do that... I wouldn't say that it is forbidden...

Quoted 2 lines

What does FreeBSD do about the 'sockaddr_storage'?

Need to double check, but we just use it as an large enough memory block to hold struct sockaddr_in and struct sockaddr_in6. There was a lengthy discussion a long time ago and that was the compromise...

Quoted 2 lines

I'd have thought it had the same rules as NetBSD - where (IIRC) it should never be instantiated, but only exists as a pointer type for function parameters.

Would't you use struct sockaddr * for that?

Best regards
Michael

Quoted 7 lines

David

#17 lore raw
In reply to David Laight
Quoted 35 lines · David Laight

From: Michael Tuexen [

Quoted 22 lines · David Laight
Quoted 5 lines

From: Vlad Yasevich

Quoted 3 lines · David Laight
Quoted 2 lines

From: Of Geir Ola Vaagland

Quoted 1 line

These patches are part of my master thesis project. I have been searching for discrepancies

between

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the socket API specificiation in RFC 6458 and the current Linux SCTP implementation. The

following

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

patches are my humble attempts at getting somewhat closer to compliancy.

I've just been reading RFC 6458 - HTF did it get past the editors and then published in its current form?
Lots of the structures have implied padding.

Quoted 7 lines

...

Quoted 2 lines

I've argued the padding issue, but the editor stance is that it's implementation dependent.

It wouldn't be as bad if the RFC said that the structure contained the fields that followed (as is typical of the posix definitions), but instead it gives a definition of the structure.

Quoted 11 lines

That would have been a possibility, but it was never suggested. As far as I know, C does not guarantee the memory layout for structs, except for the sequence of the components. So a compiler might add some padding at any place. When implementing this, you need to take care of this (and your job might be simpler, since you might only work with a specific set of compilers).
In FreeBSD we also added some padding to some structures since they "evolved" during the lifetime of of the internet draft and we wanted to preserve some compatibility.
I agree, that one must take care of the implied padding and I will double check how this is handled in FreeBSD. Not sure...

Quoted 8 lines

You need to add explicit named pad fields in order to zero them. (since you don't really want a memset())
That is against my reading of the RFC.

What does FreeBSD do about the 'sockaddr_storage'?
I'd have thought it had the same rules as NetBSD - where (IIRC) it should never be instantiated, but only exists as a pointer type for function parameters.

I don't remember any such rules when sockaddr_storage was defined. Can you point to any document stating such rules?
It is definitely useful as a container object at times.

-vlad

#18 lore raw
Quoted 40 lines · Vlad Yasevich
Quoted 39 lines · David Laight

From: Michael Tuexen [

Quoted 22 lines · David Laight
Quoted 5 lines

From: Vlad Yasevich

Quoted 3 lines · David Laight
Quoted 2 lines

From: Of Geir Ola Vaagland

Quoted 1 line

These patches are part of my master thesis project. I have been searching for discrepancies

between

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the socket API specificiation in RFC 6458 and the current Linux SCTP implementation. The

following

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

patches are my humble attempts at getting somewhat closer to compliancy.

I've just been reading RFC 6458 - HTF did it get past the editors and then published in its current form?
Lots of the structures have implied padding.

Quoted 7 lines

...

Quoted 2 lines

I've argued the padding issue, but the editor stance is that it's implementation dependent.

It wouldn't be as bad if the RFC said that the structure contained the fields that followed (as is typical of the posix definitions), but instead it gives a definition of the structure.

Quoted 11 lines

That would have been a possibility, but it was never suggested. As far as I know, C does not guarantee the memory layout for structs, except for the sequence of the components. So a compiler might add some padding at any place. When implementing this, you need to take care of this (and your job might be simpler, since you might only work with a specific set of compilers).
In FreeBSD we also added some padding to some structures since they "evolved" during the lifetime of of the internet draft and we wanted to preserve some compatibility.
I agree, that one must take care of the implied padding and I will double check how this is handled in FreeBSD. Not sure...

You need to add explicit named pad fields in order to zero them. (since you don't really want a memset())
That is against my reading of the RFC.

Quoted 8 lines
Quoted 4 lines

What does FreeBSD do about the 'sockaddr_storage'?
I'd have thought it had the same rules as NetBSD - where (IIRC) it should never be instantiated, but only exists as a pointer type for function parameters.

I don't remember any such rules when sockaddr_storage was defined. Can you point to any document stating such rules?
It is definitely useful as a container object at times.

I agree. The description would be OK for struct sockaddr. I have never instantiated a variable of that type. The only use (I know of) of struct sockaddr_storage is as a container object.

Best regards
Michael

Quoted 4 lines

-vlad

#19 lore raw

From: Michael Tuexen

Quoted 47 lines · Vlad Yasevich
Quoted 46 lines · David Laight
Quoted 43 lines

From: Michael Tuexen [

Quoted 22 lines · David Laight
Quoted 5 lines

From: Vlad Yasevich

Quoted 3 lines · David Laight
Quoted 2 lines

From: Of Geir Ola Vaagland

Quoted 1 line

These patches are part of my master thesis project. I have been searching for discrepancies

between

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the socket API specificiation in RFC 6458 and the current Linux SCTP implementation. The

following

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

patches are my humble attempts at getting somewhat closer to compliancy.

I've just been reading RFC 6458 - HTF did it get past the editors and then published in its current form?
Lots of the structures have implied padding.

Quoted 7 lines

...

Quoted 2 lines

I've argued the padding issue, but the editor stance is that it's implementation dependent.

It wouldn't be as bad if the RFC said that the structure contained the fields that followed (as is typical of the posix definitions), but instead it gives a definition of the structure.

Quoted 11 lines

That would have been a possibility, but it was never suggested. As far as I know, C does not guarantee the memory layout for structs, except for the sequence of the components. So a compiler might add some padding at any place. When implementing this, you need to take care of this (and your job might be simpler, since you might only work with a specific set of compilers).
In FreeBSD we also added some padding to some structures since they "evolved" during the lifetime of of the internet draft and we wanted to preserve some compatibility.
I agree, that one must take care of the implied padding and I will double check how this is handled in FreeBSD. Not sure...

You need to add explicit named pad fields in order to zero them. (since you don't really want a memset())
That is against my reading of the RFC.

What does FreeBSD do about the 'sockaddr_storage'?
I'd have thought it had the same rules as NetBSD - where (IIRC) it should never be instantiated, but only exists as a pointer type for function parameters.

Quoted 6 lines
Quoted 3 lines

I don't remember any such rules when sockaddr_storage was defined. Can you point to any document stating such rules?
It is definitely useful as a container object at times.

I agree. The description would be OK for struct sockaddr. I have never instantiated a variable of that type. The only use (I know of) of struct sockaddr_storage is as a container object.

I remember Christos saying something to that effect on one of the NetBSD lists. But I can't remember exactly when and searching the archives might be hard. He might remember.

David

maintainer
#2 lore raw

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

In reply to Geir Ola Vaagland

From: Geir Ola Vaagland <[email protected]>
Date: Tue, 17 Jun 2014 17:01:31 +0200

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

Quoted 5 lines
net/sctp/socket.c +4 -0
+}
+
+
+
 /* API 6.2 setsockopt(), getsockopt()

Please do not add more than one empty line between top-level objects in the source file.

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

Quoted 7 lines
net/sctp/socket.c +5 -0
+	return 0;
+}
+
+
+
 static int sctp_getsockopt(struct sock *sk, int level, int optname,
 			   char __user *optval, int __user *optlen)

Likewise.

maintainer
#4 lore raw

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

In reply to Geir Ola Vaagland

From: Geir Ola Vaagland <[email protected]>
Date: Tue, 17 Jun 2014 17:01:32 +0200

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

Quoted 4 lines
net/sctp/ulpevent.c +3 -0
+}
+
+
 /* Copy out the sndrcvinfo into a msghdr.  */

One empty line only here, thanks.

maintainer
#9 lore raw

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

In reply to Geir Ola Vaagland

From: Geir Ola Vaagland <[email protected]>
Date: Tue, 17 Jun 2014 17:01:36 +0200

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

Quoted 4 lines
net/sctp/socket.c +4 -0
+
+	/* Note! asoc->default_timetolive is not set in this way anymore.
+	 * The PR-SCTP extension needs to be implemented.
+    */

This comment is not formatted correctly.

Quoted 6 lines
net/sctp/socket.c +6 -0
+	if (asoc) {
+		asoc->default_stream = info.snd_sid;
+		asoc->default_flags = info.snd_flags;
+		asoc->default_ppid = info.snd_ppid;
+		asoc->default_context = info.snd_context;
+	} else {

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

Quoted 10 lines
net/sctp/socket.c +8 -0
+		sp->default_stream = info.snd_sid;
+		sp->default_flags = info.snd_flags;
+		sp->default_ppid = info.snd_ppid;
+		sp->default_context = info.snd_context;
+	}
+	return 0;
+}
+
 
 /* 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR)

Only one empty line between top-level objects in a source file, thank you.

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

Quoted 7 lines

*

net/sctp/socket.c +2 -0
@@ -5063,6 +5115,45 @@ static int sctp_getsockopt_default_send_param(struct sock *sk,
 
 	return 0;
 }
+static int sctp_getsockopt_default_sndinfo(struct sock *sk,
+					int len, char __user *optval,

Please one empty line between top level objects in the source file.