]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iplink: bond_slave: add per port prio support
authorHangbin Liu <liuhangbin@gmail.com>
Tue, 21 Jun 2022 07:51:05 +0000 (15:51 +0800)
committerDavid Ahern <dsahern@kernel.org>
Sun, 26 Jun 2022 17:23:19 +0000 (11:23 -0600)
Add per port priority support for active slave re-selection during
bonding failover. A higher number means higher priority.

This option is only valid for active-backup(1), balance-tlb (5) and
balance-alb (6) mode.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Jonathan Toppins <jtoppins@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/iplink_bond_slave.c
man/man8/ip-link.8.in

index d488aaab4fef5393b3b92eef9f10931d4b02e23b..8103704bc9aa5107fcce35600318a433212611db 100644 (file)
@@ -19,7 +19,7 @@
 
 static void print_explain(FILE *f)
 {
-       fprintf(f, "Usage: ... bond_slave [ queue_id ID ]\n");
+       fprintf(f, "Usage: ... bond_slave [ queue_id ID ] [ prio PRIORITY ]\n");
 }
 
 static void explain(void)
@@ -120,6 +120,10 @@ static void bond_slave_print_opt(struct link_util *lu, FILE *f, struct rtattr *t
                          "queue_id %d ",
                          rta_getattr_u16(tb[IFLA_BOND_SLAVE_QUEUE_ID]));
 
+       if (tb[IFLA_BOND_SLAVE_PRIO])
+               print_int(PRINT_ANY, "prio", "prio %d ",
+                         rta_getattr_s32(tb[IFLA_BOND_SLAVE_PRIO]));
+
        if (tb[IFLA_BOND_SLAVE_AD_AGGREGATOR_ID])
                print_int(PRINT_ANY,
                          "ad_aggregator_id",
@@ -151,6 +155,7 @@ static int bond_slave_parse_opt(struct link_util *lu, int argc, char **argv,
                                struct nlmsghdr *n)
 {
        __u16 queue_id;
+       int prio;
 
        while (argc > 0) {
                if (matches(*argv, "queue_id") == 0) {
@@ -158,6 +163,11 @@ static int bond_slave_parse_opt(struct link_util *lu, int argc, char **argv,
                        if (get_u16(&queue_id, *argv, 0))
                                invarg("queue_id is invalid", *argv);
                        addattr16(n, 1024, IFLA_BOND_SLAVE_QUEUE_ID, queue_id);
+               } else if (strcmp(*argv, "prio") == 0) {
+                       NEXT_ARG();
+                       if (get_s32(&prio, *argv, 0))
+                               invarg("prio is invalid", *argv);
+                       addattr32(n, 1024, IFLA_BOND_SLAVE_PRIO, prio);
                } else {
                        if (matches(*argv, "help") != 0)
                                fprintf(stderr,
index 6f332645058486f05c2366d093bfc4afaf695cd5..3dbcdbb60c5645a54694b8137a611c3ac5a43614 100644 (file)
@@ -2567,6 +2567,8 @@ the following additional arguments are supported:
 .B "ip link set type bond_slave"
 [
 .BI queue_id " ID"
+] [
+.BI prio " PRIORITY"
 ]
 
 .in +8
@@ -2574,6 +2576,12 @@ the following additional arguments are supported:
 .BI queue_id " ID"
 - set the slave's queue ID (a 16bit unsigned value).
 
+.sp
+.BI prio " PRIORITY"
+- set the slave's priority for active slave re-selection during failover
+(a 32bit signed value). This option only valid for active-backup(1),
+balance-tlb (5) and balance-alb (6) mode.
+
 .in -8
 
 .TP