Changeset View
Standalone View
sys/net/if_llatbl.c
Show First 20 Lines • Show All 704 Lines • ▼ Show 20 Lines | if ((lle->la_flags & LLE_IFADDR) != 0 && (flags & LLE_IFADDR) == 0) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LLE_WUNLOCK(lle); | LLE_WUNLOCK(lle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return (EPERM); | return (EPERM); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lltable_unlink_entry(llt, lle); | lltable_unlink_entry(llt, lle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IF_AFDATA_WUNLOCK(ifp); | IF_AFDATA_WUNLOCK(ifp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
llt->llt_delete_entry(llt, lle); | llt->llt_delete_entry(llt, lle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
melifaro: I'd rather simplify this check to only verify `LLE_PUB` flag set.
`LLE_STATIC` generally means… | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Done Inline Actions
I think your comment is reasonable. I'll simply the check to verify the LLE_PUB flag only and move the code to in6_llatable_delete_entry(). takahiro.kurosawa_gmail.com: > I'd rather simplify this check to only verify `LLE_PUB` flag set.
I think your comment is… | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return (0); | return (0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
void | void | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lltable_prefix_free(int af, struct sockaddr *addr, struct sockaddr *mask, | lltable_prefix_free(int af, struct sockaddr *addr, struct sockaddr *mask, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
u_int flags) | u_int flags) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
struct lltable *llt; | struct lltable *llt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
llt->llt_prefix_free(llt, addr, mask, flags); | llt->llt_prefix_free(llt, addr, mask, flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LLTABLE_LIST_RUNLOCK(); | LLTABLE_LIST_RUNLOCK(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* Free llentries that the flags bit in llentry.la_flags set. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* Call cleanup_cb unless NULL before free. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
struct flags_match_data { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
struct llentries dchain; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
u_int flags; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
static int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lltable_flags_free_cb(struct lltable *llt, struct llentry *lle, void *farg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
struct flags_match_data *fmd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fmd = (struct flags_match_data *)farg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if ((lle->la_flags & fmd->flags) == fmd->flags) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LLE_WLOCK(lle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CK_LIST_INSERT_HEAD(&fmd->dchain, lle, lle_chain); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return (0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lltable_flags_free(struct lltable *llt, u_int flags, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
void (*cleanup_cb)(struct lltable *llt, struct llentry *lle, void *arg), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
void *farg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
struct llentry *lle, *next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
struct flags_match_data fmd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bzero(&fmd, sizeof(fmd)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CK_LIST_INIT(&fmd.dchain); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fmd.flags = flags; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IF_AFDATA_WLOCK(llt->llt_ifp); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lltable_foreach_lle(llt, lltable_flags_free_cb, &fmd); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
llentries_unlink(llt, &fmd.dchain); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IF_AFDATA_WUNLOCK(llt->llt_ifp); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CK_LIST_FOREACH_SAFE(lle, &fmd.dchain, lle_chain, next) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (cleanup_cb != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cleanup_cb(llt, lle, farg); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lltable_free_entry(llt, lle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
melifaroUnsubmitted Not Done Inline Actions
Thank you for addressing the feedback! melifaro: Thank you for addressing the feedback!
Looks almost perfect, I'd just try to make it a bit more… | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
takahiro.kurosawa_gmail.comAuthorUnsubmitted Done Inline ActionsIntroduced lltable_delete_conditional() according to your advice. takahiro.kurosawa_gmail.com: Introduced lltable_delete_conditional() according to your advice.
The code has got much simpler… | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
struct lltable * | struct lltable * | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lltable_allocate_htbl(uint32_t hsize) | lltable_allocate_htbl(uint32_t hsize) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
struct lltable *llt; | struct lltable *llt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | if (lle_tmp != NULL) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LLE_WUNLOCK(lle_tmp); | LLE_WUNLOCK(lle_tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lltable_free_entry(llt, lle); | lltable_free_entry(llt, lle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return (EPERM); | return (EPERM); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/* Unlink existing entry from table */ | /* Unlink existing entry from table */ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lltable_unlink_entry(llt, lle_tmp); | lltable_unlink_entry(llt, lle_tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lltable_link_entry(llt, lle); | lltable_link_entry(llt, lle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if ((lle->la_flags & LLE_PUB) != 0 && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(llt->llt_flags & LLT_ADDEDPROXY) == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
llt->llt_flags |= LLT_ADDEDPROXY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IF_AFDATA_WUNLOCK(ifp); | IF_AFDATA_WUNLOCK(ifp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (lle_tmp != NULL) { | if (lle_tmp != NULL) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
EVENTHANDLER_INVOKE(lle_event, lle_tmp,LLENTRY_EXPIRED); | EVENTHANDLER_INVOKE(lle_event, lle_tmp,LLENTRY_EXPIRED); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lltable_free_entry(llt, lle_tmp); | lltable_free_entry(llt, lle_tmp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/* | /* | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* By invoking LLE handler here we might get | * By invoking LLE handler here we might get | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* two events on static LLE entry insertion | * two events on static LLE entry insertion | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* in routing socket. However, since we might have | * in routing socket. However, since we might have | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* other subscribers we need to generate this event. | * other subscribers we need to generate this event. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*/ | */ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
EVENTHANDLER_INVOKE(lle_event, lle, LLENTRY_RESOLVED); | EVENTHANDLER_INVOKE(lle_event, lle, LLENTRY_RESOLVED); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LLE_WUNLOCK(lle); | LLE_WUNLOCK(lle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
llt->llt_post_resolved(llt, lle); | llt->llt_post_resolved(llt, lle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
break; | break; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Not Done Inline ActionsWorth introducing llt_post_resolved() (or similar) callback so we can move IPv4/IPv6 logic outside of if_llatbl.c, melifaro: Worth introducing `llt_post_resolved()` (or similar) callback so we can move IPv4/IPv6 logic… | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Done Inline Actions
Good idea! I'll post a separate diff that introduce the callback and move the existing ifdef INET/INET6s to the protocol specific code. takahiro.kurosawa_gmail.com: > Worth introducing `llt_post_resolved()` (or similar) callback so we can move IPv4/IPv6 logic… | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
case RTM_DELETE: | case RTM_DELETE: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return (lltable_delete_addr(llt, 0, dst)); | return (lltable_delete_addr(llt, 0, dst)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
default: | default: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
error = EINVAL; | error = EINVAL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |
I'd rather simplify this check to only verify LLE_PUB flag set.
LLE_STATIC generally means that the entry is not temporary (and personally I don't think that temporary entries can't be proxy ones).
LLE_IFADDR cannot be set by the user code. If there are concerns about this case, I'd add another check in lla_rt_output() instead off doing this in the runtime.
Finally, why not move it to in6_lltable_delete_entry() callback?