From patchwork Mon Sep 5 11:20:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16676 X-Patchwork-Delegate: a@unstable.cc Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id ECCB8824B9; Mon, 5 Sep 2016 13:20:50 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=narfation.org Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=gcQlmcQ+; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2001:4d88:2000:7::2; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [IPv6:2001:4d88:2000:7::2]) by open-mesh.org (Postfix) with ESMTPS id 0FD6F82404 for ; Mon, 5 Sep 2016 13:20:38 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p2003007C6F7864FA340B65BA96576E83.dip0.t-ipconnect.de [IPv6:2003:7c:6f78:64fa:340b:65ba:9657:6e83]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 84B7E1C8001; Mon, 5 Sep 2016 13:20:38 +0200 (CEST) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1473074438; bh=tFg01MZivHeCwz20xfveeiXxx7pWOWLPn+T5uYavnRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gcQlmcQ+mVwAvnuh653LDltiz3M4Dp/P0JZU7g4fO53qUKOnhdY8wFHD9nbQSj0+G JCY4Fkg0Ah2rKVB4z0D8Umtv1MlQXOTsfWTWFrkRMxy1Op8H8olfj8O3/pD7rmB1TE wzmVG8G4Zlmk2L7mDu0ke2hH3VXnGKUQ+E29T2vU= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 5 Sep 2016 13:20:27 +0200 Message-Id: <20160905112029.32533-3-sven@narfation.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160905112029.32533-1-sven@narfation.org> References: <20160905112029.32533-1-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH v7 3/5] batman-adv: drop unicast packets from other backbone gw X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" From: Andreas Pape 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 Acked-by: Simon Wunderlich [sven@narfation.org: fix conflicts with current version] Signed-off-by: Sven Eckelmann --- 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);