Skip to content

Commit

Permalink
sctp: update dst pmtu with the correct daddr
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
lxin authored and davem330 committed Sep 20, 2018
1 parent 8c6ec36 commit d7ab5cd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions net/sctp/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk)
bool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu)
{
struct dst_entry *dst = sctp_transport_dst_check(t);
struct sock *sk = t->asoc->base.sk;
bool change = true;

if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) {
Expand All @@ -271,12 +272,19 @@ bool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu)
pmtu = SCTP_TRUNC4(pmtu);

if (dst) {
dst->ops->update_pmtu(dst, t->asoc->base.sk, NULL, pmtu);
struct sctp_pf *pf = sctp_get_pf_specific(dst->ops->family);
union sctp_addr addr;

pf->af->from_sk(&addr, sk);
pf->to_sk_daddr(&t->ipaddr, sk);
dst->ops->update_pmtu(dst, sk, NULL, pmtu);
pf->to_sk_daddr(&addr, sk);

dst = sctp_transport_dst_check(t);
}

if (!dst) {
t->af_specific->get_dst(t, &t->saddr, &t->fl, t->asoc->base.sk);
t->af_specific->get_dst(t, &t->saddr, &t->fl, sk);
dst = t->dst;
}

Expand Down

0 comments on commit d7ab5cd

Please sign in to comment.