summaryrefslogtreecommitdiffstats
path: root/sys/net/if_llatbl.h
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2015-08-10 12:03:59 +0000
committermelifaro <melifaro@FreeBSD.org>2015-08-10 12:03:59 +0000
commit4f240a9c31022feb60343e2e1108338b44edb083 (patch)
tree112dd76676cd486bd689769878bb091803964520 /sys/net/if_llatbl.h
parentfa26a290636c09c75688724a15b3624e6c44c8e4 (diff)
downloadFreeBSD-src-4f240a9c31022feb60343e2e1108338b44edb083.zip
FreeBSD-src-4f240a9c31022feb60343e2e1108338b44edb083.tar.gz
Partially merge r274887,r275334,r275577,r275578,r275586 to minimize
differences between projects/routing and HEAD. This commit tries to keep code logic the same while changing underlying code to use unified callbacks. * Add llt_foreach_entry method to traverse all entries in given llt * Add llt_dump_entry method to export particular lle entry in sysctl/rtsock format (code is not indented properly to minimize diff). Will be fixed in the next commits. * Add llt_link_entry/llt_unlink_entry methods to link/unlink particular lle. * Add llt_fill_sa_entry method to export address in the lle to sockaddr format. * Add llt_hash method to use in generic hash table support code. * Add llt_free_entry method which is used in llt_prefix_free code. * Prepare for fine-grained locking by separating lle unlink and deletion in lltable_free() and lltable_prefix_free(). * Provide lltable_get<ifp|af>() functions to reduce direct 'struct lltable' access by external callers. * Remove @llt agrument from lle_free() lle callback since it was unused. * Temporarily add L3_CADDR() macro for 'const' sockaddr typecasting. * Switch to per-af hashing code. * Rename LLE_FREE_LOCKED() callback from in[6]_lltable_free() to in_[6]lltable_destroy() to avoid clashing with llt_free_entry() method. Update description from these functions. * Use unified lltable_free_entry() function instead of per-af one. Reviewed by: ae
Diffstat (limited to 'sys/net/if_llatbl.h')
-rw-r--r--sys/net/if_llatbl.h41
1 files changed, 37 insertions, 4 deletions
diff --git a/sys/net/if_llatbl.h b/sys/net/if_llatbl.h
index 69c340c..8ea711c 100644
--- a/sys/net/if_llatbl.h
+++ b/sys/net/if_llatbl.h
@@ -57,7 +57,7 @@ struct llentry {
struct rwlock lle_lock;
struct lltable *lle_tbl;
struct llentries *lle_head;
- void (*lle_free)(struct lltable *, struct llentry *);
+ void (*lle_free)(struct llentry *);
struct mbuf *la_hold;
int la_numheld; /* # of packets currently held */
time_t la_expire;
@@ -76,6 +76,7 @@ struct llentry {
uint8_t mac8[20]; /* IB needs 20 bytes. */
} ll_addr;
+ LIST_ENTRY(llentry) lle_chain; /* chain of deleted items */
/* XXX af-private? */
union {
struct callout ln_timer_ch;
@@ -114,7 +115,7 @@ struct llentry {
#define LLE_FREE_LOCKED(lle) do { \
if ((lle)->lle_refcnt == 1) \
- (lle)->lle_free((lle)->lle_tbl, (lle)); \
+ (lle)->lle_free(lle); \
else { \
LLE_REMREF(lle); \
LLE_WUNLOCK(lle); \
@@ -133,6 +134,7 @@ struct llentry {
#define la_timer lle_timer.la_timer
/* XXX bad name */
+#define L3_CADDR(lle) ((const struct sockaddr *)(&lle[1]))
#define L3_ADDR(lle) ((struct sockaddr *)(&lle[1]))
#define L3_ADDR_LEN(lle) (((struct sockaddr *)(&lle[1]))->sa_len)
@@ -152,7 +154,18 @@ typedef int (llt_delete_t)(struct lltable *, u_int flags,
const struct sockaddr *l3addr);
typedef void (llt_prefix_free_t)(struct lltable *,
const struct sockaddr *prefix, const struct sockaddr *mask, u_int flags);
-typedef int (llt_dump_t)(struct lltable *, struct sysctl_req *);
+typedef int (llt_dump_entry_t)(struct lltable *, struct llentry *,
+ struct sysctl_req *);
+typedef uint32_t (llt_hash_t)(const struct llentry *, uint32_t);
+typedef int (llt_match_prefix_t)(const struct sockaddr *,
+ const struct sockaddr *, u_int, struct llentry *);
+typedef void (llt_free_entry_t)(struct lltable *, struct llentry *);
+typedef void (llt_fill_sa_entry_t)(const struct llentry *, struct sockaddr *);
+typedef void (llt_link_entry_t)(struct lltable *, struct llentry *);
+typedef void (llt_unlink_entry_t)(struct llentry *);
+
+typedef int (llt_foreach_cb_t)(struct lltable *, struct llentry *, void *);
+typedef int (llt_foreach_entry_t)(struct lltable *, llt_foreach_cb_t *, void *);
struct lltable {
SLIST_ENTRY(lltable) llt_link;
@@ -164,7 +177,14 @@ struct lltable {
llt_create_t *llt_create;
llt_delete_t *llt_delete;
llt_prefix_free_t *llt_prefix_free;
- llt_dump_t *llt_dump;
+ llt_dump_entry_t *llt_dump_entry;
+ llt_hash_t *llt_hash;
+ llt_match_prefix_t *llt_match_prefix;
+ llt_free_entry_t *llt_free_entry;
+ llt_foreach_entry_t *llt_foreach_entry;
+ llt_link_entry_t *llt_link_entry;
+ llt_unlink_entry_t *llt_unlink_entry;
+ llt_fill_sa_entry_t *llt_fill_sa_entry;
};
MALLOC_DECLARE(M_LLTABLE);
@@ -197,6 +217,19 @@ size_t llentry_free(struct llentry *);
struct llentry *llentry_alloc(struct ifnet *, struct lltable *,
struct sockaddr_storage *);
+/* helper functions */
+size_t lltable_drop_entry_queue(struct llentry *);
+
+struct llentry *lltable_create_lle(struct lltable *llt, u_int flags,
+ const void *paddr);
+void lltable_link_entry(struct lltable *llt, struct llentry *lle);
+void lltable_unlink_entry(struct lltable *llt, struct llentry *lle);
+void lltable_fill_sa_entry(const struct llentry *lle, struct sockaddr *sa);
+struct ifnet *lltable_get_ifp(const struct lltable *llt);
+int lltable_get_af(const struct lltable *llt);
+
+int lltable_foreach_lle(struct lltable *llt, llt_foreach_cb_t *f,
+ void *farg);
/*
* Generic link layer address lookup function.
*/
OpenPOWER on IntegriCloud