Commit 0a3920d2 authored by Xin Long's avatar Xin Long Committed by David S. Miller

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: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 007b7e18
...@@ -1936,26 +1936,15 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) ...@@ -1936,26 +1936,15 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
lock_sock(sk); lock_sock(sk);
/* If a msg_name has been specified, assume this is to be used. */ /* Get and check or create asoc */
if (daddr) { if (daddr) {
/* Look for a matching association on the endpoint. */
asoc = sctp_endpoint_lookup_assoc(ep, daddr, &transport); asoc = sctp_endpoint_lookup_assoc(ep, daddr, &transport);
} else {
asoc = sctp_id2assoc(sk, sinfo->sinfo_assoc_id);
if (!asoc) {
err = -EPIPE;
goto out_unlock;
}
}
if (asoc) { if (asoc) {
err = sctp_sendmsg_check_sflags(asoc, sflags, msg, msg_len); err = sctp_sendmsg_check_sflags(asoc, sflags, msg,
msg_len);
if (err <= 0) if (err <= 0)
goto out_unlock; goto out_unlock;
} } else {
/* Do we need to create the association? */
if (!asoc) {
err = sctp_sendmsg_new_asoc(sk, sflags, &cmsgs, daddr, err = sctp_sendmsg_new_asoc(sk, sflags, &cmsgs, daddr,
&transport); &transport);
if (err) if (err)
...@@ -1967,6 +1956,17 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) ...@@ -1967,6 +1956,17 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
if (!sctp_style(sk, TCP) && !(sflags & SCTP_ADDR_OVER)) if (!sctp_style(sk, TCP) && !(sflags & SCTP_ADDR_OVER))
transport = NULL; transport = NULL;
} else {
asoc = sctp_id2assoc(sk, sinfo->sinfo_assoc_id);
if (!asoc) {
err = -EPIPE;
goto out_unlock;
}
err = sctp_sendmsg_check_sflags(asoc, sflags, msg, msg_len);
if (err <= 0)
goto out_unlock;
}
/* Update snd_info with the asoc */ /* Update snd_info with the asoc */
sctp_sendmsg_update_sinfo(asoc, sinfo, &cmsgs); sctp_sendmsg_update_sinfo(asoc, sinfo, &cmsgs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment