]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: Remove rtnl_held of struct fib_dump_filter.
authorKuniyuki Iwashima <kuniyu@google.com>
Thu, 4 Jun 2026 22:46:25 +0000 (22:46 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 9 Jun 2026 00:06:23 +0000 (17:06 -0700)
Commit 22e36ea9f5d7 ("inet: allow ip_valid_fib_dump_req() to
be called with RTNL or RCU") introduced the rtnl_held field in
struct fib_dump_filter to switch __dev_get_by_index() and
dev_get_by_index_rcu() depending on the caller's context.

This field served as an interim measure while we were incrementally
converting all callers of ip_valid_fib_dump_req() to RCU.

Now that all users (IPv4, IPv6, ipmr, ip6mr, and MPLS) have
been converted to RCU, the field is no longer necessary.

Let's remove it.

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260604224712.3209821-8-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/ip_fib.h
net/ipv4/fib_frontend.c
net/ipv4/ipmr.c
net/ipv6/ip6_fib.c
net/ipv6/ip6mr.c
net/mpls/af_mpls.c

index 318593743b6e1571971c7af2f43aea42713e6bf6..1142ffad744443cd1de4c140b01518a78f535cc5 100644 (file)
@@ -269,7 +269,6 @@ struct fib_dump_filter {
        bool                    filter_set;
        bool                    dump_routes;
        bool                    dump_exceptions;
-       bool                    rtnl_held;
        unsigned char           protocol;
        unsigned char           rt_type;
        unsigned int            flags;
index 1dab44e13d3b06f30b0ca536ca5a551ec97d7156..ceeb87b13b93a4d912d9b0687c5fc4c28b483eee 100644 (file)
@@ -946,9 +946,6 @@ int ip_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,
        struct rtmsg *rtm;
        int err, i;
 
-       if (filter->rtnl_held)
-               ASSERT_RTNL();
-
        rtm = nlmsg_payload(nlh, sizeof(*rtm));
        if (!rtm) {
                NL_SET_ERR_MSG(extack, "Invalid header for FIB dump request");
@@ -992,10 +989,8 @@ int ip_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,
                        break;
                case RTA_OIF:
                        ifindex = nla_get_u32(tb[i]);
-                       if (filter->rtnl_held)
-                               filter->dev = __dev_get_by_index(net, ifindex);
-                       else
-                               filter->dev = dev_get_by_index_rcu(net, ifindex);
+
+                       filter->dev = dev_get_by_index_rcu(net, ifindex);
                        if (!filter->dev)
                                return -ENODEV;
                        break;
@@ -1017,18 +1012,16 @@ EXPORT_SYMBOL_GPL(ip_valid_fib_dump_req);
 
 static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       const struct nlmsghdr *nlh = cb->nlh;
+       struct net *net = sock_net(skb->sk);
        struct fib_dump_filter filter = {
                .dump_routes = true,
                .dump_exceptions = true,
-               .rtnl_held = false,
        };
-       const struct nlmsghdr *nlh = cb->nlh;
-       struct net *net = sock_net(skb->sk);
-       unsigned int h, s_h;
-       unsigned int e = 0, s_e;
-       struct fib_table *tb;
+       unsigned int e = 0, s_e, h, s_h;
        struct hlist_head *head;
        int dumped = 0, err = 0;
+       struct fib_table *tb;
 
        rcu_read_lock();
        if (cb->strict_check) {
index 2628cd3a93a68469f5094456a3eaa0a25dcfeca4..78dbeecf71bbcc5a31bae2ff15fb71aa038cab24 100644 (file)
@@ -2777,9 +2777,7 @@ errout_unlock:
 
 static int ipmr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)
 {
-       struct fib_dump_filter filter = {
-               .rtnl_held = false,
-       };
+       struct fib_dump_filter filter = {};
        int err;
 
        rcu_read_lock();
index b897b3c5023b27ea87e1a2978f2e85d112219e01..fc95738ded761b68738c1e4ad41ce6b9462b5277 100644 (file)
@@ -633,7 +633,6 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
        struct rt6_rtnl_dump_arg arg = {
                .filter.dump_exceptions = true,
                .filter.dump_routes = true,
-               .filter.rtnl_held = false,
        };
        const struct nlmsghdr *nlh = cb->nlh;
        struct net *net = sock_net(skb->sk);
index 380e5eb9416d9e0a1f10189946bb226de173abbb..8c8ad1753c75813dd55830f50146d40bd127fcf0 100644 (file)
@@ -2745,9 +2745,7 @@ err:
 static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)
 {
        const struct nlmsghdr *nlh = cb->nlh;
-       struct fib_dump_filter filter = {
-               .rtnl_held = false,
-       };
+       struct fib_dump_filter filter = {};
        int err;
 
        rcu_read_lock();
index 26340a7306b59158aca2811ecf194a0e74a14142..ca504d9626cff77da1cb08eb4d37fc7043950bbb 100644 (file)
@@ -2221,12 +2221,10 @@ static bool mpls_rt_uses_dev(struct mpls_route *rt,
 
 static int mpls_dump_routes(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct mpls_route __rcu **platform_label;
        const struct nlmsghdr *nlh = cb->nlh;
        struct net *net = sock_net(skb->sk);
-       struct mpls_route __rcu **platform_label;
-       struct fib_dump_filter filter = {
-               .rtnl_held = false,
-       };
+       struct fib_dump_filter filter = {};
        unsigned int flags = NLM_F_MULTI;
        size_t platform_labels;
        unsigned int index;