6#include <netlink/cli/utils.h>
7#include <netlink/cli/link.h>
8#include <netlink/route/link/bonding.h>
10#include <linux/netlink.h>
12int main(
int argc,
char *argv[])
15 struct nl_cache *link_cache;
20 fprintf(stderr,
"Usage: nl-link-enslave master slave\n");
24 sock = nl_cli_alloc_socket();
25 nl_cli_connect(sock, NETLINK_ROUTE);
26 link_cache = nl_cli_link_alloc_cache(sock);
29 fprintf(stderr,
"Unknown link: %s\n", argv[1]);
34 fprintf(stderr,
"Unknown link: %s\n", argv[2]);
39 fprintf(stderr,
"Unable to enslave %s to %s: %s\n",
40 argv[2], argv[1], nl_geterror(err));
int rtnl_link_bond_enslave(struct nl_sock *sock, struct rtnl_link *master, struct rtnl_link *slave)
Add a link to a bond (enslave)
struct rtnl_link * rtnl_link_get_by_name(struct nl_cache *cache, const char *name)
Lookup link in cache by link name.