| 2144 | |
| 2145 | |
| 2146 | static int |
| 2147 | sysctl_dumpnhop(struct rtentry *rt, struct nhop_object *nh, uint32_t weight, |
| 2148 | struct walkarg *w) |
| 2149 | { |
| 2150 | struct rt_addrinfo info; |
| 2151 | int error = 0, size; |
| 2152 | uint32_t rtflags; |
| 2153 | |
| 2154 | rtflags = nhop_get_rtflags(nh); |
| 2155 | |
| 2156 | if (w->w_op == NET_RT_FLAGS && !(rtflags & w->w_arg)) |
| 2157 | return (0); |
| 2158 | |
| 2159 | bzero((caddr_t)&info, sizeof(info)); |
| 2160 | info.rti_info[RTAX_DST] = w->dst; |
| 2161 | info.rti_info[RTAX_GATEWAY] = &nh->gw_sa; |
| 2162 | info.rti_info[RTAX_NETMASK] = (rtflags & RTF_HOST) ? NULL : w->mask; |
| 2163 | info.rti_info[RTAX_GENMASK] = 0; |
| 2164 | if (nh->nh_ifp && !(nh->nh_ifp->if_flags & IFF_DYING)) { |
| 2165 | info.rti_info[RTAX_IFP] = nh->nh_ifp->if_addr->ifa_addr; |
| 2166 | info.rti_info[RTAX_IFA] = nh->nh_ifa->ifa_addr; |
| 2167 | if (nh->nh_ifp->if_flags & IFF_POINTOPOINT) |
| 2168 | info.rti_info[RTAX_BRD] = nh->nh_ifa->ifa_dstaddr; |
| 2169 | } |
| 2170 | if ((error = rtsock_msg_buffer(RTM_GET, &info, w, &size)) != 0) |
| 2171 | return (error); |
| 2172 | if (w->w_req && w->w_tmem) { |
| 2173 | struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem; |
| 2174 | |
| 2175 | bzero(&rtm->rtm_index, |
| 2176 | sizeof(*rtm) - offsetof(struct rt_msghdr, rtm_index)); |
| 2177 | |
| 2178 | /* |
| 2179 | * rte flags may consist of RTF_HOST (duplicated in nhop rtflags) |
| 2180 | * and RTF_UP (if entry is linked, which is always true here). |
| 2181 | * Given that, use nhop rtflags & add RTF_UP. |
| 2182 | */ |
| 2183 | rtm->rtm_flags = rtflags | RTF_UP; |
| 2184 | if (rtm->rtm_flags & RTF_GWFLAG_COMPAT) |
| 2185 | rtm->rtm_flags = RTF_GATEWAY | |
| 2186 | (rtm->rtm_flags & ~RTF_GWFLAG_COMPAT); |
| 2187 | rt_getmetrics(rt, nh, &rtm->rtm_rmx); |
| 2188 | rtm->rtm_rmx.rmx_weight = weight; |
| 2189 | rtm->rtm_index = nh->nh_ifp->if_index; |
| 2190 | rtm->rtm_addrs = info.rti_addrs; |
| 2191 | error = SYSCTL_OUT(w->w_req, (caddr_t)rtm, size); |
| 2192 | return (error); |
| 2193 | } |
| 2194 | return (error); |
| 2195 | } |
| 2196 | |
| 2197 | static int |
| 2198 | sysctl_iflist_ifml(struct ifnet *ifp, const struct if_data *src_ifd, |
no test coverage detected