Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_llatbl.c
Show First 20 Lines • Show All 409 Lines • ▼ Show 20 Lines | lltable_free_cb(struct lltable *llt, struct llentry *lle, void *farg) | ||||
dchain = (struct llentries *)farg; | dchain = (struct llentries *)farg; | ||||
LLE_WLOCK(lle); | LLE_WLOCK(lle); | ||||
LIST_INSERT_HEAD(dchain, lle, lle_chain); | LIST_INSERT_HEAD(dchain, lle, lle_chain); | ||||
return (0); | return (0); | ||||
} | } | ||||
void | |||||
llentry_timer_start(struct llentry *lle, int timeout, void (*func)(void *)) | |||||
{ | |||||
if (callout_reset(&lle->lle_timer, timeout, func, lle) <= 0) | |||||
LLE_ADDREF(lle); | |||||
} | |||||
void | |||||
llentry_timer_stop(struct llentry *lle) | |||||
{ | |||||
if (callout_stop(&lle->lle_timer) > 0) | |||||
LLE_REMREF(lle); | |||||
} | |||||
static void | |||||
llentry_timer_drain_callback(void *arg) | |||||
{ | |||||
struct llentry *lle = arg; | |||||
LLE_FREE(lle); | |||||
} | |||||
void | |||||
llentry_timer_uninit(struct llentry *lle) | |||||
{ | |||||
int cancelled; | |||||
cancelled = callout_async_drain(&lle->lle_timer, | |||||
&llentry_timer_drain_callback); | |||||
if (cancelled > 0) | |||||
LLE_REMREF(lle); /* was stopped */ | |||||
else if (cancelled == 0) | |||||
LLE_ADDREF(lle); /* needs drain */ | |||||
} | |||||
/* | /* | ||||
* Free all entries from given table and free itself. | * Free all entries from given table and free itself. | ||||
*/ | */ | ||||
void | void | ||||
lltable_free(struct lltable *llt) | lltable_free(struct lltable *llt) | ||||
{ | { | ||||
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); | 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) | llentry_timer_uninit(lle); | ||||
LLE_REMREF(lle); | |||||
llentry_free(lle); | llentry_free(lle); | ||||
} | } | ||||
llt->llt_free_tbl(llt); | llt->llt_free_tbl(llt); | ||||
} | } | ||||
#if 0 | #if 0 | ||||
void | void | ||||
▲ Show 20 Lines • Show All 434 Lines • Show Last 20 Lines |