Lines Matching refs:llt
86 static void lltable_unlink(struct lltable *llt);
88 static void llentries_unlink(struct lltable *llt, struct llentries *head);
91 static void htable_link_entry(struct lltable *llt, struct llentry *lle);
92 static int htable_foreach_lle(struct lltable *llt, llt_foreach_cb_t *f,
99 lltable_dump_af(struct lltable *llt, struct sysctl_req *wr) in lltable_dump_af() argument
105 if (llt->llt_ifp->if_flags & IFF_LOOPBACK) { in lltable_dump_af()
110 IF_AFDATA_RLOCK(llt->llt_ifp, llt->llt_af); in lltable_dump_af()
111 error = lltable_foreach_lle(llt, in lltable_dump_af()
112 (llt_foreach_cb_t *)llt->llt_dump_entry, wr); in lltable_dump_af()
113 IF_AFDATA_RUNLOCK(llt->llt_ifp, llt->llt_af); in lltable_dump_af()
124 struct lltable *llt = NULL; in lltable_sysctl_dumparp() local
128 SLIST_FOREACH(llt, &lltables, llt_link) { in lltable_sysctl_dumparp()
129 if (llt->llt_af == af) { in lltable_sysctl_dumparp()
130 error = lltable_dump_af(llt, wr); in lltable_sysctl_dumparp()
151 htable_foreach_lle(struct lltable *llt, llt_foreach_cb_t *f, void *farg) in htable_foreach_lle() argument
158 for (i = 0; i < llt->llt_hsize; i++) { in htable_foreach_lle()
159 LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) { in htable_foreach_lle()
160 error = f(llt, lle, farg); in htable_foreach_lle()
171 htable_link_entry(struct lltable *llt, struct llentry *lle) in htable_link_entry() argument
180 IF_AFDATA_WLOCK_ASSERT(llt->llt_ifp, llt->llt_af); in htable_link_entry()
182 hashidx = llt->llt_hash(lle, llt->llt_hsize); in htable_link_entry()
183 lleh = &llt->lle_head[hashidx]; in htable_link_entry()
185 lle->lle_tbl = llt; in htable_link_entry()
213 htable_prefix_free_cb(struct lltable *llt, struct llentry *lle, void *farg) in htable_prefix_free_cb() argument
219 if (llt->llt_match_prefix(pmd->addr, pmd->mask, pmd->flags, lle)) { in htable_prefix_free_cb()
228 htable_prefix_free(struct lltable *llt, const struct sockaddr *addr, in htable_prefix_free() argument
240 IF_AFDATA_WLOCK(llt->llt_ifp, llt->llt_af); in htable_prefix_free()
242 lltable_foreach_lle(llt, htable_prefix_free_cb, &pmd); in htable_prefix_free()
244 llentries_unlink(llt, &pmd.dchain); in htable_prefix_free()
245 IF_AFDATA_WUNLOCK(llt->llt_ifp, llt->llt_af); in htable_prefix_free()
248 lltable_free_entry(llt, lle); in htable_prefix_free()
253 htable_free_tbl(struct lltable *llt)
255 kfree_type(struct llentries, llt->llt_hsize, llt->lle_head);
256 kfree_type(struct lltable, llt);
261 llentries_unlink(struct lltable *llt, struct llentries *head) in llentries_unlink() argument
266 llt->llt_unlink_entry(lle); in llentries_unlink()
387 llentry_update_ifaddr(struct lltable *llt, struct llentry *lle, void *farg)
410 lltable_calc_llheader(ifp, llt->llt_af, (void *)lladdr, (void *)linkhdr, &linkhdrsize,
422 lltable_update_ifaddr(struct lltable *llt)
424 if (llt->llt_ifp->if_flags & IFF_LOOPBACK) {
428 IF_AFDATA_WLOCK(llt->llt_ifp, llt->llt_af);
429 lltable_foreach_lle(llt, llentry_update_ifaddr, llt->llt_ifp);
430 IF_AFDATA_WUNLOCK(llt->llt_ifp, llt->llt_af);
511 lltable_free_cb(struct lltable *llt, struct llentry *lle, void *farg) in lltable_free_cb() argument
513 #pragma unused(llt) in lltable_free_cb()
528 lltable_free(struct lltable *llt) in lltable_free() argument
533 KASSERT(llt != NULL, ("%s: llt is NULL", __func__)); in lltable_free()
538 IF_AFDATA_WLOCK(llt->llt_ifp, llt->llt_af); in lltable_free()
540 lltable_foreach_lle(llt, lltable_free_cb, &dchain); in lltable_free()
541 llentries_unlink(llt, &dchain); in lltable_free()
542 IF_AFDATA_WUNLOCK(llt->llt_ifp, llt->llt_af); in lltable_free()
559 lltable_purge(struct lltable *llt) in lltable_purge() argument
565 KASSERT(llt != NULL, ("%s: llt is NULL", __func__)); in lltable_purge()
568 IF_AFDATA_WLOCK(llt->llt_ifp, llt->llt_af); in lltable_purge()
570 lltable_foreach_lle(llt, lltable_free_cb, &dchain); in lltable_purge()
571 llentries_unlink(llt, &dchain); in lltable_purge()
572 IF_AFDATA_WUNLOCK(llt->llt_ifp, llt->llt_af); in lltable_purge()
583 struct lltable *llt;
588 SLIST_FOREACH(llt, &lltables, llt_link) {
589 if (llt->llt_af != af) {
593 for (i = 0; i < llt->llt_hsize; i++) {
594 LIST_FOREACH(lle, &llt->lle_head[i], lle_next) {
614 lltable_delete_addr(struct lltable *llt, u_int flags, in lltable_delete_addr() argument
620 ifp = llt->llt_ifp; in lltable_delete_addr()
621 IF_AFDATA_WLOCK(ifp, llt->llt_af); in lltable_delete_addr()
622 lle = lla_lookup(llt, LLE_EXCLUSIVE, l3addr); in lltable_delete_addr()
625 IF_AFDATA_WUNLOCK(ifp, llt->llt_af); in lltable_delete_addr()
629 IF_AFDATA_WUNLOCK(ifp, llt->llt_af); in lltable_delete_addr()
634 lltable_unlink_entry(llt, lle); in lltable_delete_addr()
635 IF_AFDATA_WUNLOCK(ifp, llt->llt_af); in lltable_delete_addr()
637 llt->llt_delete_entry(llt, lle); in lltable_delete_addr()
646 struct lltable *llt; in lltable_prefix_free() local
649 SLIST_FOREACH(llt, &lltables, llt_link) { in lltable_prefix_free()
650 if (llt->llt_af != af) { in lltable_prefix_free()
654 llt->llt_prefix_free(llt, addr, mask, flags); in lltable_prefix_free()
662 struct lltable *llt; in lltable_allocate_htbl() local
664 llt = kalloc_type(struct lltable, Z_WAITOK | Z_ZERO); in lltable_allocate_htbl()
665 llt->llt_hsize = hsize; in lltable_allocate_htbl()
666 llt->lle_head = kalloc_type(struct llentries, hsize, in lltable_allocate_htbl()
669 for (int i = 0; i < llt->llt_hsize; i++) { in lltable_allocate_htbl()
670 LIST_INIT(&llt->lle_head[i]); in lltable_allocate_htbl()
674 llt->llt_link_entry = htable_link_entry; in lltable_allocate_htbl()
675 llt->llt_unlink_entry = htable_unlink_entry; in lltable_allocate_htbl()
676 llt->llt_prefix_free = htable_prefix_free; in lltable_allocate_htbl()
677 llt->llt_foreach_entry = htable_foreach_lle; in lltable_allocate_htbl()
679 return llt; in lltable_allocate_htbl()
686 lltable_link(struct lltable *llt) in lltable_link() argument
689 SLIST_INSERT_HEAD(&lltables, llt, llt_link); in lltable_link()
695 lltable_unlink(struct lltable *llt)
698 SLIST_REMOVE(&lltables, llt, lltable, llt_link);
708 lltable_foreach_lle(struct lltable *llt, llt_foreach_cb_t *f, void *farg) in lltable_foreach_lle() argument
710 return llt->llt_foreach_entry(llt, f, farg); in lltable_foreach_lle()
714 lltable_alloc_entry(struct lltable *llt, uint16_t flags, in lltable_alloc_entry() argument
717 return llt->llt_alloc_entry(llt, flags, l3addr); in lltable_alloc_entry()
721 lltable_free_entry(struct lltable *llt, struct llentry *lle) in lltable_free_entry() argument
723 llt->llt_free_entry(llt, lle); in lltable_free_entry()
727 lltable_link_entry(struct lltable *llt, struct llentry *lle) in lltable_link_entry() argument
729 llt->llt_link_entry(llt, lle); in lltable_link_entry()
733 lltable_unlink_entry(struct lltable *llt, struct llentry *lle) in lltable_unlink_entry() argument
735 llt->llt_unlink_entry(lle); in lltable_unlink_entry()
741 struct lltable *llt; in lltable_fill_sa_entry() local
743 llt = lle->lle_tbl; in lltable_fill_sa_entry()
744 llt->llt_fill_sa_entry(lle, sa); in lltable_fill_sa_entry()
748 lltable_get_ifp(const struct lltable *llt) in lltable_get_ifp() argument
750 return llt->llt_ifp; in lltable_get_ifp()
754 lltable_get_af(const struct lltable *llt) in lltable_get_af() argument
756 return llt->llt_af; in lltable_get_af()
771 struct lltable *llt; in lla_rt_output() local
788 SLIST_FOREACH(llt, &lltables, llt_link) { in lla_rt_output()
789 if (llt->llt_af == dst->sa_family && in lla_rt_output()
790 llt->llt_ifp == ifp) { in lla_rt_output()
795 KASSERT(llt != NULL, ("Yep, ugly hacks are bad\n")); in lla_rt_output()
806 lle = lltable_alloc_entry(llt, laflags, dst); in lla_rt_output()
828 IF_AFDATA_WLOCK(ifp, llt->llt_af); in lla_rt_output()
830 lle_tmp = lla_lookup(llt, LLE_EXCLUSIVE, dst); in lla_rt_output()
834 IF_AFDATA_WUNLOCK(ifp, llt->llt_af); in lla_rt_output()
836 lltable_free_entry(llt, lle); in lla_rt_output()
840 lltable_unlink_entry(llt, lle_tmp); in lla_rt_output()
842 lltable_link_entry(llt, lle); in lla_rt_output()
843 IF_AFDATA_WUNLOCK(ifp, llt->llt_af); in lla_rt_output()
847 lltable_free_entry(llt, lle_tmp); in lla_rt_output()
868 return lltable_delete_addr(llt, 0, dst); in lla_rt_output()