]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net/ipv4: Bail early if user only wants prefix entries
authorDavid Ahern <dsahern@gmail.com>
Tue, 16 Oct 2018 01:56:51 +0000 (18:56 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 16 Oct 2018 07:14:08 +0000 (00:14 -0700)
Unlike IPv6, IPv4 does not have routes marked with RTF_PREFIX_RT. If the
flag is set in the dump request, just return.

In the process of this change, move the CLONE check to use the new
filter flags.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/fib_frontend.c

index e86ca22551811420c0598e85d93141a16415e4eb..5bf653f369115d7c78bc59951dd77d3b1ea780b9 100644 (file)
@@ -886,10 +886,14 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
                err = ip_valid_fib_dump_req(net, nlh, &filter, cb);
                if (err < 0)
                        return err;
+       } else if (nlmsg_len(nlh) >= sizeof(struct rtmsg)) {
+               struct rtmsg *rtm = nlmsg_data(nlh);
+
+               filter.flags = rtm->rtm_flags & (RTM_F_PREFIX | RTM_F_CLONED);
        }
 
-       if (nlmsg_len(nlh) >= sizeof(struct rtmsg) &&
-           ((struct rtmsg *)nlmsg_data(nlh))->rtm_flags & RTM_F_CLONED)
+       /* fib entries are never clones and ipv4 does not use prefix flag */
+       if (filter.flags & (RTM_F_PREFIX | RTM_F_CLONED))
                return skb->len;
 
        if (filter.table_id) {