Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_llatbl.h
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
struct llentry { | struct llentry { | ||||
CK_LIST_ENTRY(llentry) lle_next; | CK_LIST_ENTRY(llentry) lle_next; | ||||
union { | union { | ||||
struct in_addr addr4; | struct in_addr addr4; | ||||
struct in6_addr addr6; | struct in6_addr addr6; | ||||
} r_l3addr; | } r_l3addr; | ||||
char r_linkdata[LLE_MAX_LINKHDR]; /* L2 data */ | char r_linkdata[LLE_MAX_LINKHDR]; /* L2 data */ | ||||
uint8_t r_hdrlen; /* length for LL header */ | uint8_t r_hdrlen; /* length for LL header */ | ||||
uint8_t spare0[3]; | uint8_t r_family; /* Upper layer proto family */ | ||||
uint8_t spare0[2]; | |||||
uint16_t r_flags; /* LLE runtime flags */ | uint16_t r_flags; /* LLE runtime flags */ | ||||
uint16_t r_skip_req; /* feedback from fast path */ | uint16_t r_skip_req; /* feedback from fast path */ | ||||
struct lltable *lle_tbl; | struct lltable *lle_tbl; | ||||
struct llentries *lle_head; | struct llentries *lle_head; | ||||
void (*lle_free)(struct llentry *); | void (*lle_free)(struct llentry *); | ||||
struct mbuf *la_hold; | struct mbuf *la_hold; | ||||
int la_numheld; /* # of packets currently held */ | int la_numheld; /* # of packets currently held */ | ||||
time_t la_expire; | time_t la_expire; | ||||
uint16_t la_flags; | uint16_t la_flags; | ||||
uint16_t la_asked; | uint16_t la_asked; | ||||
uint16_t la_preempt; | uint16_t la_preempt; | ||||
int16_t ln_state; /* IPv6 has ND6_LLINFO_NOSTATE == -2 */ | int16_t ln_state; /* IPv6 has ND6_LLINFO_NOSTATE == -2 */ | ||||
uint16_t ln_router; | uint16_t ln_router; | ||||
time_t ln_ntick; | time_t ln_ntick; | ||||
time_t lle_remtime; /* Real time remaining */ | time_t lle_remtime; /* Real time remaining */ | ||||
time_t lle_hittime; /* Time when r_skip_req was unset */ | time_t lle_hittime; /* Time when r_skip_req was unset */ | ||||
int lle_refcnt; | int lle_refcnt; | ||||
char *ll_addr; /* link-layer address */ | char *ll_addr; /* link-layer address */ | ||||
CK_SLIST_HEAD(llentry_children_head,llentry) lle_children; /* child encaps */ | |||||
CK_SLIST_ENTRY(llentry) lle_child_next; /* child encaps */ | |||||
struct llentry *lle_parent; /* parent for a child */ | |||||
CK_LIST_ENTRY(llentry) lle_chain; /* chain of deleted items */ | CK_LIST_ENTRY(llentry) lle_chain; /* chain of deleted items */ | ||||
struct callout lle_timer; | struct callout lle_timer; | ||||
struct rwlock lle_lock; | struct rwlock lle_lock; | ||||
struct mtx req_mtx; | struct mtx req_mtx; | ||||
struct epoch_context lle_epoch_ctx; | struct epoch_context lle_epoch_ctx; | ||||
}; | }; | ||||
Show All 10 Lines | |||||
#define LLE_REQ_INIT(lle) mtx_init(&(lle)->req_mtx, "lle req", \ | #define LLE_REQ_INIT(lle) mtx_init(&(lle)->req_mtx, "lle req", \ | ||||
NULL, MTX_DEF) | NULL, MTX_DEF) | ||||
#define LLE_REQ_DESTROY(lle) mtx_destroy(&(lle)->req_mtx) | #define LLE_REQ_DESTROY(lle) mtx_destroy(&(lle)->req_mtx) | ||||
#define LLE_REQ_LOCK(lle) mtx_lock(&(lle)->req_mtx) | #define LLE_REQ_LOCK(lle) mtx_lock(&(lle)->req_mtx) | ||||
#define LLE_REQ_UNLOCK(lle) mtx_unlock(&(lle)->req_mtx) | #define LLE_REQ_UNLOCK(lle) mtx_unlock(&(lle)->req_mtx) | ||||
#define LLE_IS_VALID(lle) (((lle) != NULL) && ((lle) != (void *)-1)) | #define LLE_IS_VALID(lle) (((lle) != NULL) && ((lle) != (void *)-1)) | ||||
#define LLE_SF(_fl, _fam) (((_fl) & 0xFFFF) | ((_fam) << 16)) | |||||
#define LLE_ADDREF(lle) do { \ | #define LLE_ADDREF(lle) do { \ | ||||
LLE_WLOCK_ASSERT(lle); \ | LLE_WLOCK_ASSERT(lle); \ | ||||
KASSERT((lle)->lle_refcnt >= 0, \ | KASSERT((lle)->lle_refcnt >= 0, \ | ||||
("negative refcnt %d on lle %p", \ | ("negative refcnt %d on lle %p", \ | ||||
(lle)->lle_refcnt, (lle))); \ | (lle)->lle_refcnt, (lle))); \ | ||||
(lle)->lle_refcnt++; \ | (lle)->lle_refcnt++; \ | ||||
} while (0) | } while (0) | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
#define LLE_DELETED 0x0001 /* entry must be deleted */ | #define LLE_DELETED 0x0001 /* entry must be deleted */ | ||||
#define LLE_STATIC 0x0002 /* entry is static */ | #define LLE_STATIC 0x0002 /* entry is static */ | ||||
#define LLE_IFADDR 0x0004 /* entry is interface addr */ | #define LLE_IFADDR 0x0004 /* entry is interface addr */ | ||||
#define LLE_VALID 0x0008 /* ll_addr is valid */ | #define LLE_VALID 0x0008 /* ll_addr is valid */ | ||||
#define LLE_REDIRECT 0x0010 /* installed by redirect; has host rtentry */ | #define LLE_REDIRECT 0x0010 /* installed by redirect; has host rtentry */ | ||||
#define LLE_PUB 0x0020 /* publish entry ??? */ | #define LLE_PUB 0x0020 /* publish entry ??? */ | ||||
#define LLE_LINKED 0x0040 /* linked to lookup structure */ | #define LLE_LINKED 0x0040 /* linked to lookup structure */ | ||||
#define LLE_CHILD 0x0080 /* Child LLE storing different AF encap */ | |||||
/* LLE request flags */ | /* LLE request flags */ | ||||
#define LLE_EXCLUSIVE 0x2000 /* return lle xlocked */ | #define LLE_EXCLUSIVE 0x2000 /* return lle xlocked */ | ||||
#define LLE_UNLOCKED 0x4000 /* return lle unlocked */ | #define LLE_UNLOCKED 0x4000 /* return lle unlocked */ | ||||
#define LLE_ADDRONLY 0x4000 /* return lladdr instead of full header */ | #define LLE_ADDRONLY 0x4000 /* return lladdr instead of full header */ | ||||
#define LLE_CREATE 0x8000 /* hint to avoid lle lookup */ | #define LLE_CREATE 0x8000 /* hint to avoid lle lookup */ | ||||
/* LLE flags used by fastpath code */ | /* LLE flags used by fastpath code */ | ||||
#define RLLE_VALID 0x0001 /* entry is valid */ | #define RLLE_VALID 0x0001 /* entry is valid */ | ||||
Show All 23 Lines | |||||
void lltable_update_ifaddr(struct lltable *llt); | void lltable_update_ifaddr(struct lltable *llt); | ||||
struct llentry *lltable_alloc_entry(struct lltable *llt, u_int flags, | struct llentry *lltable_alloc_entry(struct lltable *llt, u_int flags, | ||||
const struct sockaddr *l4addr); | const struct sockaddr *l4addr); | ||||
void lltable_free_entry(struct lltable *llt, struct llentry *lle); | void lltable_free_entry(struct lltable *llt, struct llentry *lle); | ||||
int lltable_delete_addr(struct lltable *llt, u_int flags, | int lltable_delete_addr(struct lltable *llt, u_int flags, | ||||
const struct sockaddr *l3addr); | const struct sockaddr *l3addr); | ||||
int lltable_link_entry(struct lltable *llt, struct llentry *lle); | int lltable_link_entry(struct lltable *llt, struct llentry *lle); | ||||
int lltable_unlink_entry(struct lltable *llt, struct llentry *lle); | int lltable_unlink_entry(struct lltable *llt, struct llentry *lle); | ||||
void lltable_link_child_entry(struct llentry *parent_lle, struct llentry *child_lle); | |||||
void lltable_unlink_child_entry(struct llentry *child_lle); | |||||
void lltable_fill_sa_entry(const struct llentry *lle, struct sockaddr *sa); | void lltable_fill_sa_entry(const struct llentry *lle, struct sockaddr *sa); | ||||
struct ifnet *lltable_get_ifp(const struct lltable *llt); | struct ifnet *lltable_get_ifp(const struct lltable *llt); | ||||
int lltable_get_af(const struct lltable *llt); | int lltable_get_af(const struct lltable *llt); | ||||
bool lltable_acquire_wlock(struct ifnet *ifp, struct llentry *lle); | |||||
int lltable_foreach_lle(struct lltable *llt, llt_foreach_cb_t *f, | int lltable_foreach_lle(struct lltable *llt, llt_foreach_cb_t *f, | ||||
void *farg); | void *farg); | ||||
/* | /* | ||||
* Generic link layer address lookup function. | * Generic link layer address lookup function. | ||||
*/ | */ | ||||
static __inline struct llentry * | static __inline struct llentry * | ||||
lla_lookup(struct lltable *llt, u_int flags, const struct sockaddr *l3addr) | lla_lookup(struct lltable *llt, u_int flags, const struct sockaddr *l3addr) | ||||
{ | { | ||||
return (llt->llt_lookup(llt, flags, l3addr)); | return (llt->llt_lookup(llt, flags, l3addr)); | ||||
} | } | ||||
/* | /* | ||||
* Notify the LLE code that the entry was used by datapath. | * Notify the LLE code that the entry was used by datapath. | ||||
*/ | */ | ||||
static __inline void | static __inline void | ||||
llentry_mark_used(struct llentry *lle) | llentry_mark_used(struct llentry *lle) | ||||
{ | { | ||||
if (lle->r_skip_req == 0) | if (lle->r_skip_req == 0) | ||||
return; | return; | ||||
if ((lle->r_flags & RLLE_VALID) != 0) | if ((lle->r_flags & RLLE_VALID) != 0) | ||||
lle->lle_tbl->llt_mark_used(lle); | lle->lle_tbl->llt_mark_used(lle); | ||||
} | } | ||||
struct llentry *llentry_lookup_family(struct llentry *lle, int family); | |||||
void llentry_request_feedback(struct llentry *lle); | |||||
time_t llentry_get_hittime(struct llentry *lle); | |||||
int lla_rt_output(struct rt_msghdr *, struct rt_addrinfo *); | int lla_rt_output(struct rt_msghdr *, struct rt_addrinfo *); | ||||
enum { | enum { | ||||
LLENTRY_RESOLVED, | LLENTRY_RESOLVED, | ||||
LLENTRY_TIMEDOUT, | LLENTRY_TIMEDOUT, | ||||
LLENTRY_DELETED, | LLENTRY_DELETED, | ||||
LLENTRY_EXPIRED, | LLENTRY_EXPIRED, | ||||
}; | }; | ||||
typedef void (*lle_event_fn)(void *, struct llentry *, int); | typedef void (*lle_event_fn)(void *, struct llentry *, int); | ||||
EVENTHANDLER_DECLARE(lle_event, lle_event_fn); | EVENTHANDLER_DECLARE(lle_event, lle_event_fn); | ||||
#endif /* _NET_IF_LLATBL_H_ */ | #endif /* _NET_IF_LLATBL_H_ */ |