All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: netfilter: Fix ipv6 rp_filter dropping vrf packets by mistake
@ 2019-04-24  7:27 linmiaohe
  2019-04-24  8:02 ` Florian Westphal
  0 siblings, 1 reply; 3+ messages in thread
From: linmiaohe @ 2019-04-24  7:27 UTC (permalink / raw)
  To: pablo, kadlec, fw, davem, kuznet, yoshfuji, netfilter-devel,
	coreteam, netdev, linux-kernel
  Cc: Mingfangsen

From: Miaohe Lin <linmiaohe@huawei.com>

When firewall is enabled with rp_filter, vrf ipv6 packets
will be dropped because in device is vrf but out device
is an enslaved device. So rt->rt6i_idev->dev != dev and
maybe return false in func rpfilter_lookup_reverse6.

Here is the out message when I ping the peer:
ip vrf exec vrf1 ping 2013::2 -c 1
1 packets transmitted, 0 received, 100% packet loss, time 0ms

The drop info in /var/log/message:
Apr 24 14:59:45 localhost kernel: [81316.158259] rpfilter_DROP: IN=vrf1
OUT= MAC=52:54:00:9e:dd:c1:52:54:00:4f:81:38:86:dd
SRC=2013:0000:0000:0000:0000:0000:0000:0002
DST=2013:0000:0000:0000:0000:0000:0000:0001 LEN=104 TC=0 HOPLIMIT=64
FLOWLBL=1032942 PROTO=ICMPv6 TYPE=129 CODE=0 ID=14943 SEQ=1

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 net/ipv6/netfilter/ip6t_rpfilter.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c
index c3c6b09acdc4..5cbc91f53736 100644
--- a/net/ipv6/netfilter/ip6t_rpfilter.c
+++ b/net/ipv6/netfilter/ip6t_rpfilter.c
@@ -73,6 +73,12 @@ static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb,
 		goto out;
 	}

+	if (netif_is_l3_master(dev)) {
+		dev = __dev_get_by_index(dev_net(dev), IP6CB(skb)->iif);
+		if (!dev)
+			goto out;
+	}
+
 	if (rt->rt6i_idev->dev == dev || (flags & XT_RPFILTER_LOOSE))
 		ret = true;
  out:
-- 
2.19.1



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

* Re: [PATCH] net: netfilter: Fix ipv6 rp_filter dropping vrf packets by mistake
  2019-04-24  7:27 [PATCH] net: netfilter: Fix ipv6 rp_filter dropping vrf packets by mistake linmiaohe
@ 2019-04-24  8:02 ` Florian Westphal
  2019-04-24  9:11   ` linmiaohe
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2019-04-24  8:02 UTC (permalink / raw)
  To: linmiaohe
  Cc: pablo, kadlec, dsahern, davem, yoshfuji, netfilter-devel, netdev,
	linux-kernel, Mingfangsen

linmiaohe <linmiaohe@huawei.com> wrote:

[ CC dsa, dropped some CCs ]

> When firewall is enabled with rp_filter, vrf ipv6 packets
> will be dropped because in device is vrf but out device
> is an enslaved device. So rt->rt6i_idev->dev != dev and
> maybe return false in func rpfilter_lookup_reverse6.
> 
> Here is the out message when I ping the peer:
> ip vrf exec vrf1 ping 2013::2 -c 1
> 1 packets transmitted, 0 received, 100% packet loss, time 0ms
> 
> The drop info in /var/log/message:
> Apr 24 14:59:45 localhost kernel: [81316.158259] rpfilter_DROP: IN=vrf1
> OUT= MAC=52:54:00:9e:dd:c1:52:54:00:4f:81:38:86:dd
> SRC=2013:0000:0000:0000:0000:0000:0000:0002
> DST=2013:0000:0000:0000:0000:0000:0000:0001 LEN=104 TC=0 HOPLIMIT=64
> FLOWLBL=1032942 PROTO=ICMPv6 TYPE=129 CODE=0 ID=14943 SEQ=1
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  net/ipv6/netfilter/ip6t_rpfilter.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c
> index c3c6b09acdc4..5cbc91f53736 100644
> --- a/net/ipv6/netfilter/ip6t_rpfilter.c
> +++ b/net/ipv6/netfilter/ip6t_rpfilter.c
> @@ -73,6 +73,12 @@ static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb,
>  		goto out;
>  	}
> 
> +	if (netif_is_l3_master(dev)) {
> +		dev = __dev_get_by_index(dev_net(dev), IP6CB(skb)->iif);
> +		if (!dev)
> +			goto out;

I suspect this should be 'dev_get_by_index_rcu'.

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

* Re: [PATCH] net: netfilter: Fix ipv6 rp_filter dropping vrf packets by mistake
  2019-04-24  8:02 ` Florian Westphal
@ 2019-04-24  9:11   ` linmiaohe
  0 siblings, 0 replies; 3+ messages in thread
From: linmiaohe @ 2019-04-24  9:11 UTC (permalink / raw)
  To: Florian Westphal
  Cc: pablo, kadlec, dsahern, davem, yoshfuji, netfilter-devel, netdev,
	linux-kernel, Mingfangsen



On 2019/4/24 16:02, Florian Westphal wrote:
> linmiaohe <linmiaohe@huawei.com> wrote:
> 
> [ CC dsa, dropped some CCs ]
> 
>> When firewall is enabled with rp_filter, vrf ipv6 packets
>> will be dropped because in device is vrf but out device
>> is an enslaved device. So rt->rt6i_idev->dev != dev and
>> maybe return false in func rpfilter_lookup_reverse6.
>>
>> Here is the out message when I ping the peer:
>> ip vrf exec vrf1 ping 2013::2 -c 1
>> 1 packets transmitted, 0 received, 100% packet loss, time 0ms
>>
>> The drop info in /var/log/message:
>> Apr 24 14:59:45 localhost kernel: [81316.158259] rpfilter_DROP: IN=vrf1
>> OUT= MAC=52:54:00:9e:dd:c1:52:54:00:4f:81:38:86:dd
>> SRC=2013:0000:0000:0000:0000:0000:0000:0002
>> DST=2013:0000:0000:0000:0000:0000:0000:0001 LEN=104 TC=0 HOPLIMIT=64
>> FLOWLBL=1032942 PROTO=ICMPv6 TYPE=129 CODE=0 ID=14943 SEQ=1
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>  net/ipv6/netfilter/ip6t_rpfilter.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c
>> index c3c6b09acdc4..5cbc91f53736 100644
>> --- a/net/ipv6/netfilter/ip6t_rpfilter.c
>> +++ b/net/ipv6/netfilter/ip6t_rpfilter.c
>> @@ -73,6 +73,12 @@ static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb,
>>  		goto out;
>>  	}
>>
>> +	if (netif_is_l3_master(dev)) {
>> +		dev = __dev_get_by_index(dev_net(dev), IP6CB(skb)->iif);
>> +		if (!dev)
>> +			goto out;
> 
> I suspect this should be 'dev_get_by_index_rcu'.
> 
> .
> 
You are right, it's my mistake.Thanks for your remind.I will send v2
to fix this. Thanks.


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

end of thread, other threads:[~2019-04-24  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24  7:27 [PATCH] net: netfilter: Fix ipv6 rp_filter dropping vrf packets by mistake linmiaohe
2019-04-24  8:02 ` Florian Westphal
2019-04-24  9:11   ` linmiaohe

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.