test-create-bond.c 571 B

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