Commit ecf938fe authored by Xin Long's avatar Xin Long Committed by David S. Miller

sctp: set flow sport from saddr only when it's 0

Now sctp_transport_pmtu() passes transport->saddr into .get_dst() to set
flow sport from 'saddr'. However, transport->saddr is set only when
transport->dst exists in sctp_transport_route().

If sctp_transport_pmtu() is called without transport->saddr set, like
when transport->dst doesn't exists, the flow sport will be set to 0
from transport->saddr, which will cause a wrong route to be got.

Commit 6e91b578 ("sctp: re-use sctp_transport_pmtu in
sctp_transport_route") made the issue be triggered more easily
since sctp_transport_pmtu() would be called in sctp_transport_route()
after that.

In gerneral, fl4->fl4_sport should always be set to
htons(asoc->base.bind_addr.port), unless transport->asoc doesn't exist
in sctp_v4/6_get_dst(), which is the case:

  sctp_ootb_pkt_new() ->
    sctp_transport_route()

For that, we can simply handle it by setting flow sport from saddr only
when it's 0 in sctp_v4/6_get_dst().

Fixes: 6e91b578 ("sctp: re-use sctp_transport_pmtu in sctp_transport_route")
Reported-by: default avatarYing Xu <yinxu@redhat.com>
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4ff40b86
...@@ -280,6 +280,7 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr, ...@@ -280,6 +280,7 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
if (saddr) { if (saddr) {
fl6->saddr = saddr->v6.sin6_addr; fl6->saddr = saddr->v6.sin6_addr;
if (!fl6->fl6_sport)
fl6->fl6_sport = saddr->v6.sin6_port; fl6->fl6_sport = saddr->v6.sin6_port;
pr_debug("src=%pI6 - ", &fl6->saddr); pr_debug("src=%pI6 - ", &fl6->saddr);
......
...@@ -440,6 +440,7 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr, ...@@ -440,6 +440,7 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
} }
if (saddr) { if (saddr) {
fl4->saddr = saddr->v4.sin_addr.s_addr; fl4->saddr = saddr->v4.sin_addr.s_addr;
if (!fl4->fl4_sport)
fl4->fl4_sport = saddr->v4.sin_port; fl4->fl4_sport = saddr->v4.sin_port;
} }
......
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