All of lore.kernel.org
 help / color / mirror / Atom feed
* vrf saddr selection
@ 2015-08-29 23:40 David Miller
  2015-08-29 23:43 ` David Ahern
  0 siblings, 1 reply; 2+ messages in thread
From: David Miller @ 2015-08-29 23:40 UTC (permalink / raw)
  To: dsa; +Cc: netdev


In the output path we go:

	struct flowi4 fl4 = {
		/* needed to match OIF rule */
		.flowi4_oif = vrf_dev->ifindex,
		.flowi4_iif = LOOPBACK_IFINDEX,
		.flowi4_tos = RT_TOS(ip4h->tos),
		.flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_VRFSRC,
		.daddr = ip4h->daddr,
	};

	if (vrf_send_v4_prep(skb, &fl4, vrf_dev))
		goto err;

	if (!ip4h->saddr) {
		ip4h->saddr = inet_select_addr(skb_dst(skb)->dev, 0,
					       RT_SCOPE_LINK);
	}

So in the case where the source address is needed, this
inet_select_addr() call looks like useless work.

The route lookup already filled in fl4.saddr for you, why don't we
just use that?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: vrf saddr selection
  2015-08-29 23:40 vrf saddr selection David Miller
@ 2015-08-29 23:43 ` David Ahern
  0 siblings, 0 replies; 2+ messages in thread
From: David Ahern @ 2015-08-29 23:43 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Shrijeet Mukherjee

On 8/29/15 4:40 PM, David Miller wrote:
>
> In the output path we go:
>
> 	struct flowi4 fl4 = {
> 		/* needed to match OIF rule */
> 		.flowi4_oif = vrf_dev->ifindex,
> 		.flowi4_iif = LOOPBACK_IFINDEX,
> 		.flowi4_tos = RT_TOS(ip4h->tos),
> 		.flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_VRFSRC,
> 		.daddr = ip4h->daddr,
> 	};
>
> 	if (vrf_send_v4_prep(skb, &fl4, vrf_dev))
> 		goto err;
>
> 	if (!ip4h->saddr) {
> 		ip4h->saddr = inet_select_addr(skb_dst(skb)->dev, 0,
> 					       RT_SCOPE_LINK);
> 	}
>
> So in the case where the source address is needed, this
> inet_select_addr() call looks like useless work.
>
> The route lookup already filled in fl4.saddr for you, why don't we
> just use that?
>

We will. My intention is to remove the udp_sendmsg change and fill in 
the saddr in the VRF driver. In the process a fixed version of the above 
snippet is used.

David

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-29 23:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-29 23:40 vrf saddr selection David Miller
2015-08-29 23:43 ` David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.