Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2874898pxb; Sun, 28 Feb 2021 16:56:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPOfZHTCjw55IrNaK/t1q6Ld54RRJsGzrPyuhUWwweijp/+2PQPSdsm4yg+PFf14KP8yBI X-Received: by 2002:a17:906:503:: with SMTP id j3mr13423620eja.172.1614560179425; Sun, 28 Feb 2021 16:56:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614560179; cv=none; d=google.com; s=arc-20160816; b=0Hf7KfyO4aru/la8acx866puNnr7c9dp+Oj3eeijCJBvxH7UbqYg6MnbmE5QhOHkG6 bbAPHQq3V9lA1P87alhBIL+Wr6JqXu7NDi2ypSw+GDLtRBALFt4DF8gIHJIEXO7Sbg7I fs4NSolLnJFiuMqyqhCm5pgobLZGGczAzR+LGIkUwEukJLQCCANXO5J9e6MpRf4IH579 POQD0cSeUB91bILaBsy1b1DDKOO1o3y8mx73QjnKsC978AjZqeJsP5G2UqDz6EbAy8Gh JAxdw82uAienx31j0QWyeqmN0aPSnfFlZI96B2tyYbbu/36uhS202jhp8YD1pHu/8P5d xz3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oU64oT+/uvZCLimcb/1lw/7NAteJ0snaMeD1xJcKHCQ=; b=uYDVp/L7C1eI6jxBSH5U6QlNpQPu12MhGoMsy0KEacQqiDjGvKxndoI4bRRwQ6Cnq1 aYVm9doGcP8qp7t4PbgQ0D7ofO2HDBUCNiD0AsxGjdwih2JY6gGiGPWiyr26gqLfexYJ 02gICskFiOXRbz/6rG+Byyz9DsE+LUrMDjQOBMCIJxaVk9e42/pKBiieAxeaEvQg2elm cGomB/Q9qHLqDGI2PBLJUl7rHHu6QxmUNhRdesJi4eUQLGuQKs2UtS9jDwQkgmG6YMTb DtjIlZWNY/gmcAwBgdPa9dKzvupVjFKx/AgmMa3Jd9PU58Z4chxtFiK+MpC1FgeiF8uU b2vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=bo+wJ57M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alliedtelesis.co.nz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds7si10990809ejc.212.2021.02.28.16.55.57; Sun, 28 Feb 2021 16:56:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=bo+wJ57M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alliedtelesis.co.nz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231458AbhCAAyG (ORCPT + 99 others); Sun, 28 Feb 2021 19:54:06 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:35492 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231328AbhCAAyE (ORCPT ); Sun, 28 Feb 2021 19:54:04 -0500 Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 3EE19891AE; Mon, 1 Mar 2021 13:53:21 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1614560001; bh=oU64oT+/uvZCLimcb/1lw/7NAteJ0snaMeD1xJcKHCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bo+wJ57Mqkwt4efDuawg44+UOgC6kfDOvMaUw+VOB5Wa/a39r8yzyFqHF3zei77rG gcrdUwLewsPqaWYhKaxAC9NpqX3JBmnrmD4yp69L+nmesCd3sZjENHtoD5N9WExc5H GQ/9SmZzVysIYG9N5769pyok0yGfaePGlyxk/tFT/TWingQu1oQxn9czYv59KDv30Y z7tNm5hhaxegXMAHqIsLkvfT1w55CD2u2hzr+FdrDGC0K+wncwFyHZr228xV+YMmne MiNnCHHlbCOnPFPzf53N/mlgGEDFkIAFUJqVy4wzEkTO3hQDLGnpDnT6jU8nDnIJhu eOqZa1QB7Gh+Q== Received: from smtp (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Mon, 01 Mar 2021 13:53:21 +1300 Received: from henrys-dl.ws.atlnz.lc (henrys-dl.ws.atlnz.lc [10.33.23.26]) by smtp (Postfix) with ESMTP id 829FE13EF2A; Mon, 1 Mar 2021 13:53:31 +1300 (NZDT) Received: by henrys-dl.ws.atlnz.lc (Postfix, from userid 1052) id 129934E1333; Mon, 1 Mar 2021 13:53:21 +1300 (NZDT) From: Henry Shen To: davem@davemloft.net Cc: yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, chris.packham@alliedtelesis.co.nz, Henry Shen Subject: [PATCH] net:ipv4: Packet is not forwarded if bc_forwarding not configured on ingress interface Date: Mon, 1 Mar 2021 13:53:18 +1300 Message-Id: <20210301005318.8959-2-henry.shen@alliedtelesis.co.nz> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301005318.8959-1-henry.shen@alliedtelesis.co.nz> References: <20210301005318.8959-1-henry.shen@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SEG-SpamProfiler-Analysis: v=2.3 cv=C7uXNjH+ c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=dESyimp9J3IA:10 a=oz0IKz0CpFWYgAwaLeAA:9 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When an IPv4 packet with a destination address of broadcast is received on an ingress interface, it will not be forwarded out of the egress interface if the ingress interface is not configured with bc_forwarding=20 but the egress interface is. If both the ingress and egress interfaces are configured with bc_forwarding, the packet can be forwarded successfully. This patch is to be inline with Cisco's implementation that packet can be= =20 forwarded if ingress interface is NOT configured with bc_forwarding,=20 but egress interface is. Signed-off-by: Henry Shen --- net/ipv4/route.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 02d81d79deeb..d082b199b8c6 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2101,6 +2101,8 @@ static int ip_route_input_slow(struct sk_buff *skb,= __be32 daddr, __be32 saddr, struct rtable *rth; struct flowi4 fl4; bool do_cache =3D true; + struct in_device *out_dev; + int rcv_local =3D 0; =20 /* IP on this device is disabled. */ =20 @@ -2176,12 +2178,20 @@ static int ip_route_input_slow(struct sk_buff *sk= b, __be32 daddr, __be32 saddr, } =20 if (res->type =3D=3D RTN_BROADCAST) { + out_dev =3D in_dev_get(FIB_RES_DEV(*res)); + if (!out_dev) + goto out; + + if (in_dev =3D=3D out_dev) + rcv_local =3D 1; + in_dev_put(out_dev); if (IN_DEV_BFORWARD(in_dev)) goto make_route; /* not do cache if bc_forwarding is enabled */ if (IPV4_DEVCONF_ALL(net, BC_FORWARDING)) do_cache =3D false; - goto brd_input; + if (rcv_local) + goto brd_input; } =20 if (res->type =3D=3D RTN_LOCAL) { @@ -2197,7 +2207,8 @@ static int ip_route_input_slow(struct sk_buff *skb,= __be32 daddr, __be32 saddr, goto no_route; } if (res->type !=3D RTN_UNICAST) - goto martian_destination; + if (res->type !=3D RTN_BROADCAST) + goto martian_destination; =20 make_route: err =3D ip_mkroute_input(skb, res, in_dev, daddr, saddr, tos, flkeys); --=20 2.30.1