Skip to content

Commit 6e91b57

Browse files
marceloleitnerdavem330
authored andcommitted
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>
1 parent 22d7be2 commit 6e91b57

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

net/sctp/socket.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,16 +644,15 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
644644

645645
list_for_each_entry(trans,
646646
&asoc->peer.transport_addr_list, transports) {
647-
/* Clear the source and route cache */
648-
sctp_transport_dst_release(trans);
649647
trans->cwnd = min(4*asoc->pathmtu, max_t(__u32,
650648
2*asoc->pathmtu, 4380));
651649
trans->ssthresh = asoc->peer.i.a_rwnd;
652650
trans->rto = asoc->rto_initial;
653651
sctp_max_rto(asoc, trans);
654652
trans->rtt = trans->srtt = trans->rttvar = 0;
653+
/* Clear the source and route cache */
655654
sctp_transport_route(trans, NULL,
656-
sctp_sk(asoc->base.sk));
655+
sctp_sk(asoc->base.sk));
657656
}
658657
}
659658
retval = sctp_send_asconf(asoc, chunk);
@@ -896,7 +895,6 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
896895
*/
897896
list_for_each_entry(transport, &asoc->peer.transport_addr_list,
898897
transports) {
899-
sctp_transport_dst_release(transport);
900898
sctp_transport_route(transport, NULL,
901899
sctp_sk(asoc->base.sk));
902900
}

net/sctp/transport.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,15 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk)
242242
&transport->fl, sk);
243243
}
244244

245+
if (transport->param_flags & SPP_PMTUD_DISABLE) {
246+
struct sctp_association *asoc = transport->asoc;
247+
248+
if (!transport->pathmtu && asoc && asoc->pathmtu)
249+
transport->pathmtu = asoc->pathmtu;
250+
if (transport->pathmtu)
251+
return;
252+
}
253+
245254
if (transport->dst)
246255
transport->pathmtu = sctp_dst_mtu(transport->dst);
247256
else
@@ -290,32 +299,22 @@ void sctp_transport_route(struct sctp_transport *transport,
290299
struct sctp_association *asoc = transport->asoc;
291300
struct sctp_af *af = transport->af_specific;
292301

302+
sctp_transport_dst_release(transport);
293303
af->get_dst(transport, saddr, &transport->fl, sctp_opt2sk(opt));
294304

295305
if (saddr)
296306
memcpy(&transport->saddr, saddr, sizeof(union sctp_addr));
297307
else
298308
af->get_saddr(opt, transport, &transport->fl);
299309

300-
if ((transport->param_flags & SPP_PMTUD_DISABLE) && transport->pathmtu) {
301-
return;
302-
}
303-
if (transport->dst) {
304-
transport->pathmtu = SCTP_TRUNC4(dst_mtu(transport->dst));
310+
sctp_transport_pmtu(transport, sctp_opt2sk(opt));
305311

306-
/* Initialize sk->sk_rcv_saddr, if the transport is the
307-
* association's active path for getsockname().
308-
*/
309-
if (asoc && (!asoc->peer.primary_path ||
310-
(transport == asoc->peer.active_path)))
311-
opt->pf->to_sk_saddr(&transport->saddr,
312-
asoc->base.sk);
313-
} else if ((transport->param_flags & SPP_PMTUD_DISABLE) &&
314-
asoc && asoc->pathmtu) {
315-
transport->pathmtu = asoc->pathmtu;
316-
} else {
317-
transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT;
318-
}
312+
/* Initialize sk->sk_rcv_saddr, if the transport is the
313+
* association's active path for getsockname().
314+
*/
315+
if (transport->dst && asoc &&
316+
(!asoc->peer.primary_path || transport == asoc->peer.active_path))
317+
opt->pf->to_sk_saddr(&transport->saddr, asoc->base.sk);
319318
}
320319

321320
/* Hold a reference to a transport. */

0 commit comments

Comments
 (0)