1 #include <netlink/netlink.h> 2 #include <netlink/route/link.h> 3 4 #include <linux/netlink.h> 5 main(int argc,char * argv[])6int main(int argc, char *argv[]) 7 { 8 struct rtnl_link *link; 9 struct nl_sock *sk; 10 int err; 11 12 sk = nl_socket_alloc(); 13 if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 14 nl_perror(err, "Unable to connect socket"); 15 return err; 16 } 17 18 link = rtnl_link_alloc(); 19 rtnl_link_set_type(link, "ifb"); 20 rtnl_link_set_name(link, "ifb1"); 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