Skip to content

Commit

Permalink
do not send ipfix record without port
Browse files Browse the repository at this point in the history
  • Loading branch information
mogaika committed Feb 9, 2024
1 parent 5f8b3bd commit 644cf51
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions upf/upf.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ typedef struct
#define FAR_BUFFER 0x0004
#define FAR_NOTIFY_CP 0x0008
#define FAR_DUPLICATE 0x0010
#define FAR_NAT 0x8000

union
{
Expand Down
8 changes: 4 additions & 4 deletions upf/upf_classify.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,16 @@ upf_acl_classify_return (vlib_main_t *vm, u32 teid, flow_entry_t *flow,
return next;
}

// returns direction which has upload direction
// returns uplink traffic direction, or FLOW_ENTRY_UPLINK_DIRECTION_UNDEFINED
// if impossible to detect
always_inline flow_direction_t
upf_classify_detect_flow_direction (vlib_buffer_t *b, struct rules *r,
flow_direction_t direction, bool *found)
{
// Here we rely on the fact that interface of type ACCESS is one which
// directed to UE
// TODO: it should be possible save this value per PDR since it has this
// values available
// TODO: it should be possible to calculate and save this value per PDR
// during session creation/modification

*found = false;

Expand Down Expand Up @@ -584,7 +585,6 @@ upf_classify_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
next = upf_acl_classify_forward (
vm, upf_buffer_opaque (b)->gtpu.teid, flow, active, is_ip4,
&upf_buffer_opaque (b)->gtpu.pdr_idx);

if (reclassify_proxy_flow) /* for app detection */
{
if (upf_buffer_opaque (b)->gtpu.is_proxied)
Expand Down
6 changes: 1 addition & 5 deletions upf/upf_forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,7 @@ upf_forward (vlib_main_t *vm, vlib_node_runtime_t *node, const char *node_name,
&vnet_buffer (b)->sw_if_index[VLIB_RX],
&vnet_buffer (b)->sw_if_index[VLIB_TX]);
}
vnet_buffer (b)->sw_if_index[VLIB_TX] =
(upf_main.nwis + far->forward.nwi_index)
->fib_index[is_ip4 ? FIB_PROTOCOL_IP4 :
FIB_PROTOCOL_IP6];
next = UPF_FORWARD_NEXT_IP_LOOKUP;
next = UPF_FORWARD_NEXT_IP_INPUT;

/*
* Forwarding Policy can override the normal FAR processing
Expand Down
3 changes: 3 additions & 0 deletions upf/upf_ipfix.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ upf_ipfix_flow_init (flow_entry_t *f)
if (!up_far)
return false;

if (up_far->apply_action & FAR_NAT && f->nat_sport == 0)
return false;

if (pool_is_free_index (gtm->nwis, up_far->forward.nwi_index))
return false;

Expand Down
10 changes: 3 additions & 7 deletions upf/upf_pfcp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,7 @@ handle_create_far (upf_session_t *sx, pfcp_ie_create_far_t *create_far,
vec_dup (far->forwarding_parameters.nat_port_block);
rc = handle_nat_binding_creation (sx, pool_name, response);
vec_free (pool_name);
create->apply_action |= FAR_NAT;
if (rc)
{
far_error (response, far,
Expand Down Expand Up @@ -1571,14 +1572,9 @@ handle_create_far (upf_session_t *sx, pfcp_ie_create_far_t *create_far,
}

if (ISSET_BIT (far->grp.fields, CREATE_FAR_TP_IPFIX_POLICY))
{
create->ipfix_policy =
upf_ipfix_lookup_policy (far->ipfix_policy, 0);
}
create->ipfix_policy = upf_ipfix_lookup_policy (far->ipfix_policy, 0);
else
{
create->ipfix_policy = UPF_IPFIX_POLICY_UNSPECIFIED;
}
create->ipfix_policy = UPF_IPFIX_POLICY_UNSPECIFIED;
}

pfcp_sort_fars (rules);
Expand Down

0 comments on commit 644cf51

Please sign in to comment.