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;
242 return clib_bihash_add_del_16_8 (&st->v4_session_hash, &kv4,
249 return clib_bihash_add_del_48_8 (&st->v6_session_hash, &kv6,
268 sep->transport_proto);
270 return clib_bihash_add_del_16_8 (&st->v4_session_hash, &kv4, 1);
275 sep->transport_proto);
277 return clib_bihash_add_del_48_8 (&st->v6_session_hash, &kv6, 1);
295 sep->transport_proto);
296 return clib_bihash_add_del_16_8 (&st->v4_session_hash, &kv4, 0);
301 sep->transport_proto);
302 return clib_bihash_add_del_48_8 (&st->v6_session_hash, &kv6, 0);
321 sep->transport_proto);
322 return clib_bihash_add_del_16_8 (&st->v4_session_hash, &kv4, 0);
327 sep->transport_proto);
328 return clib_bihash_add_del_48_8 (&st->v6_session_hash, &kv6, 0);
353 return clib_bihash_add_del_16_8 (&st->v4_session_hash, &kv4,
359 return clib_bihash_add_del_48_8 (&st->v6_session_hash, &kv6,
387 switch (action_index)
431 u32 action_index, app_index;
443 ip6_address_t * lcl,
u16 lcl_port,
444 ip6_address_t * rmt,
u16 rmt_port)
447 u32 action_index, app_index;
483 sep->transport_proto);
484 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
490 srt = &st->session_rules[sep->transport_proto];
503 sep->transport_proto);
504 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
511 srt = &st->session_rules[sep->transport_proto];
559 srt = &st->session_rules[sep->transport_proto];
569 sep->transport_proto);
570 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
581 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
594 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
604 srt = &st->session_rules[sep->transport_proto];
611 sep->transport_proto);
612 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
622 kv6.
key[0] = kv6.
key[1] = 0;
623 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
629 kv6.
key[0] = kv6.
key[1] = 0;
635 kv6.
key[4] = kv6.
key[5] = 0;
636 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
654 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
664 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
677 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
703 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
710 kv6.
key[0] = kv6.
key[1] = 0;
711 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
717 kv6.
key[0] = kv6.
key[1] = 0;
721 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
750 sep->transport_proto, 0);
753 sep->transport_proto, 0);
769 sep->transport_proto,
773 sep->transport_proto,
792 return clib_bihash_add_del_16_8 (&st->v4_half_open_hash, &kv4,
799 return clib_bihash_add_del_48_8 (&st->v6_half_open_hash, &kv6,
817 return clib_bihash_add_del_16_8 (&st->v4_half_open_hash, &kv4,
823 return clib_bihash_add_del_48_8 (&st->v6_half_open_hash, &kv6,
842 make_v4_ss_kv (&kv4, &tc->lcl_ip.ip4, &tc->rmt_ip.ip4, tc->lcl_port,
843 tc->rmt_port, tc->proto);
844 rv = clib_bihash_search_inline_16_8 (&st->v4_half_open_hash, &kv4);
850 make_v6_ss_kv (&kv6, &tc->lcl_ip.ip6, &tc->rmt_ip.ip6, tc->lcl_port,
851 tc->rmt_port, tc->proto);
852 rv = clib_bihash_search_inline_48_8 (&st->v6_half_open_hash, &kv6);
916 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
932 rv = clib_bihash_search_inline_16_8 (&st->v4_half_open_hash, &kv4);
940 rmt, lcl_port, rmt_port);
998 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
1009 rv = clib_bihash_search_inline_16_8 (&st->v4_half_open_hash, &kv4);
1017 rmt, lcl_port, rmt_port);
1069 rv = clib_bihash_search_inline_16_8 (&st->v4_session_hash, &kv4);
1077 rmt, lcl_port, rmt_port);
1122 ip6_address_t * rmt,
u16 lcl_port,
1137 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
1152 rv = clib_bihash_search_inline_48_8 (&st->v6_half_open_hash, &kv6);
1158 rmt, lcl_port, rmt_port);
1198 ip6_address_t * rmt,
u16 lcl_port,
u16 rmt_port,
1212 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
1221 rv = clib_bihash_search_inline_48_8 (&st->v6_half_open_hash, &kv6);
1227 rmt, lcl_port, rmt_port);
1274 rv = clib_bihash_search_inline_48_8 (&st->v6_session_hash, &kv6);
1280 rmt, lcl_port, rmt_port);
1297 ip46_address_t * rmt,
u16 lcl_port,
u16 rmt_port,
1302 lcl_port, rmt_port,
proto);
1305 lcl_port, rmt_port,
proto);
1319 return VNET_API_ERROR_APP_INVALID_NS;
1321 if (args->scope > 3)
1322 return VNET_API_ERROR_INVALID_VALUE;
1324 if (args->transport_proto != TRANSPORT_PROTO_TCP
1325 && args->transport_proto != TRANSPORT_PROTO_UDP)
1326 return VNET_API_ERROR_INVALID_VALUE;
1330 fib_proto = args->table_args.rmt.fp_proto;
1333 srt = &st->session_rules[args->transport_proto];
1339 clib_memset (&args->table_args.lcl, 0, sizeof (args->table_args.lcl));
1340 args->table_args.lcl.fp_proto = args->table_args.rmt.fp_proto;
1341 args->table_args.lcl_port = 0;
1343 srt = &st->session_rules[args->transport_proto];
1373 v4_connection_key_t *
key = (v4_connection_key_t *) kvp->
key;
1387 &
key->dst, clib_net_to_host_u16 (
key->dst_port));
1397 clib_net_to_host_u16 (
key->src_port));
1403 typedef struct _ip4_session_table_show_ctx_t
1446 u32 proto = ~0, lcl_port, rmt_port,
action = 0, lcl_plen = 0, rmt_plen = 0;
1448 ip46_address_t lcl_ip, rmt_ip;
1449 u8 is_ip4 = 1, conn_set = 0;
1450 u8 fib_proto, is_add = 1, *ns_id = 0;
1465 else if (
unformat (input,
"appns %_%v%_", &ns_id))
1467 else if (
unformat (input,
"scope global"))
1469 else if (
unformat (input,
"scope local"))
1471 else if (
unformat (input,
"scope all"))
1476 &lcl_ip.ip4, &lcl_plen, &lcl_port,
1484 &lcl_ip.ip6, &lcl_plen, &lcl_port,
1493 else if (
unformat (input,
"tag %_%v%_", &tag))
1505 if (is_add && !conn_set &&
action == ~0)
1510 if (!is_add && !tag && !conn_set)
1538 .transport_proto =
proto,
1539 .table_args.lcl.fp_addr = lcl_ip,
1540 .table_args.lcl.fp_len = lcl_plen,
1541 .table_args.lcl.fp_proto = fib_proto,
1542 .table_args.rmt.fp_addr = rmt_ip,
1543 .table_args.rmt.fp_len = rmt_plen,
1544 .table_args.rmt.fp_proto = fib_proto,
1545 .table_args.lcl_port = lcl_port,
1546 .table_args.rmt_port = rmt_port,
1547 .table_args.action_index =
action,
1548 .table_args.is_add = is_add,
1549 .table_args.tag = tag,
1550 .appns_index = appns_index,
1563 .path =
"session rule",
1564 .short_help =
"session rule [add|del] appns <ns_id> proto <proto> "
1565 "<lcl-ip/plen> <lcl-port> <rmt-ip/plen> <rmt-port> action <action>",
1600 ip46_address_t lcl_ip, rmt_ip;
1601 u8 is_ip4 = 1, show_one = 0;
1605 u8 *ns_id = 0, fib_proto;
1615 else if (
unformat (input,
"appns %_%v%_", &ns_id))
1617 else if (
unformat (input,
"scope global"))
1619 else if (
unformat (input,
"scope local"))
1622 &lcl_ip.ip4, &lcl_plen, &lcl_port,
1630 &lcl_ip.ip6, &lcl_plen, &lcl_port,
1665 fib_index = is_ip4 ? app_ns->ip4_fib_index : app_ns->ip6_fib_index;
1694 .path =
"show session rules",
1695 .short_help =
"show session rules [<proto> appns <id> <lcl-ip/plen> "
1696 "<lcl-port> <rmt-ip/plen> <rmt-port> scope <scope>]",