netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 net-next] iproute: extend route get for mpls routes
@ 2017-07-07 22:08 Roopa Prabhu
  2017-07-19  0:15 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Roopa Prabhu @ 2017-07-07 22:08 UTC (permalink / raw)
  To: netdev, stephen

From: Roopa Prabhu <roopa@cumulusnetworks.com>

This patch extends route get to support mpls specific
route attributes like RTA_NEWDST.

Input:
RTA_DST - input label
RTA_NEWDST - labels in packet for multipath selection

By default the getroute handler returns matched
nexthop label, via and oif

With fibmatch keyword (RTM_F_FIB_MATCH flag), full matched
route is returned.

example:
$ip -f mpls route show
101
        nexthop as to 102/103 via inet 172.16.2.2 dev virt1-2
        nexthop as to 302/303 via inet 172.16.12.2 dev virt1-12
201
        nexthop as to 202/203 via inet6 2001:db8:2::2 dev virt1-2
        nexthop as to 402/403 via inet6 2001:db8:12::2 dev virt1-12

$ip -f mpls route get 103
RTNETLINK answers: Network is unreachable

$ip -f mpls route get 101
101 as to 102/103 via inet 172.16.2.2 dev virt1-2

$ip -f mpls route get as to 302/303 101
101 as to 302/303 via inet 172.16.12.2 dev virt1-12

$ip -f mpls route get fibmatch 103
RTNETLINK answers: Network is unreachable

$ip -f mpls route get fibmatch 101
101
        nexthop as to 102/103 via inet 172.16.2.2 dev virt1-2
        nexthop as to 302/303 via inet 172.16.12.2 dev virt1-12

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
 ip/iproute.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ip/iproute.c b/ip/iproute.c
index 4e022d7..a735d28 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -1731,6 +1731,16 @@ static int iproute_get(int argc, char **argv)
 			addattr32(&req.n, sizeof(req), RTA_UID, uid);
 		} else if (matches(*argv, "fibmatch") == 0) {
 			fib_match = 1;
+		} else if (strcmp(*argv, "as") == 0) {
+			inet_prefix addr;
+
+			NEXT_ARG();
+			if (strcmp(*argv, "to") == 0)
+				NEXT_ARG();
+			get_addr(&addr, *argv, req.r.rtm_family);
+			if (req.r.rtm_family == AF_UNSPEC)
+				req.r.rtm_family = addr.family;
+			addattr_l(&req.n, sizeof(req), RTA_NEWDST, &addr.data, addr.bytelen);
 		} else {
 			inet_prefix addr;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2 net-next] iproute: extend route get for mpls routes
  2017-07-07 22:08 [PATCH iproute2 net-next] iproute: extend route get for mpls routes Roopa Prabhu
@ 2017-07-19  0:15 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2017-07-19  0:15 UTC (permalink / raw)
  To: Roopa Prabhu; +Cc: netdev

On Fri,  7 Jul 2017 15:08:11 -0700
Roopa Prabhu <roopa@cumulusnetworks.com> wrote:

> From: Roopa Prabhu <roopa@cumulusnetworks.com>
> 
> This patch extends route get to support mpls specific
> route attributes like RTA_NEWDST.
> 
> Input:
> RTA_DST - input label
> RTA_NEWDST - labels in packet for multipath selection
> 
> By default the getroute handler returns matched
> nexthop label, via and oif
> 
> With fibmatch keyword (RTM_F_FIB_MATCH flag), full matched
> route is returned.
> 
> example:
> $ip -f mpls route show
> 101
>         nexthop as to 102/103 via inet 172.16.2.2 dev virt1-2
>         nexthop as to 302/303 via inet 172.16.12.2 dev virt1-12
> 201
>         nexthop as to 202/203 via inet6 2001:db8:2::2 dev virt1-2
>         nexthop as to 402/403 via inet6 2001:db8:12::2 dev virt1-12
> 
> $ip -f mpls route get 103
> RTNETLINK answers: Network is unreachable
> 
> $ip -f mpls route get 101
> 101 as to 102/103 via inet 172.16.2.2 dev virt1-2
> 
> $ip -f mpls route get as to 302/303 101
> 101 as to 302/303 via inet 172.16.12.2 dev virt1-12
> 
> $ip -f mpls route get fibmatch 103
> RTNETLINK answers: Network is unreachable
> 
> $ip -f mpls route get fibmatch 101
> 101
>         nexthop as to 102/103 via inet 172.16.2.2 dev virt1-2
>         nexthop as to 302/303 via inet 172.16.12.2 dev virt1-12
> 
> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-19  0:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-07 22:08 [PATCH iproute2 net-next] iproute: extend route get for mpls routes Roopa Prabhu
2017-07-19  0:15 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).