netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipv4: Restore accept_local behaviour in fib_validate_source()
@ 2014-08-14 12:45 Sébastien Barré
  2014-08-14 13:36 ` Hannes Frederic Sowa
  2014-08-14 13:51 ` Sergei Shtylyov
  0 siblings, 2 replies; 3+ messages in thread
From: Sébastien Barré @ 2014-08-14 12:45 UTC (permalink / raw)
  To: David Miller; +Cc: Sébastien Barré, netdev, Gregory Detal

Commit 7a9bc9b introduced a short-circuit to avoid calling
fib_validate_source when not needed. That change took rp_filter
into account, but not accept_local. This resulted in a change
of behaviour: with rp_filter and accept_local off, incoming
packets with a local address in the source field should be
dropped.

Here is how to reproduce the change pre/post 7a9bc9b commit:
-configure the same IPv4 address on hosts A and B.
-try to send an arp request from B to A.
-The arp request will be dropped before commit 7a9bc9b,
but accepted and answered after that commit.

This adds a check for ACCEPT_LOCAL, to maintain full
fib validation in case it is 0.

Signed-off-by: Sébastien Barré <sebastien.barre@uclouvain.be>

---
 net/ipv4/fib_frontend.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 255aa99..fa1fb2d 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -321,6 +321,7 @@ int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
 	int r = secpath_exists(skb) ? 0 : IN_DEV_RPFILTER(idev);
 
 	if (!r && !fib_num_tclassid_users(dev_net(dev)) &&
+	    IN_DEV_ACCEPT_LOCAL(idev) &&
 	    (dev->ifindex != oif || !IN_DEV_TX_REDIRECTS(idev))) {
 		*itag = 0;
 		return 0;
-- 
tg: (f0094b2..) net-next/accept_local-fib_validate_source (depends on: net-next/master)

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

* Re: [PATCH] ipv4: Restore accept_local behaviour in fib_validate_source()
  2014-08-14 12:45 [PATCH] ipv4: Restore accept_local behaviour in fib_validate_source() Sébastien Barré
@ 2014-08-14 13:36 ` Hannes Frederic Sowa
  2014-08-14 13:51 ` Sergei Shtylyov
  1 sibling, 0 replies; 3+ messages in thread
From: Hannes Frederic Sowa @ 2014-08-14 13:36 UTC (permalink / raw)
  To: Sébastien Barré; +Cc: David Miller, netdev, Gregory Detal

On Do, 2014-08-14 at 14:45 +0200, Sébastien Barré wrote:
> Commit 7a9bc9b introduced a short-circuit to avoid calling
> fib_validate_source when not needed. That change took rp_filter
> into account, but not accept_local. This resulted in a change
> of behaviour: with rp_filter and accept_local off, incoming
> packets with a local address in the source field should be
> dropped.
> 
> Here is how to reproduce the change pre/post 7a9bc9b commit:
> -configure the same IPv4 address on hosts A and B.
> -try to send an arp request from B to A.
> -The arp request will be dropped before commit 7a9bc9b,
> but accepted and answered after that commit.
> 
> This adds a check for ACCEPT_LOCAL, to maintain full
> fib validation in case it is 0.
> 
> Signed-off-by: Sébastien Barré <sebastien.barre@uclouvain.be>
> 
> ---
>  net/ipv4/fib_frontend.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
> index 255aa99..fa1fb2d 100644
> --- a/net/ipv4/fib_frontend.c
> +++ b/net/ipv4/fib_frontend.c
> @@ -321,6 +321,7 @@ int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
>  	int r = secpath_exists(skb) ? 0 : IN_DEV_RPFILTER(idev);
>  
>  	if (!r && !fib_num_tclassid_users(dev_net(dev)) &&
> +	    IN_DEV_ACCEPT_LOCAL(idev) &&
>  	    (dev->ifindex != oif || !IN_DEV_TX_REDIRECTS(idev))) {
>  		*itag = 0;
>  		return 0;

But fib_validate_check is too strict for this situation. In case
rp_filter and accept_local are disabled, you should also leave
__fib_validate_source directly after the RTN_UNICAST checks.

Bye,
Hannes

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

* Re: [PATCH] ipv4: Restore accept_local behaviour in fib_validate_source()
  2014-08-14 12:45 [PATCH] ipv4: Restore accept_local behaviour in fib_validate_source() Sébastien Barré
  2014-08-14 13:36 ` Hannes Frederic Sowa
@ 2014-08-14 13:51 ` Sergei Shtylyov
  1 sibling, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2014-08-14 13:51 UTC (permalink / raw)
  To: Sébastien Barré, David Miller; +Cc: netdev, Gregory Detal

Hello.

On 08/14/2014 04:45 PM, Sébastien Barré wrote:

> Commit 7a9bc9b introduced a short-circuit to avoid calling

    Please also specify that commit's summary line in parens.

> fib_validate_source when not needed. That change took rp_filter
> into account, but not accept_local. This resulted in a change
> of behaviour: with rp_filter and accept_local off, incoming
> packets with a local address in the source field should be
> dropped.

> Here is how to reproduce the change pre/post 7a9bc9b commit:
> -configure the same IPv4 address on hosts A and B.
> -try to send an arp request from B to A.
> -The arp request will be dropped before commit 7a9bc9b,

    s/arp/ARP/?

> but accepted and answered after that commit.

> This adds a check for ACCEPT_LOCAL, to maintain full
> fib validation in case it is 0.

> Signed-off-by: Sébastien Barré <sebastien.barre@uclouvain.be>

WBR, Sergei

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

end of thread, other threads:[~2014-08-14 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-14 12:45 [PATCH] ipv4: Restore accept_local behaviour in fib_validate_source() Sébastien Barré
2014-08-14 13:36 ` Hannes Frederic Sowa
2014-08-14 13:51 ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).