Skip to content

Commit

Permalink
Add vendor-specific IE for IPFIX template selection
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 51b1cc0 commit 27b608e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 deletions.
5 changes: 4 additions & 1 deletion test/e2e/framework/sessionconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ func (cfg SessionConfig) outerHeaderRemoval() *ie.IE {
// Enterprise Specific IE Types are marked with 0x8000 mask
const (
BBF_EID = 3561
TP_EID = 18681
ETYPE_MASK = 0x8000
BBF_TYPE_APPLY_ACTION = 15
BBF_TYPE_NAT_PORT_BLOCK = 18
BBF_APPLY_ACTION_NAT = 1
TP_IPFIX_TEMPLATE = 11
)

func newVendorSpecificStringIE(itype uint16, eid uint16, data string) *ie.IE {
Expand Down Expand Up @@ -129,7 +131,8 @@ func (cfg SessionConfig) forwardFAR(farID uint32) *ie.IE {
return ie.NewCreateFAR(
ie.NewFARID(farID),
ie.NewApplyAction(pfcp.ApplyAction_FORW),
ie.NewForwardingParameters(fwParams...))
ie.NewForwardingParameters(fwParams...),
newVendorSpecificStringIE(ETYPE_MASK|TP_IPFIX_TEMPLATE, TP_EID, "testing"))
}

func (cfg SessionConfig) reverseFAR(farID uint32) *ie.IE {
Expand Down
16 changes: 16 additions & 0 deletions upf/pfcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4755,6 +4755,11 @@ encode_alternative_smf_ip_address (void *p, u8 ** vec)
#define decode_tp_line_number decode_u32_ie
#define encode_tp_line_number encode_u32_ie

#define format_tp_ipfix_policy format_simple_vec_ie
#define decode_tp_ipfix_policy decode_simple_vec_ie
#define encode_tp_ipfix_policy encode_simple_vec_ie
#define free_tp_ipfix_policy free_simple_vec_ie

/* BBF Encoder-decoder */

//BBF NAT port block
Expand Down Expand Up @@ -5015,6 +5020,11 @@ static struct pfcp_group_ie_def pfcp_create_far_group[] =
.type = PFCP_IE_BAR_ID,
.offset = offsetof(pfcp_create_far_t, bar_id)
},
[CREATE_FAR_TP_IPFIX_POLICY] = {
.type = PFCP_IE_TP_IPFIX_POLICY,
.vendor = VENDOR_TRAVELPING,
.offset = offsetof(pfcp_create_far_t, ipfix_policy)
},
};

static struct pfcp_group_ie_def pfcp_forwarding_parameters_group[] =
Expand Down Expand Up @@ -5321,6 +5331,11 @@ static struct pfcp_group_ie_def pfcp_update_far_group[] =
.type = PFCP_IE_BAR_ID,
.offset = offsetof(pfcp_update_far_t, bar_id)
},
[UPDATE_FAR_TP_IPFIX_POLICY] = {
.type = PFCP_IE_TP_IPFIX_POLICY,
.vendor = VENDOR_TRAVELPING,
.offset = offsetof(pfcp_update_far_t, ipfix_policy)
},
};

static struct pfcp_group_ie_def pfcp_update_forwarding_parameters_group[] =
Expand Down Expand Up @@ -6949,6 +6964,7 @@ static struct pfcp_ie_def vendor_tp_specs[] =
SIMPLE_IE_FREE(PFCP_IE_TP_ERROR_MESSAGE, tp_error_message, "TP: Error Message"),
SIMPLE_IE_FREE(PFCP_IE_TP_FILE_NAME, tp_file_name, "TP: File Name"),
SIMPLE_IE(PFCP_IE_TP_LINE_NUMBER, tp_line_number, "TP: Line Number"),
SIMPLE_IE_FREE(PFCP_IE_TP_IPFIX_POLICY, tp_ipfix_policy, "TP: IPFIX Policy"),
};

static struct pfcp_ie_def vendor_bbf_specs[] =
Expand Down
11 changes: 9 additions & 2 deletions upf/pfcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,9 @@ typedef u32 pfcp_tp_line_number_t;

#define PFCP_IE_TP_CREATED_NAT_BINDING 10

#define PFCP_IE_TP_IPFIX_POLICY 11
typedef u8 *pfcp_tp_ipfix_policy_t;

/* Grouped PFCP Information Elements */

enum
Expand Down Expand Up @@ -1581,7 +1584,8 @@ enum
CREATE_FAR_FORWARDING_PARAMETERS,
CREATE_FAR_DUPLICATING_PARAMETERS,
CREATE_FAR_BAR_ID,
CREATE_FAR_LAST = CREATE_FAR_BAR_ID
CREATE_FAR_TP_IPFIX_POLICY,
CREATE_FAR_LAST = CREATE_FAR_TP_IPFIX_POLICY
};

typedef struct
Expand All @@ -1593,6 +1597,7 @@ typedef struct
pfcp_forwarding_parameters_t forwarding_parameters;
pfcp_duplicating_parameters_t duplicating_parameters;
pfcp_bar_id_t bar_id;
pfcp_tp_ipfix_policy_t ipfix_policy;
} pfcp_create_far_t;

enum
Expand All @@ -1602,7 +1607,8 @@ enum
UPDATE_FAR_UPDATE_FORWARDING_PARAMETERS,
UPDATE_FAR_UPDATE_DUPLICATING_PARAMETERS,
UPDATE_FAR_BAR_ID,
UPDATE_FAR_LAST = UPDATE_FAR_BAR_ID
UPDATE_FAR_TP_IPFIX_POLICY,
UPDATE_FAR_LAST = UPDATE_FAR_TP_IPFIX_POLICY
};

typedef struct
Expand All @@ -1614,6 +1620,7 @@ typedef struct
pfcp_update_forwarding_parameters_t update_forwarding_parameters;
pfcp_update_duplicating_parameters_t update_duplicating_parameters;
pfcp_bar_id_t bar_id;
pfcp_tp_ipfix_policy_t ipfix_policy;
} pfcp_update_far_t;

enum
Expand Down
1 change: 1 addition & 0 deletions upf/upf.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ typedef struct
upf_far_forward_t forward;
u16 bar_id;
};
pfcp_tp_ipfix_policy_t ipfix_policy;
} upf_far_t;

typedef struct
Expand Down
3 changes: 3 additions & 0 deletions upf/upf_pfcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ pfcp_free_far (upf_far_t * far)
free_redirect_information (&far->forward.redirect_information);
if (far->forward.flags & FAR_F_FORWARDING_POLICY)
vec_free (far->forward.forwarding_policy.identifier);
vec_free (far->ipfix_policy);
}

int
Expand All @@ -784,6 +785,8 @@ pfcp_make_pending_far (upf_session_t * sx)
clib_memset (&new->forward.redirect_information, 0,
sizeof (new->forward.redirect_information));

new->ipfix_policy = vec_dup (old->ipfix_policy);

if (!(old->apply_action & FAR_FORWARD))
continue;

Expand Down
5 changes: 5 additions & 0 deletions upf/upf_pfcp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,9 @@ handle_create_far (upf_session_t * sx, pfcp_create_far_t * create_far,
}
} //TODO: header_enrichment
}

if (ISSET_BIT (far->grp.fields, CREATE_FAR_TP_IPFIX_POLICY))
create->ipfix_policy = vec_dup (far->ipfix_policy);
}

pfcp_sort_fars (rules);
Expand Down Expand Up @@ -1736,6 +1739,8 @@ handle_update_far (upf_session_t * sx, pfcp_update_far_t * update_far,
}
//TODO: header_enrichment
}
if (ISSET_BIT (far->grp.fields, UPDATE_FAR_TP_IPFIX_POLICY))
update->ipfix_policy = vec_dup (far->ipfix_policy);
}

return 0;
Expand Down

0 comments on commit 27b608e

Please sign in to comment.