From: Henry Shen <henry.shen@alliedtelesis.co.nz>
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 <henry.shen@alliedtelesis.co.nz>
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 [thread overview]
Message-ID: <20210301005318.8959-2-henry.shen@alliedtelesis.co.nz> (raw)
In-Reply-To: <20210301005318.8959-1-henry.shen@alliedtelesis.co.nz>
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
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
forwarded if ingress interface is NOT configured with bc_forwarding,
but egress interface is.
Signed-off-by: Henry Shen <henry.shen@alliedtelesis.co.nz>
---
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 = true;
+ struct in_device *out_dev;
+ int rcv_local = 0;
/* IP on this device is disabled. */
@@ -2176,12 +2178,20 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
}
if (res->type == RTN_BROADCAST) {
+ out_dev = in_dev_get(FIB_RES_DEV(*res));
+ if (!out_dev)
+ goto out;
+
+ if (in_dev == out_dev)
+ rcv_local = 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 = false;
- goto brd_input;
+ if (rcv_local)
+ goto brd_input;
}
if (res->type == 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 != RTN_UNICAST)
- goto martian_destination;
+ if (res->type != RTN_BROADCAST)
+ goto martian_destination;
make_route:
err = ip_mkroute_input(skb, res, in_dev, daddr, saddr, tos, flkeys);
--
2.30.1
next prev parent reply other threads:[~2021-03-01 0:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-01 0:53 [PATCH] net:ipv4: Packet is not forwarded when ingress interface is not configured with bc_forwarding Henry Shen
2021-03-01 0:53 ` Henry Shen [this message]
2021-03-01 3:20 ` [PATCH] net:ipv4: Packet is not forwarded if bc_forwarding not configured on ingress interface David Ahern
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=20210301005318.8959-2-henry.shen@alliedtelesis.co.nz \
--to=henry.shen@alliedtelesis.co.nz \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.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).