Lines Matching refs:file
18 static struct tst_rtnl_context *create_request(const char *file,
28 ctx = tst_rtnl_create_context(file, lineno);
33 if (!tst_rtnl_add_message(file, lineno, ctx, &header, payload, psize)) {
34 tst_rtnl_destroy_context(file, lineno, ctx);
41 int tst_netdev_index_by_name(const char *file, const int lineno,
48 tst_brk_(file, lineno, TBROK,
53 sock = safe_socket(file, lineno, NULL, AF_INET, SOCK_DGRAM, 0);
59 ret = SAFE_IOCTL_(file, lineno, sock, SIOCGIFINDEX, &ifr);
60 safe_close(file, lineno, NULL, sock);
65 int tst_netdev_set_state(const char *file, const int lineno,
72 tst_brk_(file, lineno, TBROK,
77 sock = safe_socket(file, lineno, NULL, AF_INET, SOCK_DGRAM, 0);
83 ret = SAFE_IOCTL_(file, lineno, sock, SIOCGIFFLAGS, &ifr);
86 safe_close(file, lineno, NULL, sock);
95 ret = SAFE_IOCTL_(file, lineno, sock, SIOCSIFFLAGS, &ifr);
96 safe_close(file, lineno, NULL, sock);
101 int tst_create_veth_pair(const char *file, const int lineno, int strict,
126 tst_brk_(file, lineno, TBROK,
132 tst_brk_(file, lineno, TBROK,
137 ctx = create_request(file, lineno, RTM_NEWLINK,
143 if (tst_rtnl_add_attr_list(file, lineno, ctx, attrs) != 2) {
144 tst_rtnl_destroy_context(file, lineno, ctx);
148 ret = tst_rtnl_send_validate(file, lineno, ctx);
149 tst_rtnl_destroy_context(file, lineno, ctx);
152 tst_brk_(file, lineno, TBROK,
160 int tst_netdev_add_device(const char *file, const int lineno, int strict,
176 tst_brk_(file, lineno, TBROK,
181 ctx = create_request(file, lineno, RTM_NEWLINK,
187 if (tst_rtnl_add_attr_list(file, lineno, ctx, attrs) != 2) {
188 tst_rtnl_destroy_context(file, lineno, ctx);
192 ret = tst_rtnl_send_validate(file, lineno, ctx);
193 tst_rtnl_destroy_context(file, lineno, ctx);
196 tst_brk_(file, lineno, TBROK,
204 int tst_netdev_remove_device(const char *file, const int lineno, int strict,
212 tst_brk_(file, lineno, TBROK,
217 ctx = create_request(file, lineno, RTM_DELLINK, 0, &info, sizeof(info));
222 if (!tst_rtnl_add_attr_string(file, lineno, ctx, IFLA_IFNAME, ifname)) {
223 tst_rtnl_destroy_context(file, lineno, ctx);
227 ret = tst_rtnl_send_validate(file, lineno, ctx);
228 tst_rtnl_destroy_context(file, lineno, ctx);
231 tst_brk_(file, lineno, TBROK,
239 static int modify_address(const char *file, const int lineno, int strict,
251 index = tst_netdev_index_by_name(file, lineno, ifname);
254 tst_brk_(file, lineno, TBROK, "Interface %s not found", ifname);
259 ctx = create_request(file, lineno, action, nl_flags, &info,
265 if (!tst_rtnl_add_attr(file, lineno, ctx, IFA_FLAGS, &addr_flags,
267 tst_rtnl_destroy_context(file, lineno, ctx);
271 if (!tst_rtnl_add_attr(file, lineno, ctx, IFA_LOCAL, address,
273 tst_rtnl_destroy_context(file, lineno, ctx);
277 ret = tst_rtnl_send_validate(file, lineno, ctx);
278 tst_rtnl_destroy_context(file, lineno, ctx);
281 tst_brk_(file, lineno, TBROK,
289 int tst_netdev_add_address(const char *file, const int lineno, int strict,
293 return modify_address(file, lineno, strict, RTM_NEWADDR,
298 int tst_netdev_add_address_inet(const char *file, const int lineno, int strict,
302 return tst_netdev_add_address(file, lineno, strict, ifname, AF_INET,
306 int tst_netdev_remove_address(const char *file, const int lineno, int strict,
310 return modify_address(file, lineno, strict, RTM_DELADDR, 0, ifname,
314 int tst_netdev_remove_address_inet(const char *file, const int lineno,
317 return tst_netdev_remove_address(file, lineno, strict, ifname, AF_INET,
321 static int change_ns(const char *file, const int lineno, int strict,
329 tst_brk_(file, lineno, TBROK,
334 ctx = create_request(file, lineno, RTM_NEWLINK, 0, &info, sizeof(info));
339 if (!tst_rtnl_add_attr_string(file, lineno, ctx, IFLA_IFNAME, ifname)) {
340 tst_rtnl_destroy_context(file, lineno, ctx);
344 if (!tst_rtnl_add_attr(file, lineno, ctx, attr, &value,
346 tst_rtnl_destroy_context(file, lineno, ctx);
350 ret = tst_rtnl_send_validate(file, lineno, ctx);
351 tst_rtnl_destroy_context(file, lineno, ctx);
354 tst_brk_(file, lineno, TBROK,
362 int tst_netdev_change_ns_fd(const char *file, const int lineno, int strict,
365 return change_ns(file, lineno, strict, ifname, IFLA_NET_NS_FD, nsfd);
368 int tst_netdev_change_ns_pid(const char *file, const int lineno, int strict,
371 return change_ns(file, lineno, strict, ifname, IFLA_NET_NS_PID, nspid);
374 static int modify_route(const char *file, const int lineno, int strict,
393 tst_brk_(file, lineno, TBROK,
399 tst_brk_(file, lineno, TBROK,
405 index = tst_netdev_index_by_name(file, lineno, ifname);
416 ctx = create_request(file, lineno, action, flags, &info, sizeof(info));
421 if (srcaddr && !tst_rtnl_add_attr(file, lineno, ctx, RTA_SRC, srcaddr,
423 tst_rtnl_destroy_context(file, lineno, ctx);
427 if (dstaddr && !tst_rtnl_add_attr(file, lineno, ctx, RTA_DST, dstaddr,
429 tst_rtnl_destroy_context(file, lineno, ctx);
433 if (gateway && !tst_rtnl_add_attr(file, lineno, ctx, RTA_GATEWAY,
435 tst_rtnl_destroy_context(file, lineno, ctx);
439 if (ifname && !tst_rtnl_add_attr(file, lineno, ctx, RTA_OIF, &index,
441 tst_rtnl_destroy_context(file, lineno, ctx);
445 ret = tst_rtnl_send_validate(file, lineno, ctx);
446 tst_rtnl_destroy_context(file, lineno, ctx);
449 tst_brk_(file, lineno, TBROK,
457 static int modify_route_inet(const char *file, const int lineno, int strict,
480 return modify_route(file, lineno, strict, action, flags, ifname,
485 int tst_netdev_add_route(const char *file, const int lineno, int strict,
491 return modify_route(file, lineno, strict, RTM_NEWROUTE,
496 int tst_netdev_add_route_inet(const char *file, const int lineno, int strict,
500 return modify_route_inet(file, lineno, strict, RTM_NEWROUTE,
505 int tst_netdev_remove_route(const char *file, const int lineno, int strict,
511 return modify_route(file, lineno, strict, RTM_DELROUTE, 0, ifname,
516 int tst_netdev_remove_route_inet(const char *file, const int lineno,
521 return modify_route_inet(file, lineno, strict, RTM_DELROUTE, 0, ifname,
525 static int modify_qdisc(const char *file, const int lineno, int strict,
541 tst_brk_(file, lineno, TBROK,
547 msg.tcm_ifindex = tst_netdev_index_by_name(file, lineno,
551 tst_brk_(file, lineno, TBROK, "Interface %s not found",
557 ctx = create_request(file, lineno, action, nl_flags, &msg, sizeof(msg));
562 if (!tst_rtnl_add_attr_string(file, lineno, ctx, TCA_KIND, qd_kind)) {
563 tst_rtnl_destroy_context(file, lineno, ctx);
567 if (config && !tst_rtnl_add_attr_list(file, lineno, ctx, config)) {
568 tst_rtnl_destroy_context(file, lineno, ctx);
572 ret = tst_rtnl_send_validate(file, lineno, ctx);
573 tst_rtnl_destroy_context(file, lineno, ctx);
576 tst_brk_(file, lineno, TBROK,
584 int tst_netdev_add_qdisc(const char *file, const int lineno, int strict,
589 return modify_qdisc(file, lineno, strict, "queueing discipline",
594 int tst_netdev_remove_qdisc(const char *file, const int lineno, int strict,
598 return modify_qdisc(file, lineno, strict, "queueing discipline",
603 int tst_netdev_add_traffic_class(const char *file, const int lineno,
608 return modify_qdisc(file, lineno, strict, "traffic class",
613 int tst_netdev_remove_traffic_class(const char *file, const int lineno,
617 return modify_qdisc(file, lineno, strict, "traffic class",
622 int tst_netdev_add_traffic_filter(const char *file, const int lineno,
627 return modify_qdisc(file, lineno, strict, "traffic filter",
633 int tst_netdev_remove_traffic_filter(const char *file, const int lineno,
638 return modify_qdisc(file, lineno, strict, "traffic filter",