Lines Matching +full:poll +full:- +full:interval
1 // SPDX-License-Identifier: GPL-2.0-only
18 #include <poll.h>
33 "Usage: xdp_router_ipv4 <IFNAME-0> ... <IFNAME-N>\n";
42 static int interval = 5; variable
51 { "skb-mode", no_argument, NULL, 'S' },
53 { "interval", required_argument, NULL, 'i' },
69 len = recv(sock, buf_ptr, sizeof(buf) - nll, 0); in recv_msg()
75 if (nh->nlmsg_type == NLMSG_DONE) in recv_msg()
119 rtm_family = rt_msg->rtm_family; in read_route()
121 if (rt_msg->rtm_table != RT_TABLE_MAIN) in read_route()
127 switch (rt_attr->rta_type) { in read_route()
147 sprintf(dsts_len, "%d", rt_msg->rtm_dst_len); in read_route()
168 prefix_key->prefixlen = 32; in read_route()
169 prefix_key->prefixlen = route.dst_len; in read_route()
175 if (nh->nlmsg_type == RTM_DELROUTE) { in read_route()
189 prefix_key->data[i] = (route.dst >> i * 8) & 0xff; in read_route()
194 prefix_value->prefix[i] = prefix_key->data[i]; in read_route()
195 prefix_value->value = route.mac & 0xffffffffffff; in read_route()
196 prefix_value->ifindex = route.iface; in read_route()
197 prefix_value->gw = route.gw; in read_route()
198 prefix_value->metric = route.metric; in read_route()
205 if (nh->nlmsg_type == RTM_DELROUTE) { in read_route()
215 } else if (prefix_key->data[0] == in read_route()
216 prefix_value->prefix[0] && in read_route()
217 prefix_key->data[1] == in read_route()
218 prefix_value->prefix[1] && in read_route()
219 prefix_key->data[2] == in read_route()
220 prefix_value->prefix[2] && in read_route()
221 prefix_key->data[3] == in read_route()
222 prefix_value->prefix[3] && in read_route()
223 route.metric >= prefix_value->metric) { in read_route()
227 prefix_value->prefix[i] = in read_route()
228 prefix_key->data[i]; in read_route()
229 prefix_value->value = in read_route()
231 prefix_value->ifindex = route.iface; in read_route()
232 prefix_value->gw = route.gw; in read_route()
233 prefix_value->metric = route.metric; in read_route()
270 return -errno; in get_route_table()
276 ret = -errno; in get_route_table()
296 ret = -errno; in get_route_table()
336 ndm_family = rt_msg->ndm_family; in read_arp()
339 switch (rt_attr->rta_type) { in read_arp()
359 if (nh->nlmsg_type == RTM_DELNEIGH) { in read_arp()
362 } else if (nh->nlmsg_type == RTM_NEWNEIGH) { in read_arp()
372 if (nh->nlmsg_type == RTM_DELNEIGH) { in read_arp()
375 } else if (nh->nlmsg_type == RTM_NEWNEIGH) { in read_arp()
406 return -errno; in get_arp_table()
412 ret = -errno; in get_arp_table()
431 ret = -errno; in get_arp_table()
509 if (poll(&fds_route, 1, 3) == POLL_IN) { in monitor_routes_thread()
522 if (poll(&fds_arp, 1, 3) == POLL_IN) { in monitor_routes_thread()
534 sleep(interval); in monitor_routes_thread()
555 int i, total_ifindex = argc - 1; in main()
576 strerror(-ret)); in main()
590 fprintf(stderr, "Failed to initialize sample: %s\n", strerror(-ret)); in main()
596 long_options, &longindex)) != -1) { in main()
600 total_ifindex--; in main()
604 interval = strtoul(optarg, NULL, 0); in main()
605 total_ifindex -= 2; in main()
610 total_ifindex--; in main()
615 total_ifindex--; in main()
620 total_ifindex--; in main()
626 usage(argv, long_options, __doc__, mask, error, skel->obj); in main()
633 usage(argv, long_options, __doc__, mask, true, skel->obj); in main()
637 lpm_map_fd = bpf_map__fd(skel->maps.lpm_map); in main()
640 strerror(-lpm_map_fd)); in main()
643 arp_table_map_fd = bpf_map__fd(skel->maps.arp_table); in main()
646 strerror(-arp_table_map_fd)); in main()
649 exact_match_map_fd = bpf_map__fd(skel->maps.exact_match); in main()
652 strerror(-exact_match_map_fd)); in main()
655 tx_port_map_fd = bpf_map__fd(skel->maps.tx_port); in main()
658 strerror(-tx_port_map_fd)); in main()
668 ifname_list[i], strerror(-tx_port_map_fd)); in main()
671 if (sample_install_xdp(skel->progs.xdp_router_ipv4_prog, in main()
678 fprintf(stderr, "Failed creating routes_thread: %s\n", strerror(-ret)); in main()
683 ret = sample_run(interval, NULL, NULL); in main()
687 fprintf(stderr, "Failed during sample run: %s\n", strerror(-ret)); in main()