Skip to contentSkip to conversation

ip route: Do not imply pref and ttl-propagate are per nexthop

PATCH In review Donald Sharp 4 participants 4 messages Feb 25, 2020 – Feb 28, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip route: Do not imply pref and ttl-propagate are per nexthop

Currently ip -6 route show gives us this output:

sharpd@eva ~/i/ip (master)> ip -6 route show
::1 dev lo proto kernel metric 256 pref medium 4:5::6:7 nhid 18 proto static metric 20
nexthop via fe80::99 dev enp39s0 weight 1 nexthop via fe80::44 dev enp39s0 weight 1 pref medium

Displaying pref medium as the last bit of output implies that the RTA_PREF is a per nexthop value, when it is infact a per route piece of data.

Change the output to display RTA_PREF and RTA_TTL_PROPAGATE before the RTA_MULTIPATH data is shown:

sharpd@eva ~/i/ip (master)> ./ip -6 route show ::1 dev lo proto kernel metric 256 pref medium 4:5::6:7 nhid 18 proto static metric 20 pref medium
nexthop via fe80::99 dev enp39s0 weight 1 nexthop via fe80::44 dev enp39s0 weight 1

---
 ip/iproute.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
ip/iproute.c +8 -3
index 93b805c9..07c45169 100644
@@ -933,9 +933,6 @@ int print_route(struct nlmsghdr *n, void *arg)
 	if (tb[RTA_IIF] && filter.iifmask != -1)
 		print_rta_if(fp, tb[RTA_IIF], "iif");
 
-	if (tb[RTA_MULTIPATH])
-		print_rta_multipath(fp, r, tb[RTA_MULTIPATH]);
-
 	if (tb[RTA_PREF])
 		print_rt_pref(fp, rta_getattr_u8(tb[RTA_PREF]));
 
@@ -951,6 +948,14 @@ int print_route(struct nlmsghdr *n, void *arg)
 				     propagate ? "enabled" : "disabled");
 	}
 
+	if (tb[RTA_MULTIPATH])
+		print_rta_multipath(fp, r, tb[RTA_MULTIPATH]);
+
+	/* If you are adding new route RTA_XXXX then place it above
+	 * the RTA_MULTIPATH else it will appear that the last nexthop
+	 * in the ECMP has new attributes
+	 */
+
 	print_string(PRINT_FP, NULL, "\n", NULL);
 	close_json_object();
 	fflush(fp);
Signature · 1 line
2.25.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 57 lines · Donald Sharp

Currently ip -6 route show gives us this output:

sharpd@eva ~/i/ip (master)> ip -6 route show
::1 dev lo proto kernel metric 256 pref medium 4:5::6:7 nhid 18 proto static metric 20
nexthop via fe80::99 dev enp39s0 weight 1 nexthop via fe80::44 dev enp39s0 weight 1 pref medium

Displaying pref medium as the last bit of output implies that the RTA_PREF is a per nexthop value, when it is infact a per route piece of data.

Change the output to display RTA_PREF and RTA_TTL_PROPAGATE before the RTA_MULTIPATH data is shown:

sharpd@eva ~/i/ip (master)> ./ip -6 route show ::1 dev lo proto kernel metric 256 pref medium 4:5::6:7 nhid 18 proto static metric 20 pref medium
nexthop via fe80::99 dev enp39s0 weight 1 nexthop via fe80::44 dev enp39s0 weight 1

---
 ip/iproute.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
ip/iproute.c +8 -4
index 93b805c9..07c45169 100644
@@ -933,9 +933,6 @@ int print_route(struct nlmsghdr *n, void *arg)
        if (tb[RTA_IIF] && filter.iifmask != -1)
                print_rta_if(fp, tb[RTA_IIF], "iif");
 
-       if (tb[RTA_MULTIPATH])
-               print_rta_multipath(fp, r, tb[RTA_MULTIPATH]);
-
        if (tb[RTA_PREF])
                print_rt_pref(fp, rta_getattr_u8(tb[RTA_PREF]));
 
@@ -951,6 +948,14 @@ int print_route(struct nlmsghdr *n, void *arg)
                                     propagate ? "enabled" : "disabled");
        }
 
+       if (tb[RTA_MULTIPATH])
+               print_rta_multipath(fp, r, tb[RTA_MULTIPATH]);
+
+       /* If you are adding new route RTA_XXXX then place it above
+        * the RTA_MULTIPATH else it will appear that the last nexthop
+        * in the ECMP has new attributes
+        */
+
        print_string(PRINT_FP, NULL, "\n", NULL);
        close_json_object();
        fflush(fp);
--
Quoted 2 lines

2.25.0

LGTM. Can you please add:

Fixes f48e14880a0e5 ("iproute: refactor multipath print")
Acked-by on v1 1/1
#2 lore raw
In reply to Donald Sharp
Quoted 16 lines · Donald Sharp

Currently ip -6 route show gives us this output:

sharpd@eva ~/i/ip (master)> ip -6 route show
::1 dev lo proto kernel metric 256 pref medium 4:5::6:7 nhid 18 proto static metric 20
nexthop via fe80::99 dev enp39s0 weight 1 nexthop via fe80::44 dev enp39s0 weight 1 pref medium

Displaying pref medium as the last bit of output implies that the RTA_PREF is a per nexthop value, when it is infact a per route piece of data.

Change the output to display RTA_PREF and RTA_TTL_PROPAGATE before the RTA_MULTIPATH data is shown:

Quoted 7 lines

sharpd@eva ~/i/ip (master)> ./ip -6 route show ::1 dev lo proto kernel metric 256 pref medium 4:5::6:7 nhid 18 proto static metric 20 pref medium
nexthop via fe80::99 dev enp39s0 weight 1 nexthop via fe80::44 dev enp39s0 weight 1

Quoted 36 lines
---
 ip/iproute.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
ip/iproute.c +8 -4
index 93b805c9..07c45169 100644
@@ -933,9 +933,6 @@ int print_route(struct nlmsghdr *n, void *arg)
        if (tb[RTA_IIF] && filter.iifmask != -1)
                print_rta_if(fp, tb[RTA_IIF], "iif");
 
-       if (tb[RTA_MULTIPATH])
-               print_rta_multipath(fp, r, tb[RTA_MULTIPATH]);
-
        if (tb[RTA_PREF])
                print_rt_pref(fp, rta_getattr_u8(tb[RTA_PREF]));
 
@@ -951,6 +948,14 @@ int print_route(struct nlmsghdr *n, void *arg)
                                     propagate ? "enabled" : "disabled");
        }
 
+       if (tb[RTA_MULTIPATH])
+               print_rta_multipath(fp, r, tb[RTA_MULTIPATH]);
+
+       /* If you are adding new route RTA_XXXX then place it above
+        * the RTA_MULTIPATH else it will appear that the last nexthop
+        * in the ECMP has new attributes
+        */
+
        print_string(PRINT_FP, NULL, "\n", NULL);
        close_json_object();
        fflush(fp);
--

2.25.0

#3 lore raw
In reply to Donald Sharp
Quoted 15 lines · On Tue, 25 Feb 2020 08:12:13 -0500 Donald Sharp <[email protected]>…

Currently ip -6 route show gives us this output:

sharpd@eva ~/i/ip (master)> ip -6 route show
::1 dev lo proto kernel metric 256 pref medium 4:5::6:7 nhid 18 proto static metric 20
nexthop via fe80::99 dev enp39s0 weight 1 nexthop via fe80::44 dev enp39s0 weight 1 pref medium

Displaying pref medium as the last bit of output implies that the RTA_PREF is a per nexthop value, when it is infact a per route piece of data.

Change the output to display RTA_PREF and RTA_TTL_PROPAGATE before the RTA_MULTIPATH data is shown:

Quoted 7 lines

sharpd@eva ~/i/ip (master)> ./ip -6 route show ::1 dev lo proto kernel metric 256 pref medium 4:5::6:7 nhid 18 proto static metric 20 pref medium
nexthop via fe80::99 dev enp39s0 weight 1 nexthop via fe80::44 dev enp39s0 weight 1

Looks good applied