]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
net: Don't return invalid table id error when dumping all families
authorDavid Ahern <dsahern@gmail.com>
Wed, 24 Oct 2018 19:59:01 +0000 (12:59 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 24 Oct 2018 21:06:25 +0000 (14:06 -0700)
When doing a route dump across all address families, do not error out
if the table does not exist. This allows a route dump for AF_UNSPEC
with a table id that may only exist for some of the families.

Do return the table does not exist error if dumping routes for a
specific family and the table does not exist.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip_fib.h
net/ipv4/fib_frontend.c
net/ipv4/ipmr.c
net/ipv6/ip6_fib.c
net/ipv6/ip6mr.c

index e8d9456bf36e1e0d2c7dd6ac5d3c1dbd15f5ddec..c5969762a8f44b18b27d1776752331768743bf2f 100644 (file)
@@ -226,6 +226,7 @@ struct fib_dump_filter {
        u32                     table_id;
        /* filter_set is an optimization that an entry is set */
        bool                    filter_set;
+       bool                    dump_all_families;
        unsigned char           protocol;
        unsigned char           rt_type;
        unsigned int            flags;
index 5bf653f369115d7c78bc59951dd77d3b1ea780b9..6df95be963116ced81f70e5fb51bfe6114e8965a 100644 (file)
@@ -829,6 +829,7 @@ int ip_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,
                return -EINVAL;
        }
 
+       filter->dump_all_families = (rtm->rtm_family == AF_UNSPEC);
        filter->flags    = rtm->rtm_flags;
        filter->protocol = rtm->rtm_protocol;
        filter->rt_type  = rtm->rtm_type;
@@ -899,6 +900,9 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
        if (filter.table_id) {
                tb = fib_get_table(net, filter.table_id);
                if (!tb) {
+                       if (filter.dump_all_families)
+                               return skb->len;
+
                        NL_SET_ERR_MSG(cb->extack, "ipv4: FIB table does not exist");
                        return -ENOENT;
                }
index 7a3e2acda94ce67b92c8680e20c7446c881c4728..a6defbec4f1b4338993756ea7b8681012450aa1a 100644 (file)
@@ -2542,6 +2542,9 @@ static int ipmr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)
 
                mrt = ipmr_get_table(sock_net(skb->sk), filter.table_id);
                if (!mrt) {
+                       if (filter.dump_all_families)
+                               return skb->len;
+
                        NL_SET_ERR_MSG(cb->extack, "ipv4: MR table does not exist");
                        return -ENOENT;
                }
index 2a058b408a6a996bb2ee413c389a20384c5a5f8c..1b8bc008b53b642adef3ba9335563d430a99c1a9 100644 (file)
@@ -620,6 +620,9 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
        if (arg.filter.table_id) {
                tb = fib6_get_table(net, arg.filter.table_id);
                if (!tb) {
+                       if (arg.filter.dump_all_families)
+                               return skb->len;
+
                        NL_SET_ERR_MSG_MOD(cb->extack, "FIB table does not exist");
                        return -ENOENT;
                }
index c3317ffb09eb6892f7a0e9eda92d57a4c99f7db1..e2ea691e42c6d6efe4ddf845e01422bf31e9fc4e 100644 (file)
@@ -2473,6 +2473,9 @@ static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)
 
                mrt = ip6mr_get_table(sock_net(skb->sk), filter.table_id);
                if (!mrt) {
+                       if (filter.dump_all_families)
+                               return skb->len;
+
                        NL_SET_ERR_MSG_MOD(cb->extack, "MR table does not exist");
                        return -ENOENT;
                }