Skip to content

sctp: clean up sctp_sendmsg

Xin Long linux-sctp netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9sctp: factor out sctp_sendmsg_to_asoc from sctp_sendmsgnet/sctp/socket.c+99 -1310 replies
2/9sctp: factor out sctp_sendmsg_new_asoc from sctp_sendmsgnet/sctp/socket.c+86 -1150 replies
3/9sctp: factor out sctp_sendmsg_check_sflags from sctp_sendmsgnet/sctp/socket.c+36 -360 replies
4/9sctp: factor out sctp_sendmsg_get_daddr from sctp_sendmsgnet/sctp/socket.c+34 -240 replies
5/9sctp: factor out sctp_sendmsg_parse from sctp_sendmsgnet/sctp/socket.c+69 -1030 replies
6/9sctp: factor out sctp_sendmsg_update_sinfo from sctp_sendmsgnet/sctp/socket.c+17 -90 replies
7/9sctp: remove the unnecessary transport looking up from sctp_sendmsgnet/sctp/socket.c+6 -180 replies
8/9sctp: improve some variables in sctp_sendmsgnet/sctp/socket.c+14 -150 replies
9/9sctp: adjust some codes in a better order in sctp_sendmsgnet/sctp/socket.c+18 -180 replies

Reviews trailers per patch

None of the 9 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNeil Horman
SeriesA-b
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH net-next 0/9] sctp: clean up sctp_sendmsg

This cleanup mostly does three things:

- extract some codes into functions to make sendmsg more readable.

- tidy up some codes to avoid the unnecessary checks.

- adjust some logic so that it will be easier to add the send flags and cmsgs features that I will post after this.

To make it easy to review and to check if the code is compatible with before, this patchset is to do it step by step in 9 patches.

NOTE:
There will be a conflict when merging
Commit 2277c7cd75e3 ("sctp: Add LSM hooks") from selinux tree, the solution is to:

1. remove all the lines in [B]:

    <<<<<<< HEAD
    [A]
    ===    [B]
    >>>>>>> 2277c7c... sctp: Add LSM hooks

2. and apply the following diff-output:

net/sctp/socket.c +17 -0
index 980621e..d6803c8 100644
@@ -1686,6 +1686,7 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
 	struct net *net = sock_net(sk);
 	struct sctp_association *asoc;
 	enum sctp_scope scope;
+	struct sctp_af *af;
 	int err = -EINVAL;
 
 	*tp = NULL;
@@ -1711,6 +1712,22 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
 
 	scope = sctp_scope(daddr);
 
+	/* Label connection socket for first association 1-to-many
+	 * style for client sequence socket()->sendmsg(). This
+	 * needs to be done before sctp_assoc_add_peer() as that will
+	 * set up the initial packet that needs to account for any
+	 * security ip options (CIPSO/CALIPSO) added to the packet.
+	 */
+	af = sctp_get_af_specific(daddr->sa.sa_family);
+	if (!af)
+		return -EINVAL;
+
+	err = security_sctp_bind_connect(sk, SCTP_SENDMSG_CONNECT,
+					 (struct sockaddr *)daddr,
+					 af->sockaddr_len);
+	if (err < 0)
+		return err;
+
 	asoc = sctp_association_new(ep, sk, scope, GFP_KERNEL);
 	if (!asoc)
 		return -ENOMEM;

Xin Long (9):
sctp: factor out sctp_sendmsg_to_asoc from sctp_sendmsg
sctp: factor out sctp_sendmsg_new_asoc from sctp_sendmsg
sctp: factor out sctp_sendmsg_check_sflags from sctp_sendmsg
sctp: factor out sctp_sendmsg_get_daddr from sctp_sendmsg
sctp: factor out sctp_sendmsg_parse from sctp_sendmsg
sctp: factor out sctp_sendmsg_update_sinfo from sctp_sendmsg
sctp: remove the unnecessary transport looking up from sctp_sendmsg
sctp: improve some variables in sctp_sendmsg
sctp: adjust some codes in a better order in sctp_sendmsg

 net/sctp/socket.c | 638 +++++++++++++++++++++++-------------------------------
 1 file changed, 274 insertions(+), 364 deletions(-)
Signature · 1 line
2.1.0