Skip to content

Commit ae677bb

Browse files
dsaherndavem330
authored andcommitted
net: Don't return invalid table id error when dumping all families
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>
1 parent 242afaa commit ae677bb

5 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎include/net/ip_fib.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ struct fib_dump_filter {
226226
u32 table_id;
227227
/* filter_set is an optimization that an entry is set */
228228
bool filter_set;
229+
bool dump_all_families;
229230
unsigned char protocol;
230231
unsigned char rt_type;
231232
unsigned int flags;

‎net/ipv4/fib_frontend.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ int ip_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,
829829
return -EINVAL;
830830
}
831831

832+
filter->dump_all_families = (rtm->rtm_family == AF_UNSPEC);
832833
filter->flags = rtm->rtm_flags;
833834
filter->protocol = rtm->rtm_protocol;
834835
filter->rt_type = rtm->rtm_type;
@@ -899,6 +900,9 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
899900
if (filter.table_id) {
900901
tb = fib_get_table(net, filter.table_id);
901902
if (!tb) {
903+
if (filter.dump_all_families)
904+
return skb->len;
905+
902906
NL_SET_ERR_MSG(cb->extack, "ipv4: FIB table does not exist");
903907
return -ENOENT;
904908
}

‎net/ipv4/ipmr.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,6 +2542,9 @@ static int ipmr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)
25422542

25432543
mrt = ipmr_get_table(sock_net(skb->sk), filter.table_id);
25442544
if (!mrt) {
2545+
if (filter.dump_all_families)
2546+
return skb->len;
2547+
25452548
NL_SET_ERR_MSG(cb->extack, "ipv4: MR table does not exist");
25462549
return -ENOENT;
25472550
}

‎net/ipv6/ip6_fib.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
620620
if (arg.filter.table_id) {
621621
tb = fib6_get_table(net, arg.filter.table_id);
622622
if (!tb) {
623+
if (arg.filter.dump_all_families)
624+
return skb->len;
625+
623626
NL_SET_ERR_MSG_MOD(cb->extack, "FIB table does not exist");
624627
return -ENOENT;
625628
}

‎net/ipv6/ip6mr.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,6 +2473,9 @@ static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)
24732473

24742474
mrt = ip6mr_get_table(sock_net(skb->sk), filter.table_id);
24752475
if (!mrt) {
2476+
if (filter.dump_all_families)
2477+
return skb->len;
2478+
24762479
NL_SET_ERR_MSG_MOD(cb->extack, "MR table does not exist");
24772480
return -ENOENT;
24782481
}

0 commit comments

Comments
 (0)