aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDaniel Béreš <daniel.beres@pantheon.tech>2023-03-24 02:33:49 -0700
committerOle Tr�an <otroan@employees.org>2023-04-13 08:03:59 +0000
commitd9df1650385cd784429d3a49bffa673c450c643e (patch)
tree7509a4b65c2722538987050b802aeb2c71ade9b4 /src/plugins
parent6bec05b56dde182e4427f567828a6954a3a34995 (diff)
nat: adding a new api nat44_ed_vrf_tables_v2_dump
Adding api nat44_ed_vrf_tables_v2_dump which may replace nat44_ed_vrf_tables_dump in the future. - fixing endianess Type: improvement Signed-off-by: Daniel Béreš <daniel.beres@pantheon.tech> Change-Id: I40d09ea3252589bdcb61db9f1629dacd87f69978
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed.api26
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed_api.c50
2 files changed, 76 insertions, 0 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed.api b/src/plugins/nat/nat44-ed/nat44_ed.api
index dbcb15d8add..ad4ad698be0 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed.api
+++ b/src/plugins/nat/nat44-ed/nat44_ed.api
@@ -235,6 +235,7 @@ autoreply define nat44_ed_add_del_vrf_route {
define nat44_ed_vrf_tables_dump {
u32 client_index;
u32 context;
+ option deprecated;
};
/** \brief NAT44-ED inter VRF NAT routing table details response
@@ -248,6 +249,31 @@ define nat44_ed_vrf_tables_details {
u32 table_vrf_id;
u32 n_vrf_ids;
u32 vrf_ids[n_vrf_ids];
+ option deprecated;
+};
+
+/** \brief Dump NAT44-ED inter VRF NAT routing tables
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+*/
+define nat44_ed_vrf_tables_v2_dump {
+ u32 client_index;
+ u32 context;
+ option status="in_progress";
+};
+
+/** \brief NAT44-ED inter VRF NAT routing table details response
+ @param context - sender context, to match reply w/ request
+ @param table_vrf_id - id of the VRF NAT routing table
+ @param n_vrf_ids - number of vrf_ids
+ @param vrf_ids - ids of resolving destination (tx) VRFs
+*/
+define nat44_ed_vrf_tables_v2_details {
+ u32 context;
+ u32 table_vrf_id;
+ u32 n_vrf_ids;
+ u32 vrf_ids[n_vrf_ids];
+ option status="in_progress";
};
/** \brief Set TCP MSS rewriting configuration
diff --git a/src/plugins/nat/nat44-ed/nat44_ed_api.c b/src/plugins/nat/nat44-ed/nat44_ed_api.c
index 681fcc0a50b..1f01410afce 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed_api.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed_api.c
@@ -1250,6 +1250,38 @@ nat44_ed_vrf_tables_send_details (vl_api_registration_t *rp, u32 context,
}
static void
+nat44_ed_vrf_tables_send_details_v2 (vl_api_registration_t *rp, u32 context,
+ vrf_table_t *t)
+{
+ snat_main_t *sm = &snat_main;
+ vl_api_nat44_ed_vrf_tables_v2_details_t *mp;
+
+ u32 *vrf_ids = 0;
+ vrf_route_t *r;
+
+ mp = vl_msg_api_alloc_zero (sizeof (*mp) +
+ sizeof (mp->vrf_ids[0]) * vec_len (t->routes));
+ mp->_vl_msg_id = clib_net_to_host_u16 (VL_API_NAT44_ED_VRF_TABLES_DETAILS +
+ sm->msg_id_base);
+ mp->context = context;
+ mp->n_vrf_ids = clib_net_to_host_u32 (vec_len (t->routes));
+ mp->table_vrf_id = clib_net_to_host_u32 (t->table_vrf_id);
+ pool_foreach (r, t->routes)
+ {
+ vec_add1 (vrf_ids, clib_net_to_host_u32 (r->vrf_id));
+ }
+
+ // copy the records
+ clib_memcpy (mp->vrf_ids, vrf_ids,
+ sizeof (mp->vrf_ids[0]) * vec_len (t->routes));
+
+ vec_free (vrf_ids);
+
+ // send the message
+ vl_api_send_msg (rp, (u8 *) mp);
+}
+
+static void
vl_api_nat44_ed_vrf_tables_dump_t_handler (
vl_api_nat44_ed_vrf_tables_dump_t *mp)
{
@@ -1267,6 +1299,24 @@ vl_api_nat44_ed_vrf_tables_dump_t_handler (
}
}
+static void
+vl_api_nat44_ed_vrf_tables_v2_dump_t_handler (
+ vl_api_nat44_ed_vrf_tables_v2_dump_t *mp)
+{
+ snat_main_t *sm = &snat_main;
+ vl_api_registration_t *rp;
+ vrf_table_t *t;
+
+ rp = vl_api_client_index_to_registration (mp->client_index);
+ if (rp == 0)
+ return;
+
+ pool_foreach (t, sm->vrf_tables)
+ {
+ nat44_ed_vrf_tables_send_details_v2 (rp, mp->context, t);
+ }
+}
+
/* user (internal host) key */
typedef struct
{