Skip to content

Commit d63d399

Browse files
lxingregkh
authored andcommitted
sctp: update dst pmtu with the correct daddr
[ Upstream commit d7ab5cd ] When processing pmtu update from an icmp packet, it calls .update_pmtu with sk instead of skb in sctp_transport_update_pmtu. However for sctp, the daddr in the transport might be different from inet_sock->inet_daddr or sk->sk_v6_daddr, which is used to update or create the route cache. The incorrect daddr will cause a different route cache created for the path. So before calling .update_pmtu, inet_sock->inet_daddr/sk->sk_v6_daddr should be updated with the daddr in the transport, and update it back after it's done. The issue has existed since route exceptions introduction. Fixes: 4895c77 ("ipv4: Add FIB nexthop exceptions.") Reported-by: [email protected] Signed-off-by: Xin Long <[email protected]> Acked-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a8b0f00 commit d63d399

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

net/sctp/transport.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk)
254254
bool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu)
255255
{
256256
struct dst_entry *dst = sctp_transport_dst_check(t);
257+
struct sock *sk = t->asoc->base.sk;
257258
bool change = true;
258259

259260
if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) {
@@ -265,12 +266,19 @@ bool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu)
265266
pmtu = SCTP_TRUNC4(pmtu);
266267

267268
if (dst) {
268-
dst->ops->update_pmtu(dst, t->asoc->base.sk, NULL, pmtu);
269+
struct sctp_pf *pf = sctp_get_pf_specific(dst->ops->family);
270+
union sctp_addr addr;
271+
272+
pf->af->from_sk(&addr, sk);
273+
pf->to_sk_daddr(&t->ipaddr, sk);
274+
dst->ops->update_pmtu(dst, sk, NULL, pmtu);
275+
pf->to_sk_daddr(&addr, sk);
276+
269277
dst = sctp_transport_dst_check(t);
270278
}
271279

272280
if (!dst) {
273-
t->af_specific->get_dst(t, &t->saddr, &t->fl, t->asoc->base.sk);
281+
t->af_specific->get_dst(t, &t->saddr, &t->fl, sk);
274282
dst = t->dst;
275283
}
276284

0 commit comments

Comments
 (0)