summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/ip')
-rw-r--r--src/vnet/ip/ip.api13
-rw-r--r--src/vnet/ip/ip_api.c49
-rw-r--r--src/vnet/ip/lookup.c55
-rw-r--r--src/vnet/ip/lookup.h4
4 files changed, 121 insertions, 0 deletions
diff --git a/src/vnet/ip/ip.api b/src/vnet/ip/ip.api
index a34f0d0305f..954ec92967f 100644
--- a/src/vnet/ip/ip.api
+++ b/src/vnet/ip/ip.api
@@ -673,6 +673,19 @@ autoreply define ip_container_proxy_add_del
u8 is_add;
};
+define ip_container_proxy_dump
+{
+ u32 client_index;
+ u32 context;
+};
+
+define ip_container_proxy_details
+{
+ u32 context;
+ u32 sw_if_index;
+ vl_api_prefix_t prefix;
+};
+
/** \brief Configure IP source and L4 port-range check
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index 91832a07e09..4355d11e792 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -45,6 +45,7 @@
#include <vnet/ip/ip4_reassembly.h>
#include <vnet/ip/ip6_reassembly.h>
#include <vnet/ethernet/arp.h>
+#include <vnet/ip/ip_types_api.h>
#include <vnet/vnet_msg_enum.h>
@@ -102,6 +103,7 @@ _(SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable ) \
_(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \
sw_interface_ip6_set_link_local_address) \
_(IP_CONTAINER_PROXY_ADD_DEL, ip_container_proxy_add_del) \
+_(IP_CONTAINER_PROXY_DUMP, ip_container_proxy_dump) \
_(IOAM_ENABLE, ioam_enable) \
_(IOAM_DISABLE, ioam_disable) \
_(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
@@ -1944,6 +1946,53 @@ static void
REPLY_MACRO (VL_API_IP_CONTAINER_PROXY_ADD_DEL_REPLY);
}
+typedef struct ip_container_proxy_walk_ctx_t_
+{
+ vl_api_registration_t *reg;
+ u32 context;
+} ip_container_proxy_walk_ctx_t;
+
+static int
+ip_container_proxy_send_details (const fib_prefix_t * pfx, u32 sw_if_index,
+ void *args)
+{
+ vl_api_ip_container_proxy_details_t *mp;
+ ip_container_proxy_walk_ctx_t *ctx = args;
+
+ mp = vl_msg_api_alloc (sizeof (*mp));
+ if (!mp)
+ return 1;
+
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = ntohs (VL_API_IP_CONTAINER_PROXY_DETAILS);
+ mp->context = ctx->context;
+
+ mp->sw_if_index = ntohl (sw_if_index);
+ ip_prefix_encode (pfx, &mp->prefix);
+
+ vl_api_send_msg (ctx->reg, (u8 *) mp);
+
+ return 1;
+}
+
+static void
+vl_api_ip_container_proxy_dump_t_handler (vl_api_ip_container_proxy_dump_t *
+ mp)
+{
+ vl_api_registration_t *reg;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ ip_container_proxy_walk_ctx_t ctx = {
+ .context = mp->context,
+ .reg = reg,
+ };
+
+ ip_container_proxy_walk (ip_container_proxy_send_details, &ctx);
+}
+
static void
vl_api_ioam_enable_t_handler (vl_api_ioam_enable_t * mp)
{
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c
index 42509972a98..017ca0db39b 100644
--- a/src/vnet/ip/lookup.c
+++ b/src/vnet/ip/lookup.c
@@ -1321,6 +1321,61 @@ ip_container_proxy_is_set (fib_prefix_t * pfx, u32 sw_if_index)
return (l3p->l3p_sw_if_index == sw_if_index);
}
+typedef struct ip_container_proxy_walk_ctx_t_
+{
+ ip_container_proxy_cb_t cb;
+ void *ctx;
+} ip_container_proxy_walk_ctx_t;
+
+static fib_table_walk_rc_t
+ip_container_proxy_fib_table_walk (fib_node_index_t fei, void *arg)
+{
+ ip_container_proxy_walk_ctx_t *ctx = arg;
+ const fib_prefix_t *pfx;
+ const dpo_id_t *dpo;
+ load_balance_t *lb;
+ l3_proxy_dpo_t *l3p;
+
+ pfx = fib_entry_get_prefix (fei);
+ if (fib_entry_is_sourced (fei, FIB_SOURCE_PROXY))
+ {
+ dpo = fib_entry_contribute_ip_forwarding (fei);
+ lb = load_balance_get (dpo->dpoi_index);
+ dpo = load_balance_get_bucket_i (lb, 0);
+ l3p = l3_proxy_dpo_get (dpo->dpoi_index);
+ ctx->cb (pfx, l3p->l3p_sw_if_index, ctx->ctx);
+ }
+
+ return FIB_TABLE_WALK_CONTINUE;
+}
+
+void
+ip_container_proxy_walk (ip_container_proxy_cb_t cb, void *ctx)
+{
+ fib_table_t *fib_table;
+ ip_container_proxy_walk_ctx_t wctx = {
+ .cb = cb,
+ .ctx = ctx,
+ };
+
+ /* *INDENT-OFF* */
+ pool_foreach (fib_table, ip4_main.fibs,
+ ({
+ fib_table_walk(fib_table->ft_index,
+ FIB_PROTOCOL_IP4,
+ ip_container_proxy_fib_table_walk,
+ &wctx);
+ }));
+ pool_foreach (fib_table, ip6_main.fibs,
+ ({
+ fib_table_walk(fib_table->ft_index,
+ FIB_PROTOCOL_IP6,
+ ip_container_proxy_fib_table_walk,
+ &wctx);
+ }));
+ /* *INDENT-ON* */
+}
+
clib_error_t *
ip_container_cmd (vlib_main_t * vm,
unformat_input_t * main_input, vlib_cli_command_t * cmd)
diff --git a/src/vnet/ip/lookup.h b/src/vnet/ip/lookup.h
index 93e1e029b41..374023835f4 100644
--- a/src/vnet/ip/lookup.h
+++ b/src/vnet/ip/lookup.h
@@ -236,6 +236,10 @@ typedef struct _vnet_ip_container_proxy_args
clib_error_t *vnet_ip_container_proxy_add_del (vnet_ip_container_proxy_args_t
* args);
+typedef int (*ip_container_proxy_cb_t) (const fib_prefix_t * pfx,
+ u32 sw_if_index, void *ctx);
+void ip_container_proxy_walk (ip_container_proxy_cb_t cb, void *ctx);
+
void ip_lookup_init (ip_lookup_main_t * lm, u32 ip_lookup_node_index);
#endif /* included_ip_lookup_h */