MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sysctl_iflist_ifaml

Function sysctl_iflist_ifaml

freebsd/net/rtsock.c:2271–2319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2269}
2270
2271static int
2272sysctl_iflist_ifaml(struct ifaddr *ifa, struct rt_addrinfo *info,
2273 struct walkarg *w, int len)
2274{
2275 struct ifa_msghdrl *ifam;
2276 struct if_data *ifd;
2277
2278 ifam = (struct ifa_msghdrl *)w->w_tmem;
2279
2280#ifdef COMPAT_FREEBSD32
2281 if (w->w_req->flags & SCTL_MASK32) {
2282 struct ifa_msghdrl32 *ifam32;
2283
2284 ifam32 = (struct ifa_msghdrl32 *)ifam;
2285 ifam32->ifam_addrs = info->rti_addrs;
2286 ifam32->ifam_flags = ifa->ifa_flags;
2287 ifam32->ifam_index = ifa->ifa_ifp->if_index;
2288 ifam32->_ifam_spare1 = 0;
2289 ifam32->ifam_len = sizeof(*ifam32);
2290 ifam32->ifam_data_off =
2291 offsetof(struct ifa_msghdrl32, ifam_data);
2292 ifam32->ifam_metric = ifa->ifa_ifp->if_metric;
2293 ifd = &ifam32->ifam_data;
2294 } else
2295#endif
2296 {
2297 ifam->ifam_addrs = info->rti_addrs;
2298 ifam->ifam_flags = ifa->ifa_flags;
2299 ifam->ifam_index = ifa->ifa_ifp->if_index;
2300 ifam->_ifam_spare1 = 0;
2301 ifam->ifam_len = sizeof(*ifam);
2302 ifam->ifam_data_off = offsetof(struct ifa_msghdrl, ifam_data);
2303 ifam->ifam_metric = ifa->ifa_ifp->if_metric;
2304 ifd = &ifam->ifam_data;
2305 }
2306
2307 bzero(ifd, sizeof(*ifd));
2308 ifd->ifi_datalen = sizeof(struct if_data);
2309 ifd->ifi_ipackets = counter_u64_fetch(ifa->ifa_ipackets);
2310 ifd->ifi_opackets = counter_u64_fetch(ifa->ifa_opackets);
2311 ifd->ifi_ibytes = counter_u64_fetch(ifa->ifa_ibytes);
2312 ifd->ifi_obytes = counter_u64_fetch(ifa->ifa_obytes);
2313
2314 /* Fixup if_data carp(4) vhid. */
2315 if (carp_get_vhid_p != NULL)
2316 ifd->ifi_vhid = (*carp_get_vhid_p)(ifa);
2317
2318 return (SYSCTL_OUT(w->w_req, w->w_tmem, len));
2319}
2320
2321static int
2322sysctl_iflist_ifam(struct ifaddr *ifa, struct rt_addrinfo *info,

Callers 1

sysctl_iflistFunction · 0.85

Calls 2

bzeroFunction · 0.85
counter_u64_fetchFunction · 0.85

Tested by

no test coverage detected