* [PATCH] netfilter: rpfilter: skip locally generated bcast, too
@ 2013-04-12 20:51 Florian Westphal
2013-04-16 16:55 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2013-04-12 20:51 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
Alex Efros reported rpfilter module doesn't match following packets:
IN=br.qemu SRC=192.168.2.1 DST=192.168.2.255 [ .. ]
(netfilter bugzilla #814).
Problem is that network stack arranges for the locally generated broadcasts
to appear on the interface they were sent out, so the IFF_LOOPBACK check
doesn't trigger.
As -m rpfilter is restricted to PREROUTING, we can check for existing
skb_dst instead, it catches locally-generated broad/multicast case, too.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/ipv4/netfilter/ipt_rpfilter.c | 2 +-
net/ipv6/netfilter/ip6t_rpfilter.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c
index c301300..601abf2 100644
--- a/net/ipv4/netfilter/ipt_rpfilter.c
+++ b/net/ipv4/netfilter/ipt_rpfilter.c
@@ -76,7 +76,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
info = par->matchinfo;
invert = info->flags & XT_RPFILTER_INVERT;
- if (par->in->flags & IFF_LOOPBACK)
+ if (skb_dst(skb)) /* locally generated? */
return true ^ invert;
iph = ip_hdr(skb);
diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c
index 5060d54..8767991 100644
--- a/net/ipv6/netfilter/ip6t_rpfilter.c
+++ b/net/ipv6/netfilter/ip6t_rpfilter.c
@@ -78,7 +78,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
struct ipv6hdr *iph;
bool invert = info->flags & XT_RPFILTER_INVERT;
- if (par->in->flags & IFF_LOOPBACK)
+ if (skb_dst(skb)) /* locally generated? */
return true ^ invert;
iph = ipv6_hdr(skb);
--
1.7.8.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] netfilter: rpfilter: skip locally generated bcast, too
2013-04-12 20:51 [PATCH] netfilter: rpfilter: skip locally generated bcast, too Florian Westphal
@ 2013-04-16 16:55 ` Pablo Neira Ayuso
2013-04-16 17:48 ` Florian Westphal
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2013-04-16 16:55 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel
Hi Florian,
On Fri, Apr 12, 2013 at 10:51:31PM +0200, Florian Westphal wrote:
> Alex Efros reported rpfilter module doesn't match following packets:
> IN=br.qemu SRC=192.168.2.1 DST=192.168.2.255 [ .. ]
> (netfilter bugzilla #814).
>
> Problem is that network stack arranges for the locally generated broadcasts
> to appear on the interface they were sent out, so the IFF_LOOPBACK check
> doesn't trigger.
>
> As -m rpfilter is restricted to PREROUTING, we can check for existing
> skb_dst instead, it catches locally-generated broad/multicast case, too.
>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
> net/ipv4/netfilter/ipt_rpfilter.c | 2 +-
> net/ipv6/netfilter/ip6t_rpfilter.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c
> index c301300..601abf2 100644
> --- a/net/ipv4/netfilter/ipt_rpfilter.c
> +++ b/net/ipv4/netfilter/ipt_rpfilter.c
> @@ -76,7 +76,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
> info = par->matchinfo;
> invert = info->flags & XT_RPFILTER_INVERT;
>
> - if (par->in->flags & IFF_LOOPBACK)
> + if (skb_dst(skb)) /* locally generated? */
I'd prefer if this is narrowed down to locally generated traffic in
the same way we do in nf_conntrack_broadcast.c.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] netfilter: rpfilter: skip locally generated bcast, too
2013-04-16 16:55 ` Pablo Neira Ayuso
@ 2013-04-16 17:48 ` Florian Westphal
0 siblings, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2013-04-16 17:48 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: Florian Westphal, netfilter-devel
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> Hi Florian,
>
> > diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c
> > index c301300..601abf2 100644
> > --- a/net/ipv4/netfilter/ipt_rpfilter.c
> > +++ b/net/ipv4/netfilter/ipt_rpfilter.c
> > @@ -76,7 +76,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
> > info = par->matchinfo;
> > invert = info->flags & XT_RPFILTER_INVERT;
> >
> > - if (par->in->flags & IFF_LOOPBACK)
> > + if (skb_dst(skb)) /* locally generated? */
>
> I'd prefer if this is narrowed down to locally generated traffic in
> the same way we do in nf_conntrack_broadcast.c.
Fair enough, i will change it.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-16 17:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-12 20:51 [PATCH] netfilter: rpfilter: skip locally generated bcast, too Florian Westphal
2013-04-16 16:55 ` Pablo Neira Ayuso
2013-04-16 17:48 ` Florian Westphal
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).