Unify setting lladdr for AF_INET[6].
This commit is contained in:
parent
fa32340b9f
commit
ddd208f7ad
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=290486
@ -277,6 +277,15 @@ lltable_drop_entry_queue(struct llentry *lle)
|
||||
return (pkts_dropped);
|
||||
}
|
||||
|
||||
void
|
||||
lltable_set_entry_addr(struct ifnet *ifp, struct llentry *lle,
|
||||
const char *lladdr)
|
||||
{
|
||||
|
||||
bcopy(lladdr, &lle->ll_addr, ifp->if_addrlen);
|
||||
lle->la_flags |= LLE_VALID;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Performes generic cleanup routines and frees lle.
|
||||
|
@ -207,6 +207,8 @@ struct llentry *llentry_alloc(struct ifnet *, struct lltable *,
|
||||
|
||||
/* helper functions */
|
||||
size_t lltable_drop_entry_queue(struct llentry *);
|
||||
void lltable_set_entry_addr(struct ifnet *ifp, struct llentry *lle,
|
||||
const char *lladdr);
|
||||
|
||||
struct llentry *lltable_alloc_entry(struct lltable *llt, u_int flags,
|
||||
const struct sockaddr *l4addr);
|
||||
|
@ -141,8 +141,6 @@ static void in_arpinput(struct mbuf *);
|
||||
|
||||
static void arp_check_update_lle(struct arphdr *ah, struct in_addr isaddr,
|
||||
struct ifnet *ifp, int bridged, struct llentry *la);
|
||||
static void arp_update_lle(struct arphdr *ah, struct ifnet *ifp,
|
||||
struct llentry *la);
|
||||
static void arp_mark_lle_reachable(struct llentry *la);
|
||||
|
||||
|
||||
@ -820,7 +818,7 @@ in_arpinput(struct mbuf *m)
|
||||
la = lltable_alloc_entry(LLTABLE(ifp), 0, dst);
|
||||
if (la == NULL)
|
||||
goto drop;
|
||||
arp_update_lle(ah, ifp, la);
|
||||
lltable_set_entry_addr(ifp, la, ar_sha(ah));
|
||||
|
||||
IF_AFDATA_WLOCK(ifp);
|
||||
LLE_WLOCK(la);
|
||||
@ -1038,7 +1036,7 @@ arp_check_update_lle(struct arphdr *ah, struct in_addr isaddr, struct ifnet *ifp
|
||||
}
|
||||
|
||||
/* Update data */
|
||||
arp_update_lle(ah, ifp, la);
|
||||
lltable_set_entry_addr(ifp, la, ar_sha(ah));
|
||||
|
||||
IF_AFDATA_WUNLOCK(ifp);
|
||||
LLE_REMREF(la);
|
||||
@ -1070,17 +1068,6 @@ arp_check_update_lle(struct arphdr *ah, struct in_addr isaddr, struct ifnet *ifp
|
||||
LLE_WUNLOCK(la);
|
||||
}
|
||||
|
||||
/*
|
||||
* Updates @la fields used by fast path code.
|
||||
*/
|
||||
static void
|
||||
arp_update_lle(struct arphdr *ah, struct ifnet *ifp, struct llentry *la)
|
||||
{
|
||||
|
||||
memcpy(&la->ll_addr, ar_sha(ah), ifp->if_addrlen);
|
||||
la->la_flags |= LLE_VALID;
|
||||
}
|
||||
|
||||
static void
|
||||
arp_mark_lle_reachable(struct llentry *la)
|
||||
{
|
||||
|
@ -1258,8 +1258,8 @@ in_lltable_alloc(struct lltable *llt, u_int flags, const struct sockaddr *l3addr
|
||||
}
|
||||
lle->la_flags = flags;
|
||||
if ((flags & LLE_IFADDR) == LLE_IFADDR) {
|
||||
bcopy(IF_LLADDR(ifp), &lle->ll_addr, ifp->if_addrlen);
|
||||
lle->la_flags |= (LLE_VALID | LLE_STATIC);
|
||||
lltable_set_entry_addr(ifp, lle, IF_LLADDR(ifp));
|
||||
lle->la_flags |= LLE_STATIC;
|
||||
}
|
||||
|
||||
return (lle);
|
||||
|
@ -2261,8 +2261,8 @@ in6_lltable_alloc(struct lltable *llt, u_int flags,
|
||||
}
|
||||
lle->la_flags = flags;
|
||||
if ((flags & LLE_IFADDR) == LLE_IFADDR) {
|
||||
bcopy(IF_LLADDR(ifp), &lle->ll_addr, ifp->if_addrlen);
|
||||
lle->la_flags |= (LLE_VALID | LLE_STATIC);
|
||||
lltable_set_entry_addr(ifp, lle, IF_LLADDR(ifp));
|
||||
lle->la_flags |= LLE_STATIC;
|
||||
}
|
||||
|
||||
if ((lle->la_flags & LLE_STATIC) != 0)
|
||||
|
@ -1738,10 +1738,8 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr,
|
||||
* Since we already know all the data for the new entry,
|
||||
* fill it before insertion.
|
||||
*/
|
||||
if (lladdr != NULL) {
|
||||
bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
|
||||
ln->la_flags |= LLE_VALID;
|
||||
}
|
||||
if (lladdr != NULL)
|
||||
lltable_set_entry_addr(ifp, ln, lladdr);
|
||||
IF_AFDATA_WLOCK(ifp);
|
||||
LLE_WLOCK(ln);
|
||||
/* Prefer any existing lle over newly-created one */
|
||||
@ -1799,8 +1797,7 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr,
|
||||
* Record source link-layer address
|
||||
* XXX is it dependent to ifp->if_type?
|
||||
*/
|
||||
bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
|
||||
ln->la_flags |= LLE_VALID;
|
||||
lltable_set_entry_addr(ifp, ln, lladdr);
|
||||
nd6_llinfo_setstate(ln, ND6_LLINFO_STALE);
|
||||
|
||||
EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
|
||||
|
@ -765,8 +765,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
|
||||
/*
|
||||
* Record link-layer address, and update the state.
|
||||
*/
|
||||
bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
|
||||
ln->la_flags |= LLE_VALID;
|
||||
lltable_set_entry_addr(ifp, ln, lladdr);
|
||||
EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
|
||||
if (is_solicited)
|
||||
nd6_llinfo_setstate(ln, ND6_LLINFO_REACHABLE);
|
||||
@ -832,8 +831,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
|
||||
* Update link-local address, if any.
|
||||
*/
|
||||
if (lladdr != NULL) {
|
||||
bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen);
|
||||
ln->la_flags |= LLE_VALID;
|
||||
lltable_set_entry_addr(ifp, ln, lladdr);
|
||||
EVENTHANDLER_INVOKE(lle_event, ln,
|
||||
LLENTRY_RESOLVED);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user