netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL.
@ 2025-02-07  7:24 Kuniyuki Iwashima
  2025-02-07  7:24 ` [PATCH v2 net-next 1/8] net: fib_rules: Don't check net in rule_exists() and rule_find() Kuniyuki Iwashima
                   ` (10 more replies)
  0 siblings, 11 replies; 20+ messages in thread
From: Kuniyuki Iwashima @ 2025-02-07  7:24 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: Ido Schimmel, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev

Patch 1 ~ 2 are small cleanup, and patch 3 ~ 8 make fib_nl_newrule()
and fib_nl_delrule() hold per-netns RTNL.


Changes:
  v2:
    * Add patch 4 & 5
    * Don't use !!extack to check if RTNL is held

  v1: https://lore.kernel.org/netdev/20250206084629.16602-1-kuniyu@amazon.com/


Kuniyuki Iwashima (8):
  net: fib_rules: Don't check net in rule_exists() and rule_find().
  net: fib_rules: Pass net to fib_nl2rule() instead of skb.
  net: fib_rules: Split fib_nl2rule().
  ip: fib_rules: Fetch net from fib_rule in fib[46]_rule_configure().
  net: fib_rules: Factorise fib_newrule() and fib_delrule().
  net: fib_rules: Convert RTM_NEWRULE to per-netns RTNL.
  net: fib_rules: Add error_free label in fib_delrule().
  net: fib_rules: Convert RTM_DELRULE to per-netns RTNL.

 drivers/net/vrf.c       |   6 +-
 include/net/fib_rules.h |   8 +--
 net/core/fib_rules.c    | 151 ++++++++++++++++++++++++++--------------
 net/ipv4/fib_rules.c    |   4 +-
 net/ipv6/fib6_rules.c   |   4 +-
 5 files changed, 110 insertions(+), 63 deletions(-)

-- 
2.39.5 (Apple Git-154)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 net-next 1/8] net: fib_rules: Don't check net in rule_exists() and rule_find().
  2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
@ 2025-02-07  7:24 ` Kuniyuki Iwashima
  2025-02-07  8:27   ` Eric Dumazet
  2025-02-07  7:24 ` [PATCH v2 net-next 2/8] net: fib_rules: Pass net to fib_nl2rule() instead of skb Kuniyuki Iwashima
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Kuniyuki Iwashima @ 2025-02-07  7:24 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: Ido Schimmel, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev

fib_nl_newrule() / fib_nl_delrule() looks up struct fib_rules_ops
in sock_net(skb->sk) and calls rule_exists() / rule_find() respectively.

fib_nl_newrule() creates a new rule and links it to the found ops, so
struct fib_rule never belongs to a different netns's ops->rules_list.

Let's remove redundant netns check in rule_exists() and rule_find().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/core/fib_rules.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index e684ba3ebb38..02dfb841ab29 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -459,9 +459,6 @@ static struct fib_rule *rule_find(struct fib_rules_ops *ops,
 		if (rule->tun_id && r->tun_id != rule->tun_id)
 			continue;
 
-		if (r->fr_net != rule->fr_net)
-			continue;
-
 		if (rule->l3mdev && r->l3mdev != rule->l3mdev)
 			continue;
 
@@ -719,9 +716,6 @@ static int rule_exists(struct fib_rules_ops *ops, struct fib_rule_hdr *frh,
 		if (r->tun_id != rule->tun_id)
 			continue;
 
-		if (r->fr_net != rule->fr_net)
-			continue;
-
 		if (r->l3mdev != rule->l3mdev)
 			continue;
 
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 net-next 2/8] net: fib_rules: Pass net to fib_nl2rule() instead of skb.
  2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
  2025-02-07  7:24 ` [PATCH v2 net-next 1/8] net: fib_rules: Don't check net in rule_exists() and rule_find() Kuniyuki Iwashima
@ 2025-02-07  7:24 ` Kuniyuki Iwashima
  2025-02-07  8:28   ` Eric Dumazet
  2025-02-07  7:24 ` [PATCH v2 net-next 3/8] net: fib_rules: Split fib_nl2rule() Kuniyuki Iwashima
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Kuniyuki Iwashima @ 2025-02-07  7:24 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: Ido Schimmel, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev

skb is not used in fib_nl2rule() other than sock_net(skb->sk),
which is already available in callers, fib_nl_newrule() and
fib_nl_delrule().

Let's pass net directly to fib_nl2rule().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/core/fib_rules.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 02dfb841ab29..87f731199538 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -512,14 +512,13 @@ static int fib_nl2rule_l3mdev(struct nlattr *nla, struct fib_rule *nlrule,
 }
 #endif
 
-static int fib_nl2rule(struct sk_buff *skb, struct nlmsghdr *nlh,
+static int fib_nl2rule(struct net *net, struct nlmsghdr *nlh,
 		       struct netlink_ext_ack *extack,
 		       struct fib_rules_ops *ops,
 		       struct nlattr *tb[],
 		       struct fib_rule **rule,
 		       bool *user_priority)
 {
-	struct net *net = sock_net(skb->sk);
 	struct fib_rule_hdr *frh = nlmsg_data(nlh);
 	struct fib_rule *nlrule = NULL;
 	int err = -EINVAL;
@@ -798,7 +797,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
 		goto errout;
 	}
 
-	err = fib_nl2rule(skb, nlh, extack, ops, tb, &rule, &user_priority);
+	err = fib_nl2rule(net, nlh, extack, ops, tb, &rule, &user_priority);
 	if (err)
 		goto errout;
 
@@ -906,7 +905,7 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh,
 		goto errout;
 	}
 
-	err = fib_nl2rule(skb, nlh, extack, ops, tb, &nlrule, &user_priority);
+	err = fib_nl2rule(net, nlh, extack, ops, tb, &nlrule, &user_priority);
 	if (err)
 		goto errout;
 
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 net-next 3/8] net: fib_rules: Split fib_nl2rule().
  2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
  2025-02-07  7:24 ` [PATCH v2 net-next 1/8] net: fib_rules: Don't check net in rule_exists() and rule_find() Kuniyuki Iwashima
  2025-02-07  7:24 ` [PATCH v2 net-next 2/8] net: fib_rules: Pass net to fib_nl2rule() instead of skb Kuniyuki Iwashima
@ 2025-02-07  7:24 ` Kuniyuki Iwashima
  2025-02-07  8:30   ` Eric Dumazet
  2025-02-07  7:24 ` [PATCH v2 net-next 4/8] ip: fib_rules: Fetch net from fib_rule in fib[46]_rule_configure() Kuniyuki Iwashima
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Kuniyuki Iwashima @ 2025-02-07  7:24 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: Ido Schimmel, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev

We will move RTNL down to fib_nl_newrule() and fib_nl_delrule().

Some operations in fib_nl2rule() require RTNL: fib_default_rule_pref()
and __dev_get_by_name().

Let's split the RTNL parts as fib_nl2rule_rtnl().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/core/fib_rules.c | 58 +++++++++++++++++++++++++++++++-------------
 1 file changed, 41 insertions(+), 17 deletions(-)

diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 87f731199538..694a8c2884a8 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -550,30 +550,18 @@ static int fib_nl2rule(struct net *net, struct nlmsghdr *nlh,
 	if (tb[FRA_PRIORITY]) {
 		nlrule->pref = nla_get_u32(tb[FRA_PRIORITY]);
 		*user_priority = true;
-	} else {
-		nlrule->pref = fib_default_rule_pref(ops);
 	}
 
 	nlrule->proto = nla_get_u8_default(tb[FRA_PROTOCOL], RTPROT_UNSPEC);
 
 	if (tb[FRA_IIFNAME]) {
-		struct net_device *dev;
-
 		nlrule->iifindex = -1;
 		nla_strscpy(nlrule->iifname, tb[FRA_IIFNAME], IFNAMSIZ);
-		dev = __dev_get_by_name(net, nlrule->iifname);
-		if (dev)
-			nlrule->iifindex = dev->ifindex;
 	}
 
 	if (tb[FRA_OIFNAME]) {
-		struct net_device *dev;
-
 		nlrule->oifindex = -1;
 		nla_strscpy(nlrule->oifname, tb[FRA_OIFNAME], IFNAMSIZ);
-		dev = __dev_get_by_name(net, nlrule->oifname);
-		if (dev)
-			nlrule->oifindex = dev->ifindex;
 	}
 
 	if (tb[FRA_FWMARK]) {
@@ -615,11 +603,6 @@ static int fib_nl2rule(struct net *net, struct nlmsghdr *nlh,
 		}
 
 		nlrule->target = nla_get_u32(tb[FRA_GOTO]);
-		/* Backward jumps are prohibited to avoid endless loops */
-		if (nlrule->target <= nlrule->pref) {
-			NL_SET_ERR_MSG(extack, "Backward goto not supported");
-			goto errout_free;
-		}
 	} else if (nlrule->action == FR_ACT_GOTO) {
 		NL_SET_ERR_MSG(extack, "Missing goto target for action goto");
 		goto errout_free;
@@ -679,6 +662,39 @@ static int fib_nl2rule(struct net *net, struct nlmsghdr *nlh,
 	return err;
 }
 
+static int fib_nl2rule_rtnl(struct fib_rule *nlrule,
+			    struct fib_rules_ops *ops,
+			    struct nlattr *tb[],
+			    struct netlink_ext_ack *extack)
+{
+	if (!tb[FRA_PRIORITY])
+		nlrule->pref = fib_default_rule_pref(ops);
+
+	/* Backward jumps are prohibited to avoid endless loops */
+	if (tb[FRA_GOTO] && nlrule->target <= nlrule->pref) {
+		NL_SET_ERR_MSG(extack, "Backward goto not supported");
+		return -EINVAL;
+	}
+
+	if (tb[FRA_IIFNAME]) {
+		struct net_device *dev;
+
+		dev = __dev_get_by_name(nlrule->fr_net, nlrule->iifname);
+		if (dev)
+			nlrule->iifindex = dev->ifindex;
+	}
+
+	if (tb[FRA_OIFNAME]) {
+		struct net_device *dev;
+
+		dev = __dev_get_by_name(nlrule->fr_net, nlrule->oifname);
+		if (dev)
+			nlrule->oifindex = dev->ifindex;
+	}
+
+	return 0;
+}
+
 static int rule_exists(struct fib_rules_ops *ops, struct fib_rule_hdr *frh,
 		       struct nlattr **tb, struct fib_rule *rule)
 {
@@ -801,6 +817,10 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
 	if (err)
 		goto errout;
 
+	err = fib_nl2rule_rtnl(rule, ops, tb, extack);
+	if (err)
+		goto errout_free;
+
 	if ((nlh->nlmsg_flags & NLM_F_EXCL) &&
 	    rule_exists(ops, frh, tb, rule)) {
 		err = -EEXIST;
@@ -909,6 +929,10 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh,
 	if (err)
 		goto errout;
 
+	err = fib_nl2rule_rtnl(nlrule, ops, tb, extack);
+	if (err)
+		goto errout;
+
 	rule = rule_find(ops, frh, tb, nlrule, user_priority);
 	if (!rule) {
 		err = -ENOENT;
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 net-next 4/8] ip: fib_rules: Fetch net from fib_rule in fib[46]_rule_configure().
  2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
                   ` (2 preceding siblings ...)
  2025-02-07  7:24 ` [PATCH v2 net-next 3/8] net: fib_rules: Split fib_nl2rule() Kuniyuki Iwashima
@ 2025-02-07  7:24 ` Kuniyuki Iwashima
  2025-02-07  8:34   ` Eric Dumazet
  2025-02-07  7:24 ` [PATCH v2 net-next 5/8] net: fib_rules: Factorise fib_newrule() and fib_delrule() Kuniyuki Iwashima
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Kuniyuki Iwashima @ 2025-02-07  7:24 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: Ido Schimmel, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev

The following patch will not set skb->sk from VRF path.

Let's fetch net from fib_rule->fr_net instead of sock_net(skb->sk)
in fib[46]_rule_configure().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/ipv4/fib_rules.c  | 4 ++--
 net/ipv6/fib6_rules.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 9517b8667e00..041c46787d94 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -245,9 +245,9 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
 			       struct nlattr **tb,
 			       struct netlink_ext_ack *extack)
 {
-	struct net *net = sock_net(skb->sk);
+	struct fib4_rule *rule4 = (struct fib4_rule *)rule;
+	struct net *net = rule->fr_net;
 	int err = -EINVAL;
-	struct fib4_rule *rule4 = (struct fib4_rule *) rule;
 
 	if (tb[FRA_FLOWLABEL] || tb[FRA_FLOWLABEL_MASK]) {
 		NL_SET_ERR_MSG(extack,
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 67d39114d9a6..40af8fd6efa7 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -399,9 +399,9 @@ static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
 			       struct nlattr **tb,
 			       struct netlink_ext_ack *extack)
 {
+	struct fib6_rule *rule6 = (struct fib6_rule *)rule;
+	struct net *net = rule->fr_net;
 	int err = -EINVAL;
-	struct net *net = sock_net(skb->sk);
-	struct fib6_rule *rule6 = (struct fib6_rule *) rule;
 
 	if (!inet_validate_dscp(frh->tos)) {
 		NL_SET_ERR_MSG(extack,
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 net-next 5/8] net: fib_rules: Factorise fib_newrule() and fib_delrule().
  2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
                   ` (3 preceding siblings ...)
  2025-02-07  7:24 ` [PATCH v2 net-next 4/8] ip: fib_rules: Fetch net from fib_rule in fib[46]_rule_configure() Kuniyuki Iwashima
@ 2025-02-07  7:24 ` Kuniyuki Iwashima
  2025-02-07  8:34   ` Eric Dumazet
  2025-02-07  7:25 ` [PATCH v2 net-next 6/8] net: fib_rules: Convert RTM_NEWRULE to per-netns RTNL Kuniyuki Iwashima
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Kuniyuki Iwashima @ 2025-02-07  7:24 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: Ido Schimmel, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev

fib_nl_newrule() / fib_nl_delrule() is the doit() handler for
RTM_NEWRULE / RTM_DELRULE but also called from vrf_newlink().

Currently, we hold RTNL on both paths but will not on the former.

Also, we set dev_net(dev)->rtnl to skb->sk in vrf_fib_rule() because
fib_nl_newrule() / fib_nl_delrule() fetch net as sock_net(skb->sk).

Let's Factorise the two functions and pass net and rtnl_held flag.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 drivers/net/vrf.c       |  6 ++----
 include/net/fib_rules.h |  8 ++++----
 net/core/fib_rules.c    | 36 +++++++++++++++++++++++-------------
 3 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index ca81b212a246..5f21ce1013c4 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -1537,14 +1537,12 @@ static int vrf_fib_rule(const struct net_device *dev, __u8 family, bool add_it)
 
 	nlmsg_end(skb, nlh);
 
-	/* fib_nl_{new,del}rule handling looks for net from skb->sk */
-	skb->sk = dev_net(dev)->rtnl;
 	if (add_it) {
-		err = fib_nl_newrule(skb, nlh, NULL);
+		err = fib_newrule(dev_net(dev), skb, nlh, NULL, true);
 		if (err == -EEXIST)
 			err = 0;
 	} else {
-		err = fib_nl_delrule(skb, nlh, NULL);
+		err = fib_delrule(dev_net(dev), skb, nlh, NULL, true);
 		if (err == -ENOENT)
 			err = 0;
 	}
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 04383d90a1e3..710caacad9da 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -178,10 +178,10 @@ int fib_rules_dump(struct net *net, struct notifier_block *nb, int family,
 		   struct netlink_ext_ack *extack);
 unsigned int fib_rules_seq_read(const struct net *net, int family);
 
-int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
-		   struct netlink_ext_ack *extack);
-int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh,
-		   struct netlink_ext_ack *extack);
+int fib_newrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
+		struct netlink_ext_ack *extack, bool rtnl_held);
+int fib_delrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
+		struct netlink_ext_ack *extack, bool rtnl_held);
 
 INDIRECT_CALLABLE_DECLARE(int fib6_rule_match(struct fib_rule *rule,
 					    struct flowi *fl, int flags));
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 694a8c2884a8..d68332d9cac6 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -783,15 +783,14 @@ static const struct nla_policy fib_rule_policy[FRA_MAX + 1] = {
 	[FRA_FLOWLABEL_MASK] = { .type = NLA_BE32 },
 };
 
-int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
-		   struct netlink_ext_ack *extack)
+int fib_newrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
+		struct netlink_ext_ack *extack, bool rtnl_held)
 {
-	struct net *net = sock_net(skb->sk);
+	struct fib_rule *rule = NULL, *r, *last = NULL;
 	struct fib_rule_hdr *frh = nlmsg_data(nlh);
+	int err = -EINVAL, unresolved = 0;
 	struct fib_rules_ops *ops = NULL;
-	struct fib_rule *rule = NULL, *r, *last = NULL;
 	struct nlattr *tb[FRA_MAX + 1];
-	int err = -EINVAL, unresolved = 0;
 	bool user_priority = false;
 
 	if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh))) {
@@ -893,18 +892,23 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
 	rules_ops_put(ops);
 	return err;
 }
-EXPORT_SYMBOL_GPL(fib_nl_newrule);
+EXPORT_SYMBOL_GPL(fib_newrule);
 
-int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh,
-		   struct netlink_ext_ack *extack)
+static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
+			  struct netlink_ext_ack *extack)
 {
-	struct net *net = sock_net(skb->sk);
+	return fib_newrule(sock_net(skb->sk), skb, nlh, extack, true);
+}
+
+int fib_delrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
+		struct netlink_ext_ack *extack, bool rtnl_held)
+{
+	struct fib_rule *rule = NULL, *nlrule = NULL;
 	struct fib_rule_hdr *frh = nlmsg_data(nlh);
 	struct fib_rules_ops *ops = NULL;
-	struct fib_rule *rule = NULL, *r, *nlrule = NULL;
 	struct nlattr *tb[FRA_MAX+1];
-	int err = -EINVAL;
 	bool user_priority = false;
+	int err = -EINVAL;
 
 	if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh))) {
 		NL_SET_ERR_MSG(extack, "Invalid msg length");
@@ -969,7 +973,7 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh,
 	 * current if it is goto rule, have actually been added.
 	 */
 	if (ops->nr_goto_rules > 0) {
-		struct fib_rule *n;
+		struct fib_rule *n, *r;
 
 		n = list_next_entry(rule, list);
 		if (&n->list == &ops->rules_list || n->pref != rule->pref)
@@ -998,7 +1002,13 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh,
 	rules_ops_put(ops);
 	return err;
 }
-EXPORT_SYMBOL_GPL(fib_nl_delrule);
+EXPORT_SYMBOL_GPL(fib_delrule);
+
+static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh,
+			  struct netlink_ext_ack *extack)
+{
+	return fib_delrule(sock_net(skb->sk), skb, nlh, extack, true);
+}
 
 static inline size_t fib_rule_nlmsg_size(struct fib_rules_ops *ops,
 					 struct fib_rule *rule)
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 net-next 6/8] net: fib_rules: Convert RTM_NEWRULE to per-netns RTNL.
  2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
                   ` (4 preceding siblings ...)
  2025-02-07  7:24 ` [PATCH v2 net-next 5/8] net: fib_rules: Factorise fib_newrule() and fib_delrule() Kuniyuki Iwashima
@ 2025-02-07  7:25 ` Kuniyuki Iwashima
  2025-02-07  8:35   ` Eric Dumazet
  2025-02-07  7:25 ` [PATCH v2 net-next 7/8] net: fib_rules: Add error_free label in fib_delrule() Kuniyuki Iwashima
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Kuniyuki Iwashima @ 2025-02-07  7:25 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: Ido Schimmel, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev

fib_nl_newrule() is the doit() handler for RTM_NEWRULE but also called
from vrf_newlink().

In the latter case, RTNL is already held and the 4th arg is true.

Let's hold per-netns RTNL in fib_newrule() if rtnl_held is false.

Note that we call fib_rule_get() before releasing per-netns RTNL to call
notify_rule_change() without RTNL and prevent freeing the new rule.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/core/fib_rules.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index d68332d9cac6..d0995ea9d852 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -816,6 +816,9 @@ int fib_newrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
 	if (err)
 		goto errout;
 
+	if (!rtnl_held)
+		rtnl_net_lock(net);
+
 	err = fib_nl2rule_rtnl(rule, ops, tb, extack);
 	if (err)
 		goto errout_free;
@@ -881,12 +884,20 @@ int fib_newrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
 	if (rule->tun_id)
 		ip_tunnel_need_metadata();
 
+	fib_rule_get(rule);
+
+	if (!rtnl_held)
+		rtnl_net_unlock(net);
+
 	notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).portid);
+	fib_rule_put(rule);
 	flush_route_cache(ops);
 	rules_ops_put(ops);
 	return 0;
 
 errout_free:
+	if (!rtnl_held)
+		rtnl_net_unlock(net);
 	kfree(rule);
 errout:
 	rules_ops_put(ops);
@@ -897,7 +908,7 @@ EXPORT_SYMBOL_GPL(fib_newrule);
 static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,
 			  struct netlink_ext_ack *extack)
 {
-	return fib_newrule(sock_net(skb->sk), skb, nlh, extack, true);
+	return fib_newrule(sock_net(skb->sk), skb, nlh, extack, false);
 }
 
 int fib_delrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -1320,7 +1331,8 @@ static struct pernet_operations fib_rules_net_ops = {
 };
 
 static const struct rtnl_msg_handler fib_rules_rtnl_msg_handlers[] __initconst = {
-	{.msgtype = RTM_NEWRULE, .doit = fib_nl_newrule},
+	{.msgtype = RTM_NEWRULE, .doit = fib_nl_newrule,
+	 .flags = RTNL_FLAG_DOIT_PERNET},
 	{.msgtype = RTM_DELRULE, .doit = fib_nl_delrule},
 	{.msgtype = RTM_GETRULE, .dumpit = fib_nl_dumprule,
 	 .flags = RTNL_FLAG_DUMP_UNLOCKED},
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 net-next 7/8] net: fib_rules: Add error_free label in fib_delrule().
  2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
                   ` (5 preceding siblings ...)
  2025-02-07  7:25 ` [PATCH v2 net-next 6/8] net: fib_rules: Convert RTM_NEWRULE to per-netns RTNL Kuniyuki Iwashima
@ 2025-02-07  7:25 ` Kuniyuki Iwashima
  2025-02-07  8:37   ` Eric Dumazet
  2025-02-07  7:25 ` [PATCH v2 net-next 8/8] net: fib_rules: Convert RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Kuniyuki Iwashima @ 2025-02-07  7:25 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: Ido Schimmel, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev

We will hold RTNL just before calling fib_nl2rule_rtnl() in
fib_delrule() and release it before kfree(nlrule).

Let's add a new rule to make the following change cleaner.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/core/fib_rules.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index d0995ea9d852..10a7336b8d44 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -946,23 +946,23 @@ int fib_delrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	err = fib_nl2rule_rtnl(nlrule, ops, tb, extack);
 	if (err)
-		goto errout;
+		goto errout_free;
 
 	rule = rule_find(ops, frh, tb, nlrule, user_priority);
 	if (!rule) {
 		err = -ENOENT;
-		goto errout;
+		goto errout_free;
 	}
 
 	if (rule->flags & FIB_RULE_PERMANENT) {
 		err = -EPERM;
-		goto errout;
+		goto errout_free;
 	}
 
 	if (ops->delete) {
 		err = ops->delete(rule);
 		if (err)
-			goto errout;
+			goto errout_free;
 	}
 
 	if (rule->tun_id)
@@ -1008,8 +1008,9 @@ int fib_delrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
 	kfree(nlrule);
 	return 0;
 
-errout:
+errout_free:
 	kfree(nlrule);
+errout:
 	rules_ops_put(ops);
 	return err;
 }
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 net-next 8/8] net: fib_rules: Convert RTM_DELRULE to per-netns RTNL.
  2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
                   ` (6 preceding siblings ...)
  2025-02-07  7:25 ` [PATCH v2 net-next 7/8] net: fib_rules: Add error_free label in fib_delrule() Kuniyuki Iwashima
@ 2025-02-07  7:25 ` Kuniyuki Iwashima
  2025-02-07  8:36   ` Eric Dumazet
  2025-02-07  8:37 ` [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and " Eric Dumazet
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 20+ messages in thread
From: Kuniyuki Iwashima @ 2025-02-07  7:25 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: Ido Schimmel, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev

fib_nl_delrule() is the doit() handler for RTM_DELRULE but also called
from vrf_newlink() in case something fails in vrf_add_fib_rules().

In the latter case, RTNL is already held and the 4th arg is true.

Let's hold per-netns RTNL in fib_delrule() if rtnl_held is false.

Now we can place ASSERT_RTNL_NET() in call_fib_rule_notifiers().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/core/fib_rules.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 10a7336b8d44..5045affeac78 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -371,7 +371,8 @@ static int call_fib_rule_notifiers(struct net *net,
 		.rule = rule,
 	};
 
-	ASSERT_RTNL();
+	ASSERT_RTNL_NET(net);
+
 	/* Paired with READ_ONCE() in fib_rules_seq() */
 	WRITE_ONCE(ops->fib_rules_seq, ops->fib_rules_seq + 1);
 	return call_fib_notifiers(net, event_type, &info.info);
@@ -944,6 +945,9 @@ int fib_delrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
 	if (err)
 		goto errout;
 
+	if (!rtnl_held)
+		rtnl_net_lock(net);
+
 	err = fib_nl2rule_rtnl(nlrule, ops, tb, extack);
 	if (err)
 		goto errout_free;
@@ -998,10 +1002,12 @@ int fib_delrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
 		}
 	}
 
-	call_fib_rule_notifiers(net, FIB_EVENT_RULE_DEL, rule, ops,
-				NULL);
-	notify_rule_change(RTM_DELRULE, rule, ops, nlh,
-			   NETLINK_CB(skb).portid);
+	call_fib_rule_notifiers(net, FIB_EVENT_RULE_DEL, rule, ops, NULL);
+
+	if (!rtnl_held)
+		rtnl_net_unlock(net);
+
+	notify_rule_change(RTM_DELRULE, rule, ops, nlh, NETLINK_CB(skb).portid);
 	fib_rule_put(rule);
 	flush_route_cache(ops);
 	rules_ops_put(ops);
@@ -1009,6 +1015,8 @@ int fib_delrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
 	return 0;
 
 errout_free:
+	if (!rtnl_held)
+		rtnl_net_unlock(net);
 	kfree(nlrule);
 errout:
 	rules_ops_put(ops);
@@ -1019,7 +1027,7 @@ EXPORT_SYMBOL_GPL(fib_delrule);
 static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh,
 			  struct netlink_ext_ack *extack)
 {
-	return fib_delrule(sock_net(skb->sk), skb, nlh, extack, true);
+	return fib_delrule(sock_net(skb->sk), skb, nlh, extack, false);
 }
 
 static inline size_t fib_rule_nlmsg_size(struct fib_rules_ops *ops,
@@ -1334,7 +1342,8 @@ static struct pernet_operations fib_rules_net_ops = {
 static const struct rtnl_msg_handler fib_rules_rtnl_msg_handlers[] __initconst = {
 	{.msgtype = RTM_NEWRULE, .doit = fib_nl_newrule,
 	 .flags = RTNL_FLAG_DOIT_PERNET},
-	{.msgtype = RTM_DELRULE, .doit = fib_nl_delrule},
+	{.msgtype = RTM_DELRULE, .doit = fib_nl_delrule,
+	 .flags = RTNL_FLAG_DOIT_PERNET},
 	{.msgtype = RTM_GETRULE, .dumpit = fib_nl_dumprule,
 	 .flags = RTNL_FLAG_DUMP_UNLOCKED},
 };
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 net-next 1/8] net: fib_rules: Don't check net in rule_exists() and rule_find().
  2025-02-07  7:24 ` [PATCH v2 net-next 1/8] net: fib_rules: Don't check net in rule_exists() and rule_find() Kuniyuki Iwashima
@ 2025-02-07  8:27   ` Eric Dumazet
  0 siblings, 0 replies; 20+ messages in thread
From: Eric Dumazet @ 2025-02-07  8:27 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Ido Schimmel, Kuniyuki Iwashima, netdev

On Fri, Feb 7, 2025 at 8:25 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> fib_nl_newrule() / fib_nl_delrule() looks up struct fib_rules_ops
> in sock_net(skb->sk) and calls rule_exists() / rule_find() respectively.
>
> fib_nl_newrule() creates a new rule and links it to the found ops, so
> struct fib_rule never belongs to a different netns's ops->rules_list.
>
> Let's remove redundant netns check in rule_exists() and rule_find().
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 net-next 2/8] net: fib_rules: Pass net to fib_nl2rule() instead of skb.
  2025-02-07  7:24 ` [PATCH v2 net-next 2/8] net: fib_rules: Pass net to fib_nl2rule() instead of skb Kuniyuki Iwashima
@ 2025-02-07  8:28   ` Eric Dumazet
  0 siblings, 0 replies; 20+ messages in thread
From: Eric Dumazet @ 2025-02-07  8:28 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Ido Schimmel, Kuniyuki Iwashima, netdev

On Fri, Feb 7, 2025 at 8:26 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> skb is not used in fib_nl2rule() other than sock_net(skb->sk),
> which is already available in callers, fib_nl_newrule() and
> fib_nl_delrule().
>
> Let's pass net directly to fib_nl2rule().
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 net-next 3/8] net: fib_rules: Split fib_nl2rule().
  2025-02-07  7:24 ` [PATCH v2 net-next 3/8] net: fib_rules: Split fib_nl2rule() Kuniyuki Iwashima
@ 2025-02-07  8:30   ` Eric Dumazet
  0 siblings, 0 replies; 20+ messages in thread
From: Eric Dumazet @ 2025-02-07  8:30 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Ido Schimmel, Kuniyuki Iwashima, netdev

On Fri, Feb 7, 2025 at 8:26 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> We will move RTNL down to fib_nl_newrule() and fib_nl_delrule().
>
> Some operations in fib_nl2rule() require RTNL: fib_default_rule_pref()
> and __dev_get_by_name().
>
> Let's split the RTNL parts as fib_nl2rule_rtnl().
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 net-next 5/8] net: fib_rules: Factorise fib_newrule() and fib_delrule().
  2025-02-07  7:24 ` [PATCH v2 net-next 5/8] net: fib_rules: Factorise fib_newrule() and fib_delrule() Kuniyuki Iwashima
@ 2025-02-07  8:34   ` Eric Dumazet
  0 siblings, 0 replies; 20+ messages in thread
From: Eric Dumazet @ 2025-02-07  8:34 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Ido Schimmel, Kuniyuki Iwashima, netdev

On Fri, Feb 7, 2025 at 8:27 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> fib_nl_newrule() / fib_nl_delrule() is the doit() handler for
> RTM_NEWRULE / RTM_DELRULE but also called from vrf_newlink().
>
> Currently, we hold RTNL on both paths but will not on the former.
>
> Also, we set dev_net(dev)->rtnl to skb->sk in vrf_fib_rule() because
> fib_nl_newrule() / fib_nl_delrule() fetch net as sock_net(skb->sk).
>
> Let's Factorise the two functions and pass net and rtnl_held flag.
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Much nicer, thanks !

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 net-next 4/8] ip: fib_rules: Fetch net from fib_rule in fib[46]_rule_configure().
  2025-02-07  7:24 ` [PATCH v2 net-next 4/8] ip: fib_rules: Fetch net from fib_rule in fib[46]_rule_configure() Kuniyuki Iwashima
@ 2025-02-07  8:34   ` Eric Dumazet
  0 siblings, 0 replies; 20+ messages in thread
From: Eric Dumazet @ 2025-02-07  8:34 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Ido Schimmel, Kuniyuki Iwashima, netdev

On Fri, Feb 7, 2025 at 8:27 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> The following patch will not set skb->sk from VRF path.
>
> Let's fetch net from fib_rule->fr_net instead of sock_net(skb->sk)
> in fib[46]_rule_configure().
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 net-next 6/8] net: fib_rules: Convert RTM_NEWRULE to per-netns RTNL.
  2025-02-07  7:25 ` [PATCH v2 net-next 6/8] net: fib_rules: Convert RTM_NEWRULE to per-netns RTNL Kuniyuki Iwashima
@ 2025-02-07  8:35   ` Eric Dumazet
  0 siblings, 0 replies; 20+ messages in thread
From: Eric Dumazet @ 2025-02-07  8:35 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Ido Schimmel, Kuniyuki Iwashima, netdev

On Fri, Feb 7, 2025 at 8:27 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> fib_nl_newrule() is the doit() handler for RTM_NEWRULE but also called
> from vrf_newlink().
>
> In the latter case, RTNL is already held and the 4th arg is true.
>
> Let's hold per-netns RTNL in fib_newrule() if rtnl_held is false.
>
> Note that we call fib_rule_get() before releasing per-netns RTNL to call
> notify_rule_change() without RTNL and prevent freeing the new rule.
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 net-next 8/8] net: fib_rules: Convert RTM_DELRULE to per-netns RTNL.
  2025-02-07  7:25 ` [PATCH v2 net-next 8/8] net: fib_rules: Convert RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
@ 2025-02-07  8:36   ` Eric Dumazet
  0 siblings, 0 replies; 20+ messages in thread
From: Eric Dumazet @ 2025-02-07  8:36 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Ido Schimmel, Kuniyuki Iwashima, netdev

On Fri, Feb 7, 2025 at 8:28 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> fib_nl_delrule() is the doit() handler for RTM_DELRULE but also called
> from vrf_newlink() in case something fails in vrf_add_fib_rules().
>
> In the latter case, RTNL is already held and the 4th arg is true.
>
> Let's hold per-netns RTNL in fib_delrule() if rtnl_held is false.
>
> Now we can place ASSERT_RTNL_NET() in call_fib_rule_notifiers().
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 net-next 7/8] net: fib_rules: Add error_free label in fib_delrule().
  2025-02-07  7:25 ` [PATCH v2 net-next 7/8] net: fib_rules: Add error_free label in fib_delrule() Kuniyuki Iwashima
@ 2025-02-07  8:37   ` Eric Dumazet
  0 siblings, 0 replies; 20+ messages in thread
From: Eric Dumazet @ 2025-02-07  8:37 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Ido Schimmel, Kuniyuki Iwashima, netdev

On Fri, Feb 7, 2025 at 8:28 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> We will hold RTNL just before calling fib_nl2rule_rtnl() in
> fib_delrule() and release it before kfree(nlrule).
>
> Let's add a new rule to make the following change cleaner.
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL.
  2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
                   ` (7 preceding siblings ...)
  2025-02-07  7:25 ` [PATCH v2 net-next 8/8] net: fib_rules: Convert RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
@ 2025-02-07  8:37 ` Eric Dumazet
  2025-02-07 10:20 ` Ido Schimmel
  2025-02-11  3:30 ` patchwork-bot+netdevbpf
  10 siblings, 0 replies; 20+ messages in thread
From: Eric Dumazet @ 2025-02-07  8:37 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Ido Schimmel, Kuniyuki Iwashima, netdev

On Fri, Feb 7, 2025 at 8:25 AM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> Patch 1 ~ 2 are small cleanup, and patch 3 ~ 8 make fib_nl_newrule()
> and fib_nl_delrule() hold per-netns RTNL.
>
>
> Changes:
>   v2:
>     * Add patch 4 & 5
>     * Don't use !!extack to check if RTNL is held
>
>   v1: https://lore.kernel.org/netdev/20250206084629.16602-1-kuniyu@amazon.com/
>

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL.
  2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
                   ` (8 preceding siblings ...)
  2025-02-07  8:37 ` [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and " Eric Dumazet
@ 2025-02-07 10:20 ` Ido Schimmel
  2025-02-11  3:30 ` patchwork-bot+netdevbpf
  10 siblings, 0 replies; 20+ messages in thread
From: Ido Schimmel @ 2025-02-07 10:20 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Kuniyuki Iwashima, netdev

On Fri, Feb 07, 2025 at 04:24:54PM +0900, Kuniyuki Iwashima wrote:
> Patch 1 ~ 2 are small cleanup, and patch 3 ~ 8 make fib_nl_newrule()
> and fib_nl_delrule() hold per-netns RTNL.

Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Tested-by: Ido Schimmel <idosch@nvidia.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL.
  2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
                   ` (9 preceding siblings ...)
  2025-02-07 10:20 ` Ido Schimmel
@ 2025-02-11  3:30 ` patchwork-bot+netdevbpf
  10 siblings, 0 replies; 20+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-11  3:30 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: davem, edumazet, kuba, pabeni, horms, idosch, kuni1840, netdev

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 7 Feb 2025 16:24:54 +0900 you wrote:
> Patch 1 ~ 2 are small cleanup, and patch 3 ~ 8 make fib_nl_newrule()
> and fib_nl_delrule() hold per-netns RTNL.
> 
> 
> Changes:
>   v2:
>     * Add patch 4 & 5
>     * Don't use !!extack to check if RTNL is held
> 
> [...]

Here is the summary with links:
  - [v2,net-next,1/8] net: fib_rules: Don't check net in rule_exists() and rule_find().
    https://git.kernel.org/netdev/net-next/c/7b7df666a233
  - [v2,net-next,2/8] net: fib_rules: Pass net to fib_nl2rule() instead of skb.
    https://git.kernel.org/netdev/net-next/c/a9ffd24b5528
  - [v2,net-next,3/8] net: fib_rules: Split fib_nl2rule().
    https://git.kernel.org/netdev/net-next/c/8b498773c861
  - [v2,net-next,4/8] ip: fib_rules: Fetch net from fib_rule in fib[46]_rule_configure().
    https://git.kernel.org/netdev/net-next/c/5a1ccffd30a0
  - [v2,net-next,5/8] net: fib_rules: Factorise fib_newrule() and fib_delrule().
    https://git.kernel.org/netdev/net-next/c/a0596c2c63fc
  - [v2,net-next,6/8] net: fib_rules: Convert RTM_NEWRULE to per-netns RTNL.
    https://git.kernel.org/netdev/net-next/c/98d3a6f681ca
  - [v2,net-next,7/8] net: fib_rules: Add error_free label in fib_delrule().
    https://git.kernel.org/netdev/net-next/c/1cf770da0112
  - [v2,net-next,8/8] net: fib_rules: Convert RTM_DELRULE to per-netns RTNL.
    https://git.kernel.org/netdev/net-next/c/88b9cfca8d77

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2025-02-11  3:30 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-07  7:24 [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
2025-02-07  7:24 ` [PATCH v2 net-next 1/8] net: fib_rules: Don't check net in rule_exists() and rule_find() Kuniyuki Iwashima
2025-02-07  8:27   ` Eric Dumazet
2025-02-07  7:24 ` [PATCH v2 net-next 2/8] net: fib_rules: Pass net to fib_nl2rule() instead of skb Kuniyuki Iwashima
2025-02-07  8:28   ` Eric Dumazet
2025-02-07  7:24 ` [PATCH v2 net-next 3/8] net: fib_rules: Split fib_nl2rule() Kuniyuki Iwashima
2025-02-07  8:30   ` Eric Dumazet
2025-02-07  7:24 ` [PATCH v2 net-next 4/8] ip: fib_rules: Fetch net from fib_rule in fib[46]_rule_configure() Kuniyuki Iwashima
2025-02-07  8:34   ` Eric Dumazet
2025-02-07  7:24 ` [PATCH v2 net-next 5/8] net: fib_rules: Factorise fib_newrule() and fib_delrule() Kuniyuki Iwashima
2025-02-07  8:34   ` Eric Dumazet
2025-02-07  7:25 ` [PATCH v2 net-next 6/8] net: fib_rules: Convert RTM_NEWRULE to per-netns RTNL Kuniyuki Iwashima
2025-02-07  8:35   ` Eric Dumazet
2025-02-07  7:25 ` [PATCH v2 net-next 7/8] net: fib_rules: Add error_free label in fib_delrule() Kuniyuki Iwashima
2025-02-07  8:37   ` Eric Dumazet
2025-02-07  7:25 ` [PATCH v2 net-next 8/8] net: fib_rules: Convert RTM_DELRULE to per-netns RTNL Kuniyuki Iwashima
2025-02-07  8:36   ` Eric Dumazet
2025-02-07  8:37 ` [PATCH v2 net-next 0/8] fib: rules: Convert RTM_NEWRULE and " Eric Dumazet
2025-02-07 10:20 ` Ido Schimmel
2025-02-11  3:30 ` patchwork-bot+netdevbpf

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).