From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH v7 3/5] batman-adv: drop unicast packets from other backbone gw
Date: Mon, 5 Sep 2016 13:20:27 +0200 [thread overview]
Message-ID: <20160905112029.32533-3-sven@narfation.org> (raw)
In-Reply-To: <20160905112029.32533-1-sven@narfation.org>
From: Andreas Pape <APape@phoenixcontact.com>
Additional dropping of unicast packets received from another backbone gw of
the same backbone network before being forwarded to the same backbone again
is necessary. It was observed in a test setup that in rare cases these
frames lead to looping unicast traffic backbone->mesh->backbone.
Signed-off-by: Andreas Pape <apape@phoenixcontact.com>
Acked-by: Simon Wunderlich <sw@simonwunderlich.de>
[sven@narfation.org: fix conflicts with current version]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
net/batman-adv/routing.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 7e8dc64..03631ee 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -918,14 +918,16 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_unicast_packet *unicast_packet;
struct batadv_unicast_4addr_packet *unicast_4addr_packet;
- u8 *orig_addr;
- struct batadv_orig_node *orig_node = NULL;
+ u8 *orig_addr, *orig_addr_gw;
+ struct batadv_orig_node *orig_node = NULL, *orig_node_gw = NULL;
int check, hdr_size = sizeof(*unicast_packet);
enum batadv_subtype subtype;
- bool is4addr;
+ bool is4addr, is_gw;
+ struct ethhdr *ethhdr;
unicast_packet = (struct batadv_unicast_packet *)skb->data;
unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
+ ethhdr = eth_hdr(skb);
is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR;
/* the caller function should have already pulled 2 bytes */
@@ -948,6 +950,23 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
/* packet for me */
if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
+ /* If this is a unicast packet from another backgone gw,
+ * drop it.
+ */
+ orig_addr_gw = ethhdr->h_source;
+ orig_node_gw = batadv_orig_hash_find(bat_priv, orig_addr_gw);
+ if (orig_node_gw) {
+ is_gw = batadv_bla_is_backbone_gw(skb, orig_node_gw,
+ hdr_size);
+ batadv_orig_node_put(orig_node_gw);
+ if (is_gw) {
+ batadv_dbg(BATADV_DBG_BLA, bat_priv,
+ "Dropped unicast pkt received from another backbone gw %pM.\n",
+ orig_addr_gw);
+ return NET_RX_DROP;
+ }
+ }
+
if (is4addr) {
subtype = unicast_4addr_packet->subtype;
batadv_dat_inc_counter(bat_priv, subtype);
--
2.9.3
next prev parent reply other threads:[~2016-09-05 11:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-05 11:20 [B.A.T.M.A.N.] [PATCH v7 1/5] batman-adv: prevent multiple ARP replies sent by gateways if dat enabled Sven Eckelmann
2016-09-05 11:20 ` [B.A.T.M.A.N.] [PATCH v7 2/5] batman-adv: prevent duplication of ARP replies when DAT is used Sven Eckelmann
2016-09-05 11:20 ` Sven Eckelmann [this message]
2016-09-05 11:20 ` [B.A.T.M.A.N.] [PATCH v7 4/5] batman-adv: changed debug messages for easier bla debugging Sven Eckelmann
2016-09-05 11:20 ` [B.A.T.M.A.N.] [PATCH v7 5/5] batman-adv: handle race condition for claims between gateways Sven Eckelmann
2016-09-05 11:23 ` [B.A.T.M.A.N.] [PATCH v7 0/5] batman-adv: prevent multiple ARP replies sent by gateways if dat enabled Sven Eckelmann
2016-09-08 5:11 ` [B.A.T.M.A.N.] Antwort: " Andreas Pape
2016-09-08 5:43 ` Sven Eckelmann
2017-02-06 9:56 ` [B.A.T.M.A.N.] [PATCH v7 1/5] " Sven Eckelmann
2017-02-06 11:48 ` Antonio Quartulli
2017-02-16 15:13 ` 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=20160905112029.32533-3-sven@narfation.org \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.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 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).