Changeset View
Changeset View
Standalone View
Standalone View
sbin/route/route_netlink.c
| Show First 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | print_nhop_getmsg(struct nl_helper *h, struct nlmsghdr *hdr, struct sockaddr *dst) | ||||
| if (r.rta_dst) | if (r.rta_dst) | ||||
| printf("destination: %s\n", routename(r.rta_dst)); | printf("destination: %s\n", routename(r.rta_dst)); | ||||
| mask = get_netmask(ss, r.rtm_family, r.rtm_dst_len); | mask = get_netmask(ss, r.rtm_family, r.rtm_dst_len); | ||||
| if (mask) | if (mask) | ||||
| printf(" mask: %s\n", routename(mask)); | printf(" mask: %s\n", routename(mask)); | ||||
| printf(" fib: %u\n", (unsigned int)r.rta_table); | printf(" fib: %u\n", (unsigned int)r.rta_table); | ||||
| printf(" flags: "); | printf(" flags: "); | ||||
| printb(r.rta_rtflags, routeflags); | printb(r.rta_rtflags, routeflags); | ||||
| printf("\n nhops: %u\n", r.rta_multipath.num_nhops); | printf("\n nhops: %u\n", r.rta_multipath.count); | ||||
| if (r.rta_multipath.num_nhops != 0) { | if (r.rta_multipath.count != 0) { | ||||
| bool first = true; | bool first = true; | ||||
| for (uint32_t i = 0; i < r.rta_multipath.num_nhops; i++) { | for (uint32_t i = 0; i < r.rta_multipath.count; i++) { | ||||
| struct rta_mpath_nh *nh = r.rta_multipath.nhops[i]; | struct rta_mpath_nh *nh = r.rta_multipath.items[i]; | ||||
| printf("\tvia "); | printf("\tvia "); | ||||
| print_nlmsg_route_nhop(h, &r, nh, first); | print_nlmsg_route_nhop(h, &r, nh, first); | ||||
| first = false; | first = false; | ||||
| } | } | ||||
| } else { | } else { | ||||
| struct rta_mpath_nh nh = { | struct rta_mpath_nh nh = { | ||||
| .gw = r.rta_gw, | .gw = r.rta_gw, | ||||
| ▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | print_nlmsg_route(struct nl_helper *h, struct nlmsghdr *hdr, | ||||
| case RTN_UNREACHABLE: | case RTN_UNREACHABLE: | ||||
| printf("unreach(reject)\n"); | printf("unreach(reject)\n"); | ||||
| return; | return; | ||||
| case RTN_PROHIBIT: | case RTN_PROHIBIT: | ||||
| printf("prohibit(reject)\n"); | printf("prohibit(reject)\n"); | ||||
| return; | return; | ||||
| } | } | ||||
| if (r.rta_multipath.num_nhops != 0) { | if (r.rta_multipath.count != 0) { | ||||
| bool first = true; | bool first = true; | ||||
| memset(buf, ' ', sizeof(buf)); | memset(buf, ' ', sizeof(buf)); | ||||
| buf[len] = '\0'; | buf[len] = '\0'; | ||||
| for (uint32_t i = 0; i < r.rta_multipath.num_nhops; i++) { | for (uint32_t i = 0; i < r.rta_multipath.count; i++) { | ||||
| struct rta_mpath_nh *nh = r.rta_multipath.nhops[i]; | struct rta_mpath_nh *nh = r.rta_multipath.items[i]; | ||||
| if (!first) | if (!first) | ||||
| printf("%s", buf); | printf("%s", buf); | ||||
| print_nlmsg_route_nhop(h, &r, nh, first); | print_nlmsg_route_nhop(h, &r, nh, first); | ||||
| first = false; | first = false; | ||||
| } | } | ||||
| } else { | } else { | ||||
| struct rta_mpath_nh nh = { | struct rta_mpath_nh nh = { | ||||
| ▲ Show 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | if (!snl_read_reply_code(ss, hdr->nlmsg_seq, &e)) { | ||||
| return (true); | return (true); | ||||
| }; | }; | ||||
| if (verbose) { | if (verbose) { | ||||
| struct snl_msg_info attrs = {}; | struct snl_msg_info attrs = {}; | ||||
| print_nlmsg(h, hdr, &attrs); | print_nlmsg(h, hdr, &attrs); | ||||
| } | } | ||||
| else { | else { | ||||
| if (r->rta_multipath.num_nhops != 0) { | if (r->rta_multipath.count != 0) { | ||||
| for (uint32_t i = 0; i < r->rta_multipath.num_nhops; i++) { | for (uint32_t i = 0; i < r->rta_multipath.count; i++) { | ||||
| struct rta_mpath_nh *nh = r->rta_multipath.nhops[i]; | struct rta_mpath_nh *nh = | ||||
| r->rta_multipath.items[i]; | |||||
| print_flushed_route(r, nh->gw); | print_flushed_route(r, nh->gw); | ||||
| } | } | ||||
| } else | } else | ||||
| print_flushed_route(r, r->rta_gw); | print_flushed_route(r, r->rta_gw); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | while ((hdr = snl_read_reply_multi(&ss, nlm_seq, &e)) != NULL) { | ||||
| snl_clear_lb(&h.ss_cmd); | snl_clear_lb(&h.ss_cmd); | ||||
| } | } | ||||
| snl_free(&ss); | snl_free(&ss); | ||||
| nl_helper_free(&h); | nl_helper_free(&h); | ||||
| return (e.error); | return (e.error); | ||||
| } | } | ||||