iplink: add support for protodown reason
Subsystems (3)
PATCH v2 1/1 iplink: add support for protodown reason
From: Roopa Prabhu <[email protected]>
This patch adds support for recently
added link IFLA_PROTO_DOWN_REASON attribute.IFLA_PROTO_DOWN_REASON enumerates reasons
for the already existing IFLA_PROTO_DOWN link
attribute.
$ cat /etc/iproute2/protodown_reasons.d/r.conf 0 mlag 1 evpn 2 vrrp 3 psecurity
$ ip link set dev vx10 protodown on protodown_reason vrrp on
$ip link show dev vx10
14: vx10: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode
DEFAULT group default qlen 1000
link/ether f2:32:28:b8:35:ff brd ff:ff:ff:ff:ff:ff protodown on
protodown_reason <vrrp>
$ip -p -j link show dev vx10
[ {
<snip>
"proto_down": true,
"proto_down_reason": [ "vrrp" ]
} ]
$ip link set dev vx10 protodown_reason mlag on
$ip link show dev vx10
14: vx10: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode
DEFAULT group default qlen 1000
link/ether f2:32:28:b8:35:ff brd ff:ff:ff:ff:ff:ff protodown on
protodown_reason <mlag,vrrp>
$ip -p -j link show dev vx10
[ {
<snip>
"proto_down": true,
"protodown_reason": [ "mlag","vrrp" ]
} ]$ip -p -j link show dev vx10
$ip link set dev vx10 protodown off protodown_reason vrrp off
Error: Cannot clear protodown, active reasons.
$ip link set dev vx10 protodown off protodown_reason mlag off $
Note: for somereason the json and non-json key for protodown are different (protodown and proto_down). I have kept the same for protodown reason for consistency (protodown_reason and proto_down_reason).
---
v2 - address comments from David Ahern
include/rt_names.h | 3 ++ ip/ipaddress.c | 46 +++++++++++++++++++--- ip/iplink.c | 23 +++++++++++ lib/rt_names.c | 92 +++++++++++++++++++++++++++++++++++++++++++ man/man8/ip-link.8.in | 10 +++++ 5 files changed, 169 insertions(+), 5 deletions(-)
include/rt_names.h +3 -0
@@ -33,6 +33,9 @@ int ll_proto_a2n(unsigned short *id, const char *buf);const char *nl_proto_n2a (int id,char *buf,int len);int nl_proto_a2n (__u32 *id,const char *arg); +int protodown_reason_a2n (__u32 *id,const char *arg); +int protodown_reason_n2a (int id,char *buf,int len); +extern int numeric;#endif
ip/ipaddress.c +41 -5
58 lines not on this page · raw message
ip/iplink.c +23 -0
@@ -105,6 +105,7 @@ void iplink_usage(void)" [ nomaster ]\n" " [ addrgenmode { eui64 | none | stable_secret | random } ]\n" " [ protodown { on | off } ]\n" +" [ protodown_reason PREASON { on | off } ]\n" " [ gso_max_size BYTES ] | [ gso_max_segs PACKETS ]\n" "\n" " ip link show [ DEVICE | group GROUP ] [up] [master DEV] [vrf NAME] [type TYPE]\n"
@@ -903,6 +904,28 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)return on_off ("protodown" , *argv);addattr8 (&req->n,sizeof (*req),IFLA_PROTO_DOWN , proto_down); + }else if (strcmp (*argv,"protodown_reason" ) ==0 ) { +struct rtattr *pr; +__u32 preason =0 , prvalue =0 , prmask =0 ; + +NEXT_ARG (); +if (protodown_reason_a2n (&preason, *argv)) +invarg ("invalid protodown reason\n" , *argv); +NEXT_ARG (); + prmask =1 << preason; +if (matches (*argv,"on" ) ==0 ) + prvalue |= prmask; +else if (matches (*argv,"off" ) ==0 ) + prvalue &= ~prmask; +else +return on_off ("protodown_reason" , *argv); + pr =addattr_nest (&req->n,sizeof (*req), +IFLA_PROTO_DOWN_REASON |NLA_F_NESTED ); +addattr32 (&req->n,sizeof (*req), +IFLA_PROTO_DOWN_REASON_MASK , prmask); +addattr32 (&req->n,sizeof (*req), +IFLA_PROTO_DOWN_REASON_VALUE , prvalue); +addattr_nest_end (&req->n, pr); }else if (strcmp (*argv,"gso_max_size" ) ==0 ) {unsigned int max_size;
lib/rt_names.c +92 -0
95 lines not on this page · raw message
man/man8/ip-link.8.in +10 -0
@@ -75,6 +75,9 @@ ip-link \- network device configuration .br .RB "[ " protodown " { " on " | " off " } ]" .br +.RB "[ " protodown_reason +.IR PREASON " { " on " | " off " } ]" +.br .RB "[ " trailers " { " on " | " off " } ]" .br .RB "[ " txqueuelen
@@ -1917,6 +1920,13 @@ state on the device. Indicates that a protocol error has been detected on the port. Switch drivers can react to this error by doing a phys down on the switch port. +.TP +.BR "protodown_reason PREASON on " or " off" +set +.B PROTODOWN +reasons on the device. protodown reason bit names can be enumerated under +/etc/iproute2/protodown_reasons.d/. possible reasons bits 0-31 + .TP .BR "dynamic on " or " dynamic off" change the
Signature · 1 line
2.20.1
David Ahern
AppliedQuoted 8 lines · Roopa Prabhu
From: Roopa Prabhu <[email protected]>
This patch adds support for recently
added linkIFLA_PROTO_DOWN_REASONattribute.IFLA_PROTO_DOWN_REASONenumerates reasons
for the already existingIFLA_PROTO_DOWNlink
attribute.
Quoted 6 lines
$ cat /etc/iproute2/protodown_reasons.d/r.conf 0 mlag 1 evpn 2 vrrp 3 psecurity
none of these are standardized right? Or perhaps they are through FRR?
Would be worth mentioning in the man page that the reasons are localized if so.
Quoted 10 lines
Note: for somereason the json and non-json key for protodown are different (protodown and
proto_down). I have kept the same for protodown reason for consistency (protodown_reasonandproto_down_reason).Signed-off-by Roopa Prabhu <[email protected]>---
v2 - address comments from David Ahern
applied to iproute2-next. Thanks
Quoted 15 lines · David Ahern
Quoted 8 lines · Roopa Prabhu
From: Roopa Prabhu <[email protected]>
This patch adds support for recently
added linkIFLA_PROTO_DOWN_REASONattribute.IFLA_PROTO_DOWN_REASONenumerates reasons
for the already existingIFLA_PROTO_DOWNlink
attribute.Quoted 6 lines
$ cat /etc/iproute2/protodown_reasons.d/r.conf 0 mlag 1 evpn 2 vrrp 3 psecurity
Quoted 4 lines
none of these are standardized right? Or perhaps they are through FRR?
Would be worth mentioning in the man page that the reasons are localized if so.
yes, ack, will post a patch for the man-page update.