Commit 6e91b578 authored by Marcelo Ricardo Leitner's avatar Marcelo Ricardo Leitner Committed by David S. Miller

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: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 22d7be26
...@@ -644,14 +644,13 @@ static int sctp_send_asconf_add_ip(struct sock *sk, ...@@ -644,14 +644,13 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
list_for_each_entry(trans, list_for_each_entry(trans,
&asoc->peer.transport_addr_list, transports) { &asoc->peer.transport_addr_list, transports) {
/* Clear the source and route cache */
sctp_transport_dst_release(trans);
trans->cwnd = min(4*asoc->pathmtu, max_t(__u32, trans->cwnd = min(4*asoc->pathmtu, max_t(__u32,
2*asoc->pathmtu, 4380)); 2*asoc->pathmtu, 4380));
trans->ssthresh = asoc->peer.i.a_rwnd; trans->ssthresh = asoc->peer.i.a_rwnd;
trans->rto = asoc->rto_initial; trans->rto = asoc->rto_initial;
sctp_max_rto(asoc, trans); sctp_max_rto(asoc, trans);
trans->rtt = trans->srtt = trans->rttvar = 0; trans->rtt = trans->srtt = trans->rttvar = 0;
/* Clear the source and route cache */
sctp_transport_route(trans, NULL, sctp_transport_route(trans, NULL,
sctp_sk(asoc->base.sk)); sctp_sk(asoc->base.sk));
} }
...@@ -896,7 +895,6 @@ static int sctp_send_asconf_del_ip(struct sock *sk, ...@@ -896,7 +895,6 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
*/ */
list_for_each_entry(transport, &asoc->peer.transport_addr_list, list_for_each_entry(transport, &asoc->peer.transport_addr_list,
transports) { transports) {
sctp_transport_dst_release(transport);
sctp_transport_route(transport, NULL, sctp_transport_route(transport, NULL,
sctp_sk(asoc->base.sk)); sctp_sk(asoc->base.sk));
} }
......
...@@ -242,6 +242,15 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk) ...@@ -242,6 +242,15 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk)
&transport->fl, 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) if (transport->dst)
transport->pathmtu = sctp_dst_mtu(transport->dst); transport->pathmtu = sctp_dst_mtu(transport->dst);
else else
...@@ -290,6 +299,7 @@ void sctp_transport_route(struct sctp_transport *transport, ...@@ -290,6 +299,7 @@ void sctp_transport_route(struct sctp_transport *transport,
struct sctp_association *asoc = transport->asoc; struct sctp_association *asoc = transport->asoc;
struct sctp_af *af = transport->af_specific; struct sctp_af *af = transport->af_specific;
sctp_transport_dst_release(transport);
af->get_dst(transport, saddr, &transport->fl, sctp_opt2sk(opt)); af->get_dst(transport, saddr, &transport->fl, sctp_opt2sk(opt));
if (saddr) if (saddr)
...@@ -297,25 +307,14 @@ void sctp_transport_route(struct sctp_transport *transport, ...@@ -297,25 +307,14 @@ void sctp_transport_route(struct sctp_transport *transport,
else else
af->get_saddr(opt, transport, &transport->fl); af->get_saddr(opt, transport, &transport->fl);
if ((transport->param_flags & SPP_PMTUD_DISABLE) && transport->pathmtu) { sctp_transport_pmtu(transport, sctp_opt2sk(opt));
return;
}
if (transport->dst) {
transport->pathmtu = SCTP_TRUNC4(dst_mtu(transport->dst));
/* Initialize sk->sk_rcv_saddr, if the transport is the /* Initialize sk->sk_rcv_saddr, if the transport is the
* association's active path for getsockname(). * association's active path for getsockname().
*/ */
if (asoc && (!asoc->peer.primary_path || if (transport->dst && asoc &&
(transport == asoc->peer.active_path))) (!asoc->peer.primary_path || transport == asoc->peer.active_path))
opt->pf->to_sk_saddr(&transport->saddr, opt->pf->to_sk_saddr(&transport->saddr, asoc->base.sk);
asoc->base.sk);
} else if ((transport->param_flags & SPP_PMTUD_DISABLE) &&
asoc && asoc->pathmtu) {
transport->pathmtu = asoc->pathmtu;
} else {
transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT;
}
} }
/* Hold a reference to a transport. */ /* Hold a reference to a transport. */
......
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