Skip to content

Commit 410f038

Browse files
marceloleitnerdavem330
authored andcommitted
sctp: add routing output fallback
Commit 0ca50d1 added a restriction that the address must belong to the output interface, so that sctp will use the right interface even when using secondary addresses. But it breaks IPVS setups, on which people is used to attach VIP addresses to loopback interface on real servers. It's preferred to attach to the interface actually in use, but it's a very common setup and that used to work. This patch then saves the first routing good result, even if it would be going out through an interface that doesn't have that address. If no better hit found, it's then used. This effectively restores the original behavior if no better interface could be found. Fixes: 0ca50d1 ("sctp: fix src address selection if using secondary addresses") Signed-off-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d82f0f1 commit 410f038

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

net/sctp/protocol.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,16 +506,22 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
506506
if (IS_ERR(rt))
507507
continue;
508508

509+
if (!dst)
510+
dst = &rt->dst;
511+
509512
/* Ensure the src address belongs to the output
510513
* interface.
511514
*/
512515
odev = __ip_dev_find(sock_net(sk), laddr->a.v4.sin_addr.s_addr,
513516
false);
514517
if (!odev || odev->ifindex != fl4->flowi4_oif) {
515-
dst_release(&rt->dst);
518+
if (&rt->dst != dst)
519+
dst_release(&rt->dst);
516520
continue;
517521
}
518522

523+
if (dst != &rt->dst)
524+
dst_release(dst);
519525
dst = &rt->dst;
520526
break;
521527
}

0 commit comments

Comments
 (0)