Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/ip_fw_table_algo.c
| Show First 20 Lines • Show All 2,098 Lines • ▼ Show 20 Lines | |||||
| static int | static int | ||||
| ta_init_ifidx(struct ip_fw_chain *ch, void **ta_state, struct table_info *ti, | ta_init_ifidx(struct ip_fw_chain *ch, void **ta_state, struct table_info *ti, | ||||
| char *data, uint8_t tflags) | char *data, uint8_t tflags) | ||||
| { | { | ||||
| struct iftable_cfg *icfg; | struct iftable_cfg *icfg; | ||||
| icfg = malloc(sizeof(struct iftable_cfg), M_IPFW, M_WAITOK | M_ZERO); | icfg = malloc(sizeof(struct iftable_cfg), M_IPFW, M_WAITOK | M_ZERO); | ||||
| icfg->ii = ipfw_objhash_create(DEFAULT_IFIDX_SIZE); | icfg->ii = ipfw_objhash_create(DEFAULT_IFIDX_SIZE, DEFAULT_OBJHASH_SIZE); | ||||
| icfg->size = DEFAULT_IFIDX_SIZE; | icfg->size = DEFAULT_IFIDX_SIZE; | ||||
| icfg->main_ptr = malloc(sizeof(struct ifidx) * icfg->size, M_IPFW, | icfg->main_ptr = malloc(sizeof(struct ifidx) * icfg->size, M_IPFW, | ||||
| M_WAITOK | M_ZERO); | M_WAITOK | M_ZERO); | ||||
| icfg->ch = ch; | icfg->ch = ch; | ||||
| *ta_state = icfg; | *ta_state = icfg; | ||||
| ti->state = icfg->main_ptr; | ti->state = icfg->main_ptr; | ||||
| ti->lookup = ta_lookup_ifidx; | ti->lookup = ta_lookup_ifidx; | ||||
| ▲ Show 20 Lines • Show All 1,074 Lines • ▼ Show 20 Lines | |||||
| static int | static int | ||||
| ta_lookup_fhash(struct table_info *ti, void *key, uint32_t keylen, | ta_lookup_fhash(struct table_info *ti, void *key, uint32_t keylen, | ||||
| uint32_t *val) | uint32_t *val) | ||||
| { | { | ||||
| struct fhashbhead *head; | struct fhashbhead *head; | ||||
| struct fhashentry *ent; | struct fhashentry *ent; | ||||
| struct fhashentry4 *m4; | struct fhashentry4 *m4; | ||||
| struct ipfw_flow_id *id; | struct ipfw_flow_id *id; | ||||
| uint32_t hsize; | uint32_t hash, hsize; | ||||
| uint16_t hash; | |||||
| id = (struct ipfw_flow_id *)key; | id = (struct ipfw_flow_id *)key; | ||||
| head = (struct fhashbhead *)ti->state; | head = (struct fhashbhead *)ti->state; | ||||
| hsize = ti->data; | hsize = ti->data; | ||||
| m4 = (struct fhashentry4 *)ti->xstate; | m4 = (struct fhashentry4 *)ti->xstate; | ||||
| if (id->addr_type == 4) { | if (id->addr_type == 4) { | ||||
| struct fhashentry4 f; | struct fhashentry4 f; | ||||
| ▲ Show 20 Lines • Show All 805 Lines • ▼ Show 20 Lines | struct table_algo addr_kfib = { | ||||
| .dump_tentry = ta_dump_kfib_tentry, | .dump_tentry = ta_dump_kfib_tentry, | ||||
| .find_tentry = ta_find_kfib_tentry, | .find_tentry = ta_find_kfib_tentry, | ||||
| .dump_tinfo = ta_dump_kfib_tinfo, | .dump_tinfo = ta_dump_kfib_tinfo, | ||||
| .print_config = ta_print_kfib_config, | .print_config = ta_print_kfib_config, | ||||
| }; | }; | ||||
| struct mac_radix_entry { | struct mac_radix_entry { | ||||
| struct radix_node rn[2]; | struct radix_node rn[2]; | ||||
| struct sa_mac sa; | |||||
| uint32_t value; | uint32_t value; | ||||
| uint8_t masklen; | uint8_t masklen; | ||||
| struct sa_mac sa; | |||||
| }; | }; | ||||
| struct mac_radix_cfg { | struct mac_radix_cfg { | ||||
| struct radix_node_head *head; | struct radix_node_head *head; | ||||
| size_t count; | size_t count; | ||||
| }; | }; | ||||
| static int | static int | ||||
| ▲ Show 20 Lines • Show All 269 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| struct radix_node_head *rnh; | struct radix_node_head *rnh; | ||||
| void *e; | void *e; | ||||
| e = NULL; | e = NULL; | ||||
| if (tent->subtype == AF_LINK) { | if (tent->subtype == AF_LINK) { | ||||
| struct sa_mac sa; | struct sa_mac sa; | ||||
| KEY_LEN(sa) = KEY_LEN_MAC; | KEY_LEN(sa) = KEY_LEN_MAC; | ||||
| memcpy(tent->k.mac, sa.mac_addr.octet, ETHER_ADDR_LEN); | memcpy(sa.mac_addr.octet, tent->k.mac, ETHER_ADDR_LEN); | ||||
| rnh = (struct radix_node_head *)ti->state; | rnh = (struct radix_node_head *)ti->state; | ||||
| e = rnh->rnh_matchaddr(&sa, &rnh->rh); | e = rnh->rnh_matchaddr(&sa, &rnh->rh); | ||||
| } | } | ||||
| if (e != NULL) { | if (e != NULL) { | ||||
| ta_dump_mac_radix_tentry(ta_state, ti, e, tent); | ta_dump_mac_radix_tentry(ta_state, ti, e, tent); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines | |||||