From: Xin Long <lucien.xin@gmail.com>
To: network dev <netdev@vger.kernel.org>, linux-sctp@vger.kernel.org
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Neil Horman <nhorman@tuxdriver.com>,
davem@davemloft.net
Subject: [PATCH net-next 0/9] sctp: clean up sctp_sendmsg
Date: Thu, 01 Mar 2018 15:05:09 +0000 [thread overview]
Message-ID: <cover.1519916440.git.lucien.xin@gmail.com> (raw)
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:
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 980621e..d6803c8 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -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(-)
--
2.1.0
WARNING: multiple messages have this Message-ID (diff)
From: Xin Long <lucien.xin@gmail.com>
To: network dev <netdev@vger.kernel.org>, linux-sctp@vger.kernel.org
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Neil Horman <nhorman@tuxdriver.com>,
davem@davemloft.net
Subject: [PATCH net-next 0/9] sctp: clean up sctp_sendmsg
Date: Thu, 1 Mar 2018 23:05:09 +0800 [thread overview]
Message-ID: <cover.1519916440.git.lucien.xin@gmail.com> (raw)
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:
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 980621e..d6803c8 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -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(-)
--
2.1.0
next reply other threads:[~2018-03-01 15:05 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-01 15:05 Xin Long [this message]
2018-03-01 15:05 ` [PATCH net-next 0/9] sctp: clean up sctp_sendmsg Xin Long
2018-03-01 15:05 ` [PATCH net-next 1/9] sctp: factor out sctp_sendmsg_to_asoc from sctp_sendmsg Xin Long
2018-03-01 15:05 ` Xin Long
2018-03-01 15:05 ` [PATCH net-next 2/9] sctp: factor out sctp_sendmsg_new_asoc " Xin Long
2018-03-01 15:05 ` Xin Long
2018-03-01 15:05 ` [PATCH net-next 3/9] sctp: factor out sctp_sendmsg_check_sflags " Xin Long
2018-03-01 15:05 ` Xin Long
2018-03-01 15:05 ` [PATCH net-next 4/9] sctp: factor out sctp_sendmsg_get_daddr " Xin Long
2018-03-01 15:05 ` Xin Long
2018-03-01 15:05 ` [PATCH net-next 5/9] sctp: factor out sctp_sendmsg_parse " Xin Long
2018-03-01 15:05 ` Xin Long
2018-03-01 15:05 ` [PATCH net-next 6/9] sctp: factor out sctp_sendmsg_update_sinfo " Xin Long
2018-03-01 15:05 ` Xin Long
2018-03-01 15:05 ` [PATCH net-next 7/9] sctp: remove the unnecessary transport looking up " Xin Long
2018-03-01 15:05 ` Xin Long
2018-03-01 15:05 ` [PATCH net-next 8/9] sctp: improve some variables in sctp_sendmsg Xin Long
2018-03-01 15:05 ` Xin Long
2018-03-01 15:05 ` [PATCH net-next 9/9] sctp: adjust some codes in a better order " Xin Long
2018-03-01 15:05 ` Xin Long
2018-03-01 18:09 ` [PATCH net-next 0/9] sctp: clean up sctp_sendmsg Neil Horman
2018-03-01 18:09 ` Neil Horman
2018-03-01 18:34 ` Marcelo Ricardo Leitner
2018-03-01 18:34 ` Marcelo Ricardo Leitner
2018-03-04 18:02 ` David Miller
2018-03-04 18:02 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1519916440.git.lucien.xin@gmail.com \
--to=lucien.xin@gmail.com \
--cc=davem@davemloft.net \
--cc=linux-sctp@vger.kernel.org \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.