diff options
author | Roopa Prabhu <roopa@cumulusnetworks.com> | 2017-05-25 19:42:39 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-05-26 20:12:51 +0200 |
commit | b61798130f1be5bff08712308126c2d7ebe390ef (patch) | |
tree | 5cc089995dc223f83da89be0ed59a118042e4131 /net/ipv4/route.c | |
parent | net: ipv4: add new RTM_F_FIB_MATCH flag for use with RTM_GETROUTE (diff) | |
download | linux-b61798130f1be5bff08712308126c2d7ebe390ef.tar.xz linux-b61798130f1be5bff08712308126c2d7ebe390ef.zip |
net: ipv4: RTM_GETROUTE: return matched fib result when requested
This patch adds support to return matched fib result when RTM_F_FIB_MATCH
flag is specified in RTM_GETROUTE request. This is useful for user-space
applications/controllers wanting to query a matching route.
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r-- | net/ipv4/route.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 1fa9127ec4db..3a7425694d8b 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -114,6 +114,8 @@ #include <net/ip_tunnels.h> #include <net/l3mdev.h> +#include "fib_lookup.h" + #define RT_FL_TOS(oldflp4) \ ((oldflp4)->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK)) @@ -2746,8 +2748,15 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, if (rtm->rtm_flags & RTM_F_LOOKUP_TABLE) table_id = rt->rt_table_id; - err = rt_fill_info(net, dst, src, table_id, &fl4, skb, - NETLINK_CB(in_skb).portid, nlh->nlmsg_seq, rt); + if (rtm->rtm_flags & RTM_F_FIB_MATCH) + err = fib_dump_info(skb, NETLINK_CB(in_skb).portid, + nlh->nlmsg_seq, RTM_NEWROUTE, table_id, + rt->rt_type, res.prefix, res.prefixlen, + fl4.flowi4_tos, res.fi, 0); + else + err = rt_fill_info(net, dst, src, table_id, &fl4, skb, + NETLINK_CB(in_skb).portid, nlh->nlmsg_seq, + rt); if (err < 0) goto errout_free; |