Lines Matching full:tc

93     struct table_config **tc);
99 struct table_config *tc);
102 static void link_table(struct ip_fw_chain *ch, struct table_config *tc);
103 static void unlink_table(struct ip_fw_chain *ch, struct table_config *tc);
110 static void export_table_info(struct ip_fw_chain *ch, struct table_config *tc,
119 struct table_config *tc, struct table_info *ti, uint32_t count);
163 tc_ref(struct table_config *tc) in tc_ref() argument
166 tc->no.refcnt++; in tc_ref()
170 tc_unref(struct table_config *tc) in tc_unref() argument
173 tc->no.refcnt--; in tc_unref()
177 get_table_value(struct ip_fw_chain *ch, struct table_config *tc, uint32_t kidx) in get_table_value() argument
188 * w.r.t @tc limits.
195 check_table_limit(struct table_config *tc, struct tentry_info *tei) in check_table_limit() argument
198 if (tc->limit == 0 || tc->count < tc->limit) in check_table_limit()
290 struct table_config *tc; in find_ref_table() local
297 tc = NULL; in find_ref_table()
298 if ((tc = find_table(ni, ti)) != NULL) { in find_ref_table()
300 if (tc->no.subtype != ti->type) in find_ref_table()
303 if (tc->locked != 0) in find_ref_table()
308 check_table_limit(tc, tei) != 0) in find_ref_table()
312 tc->no.refcnt++; in find_ref_table()
313 *ptc = tc; in find_ref_table()
331 tc = (struct table_config *)ipfw_objhash_lookup_kidx(ni, kidx); in find_ref_table()
332 KASSERT(tc != NULL, ("create_table_compat returned bad idx %u", kidx)); in find_ref_table()
335 *ptc = tc; in find_ref_table()
340 * Rolls back already @added to @tc entries using state array @ta_buf_m.
347 rollback_added_entries(struct ip_fw_chain *ch, struct table_config *tc, in rollback_added_entries() argument
360 ta = tc->ta; in rollback_added_entries()
372 error = ta->add(tc->astate, tinfo, ptei, v, &num); in rollback_added_entries()
380 error = ta->del(tc->astate, tinfo, ptei, vv, &num); in rollback_added_entries()
382 tc->count -= num; in rollback_added_entries()
487 if (ts->tc != object && ts->ch != object) in rollback_add_entry()
545 struct table_config *tc; in add_table_entry() local
571 error = find_ref_table(ch, ti, tei, count, OP_ADD, &tc); in add_table_entry()
576 ta = tc->ta; in add_table_entry()
581 ts.tc = tc; in add_table_entry()
582 ts.vshared = tc->vshared; in add_table_entry()
583 ts.vmask = tc->vmask; in add_table_entry()
599 tc->no.refcnt--; in add_table_entry()
628 kidx = tc->no.kidx; in add_table_entry()
629 error = check_table_space(ch, &ts, tc, KIDX_TO_TI(ch, kidx), count); in add_table_entry()
635 /* We've got valid table in @tc. Let's try to add data */ in add_table_entry()
636 kidx = tc->no.kidx; in add_table_entry()
637 ta = tc->ta; in add_table_entry()
648 if ((error = check_table_limit(tc, ptei)) == 0) { in add_table_entry()
657 error = ta->add(tc->astate, KIDX_TO_TI(ch, kidx), in add_table_entry()
664 tc->count += num; in add_table_entry()
680 rollback_added_entries(ch, tc, KIDX_TO_TI(ch, kidx), in add_table_entry()
689 ipfw_garbage_table_values(ch, tc, tei, count, rollback); in add_table_entry()
693 check_table_space(ch, NULL, tc, KIDX_TO_TI(ch, kidx), 0); in add_table_entry()
715 struct table_config *tc; in del_table_entry() local
727 error = find_ref_table(ch, ti, tei, count, OP_DEL, &tc); in del_table_entry()
732 ta = tc->ta; in del_table_entry()
745 tc->no.refcnt--; in del_table_entry()
751 if (ta != tc->ta) { in del_table_entry()
757 kidx = tc->no.kidx; in del_table_entry()
766 error = ta->del(tc->astate, KIDX_TO_TI(ch, kidx), ptei, v, in del_table_entry()
772 tc->count -= num; in del_table_entry()
778 ipfw_garbage_table_values(ch, tc, tei, count, 0); in del_table_entry()
782 check_table_space(ch, NULL, tc, KIDX_TO_TI(ch, kidx), 0); in del_table_entry()
797 * Ensure that table @tc has enough space to add @count entries without
812 struct table_config *tc, struct table_info *ti, uint32_t count) in check_table_space() argument
822 ta = tc->ta; in check_table_space()
826 /* Acquire reference not to loose @tc between locks/unlocks */ in check_table_space()
827 tc->no.refcnt++; in check_table_space()
836 if (ta->need_modify(tc->astate, ti, count, &pflags) == 0) { in check_table_space()
867 ti = KIDX_TO_TI(ch, tc->no.kidx); in check_table_space()
868 if (ta->need_modify(tc->astate, ti, count, &pflags) == 0) { in check_table_space()
879 error = ta->fill_mod(tc->astate, ti, ta_buf, &pflags); in check_table_space()
883 ta->modify(tc->astate, ti, ta_buf, pflags); in check_table_space()
891 tc->no.refcnt--; in check_table_space()
1033 struct table_config *tc; in find_table_entry() local
1064 if ((tc = find_table(ni, &ti)) == NULL) { in find_table_entry()
1070 if (tc->no.subtype != ti.type) { in find_table_entry()
1075 kti = KIDX_TO_TI(ch, tc->no.kidx); in find_table_entry()
1076 ta = tc->ta; in find_table_entry()
1081 error = ta->find_tentry(tc->astate, kti, tent); in find_table_entry()
1083 pval = get_table_value(ch, tc, tent->v.kidx); in find_table_entry()
1129 if (ts->tc != object) in restart_flush()
1149 struct table_config *tc; in flush_table() local
1165 if ((tc = find_table(ni, ti)) == NULL) { in flush_table()
1176 ts.tc = tc; in flush_table()
1178 ta = tc->ta; in flush_table()
1186 ta->print_config(tc->astate, KIDX_TO_TI(ch, tc->no.kidx), in flush_table()
1191 tflags = tc->tflags; in flush_table()
1192 tc->no.refcnt++; in flush_table()
1215 tc->no.refcnt--; in flush_table()
1236 kidx = tc->no.kidx; in flush_table()
1244 astate_old = tc->astate; in flush_table()
1245 tc->astate = astate_new; in flush_table()
1246 tc->ti_copy = ti_new; in flush_table()
1247 tc->count = 0; in flush_table()
1251 ta->change_ti(tc->astate, &tablestate[kidx]); in flush_table()
1256 ipfw_unref_table_values(ch, tc, ta, astate_old, &ti_old); in flush_table()
1302 * @tc (with name, set, kidx) and rule bindings, which is "stable".
1307 * runtime cache in @tc
1308 * algo-specific data (@tc->astate)
1317 * Note that referencing @tc won't protect tc->ta from change.
1398 /* Ensure tc.ti copies are in sync */ in swap_tables()
1424 struct table_config *tc; in destroy_table() local
1429 if ((tc = find_table(ni, ti)) == NULL) { in destroy_table()
1435 if (tc->no.refcnt > 0) { in destroy_table()
1441 unlink_table(ch, tc); in destroy_table()
1445 if (ipfw_objhash_free_idx(ni, tc->no.kidx) != 0) in destroy_table()
1447 tc->no.kidx, tc->tablename); in destroy_table()
1450 ipfw_unref_table_values(ch, tc, tc->ta, tc->astate, &tc->ti_copy); in destroy_table()
1453 free_table_config(ni, tc); in destroy_table()
1470 struct table_config *tc; in ipfw_resize_tables() local
1521 tc = (struct table_config *)ipfw_objhash_lookup_kidx(ni, i); in ipfw_resize_tables()
1522 if (tc == NULL || tc->ta->change_ti == NULL) in ipfw_resize_tables()
1525 tc->ta->change_ti(tc->astate, ti); in ipfw_resize_tables()
1555 struct table_config *tc; in ipfw_ref_table() local
1561 error = find_table_err(CHAIN_TO_NI(ch), &ti, &tc); in ipfw_ref_table()
1565 if (tc == NULL) in ipfw_ref_table()
1568 tc_ref(tc); in ipfw_ref_table()
1569 *kidx = tc->no.kidx; in ipfw_ref_table()
1655 struct table_config *tc; in describe_table() local
1667 if ((tc = find_table(CHAIN_TO_NI(ch), &ti)) == NULL) { in describe_table()
1672 export_table_info(ch, tc, (ipfw_xtable_info *)(oh + 1)); in describe_table()
1694 struct table_config *tc; in modify_table() local
1715 if ((tc = find_table(ni, &ti)) == NULL) { in modify_table()
1721 if ((tc->ta->flags & TA_FLAG_READONLY) != 0) { in modify_table()
1727 tc->limit = i->limit; in modify_table()
1729 tc->locked = ((i->flags & IPFW_TGFLAGS_LOCKED) != 0); in modify_table()
1802 struct table_config *tc, *tc_new, *tmp; in create_table_internal() local
1812 tc = alloc_table_config(ch, ti, ta, aname, i->tflags); in create_table_internal()
1813 if (tc == NULL) in create_table_internal()
1816 tc->vmask = i->vmask; in create_table_internal()
1817 tc->limit = i->limit; in create_table_internal()
1819 tc->locked = 1; in create_table_internal()
1821 tc->locked = (i->flags & IPFW_TGFLAGS_LOCKED) != 0; in create_table_internal()
1833 if (compat == 0 || tc_new->no.subtype != tc->no.subtype) { in create_table_internal()
1835 free_table_config(ni, tc); in create_table_internal()
1839 /* Exchange tc and tc_new for proper refcounting & freeing */ in create_table_internal()
1840 tmp = tc; in create_table_internal()
1841 tc = tc_new; in create_table_internal()
1849 free_table_config(ni, tc); in create_table_internal()
1852 tc->no.kidx = kidx; in create_table_internal()
1853 tc->no.etlv = IPFW_TLV_TBL_NAME; in create_table_internal()
1855 link_table(ch, tc); in create_table_internal()
1859 tc->no.refcnt++; in create_table_internal()
1861 *pkidx = tc->no.kidx; in create_table_internal()
1931 struct table_config *tc; member
1961 table_get_count(struct ip_fw_chain *ch, struct table_config *tc) in table_get_count() argument
1967 ti = KIDX_TO_TI(ch, tc->no.kidx); in table_get_count()
1968 ta = tc->ta; in table_get_count()
1972 return (tc->count); in table_get_count()
1976 return (ta->get_count(tc->astate, ti)); in table_get_count()
1980 ta->foreach(tc->astate, ti, count_ext_entries, &da); in table_get_count()
1986 * Exports table @tc info into standard ipfw_xtable_info format.
1989 export_table_info(struct ip_fw_chain *ch, struct table_config *tc, in export_table_info() argument
1995 i->type = tc->no.subtype; in export_table_info()
1996 i->tflags = tc->tflags; in export_table_info()
1997 i->vmask = tc->vmask; in export_table_info()
1998 i->set = tc->no.set; in export_table_info()
1999 i->kidx = tc->no.kidx; in export_table_info()
2000 i->refcnt = tc->no.refcnt; in export_table_info()
2001 i->count = table_get_count(ch, tc); in export_table_info()
2002 i->limit = tc->limit; in export_table_info()
2003 i->flags |= (tc->locked != 0) ? IPFW_TGFLAGS_LOCKED : 0; in export_table_info()
2006 strlcpy(i->tablename, tc->tablename, sizeof(i->tablename)); in export_table_info()
2007 ti = KIDX_TO_TI(ch, tc->no.kidx); in export_table_info()
2008 ta = tc->ta; in export_table_info()
2011 ta->print_config(tc->astate, ti, i->algoname, in export_table_info()
2017 ta->dump_tinfo(tc->astate, ti, &i->ta_info); in export_table_info()
2096 struct table_config *tc; in dump_table_v1() local
2110 if ((tc = find_table(CHAIN_TO_NI(ch), &ti)) == NULL) { in dump_table_v1()
2114 export_table_info(ch, tc, i); in dump_table_v1()
2132 da.ti = KIDX_TO_TI(ch, tc->no.kidx); in dump_table_v1()
2133 da.tc = tc; in dump_table_v1()
2136 ta = tc->ta; in dump_table_v1()
2138 ta->foreach(tc->astate, da.ti, dump_table_tentry, &da); in dump_table_v1()
2151 struct table_config *tc; in dump_table_tentry() local
2159 tc = da->tc; in dump_table_tentry()
2160 ta = tc->ta; in dump_table_tentry()
2171 error = ta->dump_tentry(tc->astate, da->ti, e, tent); in dump_table_tentry()
2175 pval = get_table_value(da->ch, da->tc, tent->v.kidx); in dump_table_tentry()
2191 struct table_config *tc; in prepare_table_tentry() local
2197 tc = da->tc; in prepare_table_tentry()
2198 ta = tc->ta; in prepare_table_tentry()
2200 error = ta->dump_tentry(tc->astate, da->ti, e, &da->tent); in prepare_table_tentry()
2217 struct table_config *tc; in ipfw_foreach_table_tentry() local
2223 tc = (struct table_config *)ipfw_objhash_lookup_kidx(ni, kidx); in ipfw_foreach_table_tentry()
2224 if (tc == NULL) in ipfw_foreach_table_tentry()
2227 ta = tc->ta; in ipfw_foreach_table_tentry()
2231 da.ti = KIDX_TO_TI(ch, tc->no.kidx); in ipfw_foreach_table_tentry()
2232 da.tc = tc; in ipfw_foreach_table_tentry()
2236 ta->foreach(tc->astate, da.ti, prepare_table_tentry, &da); in ipfw_foreach_table_tentry()
2501 struct table_config *tc; in table_findbyname() local
2506 error = find_table_err(CHAIN_TO_NI(ch), ti, &tc); in table_findbyname()
2510 *pno = &tc->no; in table_findbyname()
2519 struct table_config *tc; in table_findbykidx() local
2523 tc = (struct table_config *)ipfw_objhash_lookup_kidx(ni, idx); in table_findbykidx()
2524 KASSERT(tc != NULL, ("Table with index %u not found", idx)); in table_findbykidx()
2526 return (&tc->no); in table_findbykidx()
2787 * Returns 0 in success and fills in @tc with found config
2791 struct table_config **tc) in find_table_err() argument
2818 *tc = (struct table_config *)no; in find_table_err()
2833 struct table_config *tc; in find_table() local
2835 if (find_table_err(ni, ti, &tc) != 0) in find_table()
2838 return (tc); in find_table()
2852 struct table_config *tc; in alloc_table_config() local
2871 tc = malloc(sizeof(struct table_config), M_IPFW, M_WAITOK | M_ZERO); in alloc_table_config()
2872 tc->no.name = tc->tablename; in alloc_table_config()
2873 tc->no.subtype = ta->type; in alloc_table_config()
2874 tc->no.set = set; in alloc_table_config()
2875 tc->tflags = tflags; in alloc_table_config()
2876 tc->ta = ta; in alloc_table_config()
2877 strlcpy(tc->tablename, name, sizeof(tc->tablename)); in alloc_table_config()
2879 tc->vshared = 1; in alloc_table_config()
2882 error = ta->init(ch, &tc->astate, &tc->ti_copy, aname, tflags); in alloc_table_config()
2884 free(tc, M_IPFW); in alloc_table_config()
2888 return (tc); in alloc_table_config()
2895 free_table_config(struct namedobj_instance *ni, struct table_config *tc) in free_table_config() argument
2898 KASSERT(tc->linked == 0, ("free() on linked config")); in free_table_config()
2905 tc->ta->destroy(tc->astate, &tc->ti_copy); in free_table_config()
2906 free(tc, M_IPFW); in free_table_config()
2910 * Links @tc to @chain table named instance.
2914 link_table(struct ip_fw_chain *ch, struct table_config *tc) in link_table() argument
2923 kidx = tc->no.kidx; in link_table()
2925 ipfw_objhash_add(ni, &tc->no); in link_table()
2928 *ti = tc->ti_copy; in link_table()
2931 if (tc->ta->change_ti != NULL) in link_table()
2932 tc->ta->change_ti(tc->astate, ti); in link_table()
2934 tc->linked = 1; in link_table()
2935 tc->ta->refcnt++; in link_table()
2939 * Unlinks @tc from @chain table named instance.
2940 * Zeroes states in @chain and stores them in @tc.
2943 unlink_table(struct ip_fw_chain *ch, struct table_config *tc) in unlink_table() argument
2953 kidx = tc->no.kidx; in unlink_table()
2955 /* Clear state. @ti copy is already saved inside @tc */ in unlink_table()
2956 ipfw_objhash_del(ni, &tc->no); in unlink_table()
2959 tc->linked = 0; in unlink_table()
2960 tc->ta->refcnt--; in unlink_table()
2963 if (tc->ta->change_ti != NULL) in unlink_table()
2964 tc->ta->change_ti(tc->astate, NULL); in unlink_table()