Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_llatbl.c
Show First 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | |||||
htable_foreach_lle(struct lltable *llt, llt_foreach_cb_t *f, void *farg) | htable_foreach_lle(struct lltable *llt, llt_foreach_cb_t *f, void *farg) | ||||
{ | { | ||||
struct llentry *lle, *next; | struct llentry *lle, *next; | ||||
int i, error; | int i, error; | ||||
error = 0; | error = 0; | ||||
for (i = 0; i < llt->llt_hsize; i++) { | for (i = 0; i < llt->llt_hsize; i++) { | ||||
LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) { | CK_LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) { | ||||
error = f(llt, lle, farg); | error = f(llt, lle, farg); | ||||
if (error != 0) | if (error != 0) | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
Show All 10 Lines | htable_link_entry(struct lltable *llt, struct llentry *lle) | ||||
IF_AFDATA_WLOCK_ASSERT(llt->llt_ifp); | IF_AFDATA_WLOCK_ASSERT(llt->llt_ifp); | ||||
hashidx = llt->llt_hash(lle, llt->llt_hsize); | hashidx = llt->llt_hash(lle, llt->llt_hsize); | ||||
lleh = &llt->lle_head[hashidx]; | lleh = &llt->lle_head[hashidx]; | ||||
lle->lle_tbl = llt; | lle->lle_tbl = llt; | ||||
lle->lle_head = lleh; | lle->lle_head = lleh; | ||||
lle->la_flags |= LLE_LINKED; | lle->la_flags |= LLE_LINKED; | ||||
LIST_INSERT_HEAD(lleh, lle, lle_next); | CK_LIST_INSERT_HEAD(lleh, lle, lle_next); | ||||
} | } | ||||
static void | static void | ||||
htable_unlink_entry(struct llentry *lle) | htable_unlink_entry(struct llentry *lle) | ||||
{ | { | ||||
if ((lle->la_flags & LLE_LINKED) != 0) { | if ((lle->la_flags & LLE_LINKED) != 0) { | ||||
IF_AFDATA_WLOCK_ASSERT(lle->lle_tbl->llt_ifp); | IF_AFDATA_WLOCK_ASSERT(lle->lle_tbl->llt_ifp); | ||||
LIST_REMOVE(lle, lle_next); | CK_LIST_REMOVE(lle, lle_next); | ||||
lle->la_flags &= ~(LLE_VALID | LLE_LINKED); | lle->la_flags &= ~(LLE_VALID | LLE_LINKED); | ||||
#if 0 | #if 0 | ||||
lle->lle_tbl = NULL; | lle->lle_tbl = NULL; | ||||
lle->lle_head = NULL; | lle->lle_head = NULL; | ||||
#endif | #endif | ||||
} | } | ||||
} | } | ||||
Show All 25 Lines | |||||
{ | { | ||||
struct llentry *lle, *next; | struct llentry *lle, *next; | ||||
struct prefix_match_data pmd; | struct prefix_match_data pmd; | ||||
bzero(&pmd, sizeof(pmd)); | bzero(&pmd, sizeof(pmd)); | ||||
pmd.addr = addr; | pmd.addr = addr; | ||||
pmd.mask = mask; | pmd.mask = mask; | ||||
pmd.flags = flags; | pmd.flags = flags; | ||||
LIST_INIT(&pmd.dchain); | CK_LIST_INIT(&pmd.dchain); | ||||
IF_AFDATA_WLOCK(llt->llt_ifp); | IF_AFDATA_WLOCK(llt->llt_ifp); | ||||
/* Push matching lles to chain */ | /* Push matching lles to chain */ | ||||
lltable_foreach_lle(llt, htable_prefix_free_cb, &pmd); | lltable_foreach_lle(llt, htable_prefix_free_cb, &pmd); | ||||
llentries_unlink(llt, &pmd.dchain); | llentries_unlink(llt, &pmd.dchain); | ||||
IF_AFDATA_WUNLOCK(llt->llt_ifp); | IF_AFDATA_WUNLOCK(llt->llt_ifp); | ||||
▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct llentry *lle, *next; | struct llentry *lle, *next; | ||||
struct llentries dchain; | struct llentries dchain; | ||||
KASSERT(llt != NULL, ("%s: llt is NULL", __func__)); | KASSERT(llt != NULL, ("%s: llt is NULL", __func__)); | ||||
lltable_unlink(llt); | lltable_unlink(llt); | ||||
LIST_INIT(&dchain); | CK_LIST_INIT(&dchain); | ||||
IF_AFDATA_WLOCK(llt->llt_ifp); | IF_AFDATA_WLOCK(llt->llt_ifp); | ||||
/* Push all lles to @dchain */ | /* Push all lles to @dchain */ | ||||
lltable_foreach_lle(llt, lltable_free_cb, &dchain); | lltable_foreach_lle(llt, lltable_free_cb, &dchain); | ||||
llentries_unlink(llt, &dchain); | llentries_unlink(llt, &dchain); | ||||
IF_AFDATA_WUNLOCK(llt->llt_ifp); | IF_AFDATA_WUNLOCK(llt->llt_ifp); | ||||
LIST_FOREACH_SAFE(lle, &dchain, lle_chain, next) { | LIST_FOREACH_SAFE(lle, &dchain, lle_chain, next) { | ||||
if (callout_stop(&lle->lle_timer) > 0) | if (callout_stop(&lle->lle_timer) > 0) | ||||
Show All 13 Lines | lltable_drain(int af) | ||||
int i; | int i; | ||||
LLTABLE_LIST_RLOCK(); | LLTABLE_LIST_RLOCK(); | ||||
SLIST_FOREACH(llt, &V_lltables, llt_link) { | SLIST_FOREACH(llt, &V_lltables, llt_link) { | ||||
if (llt->llt_af != af) | if (llt->llt_af != af) | ||||
continue; | continue; | ||||
for (i=0; i < llt->llt_hsize; i++) { | for (i=0; i < llt->llt_hsize; i++) { | ||||
LIST_FOREACH(lle, &llt->lle_head[i], lle_next) { | CK_LIST_FOREACH(lle, &llt->lle_head[i], lle_next) { | ||||
LLE_WLOCK(lle); | LLE_WLOCK(lle); | ||||
if (lle->la_hold) { | if (lle->la_hold) { | ||||
m_freem(lle->la_hold); | m_freem(lle->la_hold); | ||||
lle->la_hold = NULL; | lle->la_hold = NULL; | ||||
} | } | ||||
LLE_WUNLOCK(lle); | LLE_WUNLOCK(lle); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | lltable_allocate_htbl(uint32_t hsize) | ||||
int i; | int i; | ||||
llt = malloc(sizeof(struct lltable), M_LLTABLE, M_WAITOK | M_ZERO); | llt = malloc(sizeof(struct lltable), M_LLTABLE, M_WAITOK | M_ZERO); | ||||
llt->llt_hsize = hsize; | llt->llt_hsize = hsize; | ||||
llt->lle_head = malloc(sizeof(struct llentries) * hsize, | llt->lle_head = malloc(sizeof(struct llentries) * hsize, | ||||
M_LLTABLE, M_WAITOK | M_ZERO); | M_LLTABLE, M_WAITOK | M_ZERO); | ||||
for (i = 0; i < llt->llt_hsize; i++) | for (i = 0; i < llt->llt_hsize; i++) | ||||
LIST_INIT(&llt->lle_head[i]); | CK_LIST_INIT(&llt->lle_head[i]); | ||||
/* Set some default callbacks */ | /* Set some default callbacks */ | ||||
llt->llt_link_entry = htable_link_entry; | llt->llt_link_entry = htable_link_entry; | ||||
llt->llt_unlink_entry = htable_unlink_entry; | llt->llt_unlink_entry = htable_unlink_entry; | ||||
llt->llt_prefix_free = htable_prefix_free; | llt->llt_prefix_free = htable_prefix_free; | ||||
llt->llt_foreach_entry = htable_foreach_lle; | llt->llt_foreach_entry = htable_foreach_lle; | ||||
llt->llt_free_tbl = htable_free_tbl; | llt->llt_free_tbl = htable_free_tbl; | ||||
▲ Show 20 Lines • Show All 280 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
int i; | int i; | ||||
struct llentry *lle; | struct llentry *lle; | ||||
db_printf("llt=%p llt_af=%d llt_ifp=%p\n", | db_printf("llt=%p llt_af=%d llt_ifp=%p\n", | ||||
llt, llt->llt_af, llt->llt_ifp); | llt, llt->llt_af, llt->llt_ifp); | ||||
for (i = 0; i < llt->llt_hsize; i++) { | for (i = 0; i < llt->llt_hsize; i++) { | ||||
LIST_FOREACH(lle, &llt->lle_head[i], lle_next) { | CK_LIST_FOREACH(lle, &llt->lle_head[i], lle_next) { | ||||
llatbl_lle_show((struct llentry_sa *)lle); | llatbl_lle_show((struct llentry_sa *)lle); | ||||
if (db_pager_quit) | if (db_pager_quit) | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Show All 37 Lines |