Skip to content

Commit

Permalink
sctp: factor out sctp_sendmsg_update_sinfo from sctp_sendmsg
Browse files Browse the repository at this point in the history
This patch is to move the codes for trying to get sinfo from
asoc into sctp_sendmsg_update_sinfo.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Xin Long authored and David S. Miller committed Mar 4, 2018
1 parent 204f817 commit d42cb06
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,21 @@ static union sctp_addr *sctp_sendmsg_get_daddr(struct sock *sk,
return daddr;
}

static void sctp_sendmsg_update_sinfo(struct sctp_association *asoc,
struct sctp_sndrcvinfo *sinfo,
struct sctp_cmsgs *cmsgs)
{
if (!cmsgs->srinfo && !cmsgs->sinfo) {
sinfo->sinfo_stream = asoc->default_stream;
sinfo->sinfo_ppid = asoc->default_ppid;
sinfo->sinfo_context = asoc->default_context;
sinfo->sinfo_assoc_id = sctp_assoc2id(asoc);
}

if (!cmsgs->srinfo)
sinfo->sinfo_timetolive = asoc->default_timetolive;
}

static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
{
struct sctp_endpoint *ep = sctp_sk(sk)->ep;
Expand Down Expand Up @@ -1951,15 +1966,8 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
new_asoc = asoc;
}

if (!cmsgs.srinfo && !cmsgs.sinfo) {
sinfo->sinfo_stream = asoc->default_stream;
sinfo->sinfo_ppid = asoc->default_ppid;
sinfo->sinfo_context = asoc->default_context;
sinfo->sinfo_assoc_id = sctp_assoc2id(asoc);
}

if (!cmsgs.srinfo)
sinfo->sinfo_timetolive = asoc->default_timetolive;
/* Update snd_info with the asoc */
sctp_sendmsg_update_sinfo(asoc, sinfo, &cmsgs);

/* If an address is passed with the sendto/sendmsg call, it is used
* to override the primary destination address in the TCP model, or
Expand Down

0 comments on commit d42cb06

Please sign in to comment.