From patchwork Sat Nov 20 12:39:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18412 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 0A54D83E74; Sat, 20 Nov 2021 13:40:11 +0100 (CET) Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 8B7DB83E07 for ; Sat, 20 Nov 2021 13:40:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1637412007; 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=1qBqcJVzYM60kixb22EbboOokXXtbpsZ/Y57JewX2Vg=; b=KOR7D51FdRrEiWIFTulHLpVTikmXxpGHDeka7Frl7Cn/OtuJzJ6iIacQftOllw3RV2lY0E IOduTwEqnsSjO+U2YxbJy5xiTl9l8P32XFlBcXcCtwpQHxAG8XwYUMO2eI8G0/wEqtZk4Q aRJ+KFf5bjiq55SMsvKTpgwsMwGCkMo= From: Sven Eckelmann To: stable@vger.kernel.org Subject: [PATCH 4.9 2/7] batman-adv: Fix own OGM check in aggregated OGMs Date: Sat, 20 Nov 2021 13:39:53 +0100 Message-Id: <20211120123958.260826-3-sven@narfation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211120123958.260826-1-sven@narfation.org> References: <20211120123958.260826-1-sven@narfation.org> MIME-Version: 1.0 ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1637412007; a=rsa-sha256; cv=none; b=VQl4b7b47ncojj+PSwEy4ZMbKS2Hwi9Alvbzb15kTrqEkEwWq0hyufqXkIeIEOq8qiL6/P T6UEN1cF9y9bxMVW9pTRJEVboLrfJHMyHiybswpmKyi97Mck/XunX0y3N0+hVK4khv48WN MG6OFAWyaBfB/fAlkGSVz9HVXbEavp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1637412007; 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=1qBqcJVzYM60kixb22EbboOokXXtbpsZ/Y57JewX2Vg=; b=2In4/Idc/p9p0MHLKwSjkFs9sSeDsYlFfu8DjRj8q/4fhipP1g6zQWi/IzLn6dQkarXhqm iv9TlyDr7cX6nJLNXuURyNteroNrUcJTJIPX8HCtKZQG3PnnvckBaKT3P9mydwdiacaWfE nSGiDu/zwvjnouTo9U7oGKrpzdJPQzc= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=KOR7D51F; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 213.160.73.56 as permitted sender) smtp.mailfrom=sven@narfation.org; dmarc=pass (policy=none) header.from=narfation.org Message-ID-Hash: GUKCYV25R2JJHC5M6HISNGOMI7SDO75Z X-Message-ID-Hash: GUKCYV25R2JJHC5M6HISNGOMI7SDO75Z X-MailFrom: sven@narfation.org 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 CC: b.a.t.m.a.n@lists.open-mesh.org 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: From: Linus Lüssing commit d8bf0c01642275c7dca1e5d02c34e4199c200b1f upstream. The own OGM check is currently misplaced and can lead to the following issues: For one thing we might receive an aggregated OGM from a neighbor node which has our own OGM in the first place. We would then not only skip our own OGM but erroneously also any other, following OGM in the aggregate. For another, we might receive an OGM aggregate which has our own OGM in a place other then the first one. Then we would wrongly not skip this OGM, leading to populating the orginator and gateway table with ourself. Fixes: 9323158ef9f4 ("batman-adv: OGMv2 - implement originators logic") Signed-off-by: Linus Lüssing Signed-off-by: Simon Wunderlich [ bp: 4.9 backported: adjust context, correct fixes line ] Signed-off-by: Sven Eckelmann --- net/batman-adv/bat_v_ogm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index d2e6885479cb..cb94ac988618 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -690,6 +690,12 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset, ntohl(ogm_packet->seqno), ogm_throughput, ogm_packet->ttl, ogm_packet->version, ntohs(ogm_packet->tvlv_len)); + if (batadv_is_my_mac(bat_priv, ogm_packet->orig)) { + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, + "Drop packet: originator packet from ourself\n"); + return; + } + /* If the troughput metric is 0, immediately drop the packet. No need to * create orig_node / neigh_node for an unusable route. */ @@ -788,11 +794,6 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb, if (batadv_is_my_mac(bat_priv, ethhdr->h_source)) return NET_RX_DROP; - ogm_packet = (struct batadv_ogm2_packet *)skb->data; - - if (batadv_is_my_mac(bat_priv, ogm_packet->orig)) - return NET_RX_DROP; - batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX); batadv_add_counter(bat_priv, BATADV_CNT_MGMT_RX_BYTES, skb->len + ETH_HLEN);