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>
        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;
 
                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;
        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;
                }
 
 
                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;
                }
 
        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;
                }
 
 
                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;
                }