FreeBSD/sys/netinet6/nd6.c
/*
 * Add pernament ND6 link-layer record for given
 * interface address.
 *
 * Very similar to IPv4 arp_ifinit(), but:
 * 1) IPv6 DAD is performed in different place
 * 2) It is called by IPv6 protocol stack in contrast to
 * arp_ifinit() which is typically called in SIOCSIFADDR
 * driver ioctl handler.
 *
 */
Add pernament ND6 link-layer record for given
interface address.

Very similar to IPv4 arp_ifinit(), but:
1) IPv6 DAD is performed in different place
2) It is called by IPv6 protocol stack in contrast to
arp_ifinit() which is typically called in SIOCSIFADDR
driver ioctl handler.
Add pernament ND6 link - layer record for given interface address . Very similar to IPv4 arp_ifinit () but : 1 ) IPv6 DAD is performed in different place 2 ) It is called by IPv6 protocol stack in contrast to arp_ifinit () which is typically called in SIOCSIFADDR driver ioctl handler .
int
nd6_add_ifa_lle(struct in6_ifaddr *ia)
{
	struct ifnet *ifp;
	struct llentry *ln, *ln_tmp;
	struct sockaddr *dst;
	ifp = ia->ia_ifa.ifa_ifp;
	if (nd6_need_cache(ifp) == 0)
		return (0);
	ia->ia_ifa.ifa_rtrequest = nd6_rtrequest;
	dst = (struct sockaddr *)&ia->ia_addr;
	ln = lltable_alloc_entry(LLTABLE6(ifp), LLE_IFADDR, dst);
	if (ln == NULL)
		return (ENOBUFS);
	IF_AFDATA_WLOCK(ifp);
	LLE_WLOCK(ln);
	ln_tmp = lla_lookup(LLTABLE6(ifp), LLE_EXCLUSIVE, dst);
	if (ln_tmp != NULL)
		lltable_unlink_entry(LLTABLE6(ifp), ln_tmp);
	lltable_link_entry(LLTABLE6(ifp), ln);
	IF_AFDATA_WUNLOCK(ifp);
	if (ln_tmp != NULL)
		EVENTHANDLER_INVOKE(lle_event, ln_tmp, LLENTRY_EXPIRED);
	EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
	LLE_WUNLOCK(ln);
	if (ln_tmp != NULL)
		llentry_free(ln_tmp);
	return (0);
}
int nd6_add_ifa_lle ( struct in6_ifaddr * ia ) { struct ifnet * ifp ; struct llentry * ln , * ln_tmp ; struct sockaddr * dst ; ifp = ia -> ia_ifa . ifa_ifp ; if ( nd6_need_cache ( ifp ) == 0 ) return ( 0 ) ; ia -> ia_ifa . ifa_rtrequest = nd6_rtrequest ; dst = ( struct sockaddr * ) & ia -> ia_addr ; ln = lltable_alloc_entry ( LLTABLE6 ( ifp ) , LLE_IFADDR , dst ) ; if ( ln == NULL ) return ( ENOBUFS ) ; IF_AFDATA_WLOCK ( ifp ) ; LLE_WLOCK ( ln ) ; ln_tmp = lla_lookup ( LLTABLE6 ( ifp ) , LLE_EXCLUSIVE , dst ) ; if ( ln_tmp != NULL ) lltable_unlink_entry ( LLTABLE6 ( ifp ) , ln_tmp ) ; lltable_link_entry ( LLTABLE6 ( ifp ) , ln ) ; IF_AFDATA_WUNLOCK ( ifp ) ; if ( ln_tmp != NULL ) EVENTHANDLER_INVOKE ( lle_event , ln_tmp , LLENTRY_EXPIRED ) ; EVENTHANDLER_INVOKE ( lle_event , ln , LLENTRY_RESOLVED ) ; LLE_WUNLOCK ( ln ) ; if ( ln_tmp != NULL ) llentry_free ( ln_tmp ) ; return ( 0 ) ; }
Add pernament ND6 link-layer record for given
 interface address.
Add pernament ND6 link - layer record for given interface address .
/* Unlink any entry if exists */