History

rtnetlink: add support for protodown reason

netdev protodown is a mechanism that allows protocols to hold an interface down. It was initially introduced in the kernel to hold links down by a multihoming protocol. There was also an attempt to introduce protodown reason at the time but was rejected. protodown and protodown reason is supported by almost every switching and routing platform. It was ok for a while to live without a protodown reason. But, its become more critical now given more than one protocol may need to keep a link down on a system at the same time. eg: vrrp peer node, port security, multihoming protocol. Its common for Network operators and protocol developers to look for such a reason on a networking box (Its also known as errDisable by most networking operators) This patch adds support for link protodown reason attribute. There are two ways to maintain protodown reasons. (a) enumerate every possible reason code in kernel - A protocol developer has to make a request and have that appear in a certain kernel version (b) provide the bits in the kernel, and allow user-space (sysadmin or NOS distributions) to manage the bit-to-reasonname map. - This makes extending reason codes easier (kind of like the iproute2 table to vrf-name map /etc/iproute2/rt_tables.d/) This patch takes approach (b). a few things about the patch: - It treats the protodown reason bits as counter to indicate active protodown users - Since protodown attribute is already an exposed UAPI, the reason is not enforced on a protodown set. Its a no-op if not used. the patch follows the below algorithm: - presence of reason bits set indicates protodown is in use - user can set protodown and protodown reason in a single or multiple setlink operations - setlink operation to clear protodown, will return -EBUSY if there are active protodown reason bits - reason is not included in link dumps if not used example with patched iproute2: $cat /etc/iproute2/protodown_reasons.d/r.conf 0 mlag 1 evpn 2 vrrp 3 psecurity $ip link set dev vxlan0 protodown on protodown_reason vrrp on $ip link set dev vxlan0 protodown_reason mlag on $ip link show 14: vxlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether f6:06:be:17:91:e7 brd ff:ff:ff:ff:ff:ff protodown on <mlag,vrrp> $ip link set dev vxlan0 protodown_reason mlag off $ip link set dev vxlan0 protodown off protodown_reason vrrp off

Roopa Prabhu committed 6 years ago

Commit 829eb201 parent 8f3f3304 files · +147 −5Browse files

Showing the changes to include/uapi/linux (1 of 4 files). Show all

Unified · Split

include/uapi/linux/if_link.h+10−0
@@ -170,12 +170,22 @@ enum { · 169 unmodified lines
170 IFLA_PROP_LIST,170 IFLA_PROP_LIST,
171 IFLA_ALT_IFNAME, /* Alternative ifname */171 IFLA_ALT_IFNAME, /* Alternative ifname */
172 IFLA_PERM_ADDRESS,172 IFLA_PERM_ADDRESS,
173 IFLA_PROTO_DOWN_REASON,
173 __IFLA_MAX174 __IFLA_MAX
174};175};
175 176
176 177
177#define IFLA_MAX (__IFLA_MAX - 1)178#define IFLA_MAX (__IFLA_MAX - 1)
178 179
180enum {
181 IFLA_PROTO_DOWN_REASON_UNSPEC,
182 IFLA_PROTO_DOWN_REASON_MASK, /* u32, mask for reason bits */
183 IFLA_PROTO_DOWN_REASON_VALUE, /* u32, reason bit value */
184
185 __IFLA_PROTO_DOWN_REASON_CNT,
186 IFLA_PROTO_DOWN_REASON_MAX = __IFLA_PROTO_DOWN_REASON_CNT - 1
187};
188
179/* backwards compatibility for userspace */189/* backwards compatibility for userspace */
180#ifndef __KERNEL__190#ifndef __KERNEL__
181#define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))191#define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))