]>
git.proxmox.com Git - mirror_iproute2.git/blob - ip/iplink_bond.c
2 * iplink_bond.c Bonding device support
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Jiri Pirko <jiri@resnulli.us>
15 #include <linux/if_link.h>
20 #include "ip_common.h"
22 static void explain(void)
25 "Usage: ... bond [ mode BONDMODE ] [ active_slave SLAVE_DEV ]\n"
26 " [ clear_active_slave ]\n"
32 static int bond_parse_opt(struct link_util
*lu
, int argc
, char **argv
,
39 if (matches(*argv
, "mode") == 0) {
41 if (get_u8(&mode
, *argv
, 0)) {
42 invarg("mode %s is invalid", *argv
);
45 addattr8(n
, 1024, IFLA_BOND_MODE
, mode
);
46 } else if (matches(*argv
, "active_slave") == 0) {
48 ifindex
= if_nametoindex(*argv
);
51 addattr32(n
, 1024, IFLA_BOND_ACTIVE_SLAVE
, ifindex
);
52 } else if (matches(*argv
, "clear_active_slave") == 0) {
53 addattr32(n
, 1024, IFLA_BOND_ACTIVE_SLAVE
, 0);
55 fprintf(stderr
, "bond: unknown command \"%s\"?\n", *argv
);
65 static void bond_print_opt(struct link_util
*lu
, FILE *f
, struct rtattr
*tb
[])
72 if (tb
[IFLA_BOND_MODE
])
73 fprintf(f
, "mode %u ", rta_getattr_u8(tb
[IFLA_BOND_MODE
]));
75 if (tb
[IFLA_BOND_ACTIVE_SLAVE
] &&
76 (ifindex
= rta_getattr_u32(tb
[IFLA_BOND_ACTIVE_SLAVE
]))) {
78 const char *n
= if_indextoname(ifindex
, buf
);
81 fprintf(f
, "active_slave %s ", n
);
83 fprintf(f
, "active_slave %u ", ifindex
);
87 struct link_util bond_link_util
= {
89 .maxattr
= IFLA_BOND_MAX
,
90 .parse_opt
= bond_parse_opt
,
91 .print_opt
= bond_print_opt
,