Lines Matching defs:rtnl

33 static void test_message_link_bridge(sd_netlink *rtnl) {
37 assert_se(sd_rtnl_message_new_link(rtnl, &message, RTM_NEWLINK, 1) >= 0);
51 static void test_link_configure(sd_netlink *rtnl, int ifindex) {
60 assert_se(sd_rtnl_message_new_link(rtnl, &message, RTM_GETLINK, ifindex) >= 0);
65 assert_se(sd_netlink_call(rtnl, message, 0, NULL) == 1);
78 static void test_link_get(sd_netlink *rtnl, int ifindex) {
87 assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
102 assert_se(sd_netlink_call(rtnl, m, -1, &r) == 1);
123 static void test_address_get(sd_netlink *rtnl, int ifindex) {
130 assert_se(sd_rtnl_message_new_addr(rtnl, &m, RTM_GETADDR, ifindex, AF_INET) >= 0);
133 assert_se(sd_netlink_call(rtnl, m, -1, &r) == 1);
192 static int link_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
196 assert_se(rtnl);
210 _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
217 assert_se(sd_netlink_open(&rtnl) >= 0);
218 assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
220 assert_se(sd_netlink_call_async(rtnl, m, &link_handler, ifname, 0, NULL) >= 0);
224 assert_se(sd_netlink_attach_event(rtnl, event, 0) >= 0);
228 assert_se(sd_netlink_detach_event(rtnl) >= 0);
230 assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL);
233 static int pipe_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
249 _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
257 assert_se(sd_netlink_open(&rtnl) >= 0);
259 assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
261 assert_se(sd_netlink_call_async(rtnl, m, &link_handler, ifname, 0, &serial) >= 0);
263 assert_se(sd_netlink_wait(rtnl, 0) >= 0);
264 assert_se(sd_netlink_process(rtnl, &r) >= 0);
266 assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL);
270 _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
274 assert_se(sd_netlink_open(&rtnl) >= 0);
276 assert_se(sd_rtnl_message_new_link(rtnl, &m1, RTM_GETLINK, ifindex) >= 0);
277 assert_se(sd_rtnl_message_new_link(rtnl, &m2, RTM_GETLINK, ifindex) >= 0);
280 assert_se(sd_netlink_call_async(rtnl, m1, &pipe_handler, &counter, 0, NULL) >= 0);
283 assert_se(sd_netlink_call_async(rtnl, m2, &pipe_handler, &counter, 0, NULL) >= 0);
286 assert_se(sd_netlink_wait(rtnl, 0) >= 0);
287 assert_se(sd_netlink_process(rtnl, NULL) >= 0);
290 assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL);
329 _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
331 assert_se(sd_netlink_open(&rtnl) >= 0);
333 assert_se(sd_netlink_add_match(rtnl, RTM_NEWLINK, &link_handler, NULL) >= 0);
334 assert_se(sd_netlink_add_match(rtnl, RTM_NEWLINK, &link_handler, NULL) >= 0);
336 assert_se(sd_netlink_remove_match(rtnl, RTM_NEWLINK, &link_handler, NULL) == 1);
337 assert_se(sd_netlink_remove_match(rtnl, RTM_NEWLINK, &link_handler, NULL) == 1);
338 assert_se(sd_netlink_remove_match(rtnl, RTM_NEWLINK, &link_handler, NULL) == 0);
340 assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL);
343 static void test_get_addresses(sd_netlink *rtnl) {
347 assert_se(sd_rtnl_message_new_addr(rtnl, &req, RTM_GETADDR, 0, AF_UNSPEC) >= 0);
349 assert_se(sd_netlink_call(rtnl, req, 0, &reply) >= 0);
379 sd_netlink *rtnl;
396 assert_se(sd_netlink_open(&rtnl) >= 0);
397 assert_se(rtnl);
408 test_link_configure(rtnl, if_loopback);
410 test_get_addresses(rtnl);
412 test_message_link_bridge(rtnl);
414 assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, if_loopback) >= 0);
422 assert_se(sd_netlink_call(rtnl, m, 0, &r) == 1);
428 assert_se(sd_netlink_call(rtnl, m, -1, &r) == -EPERM);
432 test_link_get(rtnl, if_loopback);
433 test_address_get(rtnl, if_loopback);
437 assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL);