Commit 007b7e18 authored by Xin Long's avatar Xin Long Committed by David S. Miller

sctp: improve some variables in sctp_sendmsg

This patch mostly is to:

  - rename sinfo_flags as sflags, to make the indents look better, and
    also keep consistent with other sctp_sendmsg_xx functions.

  - replace new_asoc with bool new, no need to define a pointer here,
    as if new_asoc is set, it must be asoc.

  - rename the 'out_nounlock:' as 'out', shorter and nicer.

  - remove associd, only one place is using it now, just use
    sinfo->sinfo_assoc_id directly.

  - remove 'cmsgs' initialization in sctp_sendmsg, as it will be done
    in sctp_sendmsg_parse.
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8e87c6eb
...@@ -1910,28 +1910,28 @@ static void sctp_sendmsg_update_sinfo(struct sctp_association *asoc, ...@@ -1910,28 +1910,28 @@ static void sctp_sendmsg_update_sinfo(struct sctp_association *asoc,
static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
{ {
struct sctp_endpoint *ep = sctp_sk(sk)->ep; struct sctp_endpoint *ep = sctp_sk(sk)->ep;
struct sctp_association *new_asoc = NULL, *asoc = NULL;
struct sctp_transport *transport = NULL; struct sctp_transport *transport = NULL;
struct sctp_sndrcvinfo _sinfo, *sinfo; struct sctp_sndrcvinfo _sinfo, *sinfo;
sctp_assoc_t associd = 0; struct sctp_association *asoc;
struct sctp_cmsgs cmsgs = { NULL }; struct sctp_cmsgs cmsgs;
__u16 sinfo_flags = 0;
union sctp_addr *daddr; union sctp_addr *daddr;
bool new = false;
__u16 sflags;
int err; int err;
/* Parse and get snd_info */ /* Parse and get snd_info */
err = sctp_sendmsg_parse(sk, &cmsgs, &_sinfo, msg, msg_len); err = sctp_sendmsg_parse(sk, &cmsgs, &_sinfo, msg, msg_len);
if (err) if (err)
goto out_nounlock; goto out;
sinfo = &_sinfo; sinfo = &_sinfo;
sinfo_flags = sinfo->sinfo_flags; sflags = sinfo->sinfo_flags;
/* Get daddr from msg */ /* Get daddr from msg */
daddr = sctp_sendmsg_get_daddr(sk, msg, &cmsgs); daddr = sctp_sendmsg_get_daddr(sk, msg, &cmsgs);
if (IS_ERR(daddr)) { if (IS_ERR(daddr)) {
err = PTR_ERR(daddr); err = PTR_ERR(daddr);
goto out_nounlock; goto out;
} }
lock_sock(sk); lock_sock(sk);
...@@ -1941,7 +1941,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) ...@@ -1941,7 +1941,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
/* Look for a matching association on the endpoint. */ /* 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 { } else {
asoc = sctp_id2assoc(sk, associd); asoc = sctp_id2assoc(sk, sinfo->sinfo_assoc_id);
if (!asoc) { if (!asoc) {
err = -EPIPE; err = -EPIPE;
goto out_unlock; goto out_unlock;
...@@ -1949,24 +1949,23 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) ...@@ -1949,24 +1949,23 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
} }
if (asoc) { if (asoc) {
err = sctp_sendmsg_check_sflags(asoc, sinfo_flags, msg, err = sctp_sendmsg_check_sflags(asoc, sflags, msg, msg_len);
msg_len);
if (err <= 0) if (err <= 0)
goto out_unlock; goto out_unlock;
} }
/* Do we need to create the association? */ /* Do we need to create the association? */
if (!asoc) { if (!asoc) {
err = sctp_sendmsg_new_asoc(sk, sinfo_flags, &cmsgs, daddr, err = sctp_sendmsg_new_asoc(sk, sflags, &cmsgs, daddr,
&transport); &transport);
if (err) if (err)
goto out_unlock; goto out_unlock;
asoc = transport->asoc; asoc = transport->asoc;
new_asoc = asoc; new = true;
} }
if (!sctp_style(sk, TCP) && !(sinfo_flags & SCTP_ADDR_OVER)) if (!sctp_style(sk, TCP) && !(sflags & SCTP_ADDR_OVER))
transport = NULL; transport = NULL;
/* Update snd_info with the asoc */ /* Update snd_info with the asoc */
...@@ -1974,12 +1973,12 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) ...@@ -1974,12 +1973,12 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
/* Send msg to the asoc */ /* Send msg to the asoc */
err = sctp_sendmsg_to_asoc(asoc, msg, msg_len, transport, sinfo); err = sctp_sendmsg_to_asoc(asoc, msg, msg_len, transport, sinfo);
if (err < 0 && err != -ESRCH && new_asoc) if (err < 0 && err != -ESRCH && new)
sctp_association_free(asoc); sctp_association_free(asoc);
out_unlock: out_unlock:
release_sock(sk); release_sock(sk);
out_nounlock: out:
return sctp_error(sk, msg->msg_flags, err); return sctp_error(sk, msg->msg_flags, err);
} }
......
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