diff options
author | Filip Varga <fivarga@cisco.com> | 2022-02-23 15:45:48 -0800 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2022-04-01 13:26:04 +0000 |
commit | 691c630b79ec2230b67944c8a9f77f95b49d95ad (patch) | |
tree | c27778fb111ef4d85d3c712ee0b68b0574f26d82 /src/plugins/nat/nat44-ed/nat44_ed_api.c | |
parent | b68108203a59e12f4b4435caba164072e234f0aa (diff) |
nat: VRF routing & FIB improvements
This patch affects how destination fib is choosen during session
creation. Default behavior of choosing fib based on output
interfaces is kept.
Configuration gives you the ability to change default behavior
to direct or restrict traffic between different FIB tables.
NAT specific VRF routing options:
a) keeping communication in the same VRF
b) option to add multiple destination VRFs
c) option to control the resolution order of destination VRFs
TX FIB resolution is based on looking up RX FIB entry in NATs
VRF table and picking the first FIB that resolves
destination address.
Ticket: VPP-2009
Type: improvement
Change-Id: If500c48d7ce3466533ad9581c0847870788fc4fb
Signed-off-by: Filip Varga <fivarga@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat44-ed/nat44_ed_api.c')
-rw-r--r-- | src/plugins/nat/nat44-ed/nat44_ed_api.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed_api.c b/src/plugins/nat/nat44-ed/nat44_ed_api.c index f4ba2bc9e8e..19e497e00c2 100644 --- a/src/plugins/nat/nat44-ed/nat44_ed_api.c +++ b/src/plugins/nat/nat44-ed/nat44_ed_api.c @@ -1194,6 +1194,79 @@ vl_api_nat44_show_running_config_t_handler ( })); } +static void +vl_api_nat44_ed_add_del_vrf_table_t_handler ( + vl_api_nat44_ed_add_del_vrf_table_t *mp) +{ + snat_main_t *sm = &snat_main; + vl_api_nat44_ed_add_del_vrf_table_reply_t *rmp; + int rv = nat44_ed_add_del_vrf_table (clib_net_to_host_u32 (mp->table_vrf_id), + mp->is_add); + REPLY_MACRO (VL_API_NAT44_ED_ADD_DEL_VRF_TABLE); +} + +static void +vl_api_nat44_ed_add_del_vrf_route_t_handler ( + vl_api_nat44_ed_add_del_vrf_route_t *mp) +{ + snat_main_t *sm = &snat_main; + vl_api_nat44_ed_add_del_vrf_route_reply_t *rmp; + int rv = + nat44_ed_add_del_vrf_route (clib_net_to_host_u32 (mp->table_vrf_id), + clib_net_to_host_u32 (mp->vrf_id), mp->is_add); + REPLY_MACRO (VL_API_NAT44_ED_ADD_DEL_VRF_ROUTE); +} + +static void +nat44_ed_vrf_tables_send_details (vl_api_registration_t *rp, u32 context, + vrf_table_t *t) +{ + snat_main_t *sm = &snat_main; + vl_api_nat44_ed_vrf_tables_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 = + ntohs (VL_API_NAT44_ED_VRF_TABLES_DETAILS + sm->msg_id_base); + mp->context = context; + mp->n_vrf_ids = clib_host_to_net_u32 (vec_len (t->routes)); + + pool_foreach (r, t->routes) + { + vec_add1 (vrf_ids, 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) +{ + 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 (rp, mp->context, t); + } +} + /* user (internal host) key */ typedef struct { |