BPF List
 help / color / mirror / Atom feed
From: Menglong Dong <menglong8.dong@gmail.com>
To: pabeni@redhat.com
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	dsahern@kernel.org, pablo@netfilter.org, kadlec@netfilter.org,
	roopa@nvidia.com, razor@blackwall.org, gnault@redhat.com,
	bigeasy@linutronix.de, idosch@nvidia.com, ast@kernel.org,
	dongml2@chinatelecom.cn, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org,
	coreteam@netfilter.org, bridge@lists.linux.dev,
	bpf@vger.kernel.org
Subject: [PATCH bpf-next v4 5/9] net: ip: make ip_route_input_rcu() return drop reasons
Date: Thu, 24 Oct 2024 17:33:44 +0800	[thread overview]
Message-ID: <20241024093348.353245-6-dongml2@chinatelecom.cn> (raw)
In-Reply-To: <20241024093348.353245-1-dongml2@chinatelecom.cn>

In this commit, we make ip_route_input_rcu() return drop reasons, which
come from ip_route_input_mc() and ip_route_input_slow().

The only caller of ip_route_input_rcu() is ip_route_input_noref(). We
adjust it by making it return -EINVAL on error and ignore the reasons that
ip_route_input_rcu() returns. In the following patch, we will make
ip_route_input_noref() returns the drop reasons.

Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
---
v4:
- collapse the 2 lines that we modify in inet_rtm_getroute()
---
 net/ipv4/route.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 7976f687d039..4b0daf3510d7 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2435,9 +2435,10 @@ ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 }
 
 /* called with rcu_read_lock held */
-static int ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
-			      dscp_t dscp, struct net_device *dev,
-			      struct fib_result *res)
+static enum skb_drop_reason
+ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
+		   dscp_t dscp, struct net_device *dev,
+		   struct fib_result *res)
 {
 	/* Multicast recognition logic is moved from route cache to here.
 	 * The problem was that too many Ethernet cards have broken/missing
@@ -2480,23 +2481,23 @@ static int ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 			reason = ip_route_input_mc(skb, daddr, saddr, dscp,
 						   dev, our);
 		}
-		return reason ? -EINVAL : 0;
+		return reason;
 	}
 
-	return ip_route_input_slow(skb, daddr, saddr, dscp, dev, res) ? -EINVAL : 0;
+	return ip_route_input_slow(skb, daddr, saddr, dscp, dev, res);
 }
 
 int ip_route_input_noref(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 			 dscp_t dscp, struct net_device *dev)
 {
+	enum skb_drop_reason reason;
 	struct fib_result res;
-	int err;
 
 	rcu_read_lock();
-	err = ip_route_input_rcu(skb, daddr, saddr, dscp, dev, &res);
+	reason = ip_route_input_rcu(skb, daddr, saddr, dscp, dev, &res);
 	rcu_read_unlock();
 
-	return err;
+	return reason ? -EINVAL : 0;
 }
 EXPORT_SYMBOL(ip_route_input_noref);
 
@@ -3308,7 +3309,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 		skb->mark	= mark;
 		err = ip_route_input_rcu(skb, dst, src,
 					 inet_dsfield_to_dscp(rtm->rtm_tos),
-					 dev, &res);
+					 dev, &res) ? -EINVAL : 0;
 
 		rt = skb_rtable(skb);
 		if (err == 0 && rt->dst.error)
-- 
2.39.5


  parent reply	other threads:[~2024-10-24  9:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24  9:33 [PATCH bpf-next v4 0/9] net: ip: add drop reasons to input route Menglong Dong
2024-10-24  9:33 ` [PATCH bpf-next v4 1/9] net: ip: make fib_validate_source() support drop reasons Menglong Dong
2024-10-24  9:33 ` [PATCH bpf-next v4 2/9] net: ip: make ip_route_input_mc() return drop reason Menglong Dong
2024-10-24  9:33 ` [PATCH bpf-next v4 3/9] net: ip: make ip_mc_validate_source() " Menglong Dong
2024-10-24  9:33 ` [PATCH bpf-next v4 4/9] net: ip: make ip_route_input_slow() return drop reasons Menglong Dong
2024-10-24  9:33 ` Menglong Dong [this message]
2024-10-24  9:33 ` [PATCH bpf-next v4 6/9] net: ip: make ip_route_input_noref() " Menglong Dong
2024-10-24  9:33 ` [PATCH bpf-next v4 7/9] net: ip: make ip_route_input() " Menglong Dong
2024-10-24  9:33 ` [PATCH bpf-next v4 8/9] net: ip: make ip_mkroute_input/__mkroute_input " Menglong Dong
2024-10-24  9:33 ` [PATCH bpf-next v4 9/9] net: ip: make ip_route_use_hint() " Menglong Dong
2024-10-30  0:03 ` [PATCH bpf-next v4 0/9] net: ip: add drop reasons to input route Jakub Kicinski
2024-10-30  1:35   ` Menglong Dong

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=20241024093348.353245-6-dongml2@chinatelecom.cn \
    --to=menglong8.dong@gmail.com \
    --cc=ast@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=bpf@vger.kernel.org \
    --cc=bridge@lists.linux.dev \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=dongml2@chinatelecom.cn \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=gnault@redhat.com \
    --cc=idosch@nvidia.com \
    --cc=kadlec@netfilter.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=razor@blackwall.org \
    --cc=roopa@nvidia.com \
    /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