22 #undef __included_bihash_template_h__
57 }) v4_connection_key_t;
109 make_v4_ss_kv (kv, &tc->lcl_ip.ip4, &tc->rmt_ip.ip4, tc->lcl_port,
110 tc->rmt_port, tc->proto);
117 kv->
key[0] = lcl->as_u64[0];
118 kv->
key[1] = lcl->as_u64[1];
119 kv->
key[2] = rmt->as_u64[0];
120 kv->
key[3] = rmt->as_u64[1];
130 kv->
key[0] = lcl->as_u64[0];
131 kv->
key[1] = lcl->as_u64[1];
142 kv->
key[0] = lcl->as_u64[0];
143 kv->
key[1] = lcl->as_u64[1];
154 make_v6_ss_kv (kv, &tc->lcl_ip.ip6, &tc->rmt_ip.ip6, tc->lcl_port,
155 tc->rmt_port, tc->proto);
177 st->active_fib_proto = fib_proto;
250 return clib_bihash_add_del_16_8 (&st->v4_session_hash, &kv4,
257 return clib_bihash_add_del_48_8 (&st->v6_session_hash, &kv6,
276 sep->transport_proto);
278 return clib_bihash_add_del_16_8 (&st->v4_session_hash, &kv4, 1);
283 sep->transport_proto);
285 return clib_bihash_add_del_48_8 (&st->v6_session_hash, &kv6, 1);
303 sep->transport_proto);
304 return clib_bihash_add_del_16_8 (&st->v4_session_hash, &kv4, 0);
309 sep->transport_proto);
310 return clib_bihash_add_del_48_8 (&st->v6_session_hash, &kv6, 0);
329 sep->transport_proto);
330 return clib_bihash_add_del_16_8 (&st->v4_session_hash, &kv4, 0);
335 sep->transport_proto);
336 return clib_bihash_add_del_48_8 (&st->v6_session_hash, &kv6, 0);
361 return clib_bihash_add_del_16_8 (&st->v4_session_hash, &kv4,
367 return clib_bihash_add_del_48_8 (&st->v6_session_hash, &kv6,
395 switch (action_index)
439 u32 action_index, app_index;
451 ip6_address_t * lcl,
u16 lcl_port,
452 ip6_address_t * rmt,
u16 rmt_port)
455 u32 action_index, app_index;
491 sep->transport_proto);
492 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
498 srt = &st->session_rules[sep->transport_proto];
511 sep->transport_proto);
512 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
519 srt = &st->session_rules[sep->transport_proto];
567 srt = &st->session_rules[sep->transport_proto];
577 sep->transport_proto);
578 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
589 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
602 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
612 srt = &st->session_rules[sep->transport_proto];
619 sep->transport_proto);
620 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
630 kv6.
key[0] = kv6.
key[1] = 0;
631 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
637 kv6.
key[0] = kv6.
key[1] = 0;
643 kv6.
key[4] = kv6.
key[5] = 0;
644 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
662 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
672 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
685 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
711 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
718 kv6.
key[0] = kv6.
key[1] = 0;
719 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
725 kv6.
key[0] = kv6.
key[1] = 0;
729 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
758 sep->transport_proto, 0);
761 sep->transport_proto, 0);
777 sep->transport_proto,
781 sep->transport_proto,
800 return clib_bihash_add_del_16_8 (&st->v4_half_open_hash, &kv4,
807 return clib_bihash_add_del_48_8 (&st->v6_half_open_hash, &kv6,
825 return clib_bihash_add_del_16_8 (&st->v4_half_open_hash, &kv4,
831 return clib_bihash_add_del_48_8 (&st->v6_half_open_hash, &kv6,
850 make_v4_ss_kv (&kv4, &tc->lcl_ip.ip4, &tc->rmt_ip.ip4, tc->lcl_port,
851 tc->rmt_port, tc->proto);
852 rv = clib_bihash_search_inline_16_8 (&st->v4_half_open_hash, &kv4);
858 make_v6_ss_kv (&kv6, &tc->lcl_ip.ip6, &tc->rmt_ip.ip6, tc->lcl_port,
859 tc->rmt_port, tc->proto);
860 rv = clib_bihash_search_inline_48_8 (&st->v6_half_open_hash, &kv6);
924 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
940 rv = clib_bihash_search_inline_16_8 (&st->v4_half_open_hash, &kv4);
948 rmt, lcl_port, rmt_port);
1006 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
1017 rv = clib_bihash_search_inline_16_8 (&st->v4_half_open_hash, &kv4);
1025 rmt, lcl_port, rmt_port);
1077 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
1085 rmt, lcl_port, rmt_port);
1130 ip6_address_t * rmt,
u16 lcl_port,
1145 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
1160 rv = clib_bihash_search_inline_48_8 (&st->v6_half_open_hash, &kv6);
1166 rmt, lcl_port, rmt_port);
1206 ip6_address_t * rmt,
u16 lcl_port,
u16 rmt_port,
1220 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
1229 rv = clib_bihash_search_inline_48_8 (&st->v6_half_open_hash, &kv6);
1235 rmt, lcl_port, rmt_port);
1282 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
1288 rmt, lcl_port, rmt_port);
1305 ip46_address_t * rmt,
u16 lcl_port,
u16 rmt_port,
1310 lcl_port, rmt_port,
proto);
1313 lcl_port, rmt_port,
proto);
1327 return VNET_API_ERROR_APP_INVALID_NS;
1329 if (args->scope > 3)
1330 return VNET_API_ERROR_INVALID_VALUE;
1332 if (args->transport_proto != TRANSPORT_PROTO_TCP
1333 && args->transport_proto != TRANSPORT_PROTO_UDP)
1334 return VNET_API_ERROR_INVALID_VALUE;
1338 fib_proto = args->table_args.rmt.fp_proto;
1341 srt = &st->session_rules[args->transport_proto];
1347 clib_memset (&args->table_args.lcl, 0, sizeof (args->table_args.lcl));
1348 args->table_args.lcl.fp_proto = args->table_args.rmt.fp_proto;
1349 args->table_args.lcl_port = 0;
1351 srt = &st->session_rules[args->transport_proto];
1381 v4_connection_key_t *
key = (v4_connection_key_t *) kvp->
key;
1395 &
key->dst, clib_net_to_host_u16 (
key->dst_port));
1405 clib_net_to_host_u16 (
key->src_port));
1411 typedef struct _ip4_session_table_show_ctx_t
1454 u32 proto = ~0, lcl_port, rmt_port,
action = 0, lcl_plen = 0, rmt_plen = 0;
1457 ip46_address_t lcl_ip, rmt_ip;
1458 u8 is_ip4 = 1, conn_set = 0;
1459 u8 fib_proto, is_add = 1, *ns_id = 0;
1474 else if (
unformat (input,
"appns %_%v%_", &ns_id))
1476 else if (
unformat (input,
"scope global"))
1478 else if (
unformat (input,
"scope local"))
1480 else if (
unformat (input,
"scope all"))
1485 &lcl_ip.ip4, &lcl_plen, &lcl_port,
1493 &lcl_ip.ip6, &lcl_plen, &lcl_port,
1502 else if (
unformat (input,
"tag %_%v%_", &tag))
1517 if (is_add && !conn_set &&
action == ~0)
1522 if (!is_add && !tag && !conn_set)
1550 .transport_proto =
proto,
1551 .table_args.lcl.fp_addr = lcl_ip,
1552 .table_args.lcl.fp_len = lcl_plen,
1553 .table_args.lcl.fp_proto = fib_proto,
1554 .table_args.rmt.fp_addr = rmt_ip,
1555 .table_args.rmt.fp_len = rmt_plen,
1556 .table_args.rmt.fp_proto = fib_proto,
1557 .table_args.lcl_port = lcl_port,
1558 .table_args.rmt_port = rmt_port,
1559 .table_args.action_index =
action,
1560 .table_args.is_add = is_add,
1561 .table_args.tag = tag,
1562 .appns_index = appns_index,
1577 .path =
"session rule",
1578 .short_help =
"session rule [add|del] appns <ns_id> proto <proto> "
1579 "<lcl-ip/plen> <lcl-port> <rmt-ip/plen> <rmt-port> action <action>",
1614 ip46_address_t lcl_ip, rmt_ip;
1615 u8 is_ip4 = 1, show_one = 0;
1619 u8 *ns_id = 0, fib_proto;
1629 else if (
unformat (input,
"appns %_%v%_", &ns_id))
1631 else if (
unformat (input,
"scope global"))
1633 else if (
unformat (input,
"scope local"))
1636 &lcl_ip.ip4, &lcl_plen, &lcl_port,
1644 &lcl_ip.ip6, &lcl_plen, &lcl_port,
1679 fib_index = is_ip4 ? app_ns->ip4_fib_index : app_ns->ip6_fib_index;
1708 .path =
"show session rules",
1709 .short_help =
"show session rules [<proto> appns <id> <lcl-ip/plen> "
1710 "<lcl-port> <rmt-ip/plen> <rmt-port> scope <scope>]",