Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57816cbc authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'sctp-src-addr'



Marcelo Ricardo Leitner says:

====================
sctp: fix src address selection if using secondary address

This series improves the way SCTP chooses its src address so that the
choosen one will always belong to the interface being used for output.

v1->v2:
 - split out the refactoring from the fix itself
 - Doing a full reverse routing as in v1 is not necessary. Only looking
   for the interface that has the address and comparing its number is
   enough.
====================

Acked-by: default avatarVlad Yasevich <vyasevich@gmail.com>
Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 7177a3b0 0ca50d12
Loading
Loading
Loading
Loading
+27 −15
Original line number Diff line number Diff line
@@ -487,10 +487,14 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
	 */
	rcu_read_lock();
	list_for_each_entry_rcu(laddr, &bp->address_list, list) {
		struct net_device *odev;

		if (!laddr->valid)
			continue;
		if ((laddr->state == SCTP_ADDR_SRC) &&
		    (AF_INET == laddr->a.sa.sa_family)) {
		if (laddr->state != SCTP_ADDR_SRC ||
		    AF_INET != laddr->a.sa.sa_family)
			continue;

		fl4->fl4_sport = laddr->a.v4.sin_port;
		flowi4_update_output(fl4,
				     asoc->base.sk->sk_bound_dev_if,
@@ -499,11 +503,19 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
				     laddr->a.v4.sin_addr.s_addr);

		rt = ip_route_output_key(sock_net(sk), fl4);
			if (!IS_ERR(rt)) {
		if (IS_ERR(rt))
			continue;

		/* Ensure the src address belongs to the output
		 * interface.
		 */
		odev = __ip_dev_find(sock_net(sk), laddr->a.v4.sin_addr.s_addr,
				     false);
		if (!odev || odev->ifindex != fl4->flowi4_oif)
			continue;

		dst = &rt->dst;
				goto out_unlock;
			}
		}
		break;
	}

out_unlock: