Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/netstat/route_netlink.c
| Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | p_path(struct snl_parsed_route *rt, bool is_mpath) | ||||||||
| add_scopeid(rt->rta_dst, rt->rta_oif); | add_scopeid(rt->rta_dst, rt->rta_oif); | ||||||||
| add_scopeid(rt->rta_gw, rt->rta_oif); | add_scopeid(rt->rta_gw, rt->rta_oif); | ||||||||
| protrusion = p_sockaddr("destination", rt->rta_dst, pmask, rt->rta_rtflags, wid.dst); | protrusion = p_sockaddr("destination", rt->rta_dst, pmask, rt->rta_rtflags, wid.dst); | ||||||||
| protrusion = p_sockaddr("gateway", rt->rta_gw, NULL, RTF_HOST, | protrusion = p_sockaddr("gateway", rt->rta_gw, NULL, RTF_HOST, | ||||||||
| wid.gw - protrusion); | wid.gw - protrusion); | ||||||||
| snprintf(buffer, sizeof(buffer), "{[:-%d}{:flags/%%s}{]:} ", | snprintf(buffer, sizeof(buffer), "{[:-%d}{:flags/%%s}{]:} ", | ||||||||
| wid.flags - protrusion); | wid.flags - protrusion); | ||||||||
| p_flags(rt->rta_rtflags | RTF_UP, buffer); | p_flags(rt->rta_rtflags | RTF_UP, buffer); | ||||||||
| /* Output path weight as non-visual property */ | /* Output path weight and metric as non-visual property */ | ||||||||
| xo_emit("{e:weight/%u}", rt->rtax_weight); | xo_emit("{e:weight/%u}", rt->rtax_weight); | ||||||||
| xo_emit("{e:metric/%lu}", rt->rta_metric); | |||||||||
markj: It's a uint32_t. | |||||||||
| if (is_mpath) | if (is_mpath) | ||||||||
| xo_emit("{e:nhg-kidx/%u}", rt->rta_knh_id); | xo_emit("{e:nhg-kidx/%u}", rt->rta_knh_id); | ||||||||
| else | else | ||||||||
| xo_emit("{e:nhop-kidx/%u}", rt->rta_knh_id); | xo_emit("{e:nhop-kidx/%u}", rt->rta_knh_id); | ||||||||
| if (rt->rta_nh_id != 0) { | if (rt->rta_nh_id != 0) { | ||||||||
| if (is_mpath) | if (is_mpath) | ||||||||
| xo_emit("{e:nhg-uidx/%u}", rt->rta_nh_id); | xo_emit("{e:nhg-uidx/%u}", rt->rta_nh_id); | ||||||||
| else | else | ||||||||
| Show All 18 Lines | if (rt->rtax_mtu != 0) | ||||||||
| xo_emit("{t:mtu/%*lu} ", wid.mtu, rt->rtax_mtu); | xo_emit("{t:mtu/%*lu} ", wid.mtu, rt->rtax_mtu); | ||||||||
| else { | else { | ||||||||
| /* use interface mtu */ | /* use interface mtu */ | ||||||||
| xo_emit("{P:/%*s} ", wid.mtu, ""); | xo_emit("{P:/%*s} ", wid.mtu, ""); | ||||||||
| } | } | ||||||||
| } | } | ||||||||
| if (Wflag) | if (Wflag) { | ||||||||
| xo_emit("{t:interface-name/%*s}", wid.iface, prettyname); | xo_emit("{t:interface-name/%*s}", wid.iface, prettyname); | ||||||||
| else | xo_emit("{t:metric/%*lu} ", wid.metric, rt->rta_metric); | ||||||||
| } else | |||||||||
Done Inline Actions
markj: | |||||||||
| xo_emit("{t:interface-name/%*.*s}", wid.iface, wid.iface, | xo_emit("{t:interface-name/%*.*s}", wid.iface, wid.iface, | ||||||||
| prettyname); | prettyname); | ||||||||
| if (rt->rta_expire > 0) { | if (rt->rta_expire > 0) { | ||||||||
| xo_emit(" {:expire-time/%*u}", wid.expire, rt->rta_expire); | xo_emit(" {:expire-time/%*u}", wid.expire, rt->rta_expire); | ||||||||
| } | } | ||||||||
| } | } | ||||||||
| static void | static void | ||||||||
| Show All 10 Lines | if (rt.rta_multipath.num_nhops != 0) { | ||||||||
| uint32_t orig_rtflags = rt.rta_rtflags; | uint32_t orig_rtflags = rt.rta_rtflags; | ||||||||
| uint32_t orig_mtu = rt.rtax_mtu; | uint32_t orig_mtu = rt.rtax_mtu; | ||||||||
| for (uint32_t i = 0; i < rt.rta_multipath.num_nhops; i++) { | for (uint32_t i = 0; i < rt.rta_multipath.num_nhops; i++) { | ||||||||
| struct rta_mpath_nh *nhop = rt.rta_multipath.nhops[i]; | struct rta_mpath_nh *nhop = rt.rta_multipath.nhops[i]; | ||||||||
| rt.rta_gw = nhop->gw; | rt.rta_gw = nhop->gw; | ||||||||
| rt.rta_oif = nhop->ifindex; | rt.rta_oif = nhop->ifindex; | ||||||||
| rt.rtax_weight = nhop->rtnh_weight; | rt.rtax_weight = nhop->rtnh_weight; | ||||||||
| rt.rta_metric = nhop->rta_metric; | |||||||||
| rt.rta_rtflags = nhop->rta_rtflags ? nhop->rta_rtflags : orig_rtflags; | rt.rta_rtflags = nhop->rta_rtflags ? nhop->rta_rtflags : orig_rtflags; | ||||||||
| rt.rtax_mtu = nhop->rtax_mtu ? nhop->rtax_mtu : orig_mtu; | rt.rtax_mtu = nhop->rtax_mtu ? nhop->rtax_mtu : orig_mtu; | ||||||||
| rt.rta_expire = nhop->rta_expire; | rt.rta_expire = nhop->rta_expire; | ||||||||
| xo_open_instance(name); | xo_open_instance(name); | ||||||||
| p_path(&rt, true); | p_path(&rt, true); | ||||||||
| xo_emit("\n"); | xo_emit("\n"); | ||||||||
| xo_close_instance(name); | xo_close_instance(name); | ||||||||
| ▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines | |||||||||
It's a uint32_t.