From: Antonio Quartulli <antonio@meshcoding.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
Marek Lindner <mareklindner@neomailbox.ch>,
Antonio Quartulli <antonio@meshcoding.com>
Subject: [B.A.T.M.A.N.] [PATCH 1/6] batman-adv: free nf_bridge member on locally delivered skb
Date: Thu, 19 Dec 2013 01:15:27 +0100 [thread overview]
Message-ID: <1387412132-889-2-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1387412132-889-1-git-send-email-antonio@meshcoding.com>
If an interface enslaved into batman-adv is a bridge (or a
virtual interface built on top of a bridge) the nf_bridge
member of the skbs reaching the soft-interface is filled
with the state about "netfilter bridge" operations.
Then, if one of such skbs is locally delivered, the nf_bridge
member should be cleaned up to avoid that the old state
could mess up with other "netfilter bridge" operations when
entering a second bridge.
This is needed because batman-adv is an encapsulation
protocol.
However at the moment skb->nf_bridge is not released at all
leading to bogus "netfilter bridge" behaviours.
Fix this by releasing skb->nf_bridge before an skb gets
delivered to the upper layer in interface_rx().
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
net/batman-adv/soft-interface.c | 8 ++++++++
net/batman-adv/soft-interface.h | 16 ++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 36f0508..59b7397 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -392,6 +392,14 @@ void batadv_interface_rx(struct net_device *soft_iface,
vid))
goto dropped;
+ /* Clean the netfilter state before delivering the skb.
+ * This packet may have traversed a bridge when it was encapsulated into
+ * the batman header. Now that the header has been removed, the
+ * netfilter state must be cleaned up to avoid to mess up with a
+ * possible second bridge
+ */
+ batadv_nf_bridge_skb_free(skb);
+
netif_rx(skb);
goto out;
diff --git a/net/batman-adv/soft-interface.h b/net/batman-adv/soft-interface.h
index 06fc91f..21b8573 100644
--- a/net/batman-adv/soft-interface.h
+++ b/net/batman-adv/soft-interface.h
@@ -33,4 +33,20 @@ void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *softif_vlan);
struct batadv_softif_vlan *batadv_softif_vlan_get(struct batadv_priv *bat_priv,
unsigned short vid);
+#ifdef CONFIG_BRIDGE_NETFILTER
+/**
+ * batadv_nf_bridge_skb_free - clean the NF bridge data in an skb
+ * @skb: the skb which nf data has to be free'd
+ */
+static inline void batadv_nf_bridge_skb_free(struct sk_buff *skb)
+{
+ nf_bridge_put(skb->nf_bridge);
+ skb->nf_bridge = NULL;
+}
+#else
+static inline void batadv_nf_bridge_skb_free(struct sk_buff *skb)
+{
+}
+#endif /* CONFIG_BRIDGE_NETFILTER */
+
#endif /* _NET_BATMAN_ADV_SOFT_INTERFACE_H_ */
--
1.8.5.1
WARNING: multiple messages have this Message-ID (diff)
From: Antonio Quartulli <antonio@meshcoding.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
Antonio Quartulli <antonio@meshcoding.com>,
Marek Lindner <mareklindner@neomailbox.ch>
Subject: [PATCH 1/6] batman-adv: free nf_bridge member on locally delivered skb
Date: Thu, 19 Dec 2013 01:15:27 +0100 [thread overview]
Message-ID: <1387412132-889-2-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1387412132-889-1-git-send-email-antonio@meshcoding.com>
If an interface enslaved into batman-adv is a bridge (or a
virtual interface built on top of a bridge) the nf_bridge
member of the skbs reaching the soft-interface is filled
with the state about "netfilter bridge" operations.
Then, if one of such skbs is locally delivered, the nf_bridge
member should be cleaned up to avoid that the old state
could mess up with other "netfilter bridge" operations when
entering a second bridge.
This is needed because batman-adv is an encapsulation
protocol.
However at the moment skb->nf_bridge is not released at all
leading to bogus "netfilter bridge" behaviours.
Fix this by releasing skb->nf_bridge before an skb gets
delivered to the upper layer in interface_rx().
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
net/batman-adv/soft-interface.c | 8 ++++++++
net/batman-adv/soft-interface.h | 16 ++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 36f0508..59b7397 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -392,6 +392,14 @@ void batadv_interface_rx(struct net_device *soft_iface,
vid))
goto dropped;
+ /* Clean the netfilter state before delivering the skb.
+ * This packet may have traversed a bridge when it was encapsulated into
+ * the batman header. Now that the header has been removed, the
+ * netfilter state must be cleaned up to avoid to mess up with a
+ * possible second bridge
+ */
+ batadv_nf_bridge_skb_free(skb);
+
netif_rx(skb);
goto out;
diff --git a/net/batman-adv/soft-interface.h b/net/batman-adv/soft-interface.h
index 06fc91f..21b8573 100644
--- a/net/batman-adv/soft-interface.h
+++ b/net/batman-adv/soft-interface.h
@@ -33,4 +33,20 @@ void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *softif_vlan);
struct batadv_softif_vlan *batadv_softif_vlan_get(struct batadv_priv *bat_priv,
unsigned short vid);
+#ifdef CONFIG_BRIDGE_NETFILTER
+/**
+ * batadv_nf_bridge_skb_free - clean the NF bridge data in an skb
+ * @skb: the skb which nf data has to be free'd
+ */
+static inline void batadv_nf_bridge_skb_free(struct sk_buff *skb)
+{
+ nf_bridge_put(skb->nf_bridge);
+ skb->nf_bridge = NULL;
+}
+#else
+static inline void batadv_nf_bridge_skb_free(struct sk_buff *skb)
+{
+}
+#endif /* CONFIG_BRIDGE_NETFILTER */
+
#endif /* _NET_BATMAN_ADV_SOFT_INTERFACE_H_ */
--
1.8.5.1
next prev parent reply other threads:[~2013-12-19 0:15 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-19 0:15 [B.A.T.M.A.N.] pull request [net]: batman-adv 2013-12-19 Antonio Quartulli
2013-12-19 0:15 ` Antonio Quartulli
2013-12-19 0:15 ` Antonio Quartulli [this message]
2013-12-19 0:15 ` [PATCH 1/6] batman-adv: free nf_bridge member on locally delivered skb Antonio Quartulli
2013-12-22 23:50 ` [B.A.T.M.A.N.] " David Miller
2013-12-22 23:50 ` David Miller
2013-12-23 0:11 ` [B.A.T.M.A.N.] " Antonio Quartulli
2013-12-23 0:11 ` Antonio Quartulli
2013-12-23 0:16 ` [B.A.T.M.A.N.] " David Miller
2013-12-23 0:16 ` David Miller
2013-12-23 0:19 ` [B.A.T.M.A.N.] " Antonio Quartulli
2013-12-23 0:19 ` Antonio Quartulli
2013-12-19 0:15 ` [B.A.T.M.A.N.] [PATCH 2/6] batman-adv: fix alignment for batadv_coded_packet Antonio Quartulli
2013-12-19 0:15 ` Antonio Quartulli
2013-12-19 0:15 ` [B.A.T.M.A.N.] [PATCH 3/6] batman-adv: fix header alignment by unrolling batadv_header Antonio Quartulli
2013-12-19 0:15 ` Antonio Quartulli
2013-12-19 0:15 ` [B.A.T.M.A.N.] [PATCH 4/6] batman-adv: fix size of batadv_icmp_header Antonio Quartulli
2013-12-19 0:15 ` Antonio Quartulli
2013-12-19 0:15 ` [B.A.T.M.A.N.] [PATCH 5/6] batman-adv: fix size of batadv_bla_claim_dst Antonio Quartulli
2013-12-19 0:15 ` Antonio Quartulli
2013-12-19 0:15 ` [B.A.T.M.A.N.] [PATCH 6/6] batman-adv: fix alignment for batadv_tvlv_tt_change Antonio Quartulli
2013-12-19 0:15 ` Antonio Quartulli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1387412132-889-2-git-send-email-antonio@meshcoding.com \
--to=antonio@meshcoding.com \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=davem@davemloft.net \
--cc=mareklindner@neomailbox.ch \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.