From patchwork Fri Sep 4 18:28:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 18161 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 397BA806FF; Fri, 4 Sep 2020 20:28:10 +0200 (CEST) Received: from mail.aperture-lab.de (mail.aperture-lab.de [IPv6:2a01:4f8:171:314c::100:a1]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 7F1D98029D for ; Fri, 4 Sep 2020 20:28:07 +0200 (CEST) From: =?utf-8?q?Linus_L=C3=BCssing?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c0d3.blue; s=2018; t=1599244087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EDUwi0/GITZ2Lp55iQqZ9p3U9MWRMTMcdviy8WCgYqs=; b=CmUZ3XKcJzXwaho+0KOC99fEC0X2qlvl9f1DSrIThOPSuwQ2AteSeNuLQk++IvfrUdP8jM fT5uTZWyORGqWELycyrQ2ayPAlXwtBZKg10o92HRk4idaDnPLxPKWdiAzyWg+H7MzdfSmP 9bcsIwD4CJwUQkt8iDS72RU30Nnp9PU23LFDO3nVEnCrS9/yCoX44hXaWCTj7uVYwsw0x5 60rcrWHh0dcK41nvlwwayjVWrkbDRIX4EE1mLEy1IKLOt/fJ4A4vR0zUVgRSel11fBumb0 TTOGUYnmkx7k0USdkoqB/J9YOqzew0ijj6GV513MlJU7j8hQsYyXfZTmnAMMVw== To: b.a.t.m.a.n@lists.open-mesh.org Cc: =?utf-8?q?Linus_L=C3=BCssing?= Subject: [PATCH maint v2 1/4] batman-adv: mcast/TT: fix wrongly dropped or rerouted packets Date: Fri, 4 Sep 2020 20:28:00 +0200 Message-Id: <20200904182803.8428-2-linus.luessing@c0d3.blue> In-Reply-To: <20200904182803.8428-1-linus.luessing@c0d3.blue> References: <20200904182803.8428-1-linus.luessing@c0d3.blue> MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=linus.luessing@c0d3.blue smtp.mailfrom=linus.luessing@c0d3.blue ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1599244087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EDUwi0/GITZ2Lp55iQqZ9p3U9MWRMTMcdviy8WCgYqs=; b=N4aOHgC+gz3P29X50UzD8c5ST5Y19t+vk+cAYiznDL3nNELgVamHFb0VxlFaS+rP+P5N0b ShHizn/dONON+NcuiGaCaUdqW8K+6YAm9r5wT+X0PQtdSZii0nypV2BK9gK/t+2aiSYpgO HInjHKmSE6fiIrf8yLPOrmtnttw9B58= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1599244087; a=rsa-sha256; cv=none; b=uSS0DhVHv8lki+uLv1olEbvIQwHplHq+0ReIf8GfNOJLEBNYnQLokvV7sIRY6D//jQjNFQ BdTMoKvXM2OHbsHE8Vyuww6zEOg+J1n7QUFjVmGjBPmdtya8YL8Znhq98I9VbaHqx+XxHM JuLkwJZTiSXZiUPAJLzTplcKrf+SYO4= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none (invalid DKIM record) header.d=c0d3.blue header.s=2018 header.b=CmUZ3XKc; spf=none (diktynna.open-mesh.org: domain of linus.luessing@c0d3.blue has no SPF policy when checking 2a01:4f8:171:314c::100:a1) smtp.mailfrom=linus.luessing@c0d3.blue Message-ID-Hash: SEQM4UCLN36JRSXWCDM3M5VVJSCTL47P X-Message-ID-Hash: SEQM4UCLN36JRSXWCDM3M5VVJSCTL47P X-MailFrom: linus.luessing@c0d3.blue X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: The unicast packet rerouting code makes several assumptions. For instance it assumes that there is always exactly one destination in the TT. This breaks for multicast frames in a unicast packets in several ways: For one thing if there is actually no TT entry and the destination node was selected due to the multicast tvlv flags it announced. Then an intermediate node will wrongly drop the packet. For another thing if there is a TT entry but the TTVN of this entry is newer than the originally addressed destination node: Then the intermediate node will wrongly redirect the packet, leading to duplicated multicast packets at a multicast listener and missing packets at other multicast listeners or multicast routers. Fixing this by not applying the unicast packet rerouting to batman-adv unicast packets with a multicast payload. We are not able to detect a roaming multicast listener at the moment and will just continue to send the multicast frame to both the new and old destination for a while in case of such a roaming multicast listener. Fixes: cea194d90b11 ("batman-adv: improved client announcement mechanism") Signed-off-by: Linus Lüssing Acked-by: Simon Wunderlich --- net/batman-adv/routing.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 27cdf5e4..9e5c71e4 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -826,6 +826,10 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, vid = batadv_get_vid(skb, hdr_len); ethhdr = (struct ethhdr *)(skb->data + hdr_len); + /* do not reroute multicast frames in a unicast header */ + if (is_multicast_ether_addr(ethhdr->h_dest)) + return true; + /* check if the destination client was served by this node and it is now * roaming. In this case, it means that the node has got a ROAM_ADV * message and that it knows the new destination in the mesh to re-route From patchwork Fri Sep 4 18:28:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 18162 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id ADFD5806FA; Fri, 4 Sep 2020 20:28:10 +0200 (CEST) Received: from mail.aperture-lab.de (mail.aperture-lab.de [IPv6:2a01:4f8:171:314c::100:a1]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 139A08029D for ; Fri, 4 Sep 2020 20:28:08 +0200 (CEST) From: =?utf-8?q?Linus_L=C3=BCssing?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c0d3.blue; s=2018; t=1599244087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b1kASZP59YOMScZ9vaL3FTS9eMn7igbssv6DMnu15sk=; b=IK3UBUYKs1B/kfs2QevJR5m6JUmzXP6iWITYekta2piIqVoauB3noA2d4cn84JwceF2dy0 YwarrsMKcCH04pc8PHJD2ULbNKQ/SN192bzKPuiZqKO4rnqii3Mzxm3QOpS6odDpwH34zu cvG/vrm6DJaioUblVpvZW9NOKHQmt9Lkmcjn1jZL3AevoVQPvZTjt9VcC49CdwUflsIOWo ngxintykZdP+BKgGbI2V3zJ2hV7gPuOBnPZ8SvB5TuepaLvg5IH+39iFJIKc88Bqwwh5XA f9w/GOkKNWBJZ3QpVT7k0QhJZ5TbMSnSQMWZLSPhIgxirKlvVDZZF7nNRbkykQ== To: b.a.t.m.a.n@lists.open-mesh.org Cc: =?utf-8?q?Linus_L=C3=BCssing?= Subject: [PATCH maint v2 2/4] batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN Date: Fri, 4 Sep 2020 20:28:01 +0200 Message-Id: <20200904182803.8428-3-linus.luessing@c0d3.blue> In-Reply-To: <20200904182803.8428-1-linus.luessing@c0d3.blue> References: <20200904182803.8428-1-linus.luessing@c0d3.blue> MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=linus.luessing@c0d3.blue smtp.mailfrom=linus.luessing@c0d3.blue ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1599244088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=b1kASZP59YOMScZ9vaL3FTS9eMn7igbssv6DMnu15sk=; b=4PGTMgSuj22MlqV4VxOK/uY7/vF1TnQ1U6ofWaHQ4mNtpo0BrGHP4lhq5OxCPPu1qeZLNu QSA66Rkdv+VSpmph7wgikavqVgd7Nb2bC49l1KsdWy9pN3HuEPhygaNYzu/eb0cFh4goP3 fLD5IKp/zujKHlbhl/k+U+GgRYtXMwc= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1599244088; a=rsa-sha256; cv=none; b=15yM2mOxvZWhv3EowyubhhB3MKjTucZx7O1+5gMGCo4Id8Piuz/4bbWKmQyRKfbt7pKvoW tWay5ZAdCRBB606MWWXGFDKMrdlSFXLQu9q/Mn5evAZJ48OvABeHtva2RoPQGeEZSnljvX IOooqiWOAYjI3KtIAa7f7FtZ9gpwK4Y= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none (invalid DKIM record) header.d=c0d3.blue header.s=2018 header.b=IK3UBUYK; spf=none (diktynna.open-mesh.org: domain of linus.luessing@c0d3.blue has no SPF policy when checking 2a01:4f8:171:314c::100:a1) smtp.mailfrom=linus.luessing@c0d3.blue Message-ID-Hash: 26IZMV5EMXKD2OMQ5CABXSEJ3OXVMWZY X-Message-ID-Hash: 26IZMV5EMXKD2OMQ5CABXSEJ3OXVMWZY X-MailFrom: linus.luessing@c0d3.blue X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Scenario: * Multicast frame send from a BLA backbone (multiple nodes with their bat0 bridged together, with BLA enabled) Issue: * BLA backbone nodes receive the frame multiple times on bat0 For multicast frames received via batman-adv broadcast packets the originator of the broadcast packet is checked before decapsulating and forwarding the frame to bat0 (batadv_bla_is_backbone_gw()-> batadv_recv_bcast_packet()). If it came from a node which shares the same BLA backbone with us then it is not forwarded to bat0 to avoid a loop. When sending a multicast frame in a non-4-address batman-adv unicast packet we are currently missing this check - and cannot do so because the batman-adv unicast packet has no originator address field. However, we can simply fix this on the sender side by only sending the multicast frame via unicasts to interested nodes which do not share the same BLA backbone with us. This also nicely avoids some unnecessary transmissions on mesh side. Note that no infinite loop was observed, probably because of dropping via batadv_interface_tx()->batadv_bla_tx(). However the duplicates still utterly confuse switches/bridges, ICMPv6 duplicate address detection and neighbor discovery and therefore leads to long delays before being able to establish TCP connections, for instance. And it also leads to the Linux bridge printing messages like: "br-lan: received packet on eth1 with own address as source address ..." Fixes: 405cc1e5a81e ("batman-adv: Modified forwarding behaviour for multicast packets") Signed-off-by: Linus Lüssing --- net/batman-adv/send.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index d267b948..67f493c0 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -29,6 +29,7 @@ #include #include +#include "bridge_loop_avoidance.h" #include "distributed-arp-table.h" #include "fragmentation.h" #include "gateway_client.h" @@ -343,6 +344,18 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv, if (!orig_node) goto out; + /* Avoid sending multicast-in-unicast packets to other BLA + * gateways - they already got the frame from the LAN side + * we share with them. + * TODO: Refactor multicast code to anticipate this, to + * avoid this check here. + */ + if (is_multicast_ether_addr(eth_hdr(skb)->h_dest) && + batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, vid)) { + dev_kfree_skb(skb); + return NET_XMIT_SUCCESS; + } + switch (packet_type) { case BATADV_UNICAST: if (!batadv_send_skb_prepare_unicast(skb, orig_node)) From patchwork Fri Sep 4 18:28:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 18163 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 350378079A; Fri, 4 Sep 2020 20:28:16 +0200 (CEST) Received: from mail.aperture-lab.de (mail.aperture-lab.de [138.201.29.205]) by diktynna.open-mesh.org (Postfix) with ESMTPS id A3B3D803F5 for ; Fri, 4 Sep 2020 20:28:08 +0200 (CEST) From: =?utf-8?q?Linus_L=C3=BCssing?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c0d3.blue; s=2018; t=1599244088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N0suu9SmFCnuF08sj9iU30UuqseVIIpflbWICWb+qBE=; b=KqVJuQD5PYkcvlz1ZfkUS3gA8BOqcircH2VxySOkbK6gvlZPTh7dhAB6ZrzzjNEGUOkJ5K xibI/Y4T37T2EyKz23LpapvzZ7b003L1RDGNhHVz221PqLCZSikK6opI2iOWxZFZk+wPbl XI31JWcyn0ChK3fn6kW/fnPEJXujaiBsU9kWD0c8O7SeT89CXCufn8mmf6olUSz8ZCXeZv V5CpZWVdUR3kGFnbaGKar8WWNmVOun1wzXFkkh7R8o29R+OHDnsU0wkeQ5+Q/I/DYH4u7j TESEmQ/NEvWTACY8VLmJwL647frd0o+hy6t4P+bJAfC5rJ+bKoMTQEQzI6CYqQ== To: b.a.t.m.a.n@lists.open-mesh.org Cc: =?utf-8?q?Linus_L=C3=BCssing?= Subject: [PATCH maint v2 3/4] batman-adv: mcast: fix duplicate mcast packets in BLA backbone from mesh Date: Fri, 4 Sep 2020 20:28:02 +0200 Message-Id: <20200904182803.8428-4-linus.luessing@c0d3.blue> In-Reply-To: <20200904182803.8428-1-linus.luessing@c0d3.blue> References: <20200904182803.8428-1-linus.luessing@c0d3.blue> MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=linus.luessing@c0d3.blue smtp.mailfrom=linus.luessing@c0d3.blue ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1599244088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=N0suu9SmFCnuF08sj9iU30UuqseVIIpflbWICWb+qBE=; b=D6e1+o9ysdgp+7G41P4s9W7t8zDKCO7eWo5fbP+BhGf1VasSxKI/9RCO4nmgyS5+3lNhPH /ZrvaMrhxq/rgaRKssZH9NlzR3w13jHFtt1m4ifvUof/tgcyXYwRreQqPu6mWjE2aHCUH/ doIGcSPoU56wGBKomGQ8LnrKEBI1vwE= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1599244088; a=rsa-sha256; cv=none; b=NynJ4q3wv3qGzk09Nhmpbn/Ah/7RdYV7n0XAhrzG0S8geFcmbv5CPZz2YsxArwmlwj6tpZ wQW6QOvcwcUe4LKPh5bSJI5heSk8+x8Vq119rFZY9xbos+0P1j/hj91KTydFlltCDi17Sq avglO5P4kDrJbfeuxnELqUX2Zu7AZlA= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none (invalid DKIM record) header.d=c0d3.blue header.s=2018 header.b=KqVJuQD5; spf=none (diktynna.open-mesh.org: domain of linus.luessing@c0d3.blue has no SPF policy when checking 138.201.29.205) smtp.mailfrom=linus.luessing@c0d3.blue Message-ID-Hash: QEB34OGOG3GECYXRTBFNO3T7JMQ3ZDW4 X-Message-ID-Hash: QEB34OGOG3GECYXRTBFNO3T7JMQ3ZDW4 X-MailFrom: linus.luessing@c0d3.blue X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Scenario: * Multicast frame send from mesh to a BLA backbone (multiple nodes with their bat0 bridged together, with BLA enabled) Issue: * BLA backbone nodes receive the frame multiple times on bat0, once from mesh->bat0 and once from each backbone_gw from LAN For unicast, a node will send only to the best backbone gateway according to the TQ. However for multicast we currently cannot determine if multiple destination nodes share the same backbone if they don't share the same backbone with us. So we need to keep sending the unicasts to all backbone gateways and let the backbone gateways decide which one will forward the frame. We can use the CLAIM mechanism to make this decision. One catch: The batman-adv gateway feature for DHCP packets potentially sends multicast packets in the same batman-adv unicast header as the multicast optimizations code. And we are not allowed to drop those even if we did not claim the source address of the sender, as for such packets there is only this one multicast-in-unicast packet. How can we distinguish the two cases? For DHCPv4: Here the broadcast MAC address is used and the multicast optimizations will never send a broadcast frame via batman-adv unicast packets (see the !is_broadcast_ether_addr() check in after the goto-send in batadv_interface_tx(). For DHCPv6: This is even trickier... DHCPv6 potentially uses non-broadcast multicast addresses. However according to RFC8415, section 7.1 it seems that currently multicast is only used from a DHCPv6 client to a DHCPv6 server, but not the other way round. Working through the gateway feature part in batadv_interface_tx() it can be inferred that a DHCPv6 packet to a DHCP client would have been the only option for a DHCPv6 multicast packet to be sent via unicast through the gateway feature. Ergo, the newly introduced claim check won't wrongly drop a DHCPv6 packet received via the gateway feature either. Fixes: e32470167379 ("batman-adv: check incoming packet type for bla") Signed-off-by: Linus Lüssing --- net/batman-adv/bridge_loop_avoidance.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index d8c5d317..9603a6d0 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -1848,7 +1848,8 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, if (unlikely(atomic_read(&bat_priv->bla.num_requests))) /* don't allow broadcasts while requests are in flight */ - if (is_multicast_ether_addr(ethhdr->h_dest) && is_bcast) + if (is_multicast_ether_addr(ethhdr->h_dest) && + (!is_broadcast_ether_addr(ethhdr->h_dest) || is_bcast)) goto handled; ether_addr_copy(search_claim.addr, ethhdr->h_source); @@ -1885,7 +1886,8 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, } /* if it is a broadcast ... */ - if (is_multicast_ether_addr(ethhdr->h_dest) && is_bcast) { + if (is_multicast_ether_addr(ethhdr->h_dest) && + (!is_broadcast_ether_addr(ethhdr->h_dest) || is_bcast)) { /* ... drop it. the responsible gateway is in charge. * * We need to check is_bcast because with the gateway From patchwork Fri Sep 4 18:28:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 18164 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id A0D2880796; Fri, 4 Sep 2020 20:28:16 +0200 (CEST) Received: from mail.aperture-lab.de (mail.aperture-lab.de [138.201.29.205]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 426E0803C2 for ; Fri, 4 Sep 2020 20:28:09 +0200 (CEST) From: =?utf-8?q?Linus_L=C3=BCssing?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c0d3.blue; s=2018; t=1599244089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n31Xq1vmzbNcVaSHSWcbI2RSJO3EQ6O37W32yC/MEYM=; b=FJY79mK3Jicbs9oQC6YRY3PfmR66w0J0OrglUrOH1E5Q/TkaioUN2VjBnDbEmsgFmBQ0H2 NFrf4G2r0i512J8FHa+1AIGfLb4mdXEVTC9kkvMZ/hRQtSEeXqDZfC3P/E4PzgdiJpo6xO 0Y7BNo4Gg2zwfZgtcQed98HnfRYYsI38cmWubRIDsU+Byd2WM2ER5tYXXvDiVNn8bHLPrb vLQHbfw3LSUWgeD+ZTiWxBPeOmQfpLsmatbkK1rhOPZ9HOHWz2ckEsnZgrZVCldCE0GS9t AGoL7NkL9WaiUGmIg9y9Bjmj8NmWyWlbLxx4ykEIXMTwGAThFwYa3e4+cyGwgg== To: b.a.t.m.a.n@lists.open-mesh.org Cc: =?utf-8?q?Linus_L=C3=BCssing?= Subject: [PATCH maint v2 4/4] batman-adv: mcast: fix duplicate mcast packets from BLA backbone to mesh Date: Fri, 4 Sep 2020 20:28:03 +0200 Message-Id: <20200904182803.8428-5-linus.luessing@c0d3.blue> In-Reply-To: <20200904182803.8428-1-linus.luessing@c0d3.blue> References: <20200904182803.8428-1-linus.luessing@c0d3.blue> MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=linus.luessing@c0d3.blue smtp.mailfrom=linus.luessing@c0d3.blue ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1599244089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=n31Xq1vmzbNcVaSHSWcbI2RSJO3EQ6O37W32yC/MEYM=; b=OdnNskxNgDOinvUMfQ+YFVu+DLv9z56eAjMVSz9rmRVwHpRkfkqY8BX40Q+S2eqRGgQH4C LcN6RFuqRl908KlNDDywZnsxWhivp6Bnxh+ViY9ForOXpDhyRhmV++DB+sIVzO30YSuSX7 A+EJ3WRO56k0gZ6OCWl88ezjnXVzYkw= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1599244089; a=rsa-sha256; cv=none; b=QbLHYr+7+yV3f+2ZJb3aaRsA6JghcDT4DlTCOH0phD725mDbY2kRqIur7HEBRz58wXtBXb WivjeTsCgXqa/kagJv7AWDREKNchuim585StnxKsdLhe19wEWk+SQ1kySZkbHDEXKLtcGV ZAl87tWO3CXDkH4uPa7zh6yEVh/GBr4= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none (invalid DKIM record) header.d=c0d3.blue header.s=2018 header.b=FJY79mK3; spf=none (diktynna.open-mesh.org: domain of linus.luessing@c0d3.blue has no SPF policy when checking 138.201.29.205) smtp.mailfrom=linus.luessing@c0d3.blue Message-ID-Hash: IIHIIQZGKPKCW75DKZ66TGJNMWQSK7KZ X-Message-ID-Hash: IIHIIQZGKPKCW75DKZ66TGJNMWQSK7KZ X-MailFrom: linus.luessing@c0d3.blue X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Scenario: * Multicast frame send from BLA backbone gateways (multiple nodes with their bat0 bridged together, with BLA enabled) sharing the same LAN to nodes in the mesh Issue: * Nodes receive the frame multiple times on bat0 from the mesh, once from each foreign BLA backbone gateway which shares the same LAN with another For multicast frames via batman-adv broadcast packets coming from the same BLA backbone but from different backbone gateways duplicates are currently detected via a CRC history of previously received packets. However this CRC so far was not performed for multicast frames received via batman-adv unicast packets. Fixing this by appyling the same check for such packets, too. Room for improvements in the future: Ideally we would introduce the possibility to not only claim a client, but a complete originator, too. This would allow us to only send a multicast-in-unicast packet from a BLA backbone gateway claiming the node and by that avoid potential redundant transmissions in the first place. Fixes: e5cf86d30a9b ("batman-adv: add broadcast duplicate check") Signed-off-by: Linus Lüssing --- net/batman-adv/bridge_loop_avoidance.c | 86 +++++++++++++++++++++----- 1 file changed, 70 insertions(+), 16 deletions(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 9603a6d0..c509a83d 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -1580,14 +1580,16 @@ int batadv_bla_init(struct batadv_priv *bat_priv) } /** - * batadv_bla_check_bcast_duplist() - Check if a frame is in the broadcast dup. + * batadv_bla_check_duplist() - Check if a frame is in the broadcast dup. * @bat_priv: the bat priv with all the soft interface information - * @skb: contains the bcast_packet to be checked - * - * check if it is on our broadcast list. Another gateway might - * have sent the same packet because it is connected to the same backbone, - * so we have to remove this duplicate. + * @skb: contains the multicast packet to be checked + * @payload_ptr: pointer to position inside the head buffer of the skb + * marking the start of the data to be CRC'ed * + * Check if it is on our broadcast list. Another gateway might have sent the + * same packet because it is connected to the same backbone, so we have to + * remove this duplicate. + * This is performed by checking the CRC, which will tell us * with a good chance that it is the same packet. If it is furthermore * sent by another host, drop it. We allow equal packets from @@ -1595,19 +1597,17 @@ int batadv_bla_init(struct batadv_priv *bat_priv) * * Return: true if a packet is in the duplicate list, false otherwise. */ -bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, - struct sk_buff *skb) +static bool batadv_bla_check_duplist(struct batadv_priv *bat_priv, + struct sk_buff *skb, u8 *payload_ptr, + const u8 *orig) { + struct batadv_bcast_duplist_entry *entry; + bool ret = false; int i, curr; __be32 crc; - struct batadv_bcast_packet *bcast_packet; - struct batadv_bcast_duplist_entry *entry; - bool ret = false; - - bcast_packet = (struct batadv_bcast_packet *)skb->data; /* calculate the crc ... */ - crc = batadv_skb_crc32(skb, (u8 *)(bcast_packet + 1)); + crc = batadv_skb_crc32(skb, payload_ptr); spin_lock_bh(&bat_priv->bla.bcast_duplist_lock); @@ -1626,7 +1626,8 @@ bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, if (entry->crc != crc) continue; - if (batadv_compare_eth(entry->orig, bcast_packet->orig)) + if (!is_zero_ether_addr(entry->orig) && + batadv_compare_eth(entry->orig, orig)) continue; /* this entry seems to match: same crc, not too old, @@ -1643,7 +1644,7 @@ bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, entry = &bat_priv->bla.bcast_duplist[curr]; entry->crc = crc; entry->entrytime = jiffies; - ether_addr_copy(entry->orig, bcast_packet->orig); + ether_addr_copy(entry->orig, orig); bat_priv->bla.bcast_duplist_curr = curr; out: @@ -1652,6 +1653,52 @@ bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, return ret; } +/** + * batadv_bla_check_ucast_duplist() - Check if a frame is in the broadcast dup. + * @bat_priv: the bat priv with all the soft interface information + * @skb: contains the multicast packet to be checked, decapsulated from a + * unicast_packet + * + * Check if it is on our broadcast list. Another gateway might have sent the + * same packet because it is connected to the same backbone, so we have to + * remove this duplicate. + * + * Return: true if a packet is in the duplicate list, false otherwise. + */ +static bool batadv_bla_check_ucast_duplist(struct batadv_priv *bat_priv, + struct sk_buff *skb) +{ + u8 orig[ETH_ALEN]; + + eth_zero_addr(orig); + + return batadv_bla_check_duplist(bat_priv, skb, (u8 *)skb->data, orig); +} + +/** + * batadv_bla_check_bcast_duplist() - Check if a frame is in the broadcast dup. + * @bat_priv: the bat priv with all the soft interface information + * @skb: contains the bcast_packet to be checked + * + * Check if it is on our broadcast list. Another gateway might have sent the + * same packet because it is connected to the same backbone, so we have to + * remove this duplicate. + * + * Return: true if a packet is in the duplicate list, false otherwise. + */ +bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, + struct sk_buff *skb) +{ + struct batadv_bcast_packet *bcast_packet; + u8 *payload_ptr; + + bcast_packet = (struct batadv_bcast_packet *)skb->data; + payload_ptr = (u8 *)(bcast_packet + 1); + + return batadv_bla_check_duplist(bat_priv, skb, payload_ptr, + bcast_packet->orig); +} + /** * batadv_bla_is_backbone_gw_orig() - Check if the originator is a gateway for * the VLAN identified by vid. @@ -1852,6 +1899,13 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, (!is_broadcast_ether_addr(ethhdr->h_dest) || is_bcast)) goto handled; + /* potential duplicates from foreign BLA backbone gateways via + * multicast-in-unicast packets + */ + if (is_multicast_ether_addr(ethhdr->h_dest) && !is_bcast && + batadv_bla_check_ucast_duplist(bat_priv, skb)) + goto handled; + ether_addr_copy(search_claim.addr, ethhdr->h_source); search_claim.vid = vid; claim = batadv_claim_hash_find(bat_priv, &search_claim);