summaryrefslogtreecommitdiffstats
path: root/net/sctp
diff options
context:
space:
mode:
authorXin Long <lucien.xin@gmail.com>2018-03-01 16:05:18 +0100
committerDavid S. Miller <davem@davemloft.net>2018-03-04 19:00:57 +0100
commit0a3920d28b5490e6c90110156135dbc12c7fc413 (patch)
tree7d239d32bbbc7dc99f06dd50f72ee67124536a08 /net/sctp
parentsctp: improve some variables in sctp_sendmsg (diff)
downloadlinux-0a3920d28b5490e6c90110156135dbc12c7fc413.tar.xz
linux-0a3920d28b5490e6c90110156135dbc12c7fc413.zip
sctp: adjust some codes in a better order in sctp_sendmsg
sctp_sendmsg_new_asoc and SCTP_ADDR_OVER check is only necessary when daddr is set, so move them up to if (daddr) statement. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r--net/sctp/socket.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index a1c78fc19d95..7fa76031bb08 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1936,38 +1936,38 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
lock_sock(sk);
- /* If a msg_name has been specified, assume this is to be used. */
+ /* Get and check or create asoc */
if (daddr) {
- /* Look for a matching association on the endpoint. */
asoc = sctp_endpoint_lookup_assoc(ep, daddr, &transport);
+ if (asoc) {
+ err = sctp_sendmsg_check_sflags(asoc, sflags, msg,
+ msg_len);
+ if (err <= 0)
+ goto out_unlock;
+ } else {
+ err = sctp_sendmsg_new_asoc(sk, sflags, &cmsgs, daddr,
+ &transport);
+ if (err)
+ goto out_unlock;
+
+ asoc = transport->asoc;
+ new = true;
+ }
+
+ if (!sctp_style(sk, TCP) && !(sflags & SCTP_ADDR_OVER))
+ transport = NULL;
} else {
asoc = sctp_id2assoc(sk, sinfo->sinfo_assoc_id);
if (!asoc) {
err = -EPIPE;
goto out_unlock;
}
- }
- if (asoc) {
err = sctp_sendmsg_check_sflags(asoc, sflags, msg, msg_len);
if (err <= 0)
goto out_unlock;
}
- /* Do we need to create the association? */
- if (!asoc) {
- err = sctp_sendmsg_new_asoc(sk, sflags, &cmsgs, daddr,
- &transport);
- if (err)
- goto out_unlock;
-
- asoc = transport->asoc;
- new = true;
- }
-
- if (!sctp_style(sk, TCP) && !(sflags & SCTP_ADDR_OVER))
- transport = NULL;
-
/* Update snd_info with the asoc */
sctp_sendmsg_update_sinfo(asoc, sinfo, &cmsgs);