* Use unified code for deleting entry by sockaddr instead of per-af one.
* Remove now unused llt_delete_addr callback.
This commit is contained in:
parent
20dd899505
commit
b44a7d5d87
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/routing/; revision=276631
@ -445,14 +445,6 @@ lltable_create_lle(struct lltable *llt, u_int flags,
|
||||
return (llt->llt_create(llt, flags, paddr));
|
||||
}
|
||||
|
||||
int
|
||||
lltable_delete_addr(struct lltable *llt, u_int flags,
|
||||
const struct sockaddr *l3addr)
|
||||
{
|
||||
|
||||
return llt->llt_delete_addr(llt, flags, l3addr);
|
||||
}
|
||||
|
||||
void
|
||||
lltable_link_entry(struct lltable *llt, struct llentry *lle)
|
||||
{
|
||||
@ -581,8 +573,34 @@ lla_rt_output(struct rt_msghdr *rtm, struct rt_addrinfo *info)
|
||||
break;
|
||||
|
||||
case RTM_DELETE:
|
||||
error = lltable_delete_addr(llt, 0, dst);
|
||||
return (error == 0 ? 0 : ENOENT);
|
||||
l3addr = llt->llt_get_sa_addr(dst);
|
||||
|
||||
IF_AFDATA_CFG_WLOCK(ifp);
|
||||
lle = lltable_lookup_lle(llt, LLE_UNLOCKED, l3addr);
|
||||
|
||||
if (lle == NULL) {
|
||||
IF_AFDATA_CFG_WUNLOCK(ifp);
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
/* Skipping LLE_IFADDR record */
|
||||
if ((lle->la_flags & LLE_IFADDR) != 0) {
|
||||
IF_AFDATA_CFG_WUNLOCK(ifp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
LLE_WLOCK(lle);
|
||||
IF_AFDATA_RUN_WLOCK(ifp);
|
||||
lltable_unlink_entry(llt, lle);
|
||||
IF_AFDATA_RUN_WUNLOCK(ifp);
|
||||
IF_AFDATA_CFG_WUNLOCK(ifp);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
log(LOG_INFO, "ifaddr cache = %p is deleted\n", lle);
|
||||
#endif
|
||||
EVENTHANDLER_INVOKE(lle_event, lle, LLENTRY_DELETED);
|
||||
llt->llt_clear_entry(llt, lle);
|
||||
break;
|
||||
|
||||
default:
|
||||
error = EINVAL;
|
||||
|
@ -50,8 +50,6 @@ typedef struct llentry *(llt_lookup_t)(struct lltable *, u_int flags,
|
||||
const void *paddr);
|
||||
typedef struct llentry *(llt_create_t)(struct lltable *, u_int flags,
|
||||
const void *paddr);
|
||||
typedef int (llt_delete_addr_t)(struct lltable *, u_int flags,
|
||||
const struct sockaddr *l3addr);
|
||||
typedef int (llt_dump_entry_t)(struct lltable *, struct llentry *,
|
||||
struct sysctl_req *);
|
||||
typedef uint32_t (llt_hash_t)(const struct llentry *);
|
||||
@ -78,7 +76,6 @@ struct lltable {
|
||||
|
||||
llt_lookup_t *llt_lookup;
|
||||
llt_create_t *llt_create;
|
||||
llt_delete_addr_t *llt_delete_addr;
|
||||
llt_dump_entry_t *llt_dump_entry;
|
||||
llt_hash_t *llt_hash;
|
||||
llt_match_prefix_t *llt_match_prefix;
|
||||
@ -114,8 +111,6 @@ lltable_lookup_lle(struct lltable *llt, u_int flags,
|
||||
|
||||
struct llentry *lltable_create_lle(struct lltable *llt, u_int flags,
|
||||
const void *paddr);
|
||||
int lltable_delete_addr(struct lltable *llt, u_int flags,
|
||||
const struct sockaddr *l3addr);
|
||||
void lltable_link_entry(struct lltable *llt, struct llentry *lle);
|
||||
void lltable_unlink_entry(struct lltable *llt, struct llentry *lle);
|
||||
|
||||
|
@ -1138,50 +1138,6 @@ in_lltable_find_dst(struct lltable *llt, struct in_addr dst)
|
||||
return (lle);
|
||||
}
|
||||
|
||||
static int
|
||||
in_lltable_delete(struct lltable *llt, u_int flags,
|
||||
const struct sockaddr *l3addr)
|
||||
{
|
||||
const struct sockaddr_in *sin = (const struct sockaddr_in *)l3addr;
|
||||
struct ifnet *ifp = llt->llt_ifp;
|
||||
struct llentry *lle;
|
||||
|
||||
IF_AFDATA_CFG_UNLOCK_ASSERT(ifp);
|
||||
KASSERT(l3addr->sa_family == AF_INET,
|
||||
("sin_family %d", l3addr->sa_family));
|
||||
|
||||
IF_AFDATA_CFG_WLOCK(ifp);
|
||||
lle = in_lltable_find_dst(llt, sin->sin_addr);
|
||||
if (lle == NULL) {
|
||||
IF_AFDATA_CFG_WUNLOCK(ifp);
|
||||
#ifdef DIAGNOSTIC
|
||||
log(LOG_INFO, "interface address is missing from cache = %p\n",
|
||||
lle);
|
||||
#endif
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
/* Skipping LLE_IFADDR record */
|
||||
if ((lle->la_flags & LLE_IFADDR) != 0 && (flags & LLE_IFADDR) == 0) {
|
||||
IF_AFDATA_CFG_WUNLOCK(ifp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
LLE_WLOCK(lle);
|
||||
IF_AFDATA_RUN_WLOCK(ifp);
|
||||
lltable_unlink_entry(llt, lle);
|
||||
IF_AFDATA_RUN_WUNLOCK(ifp);
|
||||
IF_AFDATA_CFG_WUNLOCK(ifp);
|
||||
|
||||
EVENTHANDLER_INVOKE(lle_event, lle, LLENTRY_DELETED);
|
||||
#ifdef DIAGNOSTIC
|
||||
log(LOG_INFO, "ifaddr cache = %p is deleted\n", lle);
|
||||
#endif
|
||||
llt->llt_clear_entry(llt, lle);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static struct llentry *
|
||||
in_lltable_create(struct lltable *llt, u_int flags, const void *paddr)
|
||||
{
|
||||
@ -1315,7 +1271,6 @@ in_domifattach(struct ifnet *ifp)
|
||||
|
||||
llt->llt_lookup = in_lltable_lookup;
|
||||
llt->llt_create = in_lltable_create;
|
||||
llt->llt_delete_addr = in_lltable_delete;
|
||||
llt->llt_dump_entry = in_lltable_dump_entry;
|
||||
llt->llt_hash = in_lltable_hash;
|
||||
llt->llt_get_sa_addr = in_lltable_get_sa_addr;
|
||||
|
@ -2185,49 +2185,6 @@ in6_lltable_find_dst(struct lltable *llt, const struct in6_addr *dst)
|
||||
return (lle);
|
||||
}
|
||||
|
||||
static int
|
||||
in6_lltable_delete(struct lltable *llt, u_int flags,
|
||||
const struct sockaddr *l3addr)
|
||||
{
|
||||
const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)l3addr;
|
||||
struct ifnet *ifp;
|
||||
struct llentry *lle;
|
||||
|
||||
ifp = llt->llt_ifp;
|
||||
|
||||
IF_AFDATA_CFG_UNLOCK_ASSERT(ifp);
|
||||
KASSERT(l3addr->sa_family == AF_INET6,
|
||||
("sin_family %d", l3addr->sa_family));
|
||||
|
||||
IF_AFDATA_CFG_WLOCK(ifp);
|
||||
lle = in6_lltable_find_dst(llt, &sin6->sin6_addr);
|
||||
|
||||
if (lle == NULL) {
|
||||
IF_AFDATA_CFG_WUNLOCK(ifp);
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
/* Skipping LLE_IFADDR record */
|
||||
if ((lle->la_flags & LLE_IFADDR) != 0 && (flags & LLE_IFADDR) == 0) {
|
||||
IF_AFDATA_CFG_WUNLOCK(ifp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
LLE_WLOCK(lle);
|
||||
IF_AFDATA_RUN_WLOCK(ifp);
|
||||
lltable_unlink_entry(llt, lle);
|
||||
IF_AFDATA_RUN_WUNLOCK(ifp);
|
||||
IF_AFDATA_CFG_WUNLOCK(ifp);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
log(LOG_INFO, "ifaddr cache = %p is deleted\n", lle);
|
||||
#endif
|
||||
EVENTHANDLER_INVOKE(lle_event, lle, LLENTRY_DELETED);
|
||||
llt->llt_clear_entry(llt, lle);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static struct llentry *
|
||||
in6_lltable_create(struct lltable *llt, u_int flags,
|
||||
const void *paddr)
|
||||
@ -2389,7 +2346,6 @@ in6_domifattach(struct ifnet *ifp)
|
||||
|
||||
llt->llt_lookup = in6_lltable_lookup;
|
||||
llt->llt_create = in6_lltable_create;
|
||||
llt->llt_delete_addr = in6_lltable_delete;
|
||||
llt->llt_dump_entry = in6_lltable_dump_entry;
|
||||
llt->llt_hash = in6_lltable_hash;
|
||||
llt->llt_get_sa_addr = in6_lltable_get_sa_addr;
|
||||
|
Loading…
Reference in New Issue
Block a user