Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
oai-upf-6g
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
oai-upf-6g
Commits
d96026a6
Commit
d96026a6
authored
Apr 14, 2025
by
Franck Messaoudi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update: update the code to retrieve the class_id
parent
ad9f9b6b
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
144 additions
and
249 deletions
+144
-249
src/upf_app/bpf/rules/pdr/pfcp_session_lookup_xdp_kernel.c
src/upf_app/bpf/rules/pdr/pfcp_session_lookup_xdp_kernel.c
+36
-34
src/upf_app/bpf/rules/qer/qer_tc_kernel.c
src/upf_app/bpf/rules/qer/qer_tc_kernel.c
+103
-200
src/upf_app/programs/qer_tc_user.cpp
src/upf_app/programs/qer_tc_user.cpp
+5
-15
No files found.
src/upf_app/bpf/rules/pdr/pfcp_session_lookup_xdp_kernel.c
View file @
d96026a6
...
...
@@ -174,7 +174,7 @@ static __always_inline u32 match_sdf_filter_ipv4(
/*---------------------------------------------------------------------------------------------------------------*/
static
__always_inline
u32
create_outer_header_gtpu_ipv4
(
struct
xdp_md
*
ctx
,
pfcp_far_t_
*
p_far
)
{
create_outer_header_gtpu_ipv4
(
struct
xdp_md
*
ctx
,
pfcp_far_t_
*
p_far
,
u8
qfi
)
{
// Adjust space to the left.
if
(
bpf_xdp_adjust_head
(
ctx
,
(
int32_t
)
-
GTP_ENCAPSULATED_SIZE
))
{
return
DROP
;
...
...
@@ -218,14 +218,14 @@ create_outer_header_gtpu_ipv4(struct xdp_md* ctx, pfcp_far_t_* p_far) {
*/
struct
ethhdr
*
ethh
=
data
;
if
((
void
*
)
(
ethh
+
1
)
>
data_end
)
{
bpf_debug
(
"Error: Invalid Ethernet
packet
"
);
bpf_debug
(
"Error: Invalid Ethernet
header
"
);
return
DROP
;
}
struct
ethhdr
*
ethh_orig
=
data
+
GTP_ENCAPSULATED_SIZE
;
if
((
void
*
)
(
ethh_orig
+
1
)
>
data_end
)
{
bpf_debug
(
"Error: Invalid Ethernet copy
packet
"
);
bpf_debug
(
"Error: Invalid Ethernet copy
header
"
);
return
DROP
;
}
__builtin_memcpy
(
ethh
,
ethh_orig
,
sizeof
(
*
ethh
));
...
...
@@ -324,7 +324,7 @@ create_outer_header_gtpu_ipv4(struct xdp_md* ctx, pfcp_far_t_* p_far) {
p_gtpu_ext_h
->
message_length
=
GTP_EXT_MSG_LEN
;
p_gtpu_ext_h
->
pdu_type
=
GTP_EXT_PDU_TYPE
;
// p_gtpu_ext_h->qfi = GTP_EXT_QFI;
p_gtpu_ext_h
->
qfi
=
GTP_DEFAULT_QFI
;
p_gtpu_ext_h
->
qfi
=
qfi
;
//
GTP_DEFAULT_QFI;
p_gtpu_ext_h
->
next_ext_type
=
GTP_EXT_NEXT_EXT_TYPE
;
/*
...
...
@@ -340,7 +340,7 @@ create_outer_header_gtpu_ipv4(struct xdp_md* ctx, pfcp_far_t_* p_far) {
}
bpf_debug
(
"Pushes the GTP-Encapsulated
P
acket: Data/UDP/IP/EXT/GTP/UDP/IP/ETH"
);
"Pushes the GTP-Encapsulated
p
acket: Data/UDP/IP/EXT/GTP/UDP/IP/ETH"
);
return
SUCCESS
;
}
...
...
@@ -353,7 +353,7 @@ remove_outer_header_gtpu_ipv4(struct xdp_md* ctx, pfcp_far_t_* far) {
struct
ethhdr
*
ethh
=
data
;
if
((
void
*
)
(
ethh
+
1
)
>
data_end
)
{
bpf_debug
(
"Error: Invalid Ethernet
packet
"
);
bpf_debug
(
"Error: Invalid Ethernet
header
"
);
return
DROP
;
}
...
...
@@ -366,7 +366,7 @@ remove_outer_header_gtpu_ipv4(struct xdp_md* ctx, pfcp_far_t_* far) {
struct
ethhdr
*
new_ethh
=
data
+
GTP_ENCAPSULATED_SIZE
;
if
((
void
*
)
new_ethh
+
sizeof
(
*
new_ethh
)
>
data_end
)
{
bpf_debug
(
"Error: Invalid Ethernet copy
packet
"
);
bpf_debug
(
"Error: Invalid Ethernet copy
header
"
);
return
DROP
;
}
__builtin_memcpy
(
new_ethh
,
ethh
,
sizeof
(
*
ethh
));
...
...
@@ -378,7 +378,7 @@ remove_outer_header_gtpu_ipv4(struct xdp_md* ctx, pfcp_far_t_* far) {
bpf_map_lookup_elem
(
&
m_upf_interfaces
,
&
n6_key
);
if
(
!
map_element
)
{
bpf_debug
(
"N6 interface is missing in UPF map
,
Drop the packet"
);
bpf_debug
(
"N6 interface is missing in UPF map
.
Drop the packet"
);
return
FAILURE
;
}
...
...
@@ -388,7 +388,7 @@ remove_outer_header_gtpu_ipv4(struct xdp_md* ctx, pfcp_far_t_* far) {
map_entry
=
bpf_map_lookup_elem
(
&
m_arp_table
,
&
upf_n6_ip
);
if
(
!
map_entry
)
{
bpf_debug
(
"N6's Next Hop MAC address not found
!
Drop the packet"
);
bpf_debug
(
"N6's Next Hop MAC address not found
.
Drop the packet"
);
return
FAILURE
;
}
...
...
@@ -425,13 +425,13 @@ static __always_inline struct session_id* pfcp_session_lookup_over_n3(
case
ETH_P_IP
:
{
struct
iphdr
*
iph
=
(
struct
iphdr
*
)
(
ethh
+
1
);
if
((
void
*
)
(
iph
+
1
)
>
data_end
)
{
bpf_debug
(
"Error: Invalid IPv4
Packet
"
);
bpf_debug
(
"Error: Invalid IPv4
header
"
);
return
NULL
;
}
struct
udphdr
*
udph
=
(
struct
udphdr
*
)
(
iph
+
1
);
if
((
void
*
)
(
udph
+
1
)
>
data_end
)
{
bpf_debug
(
"Error: Invalid UDP
packet
"
);
bpf_debug
(
"Error: Invalid UDP
header
"
);
return
NULL
;
}
...
...
@@ -444,7 +444,7 @@ static __always_inline struct session_id* pfcp_session_lookup_over_n3(
struct
gtpuhdr
*
gtpuh
=
(
struct
gtpuhdr
*
)
(
udph
+
1
);
if
((
void
*
)
gtpuh
+
sizeof
(
*
gtpuh
)
>
data_end
)
{
bpf_debug
(
"Error: Invalid GTP-U
packet
"
);
bpf_debug
(
"Error: Invalid GTP-U
header
"
);
return
NULL
;
}
...
...
@@ -459,13 +459,13 @@ static __always_inline struct session_id* pfcp_session_lookup_over_n3(
(
struct
gtpu_extn_pdu_session_container
*
)
(
gtpuh
+
1
);
if
((
void
*
)
(
ext_gtpuh
+
1
)
>
data_end
)
{
bpf_debug
(
"Error: Invalid GTPU Extension
packet
"
);
bpf_debug
(
"Error: Invalid GTPU Extension
header
"
);
return
NULL
;
}
struct
iphdr
*
iph_inner
=
(
struct
iphdr
*
)
(
ext_gtpuh
+
1
);
if
((
void
*
)
(
iph_inner
+
1
)
>
data_end
)
{
bpf_debug
(
"Error: Invalid Inner IP
packet
"
);
bpf_debug
(
"Error: Invalid Inner IP
header
"
);
return
NULL
;
}
...
...
@@ -474,24 +474,24 @@ static __always_inline struct session_id* pfcp_session_lookup_over_n3(
return
bpf_map_lookup_elem
(
&
m_session_mapping
,
ue_ip_out
);
}
case
ETH_P_IPV6
:
{
bpf_debug
(
"Error: Unsupported IPv6
P
acket"
);
bpf_debug
(
"Error: Unsupported IPv6
p
acket"
);
return
NULL
;
}
case
ETH_P_ARP
:
{
bpf_debug
(
"Info: This is an ARP
P
acket"
);
bpf_debug
(
"Info: This is an ARP
p
acket"
);
return
NULL
;
}
case
ETH_P_8021Q
:
{
bpf_debug
(
"Info: This is a VLAN
P
acket"
);
bpf_debug
(
"Info: This is a VLAN
p
acket"
);
return
NULL
;
}
case
ETH_P_8021AD
:
{
bpf_debug
(
"This is a VLAN
P
acket"
);
bpf_debug
(
"This is a VLAN
p
acket"
);
return
NULL
;
}
default:
{
bpf_debug
(
"Error: Unknown L3
P
acket"
);
bpf_debug
(
"Error: Unknown L3
p
acket"
);
return
NULL
;
}
}
...
...
@@ -554,8 +554,8 @@ static __always_inline pfcp_pdr_t_* pfcp_session_s_lookup_precedence_over_n3(
static
__always_inline
u32
apply_rules_matching_pdr_over_n3
(
struct
xdp_md
*
ctx
,
struct
ethhdr
*
ethh
,
struct
pdrs_per_session
key_rules_matching_pdr
)
{
void
*
data
=
(
void
*
)
(
long
)
ctx
->
data
;
void
*
data_end
=
(
void
*
)
(
long
)
ctx
->
data_end
;
//
void* data = (void*) (long) ctx->data;
//
void* data_end = (void*) (long) ctx->data_end;
struct
rules_match_pdr
*
rules
=
{
0
};
u64
seid
=
key_rules_matching_pdr
.
seid
;
...
...
@@ -573,7 +573,7 @@ static __always_inline u32 apply_rules_matching_pdr_over_n3(
int
ret
=
remove_outer_header_gtpu_ipv4
(
ctx
,
far
);
switch
(
ret
)
{
case
SUCCESS
:
{
bpf_debug
(
"Redirecting
P
acket to DN"
);
bpf_debug
(
"Redirecting
p
acket to DN"
);
return
REDIRECT
;
}
case
FAILURE
:
{
...
...
@@ -582,7 +582,7 @@ static __always_inline u32 apply_rules_matching_pdr_over_n3(
}
case
DROP
:
{
bpf_debug
(
"DROP: remove_outer_header_gtpu_ipv4() fails for session %llu
!
"
"DROP: remove_outer_header_gtpu_ipv4() fails for session %llu
.
"
"Drop packet"
,
seid
);
return
DROP
;
...
...
@@ -604,7 +604,7 @@ static __always_inline u32 apply_rules_matching_pdr_over_n3(
//--------------------------------------------------------------------------------------
static
__always_inline
u32
apply_rules_matching_pdr_over_n6
(
struct
xdp_md
*
ctx
,
struct
ethhdr
*
ethh
,
struct
pdrs_per_session
key_rules_matching_pdr
)
{
struct
pdrs_per_session
key_rules_matching_pdr
,
u8
qfi
)
{
struct
rules_match_pdr
*
rules
=
{
0
};
u64
seid
=
key_rules_matching_pdr
.
seid
;
...
...
@@ -619,7 +619,7 @@ static __always_inline u32 apply_rules_matching_pdr_over_n6(
if
(
far
)
{
bpf_debug
(
"FAR ID = %d"
,
far
->
far_id
.
far_id
);
int
ret
=
create_outer_header_gtpu_ipv4
(
ctx
,
far
);
int
ret
=
create_outer_header_gtpu_ipv4
(
ctx
,
far
,
qfi
);
switch
(
ret
)
{
case
SUCCESS
:
{
u32
*
qos_enabling
=
bpf_map_lookup_elem
(
&
m_qos_enabling
,
&
seid
);
...
...
@@ -639,7 +639,7 @@ static __always_inline u32 apply_rules_matching_pdr_over_n6(
}
case
DROP
:
{
bpf_debug
(
"DROP: create_outer_header_gtpu_ipv4() fails for session %llu
!
"
"DROP: create_outer_header_gtpu_ipv4() fails for session %llu
.
"
"Drop packet"
,
seid
);
return
DROP
;
...
...
@@ -670,7 +670,7 @@ static __always_inline struct session_id* pfcp_session_lookup_over_n6(
case
ETH_P_IP
:
{
struct
iphdr
*
iph
=
(
struct
iphdr
*
)
(
ethh
+
1
);
if
((
void
*
)
(
iph
+
1
)
>
data_end
)
{
bpf_debug
(
"Error: Invalid IPv4
Packet
"
);
bpf_debug
(
"Error: Invalid IPv4
header
"
);
return
NULL
;
}
...
...
@@ -729,24 +729,24 @@ static __always_inline struct session_id* pfcp_session_lookup_over_n6(
return
session
;
}
case
ETH_P_IPV6
:
{
bpf_debug
(
"Error: Unsupported IPv6
P
acket"
);
bpf_debug
(
"Error: Unsupported IPv6
p
acket"
);
return
NULL
;
}
case
ETH_P_ARP
:
{
bpf_debug
(
"Info: This is an ARP
P
acket"
);
bpf_debug
(
"Info: This is an ARP
p
acket"
);
return
NULL
;
}
case
ETH_P_8021Q
:
{
bpf_debug
(
"Info: This is a VLAN
P
acket"
);
bpf_debug
(
"Info: This is a VLAN
p
acket"
);
return
NULL
;
}
case
ETH_P_8021AD
:
{
bpf_debug
(
"This is a VLAN
P
acket"
);
bpf_debug
(
"This is a VLAN
p
acket"
);
return
NULL
;
}
default:
{
bpf_debug
(
"Error: Unknown L3
P
acket"
);
bpf_debug
(
"Error: Unknown L3
p
acket"
);
return
NULL
;
}
}
...
...
@@ -1032,7 +1032,8 @@ int xdp_handle_shaping(struct xdp_md* ctx) {
key_rules_matching_pdr
.
pdr_id
=
pdr_id
;
key_rules_matching_pdr
.
seid
=
seid
;
u32
ret
=
apply_rules_matching_pdr_over_n6
(
ctx
,
ethh
,
key_rules_matching_pdr
);
u32
ret
=
apply_rules_matching_pdr_over_n6
(
ctx
,
ethh
,
key_rules_matching_pdr
,
qfi
);
switch
(
ret
)
{
case
PASS
:
{
...
...
@@ -1124,7 +1125,8 @@ int xdp_handle_downlink(struct xdp_md* ctx) {
key_rules_matching_pdr
.
pdr_id
=
pdr_id
;
key_rules_matching_pdr
.
seid
=
seid
;
u32
ret
=
apply_rules_matching_pdr_over_n6
(
ctx
,
ethh
,
key_rules_matching_pdr
);
u32
ret
=
apply_rules_matching_pdr_over_n6
(
ctx
,
ethh
,
key_rules_matching_pdr
,
qfi
);
switch
(
ret
)
{
case
REDIRECT
:
{
...
...
src/upf_app/bpf/rules/qer/qer_tc_kernel.c
View file @
d96026a6
This diff is collapsed.
Click to expand it.
src/upf_app/programs/qer_tc_user.cpp
View file @
d96026a6
...
...
@@ -31,6 +31,7 @@
#include <bpf/libbpf.h>
#include <bpf/bpf.h>
#include "sdf_filter.h"
#ifndef UDP_INTERFACE
#define UDP_INTERFACE UserPlaneComponent::getInstance().getUDPInterface()
...
...
@@ -54,10 +55,10 @@
#endif // MAX_CEIL
#endif // DEFAULT_CEIL
#ifndef BUILD_DIRECTORY
#define BUILD_DIRECTORY
\
"build/upf/build/upf_app/bpf/CMakeFiles/qer_tc.dir/rules/qer"
#endif // BUILD_DIRECTORY
//
#ifndef BUILD_DIRECTORY
// #define BUILD_DIRECTORY
\
//
"build/upf/build/upf_app/bpf/CMakeFiles/qer_tc.dir/rules/qer"
//
#endif // BUILD_DIRECTORY
static
int
verbose
=
1
;
...
...
@@ -159,17 +160,6 @@ std::shared_ptr<pfcp::pfcp_pdr> QERProgram::get_pdr_by_qer_id(
return
(
it
!=
pdr_map
.
end
())
?
it
->
second
:
nullptr
;
}
/*---------------------------------------------------------------------------------------------------------------*/
static
inline
uint16_t
generate_minor_id
(
uint64_t
seid
,
uint8_t
qfi
)
{
uint16_t
hash
=
(
seid
^
(
seid
>>
16
)
^
(
seid
>>
32
)
^
(
seid
>>
48
));
uint16_t
minor_id
=
(
hash
+
(
qfi
*
37
))
&
0xFFFF
;
// Avoid modulo, use bitmask
// Limit minor_id to a max of 9999
minor_id
=
(
minor_id
>
9999
)
?
9999
:
minor_id
;
return
minor_id
?
minor_id
:
1
;
// Ensure nonzero
}
/*---------------------------------------------------------------------------------------------------------------*/
void
QERProgram
::
setup
(
uint64_t
seid
,
std
::
vector
<
std
::
shared_ptr
<
pfcp
::
pfcp_qer
>>
pQer
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment