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

Function nd6_ifattach

freebsd/netinet6/nd6.c:261–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259#endif
260
261struct nd_ifinfo *
262nd6_ifattach(struct ifnet *ifp)
263{
264 struct nd_ifinfo *nd;
265
266 nd = malloc(sizeof(*nd), M_IP6NDP, M_WAITOK | M_ZERO);
267 nd->initialized = 1;
268
269 nd->chlim = IPV6_DEFHLIM;
270 nd->basereachable = REACHABLE_TIME;
271 nd->reachable = ND_COMPUTE_RTIME(nd->basereachable);
272 nd->retrans = RETRANS_TIMER;
273
274 nd->flags = ND6_IFF_PERFORMNUD;
275
276 /* Set IPv6 disabled on all interfaces but loopback by default. */
277 if ((ifp->if_flags & IFF_LOOPBACK) == 0)
278 nd->flags |= ND6_IFF_IFDISABLED;
279
280 /* A loopback interface always has ND6_IFF_AUTO_LINKLOCAL.
281 * XXXHRS: Clear ND6_IFF_AUTO_LINKLOCAL on an IFT_BRIDGE interface by
282 * default regardless of the V_ip6_auto_linklocal configuration to
283 * give a reasonable default behavior.
284 */
285 if ((V_ip6_auto_linklocal && ifp->if_type != IFT_BRIDGE) ||
286 (ifp->if_flags & IFF_LOOPBACK))
287 nd->flags |= ND6_IFF_AUTO_LINKLOCAL;
288 /*
289 * A loopback interface does not need to accept RTADV.
290 * XXXHRS: Clear ND6_IFF_ACCEPT_RTADV on an IFT_BRIDGE interface by
291 * default regardless of the V_ip6_accept_rtadv configuration to
292 * prevent the interface from accepting RA messages arrived
293 * on one of the member interfaces with ND6_IFF_ACCEPT_RTADV.
294 */
295 if (V_ip6_accept_rtadv &&
296 !(ifp->if_flags & IFF_LOOPBACK) &&
297 (ifp->if_type != IFT_BRIDGE)) {
298 nd->flags |= ND6_IFF_ACCEPT_RTADV;
299 /* If we globally accept rtadv, assume IPv6 on. */
300 nd->flags &= ~ND6_IFF_IFDISABLED;
301 }
302 if (V_ip6_no_radr && !(ifp->if_flags & IFF_LOOPBACK))
303 nd->flags |= ND6_IFF_NO_RADR;
304
305 /* XXX: we cannot call nd6_setmtu since ifp is not fully initialized */
306 nd6_setmtu0(ifp, nd);
307
308 return nd;
309}
310
311void
312nd6_ifdetach(struct ifnet *ifp, struct nd_ifinfo *nd)

Callers 1

in6_domifattachFunction · 0.85

Calls 2

mallocFunction · 0.85
nd6_setmtu0Function · 0.85

Tested by

no test coverage detected