ip route: Make name of protocol 0 consistent
Subsystems (3)
PATCH v2 1/1 ip route: Make name of protocol 0 consistent
iproute2 can inconsistently show the name of protocol 0 if a route with a custom protocol is added. For example:
dsa@cartman:~$ ip -6 ro ls table all | egrep 'proto none|proto unspec' local ::1 dev lo table local proto none metric 0 pref medium local fe80::225:90ff:fecb:1c18 dev lo table local proto none metric 0 pref medium local fe80::92e2:baff:fe5c:da5d dev lo table local proto none metric 0 pref medium
protocol 0 is pretty printed as "none". Add a route with a custom protocol:
dsa@cartman:~$ sudo ip -6 ro add 2001:db8:200::1/128 dev eth0 proto 123
And now display has switched from "none" to "unspec":
dsa@cartman:~$ ip -6 ro ls table all | egrep 'proto none|proto unspec' local ::1 dev lo table local proto unspec metric 0 pref medium local fe80::225:90ff:fecb:1c18 dev lo table local proto unspec metric 0 pref medium local fe80::92e2:baff:fe5c:da5d dev lo table local proto unspec metric 0 pref medium
The rt_protos file has the id to name mapping as "unspec" while rtnl_rtprot_tab[0] has "none". The presence of a custom protocol id triggers reading the rt_protos file and overwriting the string in rtnl_rtprot_tab. All of this is logic from 2004 and earlier.
Update rtnl_rtprot_tab to "unspec" to match the enum value.
---
v2
- update rtnl_rtprot_tab instead of rt_protos file as requested by Stephen
lib/rt_names.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/rt_names.c +1 -1
@@ -119,7 +119,7 @@ static void rtnl_tab_initialize(const char *file, char **tab, int size) }static char *rtnl_rtprot_tab[256 ] = { - [RTPROT_UNSPEC ] ="none" , + [RTPROT_UNSPEC ] ="unspec" , [RTPROT_REDIRECT ] ="redirect" , [RTPROT_KERNEL ] ="kernel" , [RTPROT_BOOT ] ="boot" ,
Signature · 1 line
2.1.4
Stephen Hemminger
AppliedQuoted 16 lines · On Mon, 13 Feb 2017 12:21:53 -0800 David Ahern <[email protected]> wrote:
iproute2 can inconsistently show the name of protocol 0 if a route with a custom protocol is added. For example:
dsa@cartman:~$ ip -6 ro ls table all | egrep 'proto none|proto unspec' local ::1 dev lo table local proto none metric 0 pref medium local fe80::225:90ff:fecb:1c18 dev lo table local proto none metric 0 pref medium local fe80::92e2:baff:fe5c:da5d dev lo table local proto none metric 0 pref mediumprotocol 0 is pretty printed as "none". Add a route with a custom protocol:
dsa@cartman:~$ sudo ip -6 ro add 2001:db8:200::1/128 dev eth0 proto 123And now display has switched from "none" to "unspec":
dsa@cartman:~$ ip -6 ro ls table all | egrep 'proto none|proto unspec' local ::1 dev lo table local proto unspec metric 0 pref medium local fe80::225:90ff:fecb:1c18 dev lo table local proto unspec metric 0 pref medium local fe80::92e2:baff:fe5c:da5d dev lo table local proto unspec metric 0 pref medium
Quoted 8 lines
The
rt_protosfile has the id to name mapping as "unspec" while rtnl_rtprot_tab[0] has "none". The presence of a custom protocol id triggers reading thert_protosfile and overwriting the string inrtnl_rtprot_tab. All of this is logic from 2004 and earlier.Update
rtnl_rtprot_tabto "unspec" to match the enum value.Signed-off-by David Ahern <[email protected]>
Applied, thanks.