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