1 #include <netlink/netlink.h> 2 #include <netlink/route/link.h> 3 #include <netlink/route/link/bonding.h> 4 main(int argc,char * argv[])5int main(int argc, char *argv[]) 6 { 7 struct rtnl_link *link; 8 struct nl_sock *sk; 9 int err; 10 11 sk = nl_socket_alloc(); 12 if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 13 nl_perror(err, "Unable to connect socket"); 14 return err; 15 } 16 17 link = rtnl_link_bond_alloc(); 18 rtnl_link_set_name(link, "my_bond"); 19 20 if ((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0) { 21 nl_perror(err, "Unable to add link"); 22 return err; 23 } 24 25 rtnl_link_put(link); 26 nl_close(sk); 27 28 return 0; 29 } 30