diff options
author | Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> | 2018-04-26 22:58:59 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-04-27 21:35:23 +0300 |
commit | 6e91b578bf3f9e19c250835cba97a4be38ffcb31 (patch) | |
tree | 9985910ee8df0b0e20cefbf64aa9881132f202ab /net/sctp/transport.c | |
parent | 22d7be267eaa8114dcc28d66c1c347f667d7878a (diff) | |
download | linux-6e91b578bf3f9e19c250835cba97a4be38ffcb31.tar.xz |
sctp: re-use sctp_transport_pmtu in sctp_transport_route
sctp_transport_route currently is very similar to sctp_transport_pmtu plus
a few other bits.
This patch reuses sctp_transport_pmtu in sctp_transport_route and removes
the duplicated code.
Also, as all calls to sctp_transport_route were forcing the dst release
before calling it, let's just include such release too.
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/transport.c')
-rw-r--r-- | net/sctp/transport.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/net/sctp/transport.c b/net/sctp/transport.c index ed73a9d91b83..4a95e260b674 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c @@ -242,6 +242,15 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk) &transport->fl, sk); } + if (transport->param_flags & SPP_PMTUD_DISABLE) { + struct sctp_association *asoc = transport->asoc; + + if (!transport->pathmtu && asoc && asoc->pathmtu) + transport->pathmtu = asoc->pathmtu; + if (transport->pathmtu) + return; + } + if (transport->dst) transport->pathmtu = sctp_dst_mtu(transport->dst); else @@ -290,6 +299,7 @@ void sctp_transport_route(struct sctp_transport *transport, struct sctp_association *asoc = transport->asoc; struct sctp_af *af = transport->af_specific; + sctp_transport_dst_release(transport); af->get_dst(transport, saddr, &transport->fl, sctp_opt2sk(opt)); if (saddr) @@ -297,25 +307,14 @@ void sctp_transport_route(struct sctp_transport *transport, else af->get_saddr(opt, transport, &transport->fl); - if ((transport->param_flags & SPP_PMTUD_DISABLE) && transport->pathmtu) { - return; - } - if (transport->dst) { - transport->pathmtu = SCTP_TRUNC4(dst_mtu(transport->dst)); + sctp_transport_pmtu(transport, sctp_opt2sk(opt)); - /* Initialize sk->sk_rcv_saddr, if the transport is the - * association's active path for getsockname(). - */ - if (asoc && (!asoc->peer.primary_path || - (transport == asoc->peer.active_path))) - opt->pf->to_sk_saddr(&transport->saddr, - asoc->base.sk); - } else if ((transport->param_flags & SPP_PMTUD_DISABLE) && - asoc && asoc->pathmtu) { - transport->pathmtu = asoc->pathmtu; - } else { - transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT; - } + /* Initialize sk->sk_rcv_saddr, if the transport is the + * association's active path for getsockname(). + */ + if (transport->dst && asoc && + (!asoc->peer.primary_path || transport == asoc->peer.active_path)) + opt->pf->to_sk_saddr(&transport->saddr, asoc->base.sk); } /* Hold a reference to a transport. */ |