1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3 * Copyright (c) 2011 Thomas Graf <[email protected]>
4 */
5
6 #include "nl-default.h"
7
8 #include <linux/netlink.h>
9
10 #include <netlink/cli/utils.h>
11 #include <netlink/cli/link.h>
12 #include <netlink/route/link/bonding.h>
13
main(int argc,char * argv[])14 int main(int argc, char *argv[])
15 {
16 struct nl_sock *sock;
17 struct nl_cache *link_cache;
18 struct rtnl_link *slave;
19 int err;
20
21 if (argc < 2) {
22 fprintf(stderr, "Usage: nl-link-release slave\n");
23 return 1;
24 }
25
26 sock = nl_cli_alloc_socket();
27 nl_cli_connect(sock, NETLINK_ROUTE);
28 link_cache = nl_cli_link_alloc_cache(sock);
29
30 if (!(slave = rtnl_link_get_by_name(link_cache, argv[1]))) {
31 fprintf(stderr, "Unknown link: %s\n", argv[1]);
32 return 1;
33 }
34
35 if ((err = rtnl_link_bond_release(sock, slave)) < 0) {
36 fprintf(stderr, "Unable to release slave %s: %s\n",
37 argv[1], nl_geterror(err));
38 return 1;
39 }
40
41 return 0;
42 }
43
44