mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2026-01-06 03:30:35 +00:00
ip: extend route get to return matching fib route
Uses newly introduced RTM_GETROUTE flag RTM_F_FIB_MATCH
to return a matching fib route. Introduces 'fibmatch'
keyword to ip route get.
ipv4:
----
$ip route show
default via 192.168.0.2 dev eth0
10.0.14.0/24
nexthop via 172.16.0.3 dev dummy0 weight 1
nexthop via 172.16.1.3 dev dummy1 weight 1
$ip route get 10.0.14.2
10.0.14.2 via 172.16.1.3 dev dummy1 src 172.16.1.1
cache
$ip route get fibmatch 10.0.14.2
10.0.14.0/24
nexthop via 172.16.0.3 dev dummy0 weight 1
nexthop via 172.16.1.3 dev dummy1 weight 1
ipv6:
----
$ip -6 route show
2001:db9:100::/120 metric 1024
nexthop via 2001:db8:2::2 dev dummy0 weight 1
nexthop via 2001:db8:12::2 dev dummy1 weight 1
$ip -6 route get 2001:db9:100::1
2001:db9:100::1 from :: via 2001:db8:12::2 dev dummy1 \
src 2001:db8:12::1 metric 1024 pref medium
$ip -6 route get fibmatch 2001:db9:100::1
2001:db9:100::/120 metric 1024
nexthop via 2001:db8:12::2 dev dummy1 weight 1
nexthop via 2001:db8:2::2 dev dummy0 weight 1
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Acked-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
parent
d9bcafb4fe
commit
aa883d86c0
@ -65,7 +65,8 @@ static void usage(void)
|
||||
fprintf(stderr, " ip route save SELECTOR\n");
|
||||
fprintf(stderr, " ip route restore\n");
|
||||
fprintf(stderr, " ip route showdump\n");
|
||||
fprintf(stderr, " ip route get ADDRESS [ from ADDRESS iif STRING ]\n");
|
||||
fprintf(stderr, " ip route get [ ROUTE_GET_FLAGS ] ADDRESS\n");
|
||||
fprintf(stderr, " [ from ADDRESS iif STRING ]\n");
|
||||
fprintf(stderr, " [ oif STRING ] [ tos TOS ]\n");
|
||||
fprintf(stderr, " [ mark NUMBER ] [ vrf NAME ]\n");
|
||||
fprintf(stderr, " [ uid NUMBER ]\n");
|
||||
@ -103,6 +104,7 @@ static void usage(void)
|
||||
fprintf(stderr, "ENCAPHDR := [ MPLSLABEL | SEG6HDR ]\n");
|
||||
fprintf(stderr, "SEG6HDR := [ mode SEGMODE ] segs ADDR1,ADDRi,ADDRn [hmac HMACKEYID] [cleanup]\n");
|
||||
fprintf(stderr, "SEGMODE := [ encap | inline ]\n");
|
||||
fprintf(stderr, "ROUTE_GET_FLAGS := [ fibmatch ]\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -1674,6 +1676,7 @@ static int iproute_get(int argc, char **argv)
|
||||
char *idev = NULL;
|
||||
char *odev = NULL;
|
||||
int connected = 0;
|
||||
int fib_match = 0;
|
||||
int from_ok = 0;
|
||||
unsigned int mark = 0;
|
||||
|
||||
@ -1728,6 +1731,8 @@ static int iproute_get(int argc, char **argv)
|
||||
if (get_unsigned(&uid, *argv, 0))
|
||||
invarg("invalid UID\n", *argv);
|
||||
addattr32(&req.n, sizeof(req), RTA_UID, uid);
|
||||
} else if (matches(*argv, "fibmatch") == 0) {
|
||||
fib_match = 1;
|
||||
} else {
|
||||
inet_prefix addr;
|
||||
|
||||
@ -1776,6 +1781,8 @@ static int iproute_get(int argc, char **argv)
|
||||
req.r.rtm_family = AF_INET;
|
||||
|
||||
req.r.rtm_flags |= RTM_F_LOOKUP_TABLE;
|
||||
if (fib_match)
|
||||
req.r.rtm_flags |= RTM_F_FIB_MATCH;
|
||||
|
||||
if (rtnl_talk(&rth, &req.n, &req.n, sizeof(req)) < 0)
|
||||
return -2;
|
||||
|
||||
@ -28,6 +28,7 @@ ip-route \- routing table management
|
||||
|
||||
.ti -8
|
||||
.B ip route get
|
||||
.I ROUTE_GET_FLAGS
|
||||
.IR ADDRESS " [ "
|
||||
.BI from " ADDRESS " iif " STRING"
|
||||
.RB " ] [ " oif
|
||||
@ -219,6 +220,12 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
|
||||
.B hmac
|
||||
.IR KEYID " ]"
|
||||
|
||||
.ti -8
|
||||
.IR ROUTE_GET_FLAGS " := "
|
||||
.BR " [ "
|
||||
.BR fibmatch
|
||||
.BR " ] "
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B ip route
|
||||
is used to manipulate entries in the kernel routing tables.
|
||||
@ -929,6 +936,11 @@ get a single route
|
||||
this command gets a single route to a destination and prints its
|
||||
contents exactly as the kernel sees it.
|
||||
|
||||
.TP
|
||||
.BI fibmatch
|
||||
Return full fib lookup matched route. Default is to return the resolved
|
||||
dst entry
|
||||
|
||||
.TP
|
||||
.BI to " ADDRESS " (default)
|
||||
the destination address.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user