Lines Matching +full:mac +full:- +full:s

1 // SPDX-License-Identifier: GPL-2.0-only
33 "Usage: xdp_router_ipv4 <IFNAME-0> ... <IFNAME-N>\n";
51 { "skb-mode", no_argument, NULL, 'S' },
55 { "stats", no_argument, NULL, 's' },
69 len = recv(sock, buf_ptr, sizeof(buf) - nll, 0); in recv_msg()
75 if (nh->nlmsg_type == NLMSG_DONE) in recv_msg()
103 __be64 mac; in read_route() member
106 __be64 mac; in read_route() member
113 __be64 mac; in read_route() member
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()
153 assert(get_mac_addr(route.iface, &route.mac) == 0); in read_route()
168 prefix_key->prefixlen = 32; in read_route()
169 prefix_key->prefixlen = route.dst_len; in read_route()
170 direct_entry.mac = route.mac & 0xffffffffffff; in read_route()
172 direct_entry.arp.mac = 0; in read_route()
175 if (nh->nlmsg_type == RTM_DELROUTE) { in read_route()
181 &direct_entry.arp.mac) == 0) 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()
230 route.mac & 0xffffffffffff; 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()
269 fprintf(stderr, "open netlink socket: %s\n", strerror(errno)); in get_route_table()
270 return -errno; in get_route_table()
275 fprintf(stderr, "bind netlink socket: %s\n", strerror(errno)); in get_route_table()
276 ret = -errno; in get_route_table()
295 fprintf(stderr, "send to netlink: %s\n", strerror(errno)); in get_route_table()
296 ret = -errno; in get_route_table()
302 fprintf(stderr, "recv from netlink: %s\n", strerror(nll)); in get_route_table()
319 char dsts[24], mac[24]; in read_arp() local
324 __be64 mac; in read_arp() member
330 __be64 mac; in read_arp() member
336 ndm_family = rt_msg->ndm_family; in read_arp()
339 switch (rt_attr->rta_type) { in read_arp()
345 sprintf(mac, "%lld", in read_arp()
353 arp_entry.mac = atol(mac); in read_arp()
359 if (nh->nlmsg_type == RTM_DELNEIGH) { in read_arp()
361 direct_entry.arp.mac = 0; in read_arp()
362 } else if (nh->nlmsg_type == RTM_NEWNEIGH) { in read_arp()
364 direct_entry.arp.mac = arp_entry.mac; in read_arp()
372 if (nh->nlmsg_type == RTM_DELNEIGH) { in read_arp()
375 } else if (nh->nlmsg_type == RTM_NEWNEIGH) { in read_arp()
378 &arp_entry.mac, 0 in read_arp()
405 fprintf(stderr, "open netlink socket: %s\n", strerror(errno)); in get_arp_table()
406 return -errno; in get_arp_table()
411 fprintf(stderr, "bind netlink socket: %s\n", strerror(errno)); in get_arp_table()
412 ret = -errno; in get_arp_table()
430 fprintf(stderr, "send to netlink: %s\n", strerror(errno)); in get_arp_table()
431 ret = -errno; in get_arp_table()
437 fprintf(stderr, "recv from netlink: %s\n", strerror(nll)); in get_arp_table()
460 fprintf(stderr, "open netlink socket: %s\n", strerror(errno)); in monitor_routes_thread()
469 fprintf(stderr, "bind netlink socket: %s\n", strerror(errno)); in monitor_routes_thread()
479 fprintf(stderr, "open netlink socket: %s\n", strerror(errno)); in monitor_routes_thread()
489 fprintf(stderr, "bind netlink socket: %s\n", strerror(errno)); in monitor_routes_thread()
512 fprintf(stderr, "recv from netlink: %s\n", in monitor_routes_thread()
525 fprintf(stderr, "recv from netlink: %s\n", in monitor_routes_thread()
555 int i, total_ifindex = argc - 1; in main()
561 fprintf(stderr, "Failed to set libbpf strict mode: %s\n", in main()
568 fprintf(stderr, "Failed to xdp_router_ipv4__open: %s\n", in main()
575 fprintf(stderr, "Failed to sample_init_pre_load: %s\n", in main()
576 strerror(-ret)); in main()
583 fprintf(stderr, "Failed to xdp_router_ipv4__load: %s\n", in main()
590 fprintf(stderr, "Failed to initialize sample: %s\n", strerror(-ret)); in main()
596 long_options, &longindex)) != -1) { in main()
598 case 's': in main()
600 total_ifindex--; in main()
605 total_ifindex -= 2; in main()
608 case 'S': 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()
639 fprintf(stderr, "Failed loading lpm_map %s\n", in main()
640 strerror(-lpm_map_fd)); in main()
643 arp_table_map_fd = bpf_map__fd(skel->maps.arp_table); in main()
645 fprintf(stderr, "Failed loading arp_table_map_fd %s\n", in main()
646 strerror(-arp_table_map_fd)); in main()
649 exact_match_map_fd = bpf_map__fd(skel->maps.exact_match); in main()
651 fprintf(stderr, "Failed loading exact_match_map_fd %s\n", in main()
652 strerror(-exact_match_map_fd)); in main()
655 tx_port_map_fd = bpf_map__fd(skel->maps.tx_port); in main()
657 fprintf(stderr, "Failed loading tx_port_map_fd %s\n", in main()
658 strerror(-tx_port_map_fd)); in main()
667 fprintf(stderr, "Interface %s not found %s\n", 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()
687 fprintf(stderr, "Failed during sample run: %s\n", strerror(-ret)); in main()