* [RFC net] bridge: clean the nf_bridge status when forwarding the skb
@ 2013-09-26 20:19 Antonio Quartulli
2013-09-26 21:08 ` Stephen Hemminger
2013-09-26 21:10 ` Stephen Hemminger
0 siblings, 2 replies; 9+ messages in thread
From: Antonio Quartulli @ 2013-09-26 20:19 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David S. Miller, bridge, netdev, Antonio Quartulli
From: Antonio Quartulli <antonio@open-mesh.com>
Even if enslaving a bridge interface into another bridge is
forbidden, it is still possible to create a chain of
virtual interfaces including two distinct bridges.
In this case, the skb entering the second bridge could have
the nf_bridge field already set due to a previous operation
and consequently lead to a wrong processing of the packet
itself.
To prevent this behaviour release and set to NULL the
nf_bridge field of the skb when exiting the bridge interface.
Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
I am not sure if this is a wanted behaviour or a real BUG. I found this
"misbehaviour" while testing batman-adv with the following configuration:
- br0 (bridge interface) having bat0 and eth0 as slaves
- bat0 (which is a virtual interface provided by the batman-adv module and that
works similarly to a bridge - to some extends) having br1 as slave
- br1 (second bridge interface) having eth1 as slave
Then follow these events:
- a broadcast packet arrives on eth0
- the skb enters br0 and skb->nf_bridge gets initialised and used
- the skb enters bat0 and the packet *gets encapsulated in the batman-adv packet
which adds a batman-adv header and another Ethernet header*
- the skb enters br1 and gets ruined because nf_bridge_maybe_copy_header() (in
br_dev_queue_push_xmit()) will try to restore an header that does not make
sense anymore.
With this patch the nf_bridge gets de-initialised before exiting br0 and
therefore it is processed properly inside br1: nf_bridge_maybe_copy_header()
does not take place at all because nf_bridge is never initialised (the packet is
non-IP since it is a batman-adv packet)
To the developers of the bridge module I would like to ask:
1) is skb->nf_bridge allowed to be non NULL when entering br_dev_xmit() ? If so,
when is this supposed to happen?
2) do you think this patch is logically correct but the nf_bridge release should
be done in batman-adv since it is the one re-encapsulating the packet?
I hope I have made the problem clear.
Best regards,
net/bridge/br_forward.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 4b81b14..65864bc 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -49,6 +49,11 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
} else {
skb_push(skb, ETH_HLEN);
br_drop_fake_rtable(skb);
+
+ /* clean the NF bridge data */
+ nf_bridge_put(skb->nf_bridge);
+ skb->nf_bridge = NULL;
+
dev_queue_xmit(skb);
}
--
1.8.1.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [RFC net] bridge: clean the nf_bridge status when forwarding the skb
2013-09-26 20:19 [RFC net] bridge: clean the nf_bridge status when forwarding the skb Antonio Quartulli
@ 2013-09-26 21:08 ` Stephen Hemminger
2013-09-26 21:10 ` Stephen Hemminger
1 sibling, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2013-09-26 21:08 UTC (permalink / raw)
To: Antonio Quartulli; +Cc: David S. Miller, bridge, netdev, Antonio Quartulli
On Thu, 26 Sep 2013 22:19:50 +0200
Antonio Quartulli <antonio@meshcoding.com> wrote:
> From: Antonio Quartulli <antonio@open-mesh.com>
>
> Even if enslaving a bridge interface into another bridge is
> forbidden, it is still possible to create a chain of
> virtual interfaces including two distinct bridges.
>
> In this case, the skb entering the second bridge could have
> the nf_bridge field already set due to a previous operation
> and consequently lead to a wrong processing of the packet
> itself.
>
> To prevent this behaviour release and set to NULL the
> nf_bridge field of the skb when exiting the bridge interface.
>
> Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
> ---
>
> I am not sure if this is a wanted behaviour or a real BUG. I found this
> "misbehaviour" while testing batman-adv with the following configuration:
>
> - br0 (bridge interface) having bat0 and eth0 as slaves
> - bat0 (which is a virtual interface provided by the batman-adv module and that
> works similarly to a bridge - to some extends) having br1 as slave
> - br1 (second bridge interface) having eth1 as slave
>
> Then follow these events:
> - a broadcast packet arrives on eth0
> - the skb enters br0 and skb->nf_bridge gets initialised and used
> - the skb enters bat0 and the packet *gets encapsulated in the batman-adv packet
> which adds a batman-adv header and another Ethernet header*
> - the skb enters br1 and gets ruined because nf_bridge_maybe_copy_header() (in
> br_dev_queue_push_xmit()) will try to restore an header that does not make
> sense anymore.
>
> With this patch the nf_bridge gets de-initialised before exiting br0 and
> therefore it is processed properly inside br1: nf_bridge_maybe_copy_header()
> does not take place at all because nf_bridge is never initialised (the packet is
> non-IP since it is a batman-adv packet)
>
> To the developers of the bridge module I would like to ask:
> 1) is skb->nf_bridge allowed to be non NULL when entering br_dev_xmit() ? If so,
> when is this supposed to happen?
>
> 2) do you think this patch is logically correct but the nf_bridge release should
> be done in batman-adv since it is the one re-encapsulating the packet?
>
>
> I hope I have made the problem clear.
>
> Best regards,
>
>
> net/bridge/br_forward.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
> index 4b81b14..65864bc 100644
> --- a/net/bridge/br_forward.c
> +++ b/net/bridge/br_forward.c
> @@ -49,6 +49,11 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
> } else {
> skb_push(skb, ETH_HLEN);
> br_drop_fake_rtable(skb);
> +
> + /* clean the NF bridge data */
> + nf_bridge_put(skb->nf_bridge);
> + skb->nf_bridge = NULL;
> +
> dev_queue_xmit(skb);
> }
>
You need to bracket this with CONFIG_BRIDGE_NETFILTER
since nf_bridge is only in skbuff if that option is enabled.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC net] bridge: clean the nf_bridge status when forwarding the skb
2013-09-26 20:19 [RFC net] bridge: clean the nf_bridge status when forwarding the skb Antonio Quartulli
2013-09-26 21:08 ` Stephen Hemminger
@ 2013-09-26 21:10 ` Stephen Hemminger
2013-09-26 21:16 ` Antonio Quartulli
1 sibling, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2013-09-26 21:10 UTC (permalink / raw)
To: Antonio Quartulli; +Cc: netdev, bridge, David S. Miller, Antonio Quartulli
On Thu, 26 Sep 2013 22:19:50 +0200
Antonio Quartulli <antonio@meshcoding.com> wrote:
> From: Antonio Quartulli <antonio@open-mesh.com>
>
> Even if enslaving a bridge interface into another bridge is
> forbidden, it is still possible to create a chain of
> virtual interfaces including two distinct bridges.
>
> In this case, the skb entering the second bridge could have
> the nf_bridge field already set due to a previous operation
> and consequently lead to a wrong processing of the packet
> itself.
>
> To prevent this behaviour release and set to NULL the
> nf_bridge field of the skb when exiting the bridge interface.
>
> Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
> ---
>
> I am not sure if this is a wanted behaviour or a real BUG. I found this
> "misbehaviour" while testing batman-adv with the following configuration:
>
> - br0 (bridge interface) having bat0 and eth0 as slaves
> - bat0 (which is a virtual interface provided by the batman-adv module and that
> works similarly to a bridge - to some extends) having br1 as slave
> - br1 (second bridge interface) having eth1 as slave
>
> Then follow these events:
> - a broadcast packet arrives on eth0
> - the skb enters br0 and skb->nf_bridge gets initialised and used
> - the skb enters bat0 and the packet *gets encapsulated in the batman-adv packet
> which adds a batman-adv header and another Ethernet header*
> - the skb enters br1 and gets ruined because nf_bridge_maybe_copy_header() (in
> br_dev_queue_push_xmit()) will try to restore an header that does not make
> sense anymore.
>
> With this patch the nf_bridge gets de-initialised before exiting br0 and
> therefore it is processed properly inside br1: nf_bridge_maybe_copy_header()
> does not take place at all because nf_bridge is never initialised (the packet is
> non-IP since it is a batman-adv packet)
>
> To the developers of the bridge module I would like to ask:
> 1) is skb->nf_bridge allowed to be non NULL when entering br_dev_xmit() ? If so,
> when is this supposed to happen?
>
> 2) do you think this patch is logically correct but the nf_bridge release should
> be done in batman-adv since it is the one re-encapsulating the packet?
>
>
> I hope I have made the problem clear.
>
> Best regards,
>
>
> net/bridge/br_forward.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
> index 4b81b14..65864bc 100644
> --- a/net/bridge/br_forward.c
> +++ b/net/bridge/br_forward.c
> @@ -49,6 +49,11 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
> } else {
> skb_push(skb, ETH_HLEN);
> br_drop_fake_rtable(skb);
> +
> + /* clean the NF bridge data */
> + nf_bridge_put(skb->nf_bridge);
> + skb->nf_bridge = NULL;
> +
> dev_queue_xmit(skb);
> }
>
I think the header will also be garbage if bridge on bridge with netfilter is used.
See nf_bridge_save_header.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC net] bridge: clean the nf_bridge status when forwarding the skb
2013-09-26 21:10 ` Stephen Hemminger
@ 2013-09-26 21:16 ` Antonio Quartulli
2013-09-26 21:32 ` Stephen Hemminger
0 siblings, 1 reply; 9+ messages in thread
From: Antonio Quartulli @ 2013-09-26 21:16 UTC (permalink / raw)
To: Stephen Hemminger
Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org,
David S. Miller
[-- Attachment #1: Type: text/plain, Size: 3479 bytes --]
On Thu, Sep 26, 2013 at 02:10:21PM -0700, Stephen Hemminger wrote:
> On Thu, 26 Sep 2013 22:19:50 +0200
> Antonio Quartulli <antonio@meshcoding.com> wrote:
>
> > From: Antonio Quartulli <antonio@open-mesh.com>
> >
> > Even if enslaving a bridge interface into another bridge is
> > forbidden, it is still possible to create a chain of
> > virtual interfaces including two distinct bridges.
> >
> > In this case, the skb entering the second bridge could have
> > the nf_bridge field already set due to a previous operation
> > and consequently lead to a wrong processing of the packet
> > itself.
> >
> > To prevent this behaviour release and set to NULL the
> > nf_bridge field of the skb when exiting the bridge interface.
> >
> > Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
> > ---
> >
> > I am not sure if this is a wanted behaviour or a real BUG. I found this
> > "misbehaviour" while testing batman-adv with the following configuration:
> >
> > - br0 (bridge interface) having bat0 and eth0 as slaves
> > - bat0 (which is a virtual interface provided by the batman-adv module and that
> > works similarly to a bridge - to some extends) having br1 as slave
> > - br1 (second bridge interface) having eth1 as slave
> >
> > Then follow these events:
> > - a broadcast packet arrives on eth0
> > - the skb enters br0 and skb->nf_bridge gets initialised and used
> > - the skb enters bat0 and the packet *gets encapsulated in the batman-adv packet
> > which adds a batman-adv header and another Ethernet header*
> > - the skb enters br1 and gets ruined because nf_bridge_maybe_copy_header() (in
> > br_dev_queue_push_xmit()) will try to restore an header that does not make
> > sense anymore.
> >
> > With this patch the nf_bridge gets de-initialised before exiting br0 and
> > therefore it is processed properly inside br1: nf_bridge_maybe_copy_header()
> > does not take place at all because nf_bridge is never initialised (the packet is
> > non-IP since it is a batman-adv packet)
> >
> > To the developers of the bridge module I would like to ask:
> > 1) is skb->nf_bridge allowed to be non NULL when entering br_dev_xmit() ? If so,
> > when is this supposed to happen?
> >
> > 2) do you think this patch is logically correct but the nf_bridge release should
> > be done in batman-adv since it is the one re-encapsulating the packet?
> >
> >
> > I hope I have made the problem clear.
> >
> > Best regards,
> >
> >
> > net/bridge/br_forward.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
> > index 4b81b14..65864bc 100644
> > --- a/net/bridge/br_forward.c
> > +++ b/net/bridge/br_forward.c
> > @@ -49,6 +49,11 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
> > } else {
> > skb_push(skb, ETH_HLEN);
> > br_drop_fake_rtable(skb);
> > +
> > + /* clean the NF bridge data */
> > + nf_bridge_put(skb->nf_bridge);
> > + skb->nf_bridge = NULL;
> > +
> > dev_queue_xmit(skb);
> > }
> >
Regarding CONFIG_BRIDGE_NETFILTER you are right, thanks.
>
> I think the header will also be garbage if bridge on bridge with netfilter is used.
> See nf_bridge_save_header.
What header are you referring to? nf_bridge_save_header() saves the header in
skb->nf_bridge->data, which is freed during nf_bridge_put() (assuming
->use reached 0).
--
Antonio Quartulli
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC net] bridge: clean the nf_bridge status when forwarding the skb
2013-09-26 21:16 ` Antonio Quartulli
@ 2013-09-26 21:32 ` Stephen Hemminger
2013-09-26 22:01 ` Antonio Quartulli
0 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2013-09-26 21:32 UTC (permalink / raw)
To: Antonio Quartulli
Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org,
David S. Miller
On Thu, 26 Sep 2013 23:16:48 +0200
Antonio Quartulli <antonio@open-mesh.com> wrote:
> On Thu, Sep 26, 2013 at 02:10:21PM -0700, Stephen Hemminger wrote:
> > On Thu, 26 Sep 2013 22:19:50 +0200
> > Antonio Quartulli <antonio@meshcoding.com> wrote:
> >
> > > From: Antonio Quartulli <antonio@open-mesh.com>
> > >
> > > Even if enslaving a bridge interface into another bridge is
> > > forbidden, it is still possible to create a chain of
> > > virtual interfaces including two distinct bridges.
> > >
> > > In this case, the skb entering the second bridge could have
> > > the nf_bridge field already set due to a previous operation
> > > and consequently lead to a wrong processing of the packet
> > > itself.
> > >
> > > To prevent this behaviour release and set to NULL the
> > > nf_bridge field of the skb when exiting the bridge interface.
> > >
> > > Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
> > > ---
> > >
> > > I am not sure if this is a wanted behaviour or a real BUG. I found this
> > > "misbehaviour" while testing batman-adv with the following configuration:
> > >
> > > - br0 (bridge interface) having bat0 and eth0 as slaves
> > > - bat0 (which is a virtual interface provided by the batman-adv module and that
> > > works similarly to a bridge - to some extends) having br1 as slave
> > > - br1 (second bridge interface) having eth1 as slave
> > >
> > > Then follow these events:
> > > - a broadcast packet arrives on eth0
> > > - the skb enters br0 and skb->nf_bridge gets initialised and used
> > > - the skb enters bat0 and the packet *gets encapsulated in the batman-adv packet
> > > which adds a batman-adv header and another Ethernet header*
> > > - the skb enters br1 and gets ruined because nf_bridge_maybe_copy_header() (in
> > > br_dev_queue_push_xmit()) will try to restore an header that does not make
> > > sense anymore.
> > >
> > > With this patch the nf_bridge gets de-initialised before exiting br0 and
> > > therefore it is processed properly inside br1: nf_bridge_maybe_copy_header()
> > > does not take place at all because nf_bridge is never initialised (the packet is
> > > non-IP since it is a batman-adv packet)
> > >
> > > To the developers of the bridge module I would like to ask:
> > > 1) is skb->nf_bridge allowed to be non NULL when entering br_dev_xmit() ? If so,
> > > when is this supposed to happen?
> > >
> > > 2) do you think this patch is logically correct but the nf_bridge release should
> > > be done in batman-adv since it is the one re-encapsulating the packet?
> > >
> > >
> > > I hope I have made the problem clear.
> > >
> > > Best regards,
> > >
> > >
> > > net/bridge/br_forward.c | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
> > > index 4b81b14..65864bc 100644
> > > --- a/net/bridge/br_forward.c
> > > +++ b/net/bridge/br_forward.c
> > > @@ -49,6 +49,11 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
> > > } else {
> > > skb_push(skb, ETH_HLEN);
> > > br_drop_fake_rtable(skb);
> > > +
> > > + /* clean the NF bridge data */
> > > + nf_bridge_put(skb->nf_bridge);
> > > + skb->nf_bridge = NULL;
> > > +
> > > dev_queue_xmit(skb);
> > > }
> > >
>
> Regarding CONFIG_BRIDGE_NETFILTER you are right, thanks.
>
> >
> > I think the header will also be garbage if bridge on bridge with netfilter is used.
> > See nf_bridge_save_header.
>
> What header are you referring to? nf_bridge_save_header() saves the header in
> skb->nf_bridge->data, which is freed during nf_bridge_put() (assuming
> ->use reached 0).
>
>
If bridge is stacked the original ether header will get overwritten by the second
call to save_header.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC net] bridge: clean the nf_bridge status when forwarding the skb
2013-09-26 21:32 ` Stephen Hemminger
@ 2013-09-26 22:01 ` Antonio Quartulli
2013-10-14 22:20 ` Antonio Quartulli
0 siblings, 1 reply; 9+ messages in thread
From: Antonio Quartulli @ 2013-09-26 22:01 UTC (permalink / raw)
To: Stephen Hemminger
Cc: David S. Miller, bridge@lists.linux-foundation.org,
netdev@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1943 bytes --]
On Thu, Sep 26, 2013 at 02:32:48PM -0700, Stephen Hemminger wrote:
> > > > diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
> > > > index 4b81b14..65864bc 100644
> > > > --- a/net/bridge/br_forward.c
> > > > +++ b/net/bridge/br_forward.c
> > > > @@ -49,6 +49,11 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
> > > > } else {
> > > > skb_push(skb, ETH_HLEN);
> > > > br_drop_fake_rtable(skb);
> > > > +
> > > > + /* clean the NF bridge data */
> > > > + nf_bridge_put(skb->nf_bridge);
> > > > + skb->nf_bridge = NULL;
> > > > +
> > > > dev_queue_xmit(skb);
> > > > }
> > > >
> >
> > Regarding CONFIG_BRIDGE_NETFILTER you are right, thanks.
> >
> > >
> > > I think the header will also be garbage if bridge on bridge with netfilter is used.
> > > See nf_bridge_save_header.
> >
> > What header are you referring to? nf_bridge_save_header() saves the header in
> > skb->nf_bridge->data, which is freed during nf_bridge_put() (assuming
> > ->use reached 0).
> >
> >
>
> If bridge is stacked the original ether header will get overwritten by the second
> call to save_header.
Sorry, but I am not getting what you mean (I am new to the code and it is late here..):
save_header() will store the Ethernet header in nf_bridge->data for
later recover (if needed).
By freeing nf_bridge I also destroy this header copy.
When the skb enters the second bridge, save_header() will save again the header
in nf_bridge->data. But I don't see how this can create a problem.
The problem I had before this patch comes from the fact that
nf_bridge_copy_header() is invoked in the second bridge with the nf_bridge state
of the first. This was overwriting my the packet Ethernet header with what the
first invocation of save_header() stored in nf_bridge->data.
But by unsetting nf_bridge I think I am preventing this from happening again.
no?
--
Antonio Quartulli
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC net] bridge: clean the nf_bridge status when forwarding the skb
2013-09-26 22:01 ` Antonio Quartulli
@ 2013-10-14 22:20 ` Antonio Quartulli
2013-10-14 22:27 ` Stephen Hemminger
0 siblings, 1 reply; 9+ messages in thread
From: Antonio Quartulli @ 2013-10-14 22:20 UTC (permalink / raw)
To: Stephen Hemminger
Cc: David S. Miller, bridge@lists.linux-foundation.org,
netdev@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 2351 bytes --]
On Fri, Sep 27, 2013 at 12:01:43AM +0200, Antonio Quartulli wrote:
> On Thu, Sep 26, 2013 at 02:32:48PM -0700, Stephen Hemminger wrote:
> > > > > diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
> > > > > index 4b81b14..65864bc 100644
> > > > > --- a/net/bridge/br_forward.c
> > > > > +++ b/net/bridge/br_forward.c
> > > > > @@ -49,6 +49,11 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
> > > > > } else {
> > > > > skb_push(skb, ETH_HLEN);
> > > > > br_drop_fake_rtable(skb);
> > > > > +
> > > > > + /* clean the NF bridge data */
> > > > > + nf_bridge_put(skb->nf_bridge);
> > > > > + skb->nf_bridge = NULL;
> > > > > +
> > > > > dev_queue_xmit(skb);
> > > > > }
> > > > >
> > >
> > > Regarding CONFIG_BRIDGE_NETFILTER you are right, thanks.
> > >
> > > >
> > > > I think the header will also be garbage if bridge on bridge with netfilter is used.
> > > > See nf_bridge_save_header.
> > >
> > > What header are you referring to? nf_bridge_save_header() saves the header in
> > > skb->nf_bridge->data, which is freed during nf_bridge_put() (assuming
> > > ->use reached 0).
> > >
> > >
> >
> > If bridge is stacked the original ether header will get overwritten by the second
> > call to save_header.
>
> Sorry, but I am not getting what you mean (I am new to the code and it is late here..):
> save_header() will store the Ethernet header in nf_bridge->data for
> later recover (if needed).
>
> By freeing nf_bridge I also destroy this header copy.
>
> When the skb enters the second bridge, save_header() will save again the header
> in nf_bridge->data. But I don't see how this can create a problem.
>
> The problem I had before this patch comes from the fact that
> nf_bridge_copy_header() is invoked in the second bridge with the nf_bridge state
> of the first. This was overwriting my the packet Ethernet header with what the
> first invocation of save_header() stored in nf_bridge->data.
>
> But by unsetting nf_bridge I think I am preventing this from happening again.
> no?
Hello Stephen,
do you have other comments about this patch? I know it is rather difficult that
a generic user hits this issue, but I'd like to see it fixed because other
people using batman-adv may incur in this problem.
Cheers,
--
Antonio Quartulli
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC net] bridge: clean the nf_bridge status when forwarding the skb
2013-10-14 22:20 ` Antonio Quartulli
@ 2013-10-14 22:27 ` Stephen Hemminger
2013-10-14 22:35 ` Antonio Quartulli
0 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2013-10-14 22:27 UTC (permalink / raw)
To: Antonio Quartulli
Cc: David S. Miller, bridge@lists.linux-foundation.org,
netdev@vger.kernel.org
On Tue, 15 Oct 2013 00:20:10 +0200
Antonio Quartulli <antonio@meshcoding.com> wrote:
> On Fri, Sep 27, 2013 at 12:01:43AM +0200, Antonio Quartulli wrote:
> > On Thu, Sep 26, 2013 at 02:32:48PM -0700, Stephen Hemminger wrote:
> > > > > > diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
> > > > > > index 4b81b14..65864bc 100644
> > > > > > --- a/net/bridge/br_forward.c
> > > > > > +++ b/net/bridge/br_forward.c
> > > > > > @@ -49,6 +49,11 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
> > > > > > } else {
> > > > > > skb_push(skb, ETH_HLEN);
> > > > > > br_drop_fake_rtable(skb);
> > > > > > +
> > > > > > + /* clean the NF bridge data */
> > > > > > + nf_bridge_put(skb->nf_bridge);
> > > > > > + skb->nf_bridge = NULL;
> > > > > > +
> > > > > > dev_queue_xmit(skb);
> > > > > > }
> > > > > >
> > > >
> > > > Regarding CONFIG_BRIDGE_NETFILTER you are right, thanks.
> > > >
> > > > >
> > > > > I think the header will also be garbage if bridge on bridge with netfilter is used.
> > > > > See nf_bridge_save_header.
> > > >
> > > > What header are you referring to? nf_bridge_save_header() saves the header in
> > > > skb->nf_bridge->data, which is freed during nf_bridge_put() (assuming
> > > > ->use reached 0).
> > > >
> > > >
> > >
> > > If bridge is stacked the original ether header will get overwritten by the second
> > > call to save_header.
> >
> > Sorry, but I am not getting what you mean (I am new to the code and it is late here..):
> > save_header() will store the Ethernet header in nf_bridge->data for
> > later recover (if needed).
> >
> > By freeing nf_bridge I also destroy this header copy.
> >
> > When the skb enters the second bridge, save_header() will save again the header
> > in nf_bridge->data. But I don't see how this can create a problem.
> >
> > The problem I had before this patch comes from the fact that
> > nf_bridge_copy_header() is invoked in the second bridge with the nf_bridge state
> > of the first. This was overwriting my the packet Ethernet header with what the
> > first invocation of save_header() stored in nf_bridge->data.
> >
> > But by unsetting nf_bridge I think I am preventing this from happening again.
> > no?
>
> Hello Stephen,
>
> do you have other comments about this patch? I know it is rather difficult that
> a generic user hits this issue, but I'd like to see it fixed because other
> people using batman-adv may incur in this problem.
>
> Cheers,
>
>
The patch content is fine, but it needs necessary ifdef's.
I would also prefer to have the clean done as a function that can be stubbed out
like the other bridge netfilter stuff.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC net] bridge: clean the nf_bridge status when forwarding the skb
2013-10-14 22:27 ` Stephen Hemminger
@ 2013-10-14 22:35 ` Antonio Quartulli
0 siblings, 0 replies; 9+ messages in thread
From: Antonio Quartulli @ 2013-10-14 22:35 UTC (permalink / raw)
To: Stephen Hemminger
Cc: David S. Miller, bridge@lists.linux-foundation.org,
netdev@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 410 bytes --]
On Mon, Oct 14, 2013 at 03:27:56PM -0700, Stephen Hemminger wrote:
> The patch content is fine, but it needs necessary ifdef's.
> I would also prefer to have the clean done as a function that can be stubbed out
> like the other bridge netfilter stuff.
>
Ok, I will apply those changes and I will send it as PATCH.
Thank you very much for your feedback!
Regards,
--
Antonio Quartulli
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-10-14 22:36 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-26 20:19 [RFC net] bridge: clean the nf_bridge status when forwarding the skb Antonio Quartulli
2013-09-26 21:08 ` Stephen Hemminger
2013-09-26 21:10 ` Stephen Hemminger
2013-09-26 21:16 ` Antonio Quartulli
2013-09-26 21:32 ` Stephen Hemminger
2013-09-26 22:01 ` Antonio Quartulli
2013-10-14 22:20 ` Antonio Quartulli
2013-10-14 22:27 ` Stephen Hemminger
2013-10-14 22:35 ` Antonio Quartulli
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).