Skip to content

Commit

Permalink
Update for VPP CG-NAT changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Matov authored and ivan4th committed Mar 17, 2022
1 parent 06a5e96 commit c4ed5bf
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions upf/flowtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,13 @@ format_flow (u8 * s, va_list * args)
#endif
s = format (s, "%U, UL pkt %u, DL pkt %u, "
"Forward PDR %u, Reverse PDR %u, "
"app %v, lifetime %u, proxy %d, spliced %d",
"app %v, lifetime %u, proxy %d, spliced %d nat port %d",
format_flow_key, &flow->key,
flow->stats[is_reverse].pkts,
flow->stats[is_reverse ^ FT_REVERSE].pkts,
flow_pdr_id (flow, FT_ORIGIN),
flow_pdr_id (flow, FT_REVERSE), app_name, flow->lifetime,
flow->is_l3_proxy, flow->is_spliced);
flow->is_l3_proxy, flow->is_spliced, flow->nat_sport);
#if CLIB_DEBUG > 0
s = format (s, ", dont_splice %d", flow->dont_splice);
#endif
Expand Down
1 change: 1 addition & 0 deletions upf/flowtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ typedef struct flow_entry
#if CLIB_DEBUG > 0
u32 cpu_index;
#endif
u16 nat_sport;
} flow_entry_t;

/* accessor helper */
Expand Down
17 changes: 16 additions & 1 deletion upf/upf.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,8 @@ const fib_node_vft_t upf_fp_vft = {
static clib_error_t *
upf_policy_init (vlib_main_t * vm)
{
upf_policy_fib_node_type = fib_node_register_new_type ("upf-fp", &upf_fp_vft);
upf_policy_fib_node_type =
fib_node_register_new_type ("upf-fp", &upf_fp_vft);
return (NULL);
}

Expand Down Expand Up @@ -871,6 +872,20 @@ upf_name_to_labels (u8 * name)
return rv;
}

void
upf_nat_get_src_port (vlib_buffer_t * b, u16 port)
{
flowtable_main_t *fm = &flowtable_main;
flow_entry_t *flow;
u32 flow_id;

flow_id = upf_buffer_opaque (b)->gtpu.flow_id;
flow = flowtable_get_flow (fm, flow_id);
if (!flow)
return;
flow->nat_sport = clib_net_to_host_u16 (port);
}

/*
* fd.io coding-style-patch-verification: ON
*
Expand Down
2 changes: 2 additions & 0 deletions upf/upf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,8 @@ int vnet_upf_policy_fn (fib_route_path_t * rpaths, u8 * id, u8 action);
u8 *format_upf_policy (u8 * s, va_list * args);
u8 *upf_name_to_labels (u8 * name);

__clib_export void upf_nat_get_src_port (vlib_buffer_t * b, u16 port);

#endif /* __included_upf_h__ */

/*
Expand Down
2 changes: 1 addition & 1 deletion upf/upf_pfcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ upf_delete_nat_binding (upf_session_t * sx)
--ap->used_blocks;

upf_nat_del_binding =
vlib_get_plugin_symbol ("nat_plugin.so", "nat_del_binding");
vlib_get_plugin_symbol ("nat_plugin.so", "nat_ed_del_binding");

upf_nat_del_binding (sx->user_addr);
}
Expand Down
2 changes: 1 addition & 1 deletion upf/upf_pfcp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ upf_alloc_and_assign_nat_binding (upf_nat_pool_t * np, upf_nat_addr_t * addr,
u16 block_size);

upf_nat_create_binding =
vlib_get_plugin_symbol ("nat_plugin.so", "nat_create_binding");
vlib_get_plugin_symbol ("nat_plugin.so", "nat_ed_create_binding");

port_start =
upf_nat_create_binding (user_ip, addr->ext_addr, np->min_port,
Expand Down
3 changes: 1 addition & 2 deletions vpp.spec
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
VPP_IMAGE_BASE=registry.cennso.com/upg/vpp-base:22.02-rc1-1dc3be1f4
VPP_IMAGE_BASE=registry.cennso.com/upg/vpp-base:22.02-rc1-d876422c6
VPP_IMAGE_BASE=registry.cennso.com/upg/vpp-base:22.02-rc1-2d5867d97

0 comments on commit c4ed5bf

Please sign in to comment.