diff --git a/fw/hpack.c b/fw/hpack.c index 911c595d2..1c6f5987c 100644 --- a/fw/hpack.c +++ b/fw/hpack.c @@ -3026,19 +3026,17 @@ tfw_hpack_rbuf_commit(TfwHPackETbl *__restrict tbl, * headers will be evicted from the index table. */ static int -tfw_hpack_add_node(TfwHPackETbl *__restrict tbl, TfwStr *__restrict hdr, - TfwHPackNodeIter *__restrict place, bool spcolon) +tfw_hpack_add_node(TfwHPackETbl *__restrict tbl, TfwStr *__restrict h_name, + TfwStr *__restrict h_val, TfwHPackNodeIter *__restrict place) { char *ptr; unsigned long node_size, hdr_len; unsigned short new_size, node_len; unsigned short cur_size = tbl->size, window = tbl->window; TfwHPackNode *del_list[HPACK_MAX_ENC_EVICTION] = {}; - TfwStr s_nm = {}, s_val = {}; TfwHPackETblIter it = {}; - hdr_len = tfw_http_hdr_split(hdr, &s_nm, &s_val, spcolon); - WARN_ON_ONCE(TFW_STR_EMPTY(&s_nm)); + hdr_len = h_name->len + h_val->len; WARN_ON_ONCE(cur_size > window || window > HPACK_ENC_TABLE_MAX_SIZE); if ((node_size = hdr_len + HPACK_ENTRY_OVERHEAD) > window) { @@ -3131,14 +3129,14 @@ tfw_hpack_add_node(TfwHPackETbl *__restrict tbl, TfwStr *__restrict hdr, it.size += node_size; it.rb_len += node_len; it.last->hdr_len = hdr_len; - it.last->name_len = s_nm.len; + it.last->name_len = h_name->len; it.last->rindex = ++tbl->idx_acc; - tfw_hpack_rbuf_commit(tbl, &s_nm, &s_val, del_list, place, &it); + tfw_hpack_rbuf_commit(tbl, h_name, h_val, del_list, place, &it); - ptr = tfw_hpack_write(&s_nm, it.last->hdr); - if (!TFW_STR_EMPTY(&s_val)) - tfw_hpack_write(&s_val, ptr); + ptr = tfw_hpack_write(h_name, it.last->hdr); + if (!TFW_STR_EMPTY(h_val)) + tfw_hpack_write(h_val, ptr); WARN_ON_ONCE(tbl->rb_len > tbl->size); @@ -3150,36 +3148,28 @@ tfw_hpack_add_node(TfwHPackETbl *__restrict tbl, TfwStr *__restrict hdr, * encoder dynamic table with potentially concurrent access from different * threads, so lock is used to protect the find/add/erase operations inside * this procedure. - * - * TODO #1411: get rid of tfw_http_hdr_split and related safety checks */ static TfwHPackETblRes tfw_hpack_encoder_index(TfwHPackETbl *__restrict tbl, - TfwStr *__restrict hdr, + TfwStr *__restrict h_name, + TfwStr *__restrict h_val, unsigned short *__restrict out_index, - unsigned long *__restrict flags, - bool spcolon) + unsigned long *__restrict flags) { TfwHPackNodeIter place = {}; const TfwHPackNode *node = NULL; TfwHPackETblRes res = HPACK_IDX_ST_NOT_FOUND; - TfwStr h_name = {}, h_val = {}; BUILD_BUG_ON(HPACK_IDX_ST_MASK < _HPACK_IDX_ST_NUM - 1); - if (WARN_ON_ONCE(!hdr)) - return -EINVAL; - tfw_http_hdr_split(hdr, &h_name, &h_val, spcolon); - if (WARN_ON_ONCE(TFW_STR_EMPTY(&h_name))) - return -EINVAL; - res = tfw_hpack_rbtree_find(tbl, &h_name, &h_val, &node, &place); + res = tfw_hpack_rbtree_find(tbl, h_name, h_val, &node, &place); WARN_ON_ONCE(!node && res != HPACK_IDX_ST_NOT_FOUND); *out_index = HPACK_NODE_GET_INDEX(tbl, node); if(res != HPACK_IDX_ST_FOUND - && !tfw_hpack_add_node(tbl, hdr, &place, spcolon)) + && !tfw_hpack_add_node(tbl, h_name, h_val, &place)) res |= HPACK_IDX_FLAG_ADD; return res; @@ -3424,31 +3414,23 @@ tfw_hpack_write_idx(TfwHttpResp *__restrict resp, TfwHPackInt *__restrict idx, * response @resp using @resp->pool. */ static int -tfw_hpack_hdr_add(TfwHttpResp *__restrict resp, TfwStr *__restrict hdr, - TfwHPackInt *__restrict idx, bool name_indexed, bool trans) +tfw_hpack_hdr_add(TfwHttpResp *__restrict resp, TfwStr *__restrict h_name, + TfwStr *__restrict h_val, TfwHPackInt *__restrict idx, + bool name_indexed, bool trans) { int r; TfwHPackInt vlen; - TfwStr s_name = {}, s_val = {}, s_vlen = {}; - - if (!hdr) - return -EINVAL; + TfwStr s_vlen = {}; r = tfw_hpack_write_idx(resp, idx, true); if (unlikely(r)) return r; - if (WARN_ON_ONCE(TFW_STR_PLAIN(hdr) || TFW_STR_DUP(hdr))) - return -EINVAL; - - if (!tfw_http_hdr_split(hdr, &s_name, &s_val, trans)) - return -EINVAL; - if (unlikely(!name_indexed)) { TfwHPackInt nlen; TfwStr s_nlen = {}; - write_int(s_name.len, 0x7F, 0, &nlen); + write_int(h_name->len, 0x7F, 0, &nlen); s_nlen.data = nlen.buf; s_nlen.len = nlen.sz; @@ -3457,23 +3439,23 @@ tfw_hpack_hdr_add(TfwHttpResp *__restrict resp, TfwStr *__restrict hdr, return r; if (trans) - r = tfw_http_msg_expand_from_pool_lc(resp, &s_name); + r = tfw_http_msg_expand_from_pool_lc(resp, h_name); else - r = tfw_http_msg_expand_from_pool(resp, &s_name); + r = tfw_http_msg_expand_from_pool(resp, h_name); if (unlikely(r)) return r; } - write_int(s_val.len, 0x7F, 0, &vlen); + write_int(h_val->len, 0x7F, 0, &vlen); s_vlen.data = vlen.buf; s_vlen.len = vlen.sz; r = tfw_http_msg_expand_from_pool(resp, &s_vlen); - if (unlikely(r)) return r; - if (!TFW_STR_EMPTY(&s_val)) - r = tfw_http_msg_expand_from_pool(resp, &s_val); + + if (!TFW_STR_EMPTY(h_val)) + r = tfw_http_msg_expand_from_pool(resp, h_val); return r; } @@ -3539,6 +3521,18 @@ tfw_hpack_hdr_expand(TfwHttpResp *__restrict resp, TfwStr *__restrict hdr, return tfw_hpack_str_expand(mit, iter, skb_head, &s_val, NULL); } +static inline int +__tfw_hpack_check_and_split_hdr(TfwStr *__restrict hdr, TfwStr *h_name, + TfwStr *h_val, bool trans) +{ + if (unlikely(TFW_STR_PLAIN(hdr) || TFW_STR_DUP(hdr) + || !tfw_http_hdr_split(hdr, h_name, h_val, trans) + || TFW_STR_EMPTY(h_name))) + return -EINVAL; + + return 0; +} + /** * Perform encoding of the header @hdr into the HTTP/2 HPACK format. * @@ -3565,6 +3559,7 @@ __tfw_hpack_encode(TfwHttpResp *__restrict resp, TfwStr *__restrict hdr, TfwHPackETbl *tbl = &ctx->hpack.enc_tbl; int r = HPACK_IDX_ST_NOT_FOUND; bool name_indexed = true; + TfwStr h_name = {}, h_val = {}; if (WARN_ON_ONCE(!hdr || TFW_STR_EMPTY(hdr))) return -EINVAL; @@ -3577,11 +3572,14 @@ __tfw_hpack_encode(TfwHttpResp *__restrict resp, TfwStr *__restrict hdr, T_DBG_PRINT_HPACK_RBTREE(tbl); if (!st_full_index && dyn_indexing) { - assert_spin_locked(&conn->sk->sk_lock.slock); - r = tfw_hpack_encoder_index(tbl, hdr, &index, resp->flags, - trans); - if (r < 0) + r = __tfw_hpack_check_and_split_hdr(hdr, &h_name, &h_val, + trans); + if (unlikely(r)) return r; + + assert_spin_locked(&conn->sk->sk_lock.slock); + r = tfw_hpack_encoder_index(tbl, &h_name, &h_val, + &index, resp->flags); } if (st_full_index || HPACK_IDX_RES(r) == HPACK_IDX_ST_FOUND) { @@ -3631,10 +3629,19 @@ __tfw_hpack_encode(TfwHttpResp *__restrict resp, TfwStr *__restrict hdr, name_indexed = false; encode: - if (use_pool) - r = tfw_hpack_hdr_add(resp, hdr, &idx, name_indexed, trans); - else + if (use_pool) { + if (!dyn_indexing) { + r = __tfw_hpack_check_and_split_hdr(hdr, &h_name, + &h_val, trans); + if (unlikely(r < 0)) + return r; + } + r = tfw_hpack_hdr_add(resp, &h_name, &h_val, &idx, + name_indexed, trans); + } else { r = tfw_hpack_hdr_expand(resp, hdr, &idx, name_indexed); + } + return r; } diff --git a/fw/t/unit/test_hpack.c b/fw/t/unit/test_hpack.c index 8ee320e78..35f0ff93d 100644 --- a/fw/t/unit/test_hpack.c +++ b/fw/t/unit/test_hpack.c @@ -140,24 +140,6 @@ test_h2_hdr_name(TfwStr *hdr, TfwStr *out_name) } } -/** Helper to perform string header splitting after - * tfw_hpack_rbtree_find interface change in #1920 - */ -static TfwHPackETblRes -hpack_rbtree_find(TfwHPackETbl *__restrict tbl, - const TfwStr *__restrict hdr, - const TfwHPackNode **__restrict out_node, - TfwHPackNodeIter *__restrict out_place) -{ - TfwStr h_name = {}, h_val = {}; - - /* hdr isn't changed, it's const correctess that is difficult - * to follow */ - tfw_http_hdr_split((TfwStr*)hdr, &h_name, &h_val, true); - - return tfw_hpack_rbtree_find(tbl, &h_name, &h_val, out_node, out_place); -} - /** Helper to validate rbtree invariants */ static int validator_walk(TfwHPackETbl *tree, TfwHPackNode *n, @@ -1495,6 +1477,9 @@ TEST(hpack, enc_table_index) TfwHPackNodeIter pl = {}; const TfwHPackNode *node = NULL; unsigned short index = 0; + TfwStr s1_name = {}, s1_val = {}; + TfwStr s2_name = {}, s2_val = {}; + TfwStr s3_name = {}, s3_val = {}; #define HDR_NAME_1 "test-custom-header-name" #define HDR_VALUE_1 "foo test example value" @@ -1535,34 +1520,38 @@ TEST(hpack, enc_table_index) collect_compound_str(s3, s3_value, 0); collect_compound_str(s3, s3_rws, TFW_STR_OWS); + tfw_http_hdr_split(s1, &s1_name, &s1_val, true); + tfw_http_hdr_split(s2, &s2_name, &s2_val, true); + tfw_http_hdr_split(s3, &s3_name, &s3_val, true); + tbl = &ctx.hpack.enc_tbl; /* * Prepare encoder dynamic index: add headers into the appropriate * positions of ring buffer and corresponding red-black tree. */ - res = hpack_rbtree_find(tbl, s1, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s1_name, &s1_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); - EXPECT_OK(tfw_hpack_add_node(tbl, s1, &pl, true)); + EXPECT_OK(tfw_hpack_add_node(tbl, &s1_name, &s1_val, &pl)); node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s2, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s2_name, &s2_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); EXPECT_NOT_NULL(pl.parent); if (pl.parent) - EXPECT_OK(tfw_hpack_add_node(tbl, s2, &pl, true)); + EXPECT_OK(tfw_hpack_add_node(tbl, &s2_name, &s2_val, &pl)); node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s3, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s3_name, &s3_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); EXPECT_NOT_NULL(pl.parent); if (pl.parent) - EXPECT_OK(tfw_hpack_add_node(tbl, s3, &pl, true)); + EXPECT_OK(tfw_hpack_add_node(tbl, &s3_name, &s3_val, &pl)); /* * Verify that headers had been correctly added into encoder dynamic @@ -1570,7 +1559,7 @@ TEST(hpack, enc_table_index) */ node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s1, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s1_name, &s1_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_FOUND); EXPECT_NULL(pl.parent); EXPECT_NOT_NULL(node); @@ -1583,7 +1572,7 @@ TEST(hpack, enc_table_index) node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s2, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s2_name, &s2_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_FOUND); EXPECT_NULL(pl.parent); EXPECT_NOT_NULL(node); @@ -1596,7 +1585,7 @@ TEST(hpack, enc_table_index) node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s3, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s3_name, &s3_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_FOUND); EXPECT_NULL(pl.parent); EXPECT_NOT_NULL(node); @@ -1623,6 +1612,11 @@ TEST(hpack, enc_table_rbtree) const TfwHPackNode *node = NULL; const TfwHPackNode *n1 = NULL, *n2 = NULL, *n3 = NULL; const TfwHPackNode *n4 = NULL, *n5 = NULL; + TfwStr s1_name = {}, s1_val = {}; + TfwStr s2_name = {}, s2_val = {}; + TfwStr s3_name = {}, s3_val = {}; + TfwStr s4_name = {}, s4_val = {}; + TfwStr s5_name = {}, s5_val = {}; #define HDR_NAME_1 "test-custom-name" #define HDR_VALUE_1 "test-custom-value" @@ -1658,6 +1652,12 @@ TEST(hpack, enc_table_rbtree) collect_compound_str(s5, col, 0); collect_compound_str(s5, s5_value, 0); + tfw_http_hdr_split(s1, &s1_name, &s1_val, true); + tfw_http_hdr_split(s2, &s2_name, &s2_val, true); + tfw_http_hdr_split(s3, &s3_name, &s3_val, true); + tfw_http_hdr_split(s4, &s4_name, &s4_val, true); + tfw_http_hdr_split(s5, &s5_name, &s5_val, true); + tbl = &ctx.hpack.enc_tbl; /* @@ -1678,13 +1678,13 @@ TEST(hpack, enc_table_rbtree) * node insertion, and the re-balancing procedure must be performed * during the 3rd call of @tfw_hpack_add_node() function. */ - res = hpack_rbtree_find(tbl, s1, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s1_name, &s1_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); - EXPECT_OK(tfw_hpack_add_node(tbl, s1, &pl, true)); + EXPECT_OK(tfw_hpack_add_node(tbl, &s1_name, &s1_val, &pl)); rbt_validate(tbl); bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s1, &n1, &pl); + res = tfw_hpack_rbtree_find(tbl, &s1_name, &s1_val, &n1, &pl); EXPECT_EQ(res, HPACK_IDX_ST_FOUND); EXPECT_NULL(pl.parent); EXPECT_NOT_NULL(n1); @@ -1696,32 +1696,32 @@ TEST(hpack, enc_table_rbtree) node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s2, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s2_name, &s2_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); EXPECT_NOT_NULL(pl.parent); if (pl.parent) { - EXPECT_OK(tfw_hpack_add_node(tbl, s2, &pl, true)); + EXPECT_OK(tfw_hpack_add_node(tbl, &s2_name, &s2_val, &pl)); rbt_validate(tbl); } bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s2, &n2, &pl); + res = tfw_hpack_rbtree_find(tbl, &s2_name, &s2_val, &n2, &pl); EXPECT_EQ(res, HPACK_IDX_ST_FOUND); EXPECT_NULL(pl.parent); EXPECT_NOT_NULL(n2); node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s3, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s3_name, &s3_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); EXPECT_NOT_NULL(pl.parent); if (pl.parent) { - EXPECT_OK(tfw_hpack_add_node(tbl, s3, &pl, true)); + EXPECT_OK(tfw_hpack_add_node(tbl, &s3_name, &s3_val, &pl)); rbt_validate(tbl); } bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s3, &n3, &pl); + res = tfw_hpack_rbtree_find(tbl, &s3_name, &s3_val, &n3, &pl); EXPECT_EQ(res, HPACK_IDX_ST_FOUND); EXPECT_NULL(pl.parent); EXPECT_NOT_NULL(n3); @@ -1761,16 +1761,16 @@ TEST(hpack, enc_table_rbtree) */ node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s4, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s4_name, &s4_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); EXPECT_NOT_NULL(pl.parent); if (pl.parent) { - EXPECT_OK(tfw_hpack_add_node(tbl, s4, &pl, true)); + EXPECT_OK(tfw_hpack_add_node(tbl, &s4_name, &s4_val, &pl)); rbt_validate(tbl); } bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s4, &n4, &pl); + res = tfw_hpack_rbtree_find(tbl, &s4_name, &s4_val, &n4, &pl); EXPECT_EQ(res, HPACK_IDX_ST_FOUND); EXPECT_NULL(pl.parent); EXPECT_NOT_NULL(n4); @@ -1807,16 +1807,16 @@ TEST(hpack, enc_table_rbtree) */ node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s5, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s5_name, &s5_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); EXPECT_NOT_NULL(pl.parent); if (pl.parent) { - EXPECT_OK(tfw_hpack_add_node(tbl, s5, &pl, true)); + EXPECT_OK(tfw_hpack_add_node(tbl, &s5_name, &s5_val, &pl)); rbt_validate(tbl); } bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s5, &n5, &pl); + res = tfw_hpack_rbtree_find(tbl, &s5_name, &s5_val, &n5, &pl); EXPECT_EQ(res, HPACK_IDX_ST_FOUND); EXPECT_NULL(pl.parent); EXPECT_NOT_NULL(n5); @@ -1859,7 +1859,7 @@ TEST(hpack, enc_table_rbtree) node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s3, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s3_name, &s3_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); @@ -1881,7 +1881,7 @@ TEST(hpack, enc_table_rbtree) node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s4, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s4_name, &s4_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); @@ -1903,7 +1903,7 @@ TEST(hpack, enc_table_rbtree) node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s2, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s2_name, &s2_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); @@ -1920,7 +1920,7 @@ TEST(hpack, enc_table_rbtree) node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s5, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s5_name, &s5_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); @@ -1928,7 +1928,7 @@ TEST(hpack, enc_table_rbtree) node = NULL; bzero_fast(&pl, sizeof(pl)); - res = hpack_rbtree_find(tbl, s1, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &s1_name, &s1_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); @@ -1956,6 +1956,8 @@ TEST(hpack, enc_table_eviction) char long_val[255] = "qwertyuiopqwertyuiopqwertyuiopqwertyuiopqwerty" "uiopqwertyuiopqwertyuiop"; const TfwHPackNode *node = NULL; + TfwStr f_name = {}, f_val = {}; + TfwStr l_name = {}, l_val = {}; TFW_STR(col, ":"); TFW_STR(f_hdr_val, "first header"); @@ -1966,15 +1968,19 @@ TEST(hpack, enc_table_eviction) f_hdr = make_compound_str("HeaderFirst"); collect_compound_str(f_hdr, col, 0); collect_compound_str(f_hdr, f_hdr_val, 0); - res = hpack_rbtree_find(tbl, f_hdr, &node, &pl); + tfw_http_hdr_split(f_hdr, &f_name, &f_val, true); + + res = tfw_hpack_rbtree_find(tbl, &f_name, &f_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); - EXPECT_OK(tfw_hpack_add_node(tbl, f_hdr, &pl, true)); + + EXPECT_OK(tfw_hpack_add_node(tbl, &f_name, &f_val, &pl)); bzero_fast(&pl, sizeof(pl)); for (;;) { unsigned long node_size; unsigned long new_size; + TfwStr fil_name = {}, fil_val = {}; sprintf(hdr, "Header%i", i); @@ -1990,16 +1996,19 @@ TEST(hpack, enc_table_eviction) if (new_size > tbl->window) break; - res = hpack_rbtree_find(tbl, filler, &node, &pl); + tfw_http_hdr_split(filler, &fil_name, &fil_val, true); + + res = tfw_hpack_rbtree_find(tbl, &fil_name, &fil_val, + &node, &pl); EXPECT_GT(res, HPACK_IDX_ST_FOUND); EXPECT_NULL(node); - EXPECT_OK(tfw_hpack_add_node(tbl, filler, &pl, true)); + EXPECT_OK(tfw_hpack_add_node(tbl, &fil_name, &fil_val, &pl)); bzero_fast(&pl, sizeof(pl)); bzero_fast(hdr, sizeof(hdr)); i++; } - res = hpack_rbtree_find(tbl, f_hdr, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &f_name, &f_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_FOUND); node = NULL; bzero_fast(&pl, sizeof(pl)); @@ -2008,25 +2017,29 @@ TEST(hpack, enc_table_eviction) collect_compound_str(l_hdr, col, 0); collect_compound_str(l_hdr, l_hdr_val, 0); - res = hpack_rbtree_find(tbl, l_hdr, &node, &pl); + tfw_http_hdr_split(l_hdr, &l_name, &l_val, true); + + res = tfw_hpack_rbtree_find(tbl, &l_name, &l_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); EXPECT_NULL(node); - EXPECT_OK(tfw_hpack_add_node(tbl, l_hdr, &pl, true)); + EXPECT_OK(tfw_hpack_add_node(tbl, &l_name, &l_val, &pl)); bzero_fast(&pl, sizeof(pl)); /* first header must not present. */ - res = hpack_rbtree_find(tbl, f_hdr, &node, &pl); + res = tfw_hpack_rbtree_find(tbl, &f_name, &f_val, &node, &pl); EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); } #define ADD_NODE(s, n) \ do { \ - res = hpack_rbtree_find(tbl, s, &n, &pl); \ + TfwStr s_name = {}, s_val = {}; \ + tfw_http_hdr_split(s, &s_name, &s_val, true); \ + res = tfw_hpack_rbtree_find(tbl, &s_name, &s_val, &n, &pl); \ EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); \ EXPECT_NULL(n); \ - EXPECT_OK(tfw_hpack_add_node(tbl, s, &pl, true)); \ + EXPECT_OK(tfw_hpack_add_node(tbl, &s_name, &s_val, &pl)); \ bzero_fast(&pl, sizeof(pl)); \ - res = hpack_rbtree_find(tbl, s, &n, &pl); \ + res = tfw_hpack_rbtree_find(tbl, &s_name, &s_val, &n, &pl); \ EXPECT_EQ(res, HPACK_IDX_ST_FOUND); \ EXPECT_NULL(pl.parent); \ EXPECT_NOT_NULL(n); \