lltable: introduce the llt_post_resolved callback

In order to decrease ifdef INET/INET6s in the lltable implementation,
introduce the llt_post_resolved callback and implement protocol-dependent
code in the protocol-dependent part.

Reviewed By: melifaro
Differential Revision: https://reviews.freebsd.org/D35322
MFC after:	2 weeks
This commit is contained in:
KUROSAWA Takahiro 2022-05-30 07:38:54 +00:00 committed by Alexander V. Chernikov
parent 3719dedb91
commit 77001f9b6d
4 changed files with 22 additions and 9 deletions

View File

@ -970,15 +970,7 @@ lla_rt_output(struct rt_msghdr *rtm, struct rt_addrinfo *info)
*/
EVENTHANDLER_INVOKE(lle_event, lle, LLENTRY_RESOLVED);
LLE_WUNLOCK(lle);
#ifdef INET
/* gratuitous ARP */
if ((laflags & LLE_PUB) && dst->sa_family == AF_INET)
arprequest(ifp,
&((struct sockaddr_in *)dst)->sin_addr,
&((struct sockaddr_in *)dst)->sin_addr,
(u_char *)LLADDR(dl));
#endif
llt->llt_post_resolved(llt, lle);
break;
case RTM_DELETE:

View File

@ -160,6 +160,7 @@ typedef void (llt_free_tbl_t)(struct lltable *);
typedef int (llt_link_entry_t)(struct lltable *, struct llentry *);
typedef int (llt_unlink_entry_t)(struct llentry *);
typedef void (llt_mark_used_t)(struct llentry *);
typedef void (llt_post_resolved_t)(struct lltable *, struct llentry *);
typedef int (llt_foreach_cb_t)(struct lltable *, struct llentry *, void *);
typedef int (llt_foreach_entry_t)(struct lltable *, llt_foreach_cb_t *, void *);
@ -188,6 +189,7 @@ struct lltable {
llt_fill_sa_entry_t *llt_fill_sa_entry;
llt_free_tbl_t *llt_free_tbl;
llt_mark_used_t *llt_mark_used;
llt_post_resolved_t *llt_post_resolved;
};
MALLOC_DECLARE(M_LLTABLE);

View File

@ -1681,6 +1681,17 @@ in_lltable_dump_entry(struct lltable *llt, struct llentry *lle,
return (error);
}
static void
in_lltable_post_resolved(struct lltable *llt, struct llentry *lle)
{
struct ifnet *ifp = llt->llt_ifp;
/* gratuitous ARP */
if ((lle->la_flags & LLE_PUB) != 0)
arprequest(ifp, &lle->r_l3addr.addr4, &lle->r_l3addr.addr4,
lle->ll_addr);
}
static struct lltable *
in_lltattach(struct ifnet *ifp)
{
@ -1699,6 +1710,7 @@ in_lltattach(struct ifnet *ifp)
llt->llt_free_entry = in_lltable_free_entry;
llt->llt_match_prefix = in_lltable_match_prefix;
llt->llt_mark_used = llentry_mark_used;
llt->llt_post_resolved = in_lltable_post_resolved;
lltable_link(llt);
return (llt);

View File

@ -2460,6 +2460,12 @@ in6_lltable_dump_entry(struct lltable *llt, struct llentry *lle,
return (error);
}
static void
in6_lltable_post_resolved(struct lltable *llt, struct llentry *lle)
{
/* Handle proxy NDP entries (not yet). */
}
static struct lltable *
in6_lltattach(struct ifnet *ifp)
{
@ -2478,6 +2484,7 @@ in6_lltattach(struct ifnet *ifp)
llt->llt_free_entry = in6_lltable_free_entry;
llt->llt_match_prefix = in6_lltable_match_prefix;
llt->llt_mark_used = llentry_mark_used;
llt->llt_post_resolved = in6_lltable_post_resolved;
lltable_link(llt);
return (llt);