@@ -187,6 +187,10 @@ static void print_protinfo(FILE *fp, struct rtattr *attr)
ll_index_to_name(ifidx));
}
+ if (prtb[IFLA_BRPORT_BACKUP_NHID])
+ print_uint(PRINT_ANY, "backup_nhid", "backup_nhid %u ",
+ rta_getattr_u32(prtb[IFLA_BRPORT_BACKUP_NHID]));
+
if (prtb[IFLA_BRPORT_ISOLATED])
print_on_off(PRINT_ANY, "isolated", "isolated %s ",
rta_getattr_u8(prtb[IFLA_BRPORT_ISOLATED]));
@@ -316,6 +320,7 @@ static void usage(void)
" [ mab {on | off} ]\n"
" [ hwmode {vepa | veb} ]\n"
" [ backup_port DEVICE ] [ nobackup_port ]\n"
+ " [ backup_nhid NHID ]\n"
" [ self ] [ master ]\n"
" bridge link show [dev DEV] [master DEVICE]\n");
exit(-1);
@@ -334,6 +339,8 @@ static int brlink_modify(int argc, char **argv)
.ifm.ifi_family = PF_BRIDGE,
};
char *d = NULL;
+ bool backup_nhid_set = false;
+ __u32 backup_nhid;
int backup_port_idx = -1;
__s8 neigh_suppress = -1;
__s8 neigh_vlan_suppress = -1;
@@ -498,6 +505,11 @@ static int brlink_modify(int argc, char **argv)
}
} else if (strcmp(*argv, "nobackup_port") == 0) {
backup_port_idx = 0;
+ } else if (strcmp(*argv, "backup_nhid") == 0) {
+ NEXT_ARG();
+ if (get_u32(&backup_nhid, *argv, 0))
+ invarg("invalid backup_nhid", *argv);
+ backup_nhid_set = true;
} else {
usage();
}
@@ -584,6 +596,10 @@ static int brlink_modify(int argc, char **argv)
addattr32(&req.n, sizeof(req), IFLA_BRPORT_BACKUP_PORT,
backup_port_idx);
+ if (backup_nhid_set)
+ addattr32(&req.n, sizeof(req), IFLA_BRPORT_BACKUP_NHID,
+ backup_nhid);
+
addattr_nest_end(&req.n, nest);
/* IFLA_AF_SPEC nested attribute. Contains IFLA_BRIDGE_FLAGS that
@@ -43,6 +43,7 @@ static void print_explain(FILE *f)
" [ locked {on | off} ]\n"
" [ mab {on | off} ]\n"
" [ backup_port DEVICE ] [ nobackup_port ]\n"
+ " [ backup_nhid NHID ]\n"
);
}
@@ -301,6 +302,10 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
print_string(PRINT_ANY, "backup_port", "backup_port %s ",
ll_index_to_name(backup_p));
}
+
+ if (tb[IFLA_BRPORT_BACKUP_NHID])
+ print_uint(PRINT_ANY, "backup_nhid", "backup_nhid %u ",
+ rta_getattr_u32(tb[IFLA_BRPORT_BACKUP_NHID]));
}
static void bridge_slave_parse_on_off(char *arg_name, char *arg_val,
@@ -436,6 +441,14 @@ static int bridge_slave_parse_opt(struct link_util *lu, int argc, char **argv,
addattr32(n, 1024, IFLA_BRPORT_BACKUP_PORT, ifindex);
} else if (matches(*argv, "nobackup_port") == 0) {
addattr32(n, 1024, IFLA_BRPORT_BACKUP_PORT, 0);
+ } else if (strcmp(*argv, "backup_nhid") == 0) {
+ __u32 backup_nhid;
+
+ NEXT_ARG();
+ if (get_u32(&backup_nhid, *argv, 0))
+ invarg("backup_nhid is invalid", *argv);
+ addattr32(n, 1024, IFLA_BRPORT_BACKUP_NHID,
+ backup_nhid);
} else if (matches(*argv, "help") == 0) {
explain();
return -1;
@@ -61,6 +61,8 @@ bridge \- show / manipulate bridge addresses and devices
.B backup_port
.IR DEVICE " ] ["
.BR nobackup_port " ] [ "
+.B backup_nhid
+.IR NHID " ] ["
.BR self " ] [ " master " ]"
.ti -8
@@ -647,6 +649,13 @@ configured backup port
.B nobackup_port
Removes the currently configured backup port
+.TP
+.BI backup_nhid " NHID"
+The FDB nexthop object ID (see \fBip-nexthop\fR(8)) to attach to packets being
+redirected to a backup port that has VLAN tunnel mapping enabled (via the
+\fBvlan_tunnel\fR option). Setting a value of 0 (default) has the effect of not
+attaching any ID.
+
.TP
.B self
link setting is configured on specified physical device
@@ -2540,7 +2540,10 @@ the following additional arguments are supported:
] [
.BR backup_port " DEVICE"
] [
-.BR nobackup_port " ]"
+.BR nobackup_port
+] [
+.BR backup_nhid " NHID"
+]
.in +8
.sp
@@ -2679,6 +2682,12 @@ configured backup port
.BR nobackup_port
- removes the currently configured backup port
+.BI backup_nhid " NHID"
+- the FDB nexthop object ID (see \fBip-nexthop\fR(8)) to attach to packets
+being redirected to a backup port that has VLAN tunnel mapping enabled (via the
+\fBvlan_tunnel\fR option). Setting a value of 0 (default) has the effect of not
+attaching any ID.
+
.in -8
.TP
Extend the bridge and ip utilities to set and show the backup nexthop ID bridge port attribute. A value of 0 (default) disables the feature, in which case the attribute is not printed since it is not emitted by the kernel. Example: # bridge -d link show dev swp1 | grep -o "backup_nhid [0-9]*" # bridge -d -j -p link show dev swp1 | jq '.[]["backup_nhid"]' null # bridge link set dev swp1 backup_nhid 10 # bridge -d link show dev swp1 | grep -o "backup_nhid [0-9]*" backup_nhid 10 # bridge -d -j -p link show dev swp1 | jq '.[]["backup_nhid"]' 10 # bridge link set dev swp1 backup_nhid 0 # bridge -d link show dev swp1 | grep -o "backup_nhid [0-9]*" # bridge -d -j -p link show dev swp1 | jq '.[]["backup_nhid"]' null # ip -d link show dev swp1 | grep -o "backup_nhid [0-9]*" # ip -d -j -p lin show dev swp1 | jq '.[]["linkinfo"]["info_slave_data"]["backup_nhid"]' null # ip link set dev swp1 type bridge_slave backup_nhid 10 # ip -d link show dev swp1 | grep -o "backup_nhid [0-9]*" backup_nhid 10 # ip -d -j -p lin show dev swp1 | jq '.[]["linkinfo"]["info_slave_data"]["backup_nhid"]' 10 # ip link set dev swp1 type bridge_slave backup_nhid 0 # ip -d link show dev swp1 | grep -o "backup_nhid [0-9]*" # ip -d -j -p lin show dev swp1 | jq '.[]["linkinfo"]["info_slave_data"]["backup_nhid"]' null Signed-off-by: Ido Schimmel <idosch@nvidia.com> --- v2: * Use __u32 instead of __s32 for backup nexthop ID --- bridge/link.c | 16 ++++++++++++++++ ip/iplink_bridge_slave.c | 13 +++++++++++++ man/man8/bridge.8 | 9 +++++++++ man/man8/ip-link.8.in | 11 ++++++++++- 4 files changed, 48 insertions(+), 1 deletion(-)