]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - ip/iplink_bridge_slave.c
Merge branch 'iproute2-master' into iproute2-next
[mirror_iproute2.git] / ip / iplink_bridge_slave.c
index be0fb4fa34b701f255a307ea88e0aa4bbd5f338d..8b4f93f265be9f2519c85236aabe29184724868d 100644 (file)
@@ -40,6 +40,8 @@ static void print_explain(FILE *f)
                "                        [ group_fwd_mask MASK ]\n"
                "                        [ neigh_suppress {on | off} ]\n"
                "                        [ vlan_tunnel {on | off} ]\n"
+               "                        [ isolated {on | off} ]\n"
+               "                        [ backup_port DEVICE ] [ nobackup_port ]\n"
        );
 }
 
@@ -81,21 +83,6 @@ static void _print_onoff(FILE *f, char *json_flag, char *flag, __u8 val)
                fprintf(f, "%s %s ", flag, val ? "on" : "off");
 }
 
-static void _print_hex(FILE *f,
-                      const char *json_attr,
-                      const char *attr,
-                      __u16 val)
-{
-       if (is_json_context()) {
-               SPRINT_BUF(b1);
-
-               snprintf(b1, sizeof(b1), "0x%x", val);
-               print_string(PRINT_JSON, json_attr, NULL, b1);
-       } else {
-               fprintf(f, "%s 0x%x ", attr, val);
-       }
-}
-
 static void _print_timer(FILE *f, const char *attr, struct rtattr *timer)
 {
        struct timeval tv;
@@ -181,11 +168,11 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
                             rta_getattr_u8(tb[IFLA_BRPORT_UNICAST_FLOOD]));
 
        if (tb[IFLA_BRPORT_ID])
-               _print_hex(f, "id", "port_id",
-                          rta_getattr_u16(tb[IFLA_BRPORT_ID]));
+               print_0xhex(PRINT_ANY, "id", "port_id 0x%x ",
+                           rta_getattr_u16(tb[IFLA_BRPORT_ID]));
 
        if (tb[IFLA_BRPORT_NO])
-               _print_hex(f, "no", "port_no",
+               print_0xhex(PRINT_ANY, "no", "port_no 0x%x ",
                           rta_getattr_u16(tb[IFLA_BRPORT_NO]));
 
        if (tb[IFLA_BRPORT_DESIGNATED_PORT])
@@ -279,7 +266,8 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
                __u16 fwd_mask;
 
                fwd_mask = rta_getattr_u16(tb[IFLA_BRPORT_GROUP_FWD_MASK]);
-               _print_hex(f, "group_fwd_mask", "group_fwd_mask", fwd_mask);
+               print_0xhex(PRINT_ANY, "group_fwd_mask",
+                           "group_fwd_mask 0x%x ", fwd_mask);
                _bitmask2str(fwd_mask, convbuf, sizeof(convbuf), fwd_mask_tbl);
                print_string(PRINT_ANY, "group_fwd_mask_str",
                             "group_fwd_mask_str %s ", convbuf);
@@ -288,6 +276,17 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
        if (tb[IFLA_BRPORT_VLAN_TUNNEL])
                _print_onoff(f, "vlan_tunnel", "vlan_tunnel",
                             rta_getattr_u8(tb[IFLA_BRPORT_VLAN_TUNNEL]));
+
+       if (tb[IFLA_BRPORT_ISOLATED])
+               _print_onoff(f, "isolated", "isolated",
+                            rta_getattr_u8(tb[IFLA_BRPORT_ISOLATED]));
+
+       if (tb[IFLA_BRPORT_BACKUP_PORT]) {
+               int backup_p = rta_getattr_u32(tb[IFLA_BRPORT_BACKUP_PORT]);
+
+               print_string(PRINT_ANY, "backup_port", "backup_port %s ",
+                            ll_index_to_name(backup_p));
+       }
 }
 
 static void bridge_slave_parse_on_off(char *arg_name, char *arg_val,
@@ -393,6 +392,20 @@ static int bridge_slave_parse_opt(struct link_util *lu, int argc, char **argv,
                        NEXT_ARG();
                        bridge_slave_parse_on_off("vlan_tunnel", *argv, n,
                                                  IFLA_BRPORT_VLAN_TUNNEL);
+               } else if (matches(*argv, "isolated") == 0) {
+                       NEXT_ARG();
+                       bridge_slave_parse_on_off("isolated", *argv, n,
+                                                 IFLA_BRPORT_ISOLATED);
+               } else if (matches(*argv, "backup_port") == 0) {
+                       int ifindex;
+
+                       NEXT_ARG();
+                       ifindex = ll_name_to_index(*argv);
+                       if (!ifindex)
+                               invarg("Device does not exist\n", *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 (matches(*argv, "help") == 0) {
                        explain();
                        return -1;