Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-UPF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
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
OpenXG-UPF
Commits
061832ae
Commit
061832ae
authored
Mar 18, 2021
by
wangyongshou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize multiple GNB multiple GTPU TUNNEL codes
parent
0f7e1add
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
79 deletions
+75
-79
src/vppe/src/plugins/upf/upf_api.c
src/vppe/src/plugins/upf/upf_api.c
+75
-79
No files found.
src/vppe/src/plugins/upf/upf_api.c
View file @
061832ae
...
...
@@ -54,9 +54,9 @@ unix_main_t *um = &unix_main;
extern
vlib_main_t
vlib_global_main
;
extern
bupt_ueip_dl_gtpu4_header_t
*
bupt_ueip_dl_gtpu4_header
;
//Gtpu N3 interface index 1 ;
#define UPF_BUF 1024
const
u32
gtpu_n3_dst_sw_if_index
=
1
;
#define GTPU_TUNNEL "create gtpu tunnel src %s dst %s teid %u encap-vrf-id 0 decap-next node ip4-lookup\n"
...
...
@@ -65,35 +65,33 @@ const u32 gtpu_n3_dst_sw_if_index = 1;
void
upf_ip4_to_str
(
u32
ip4addr
,
char
*
str
,
const
u16
buf_len
)
{
u32
addr1_1
=
ip4addr
>>
24
;
// 提取第一部分IP地址
u32
addr1_1
=
ip4addr
>>
24
;
ip4addr
=
ip4addr
<<
8
;
u32
addr1_2
=
ip4addr
>>
24
;
// 提取第二部分IP地址
u32
addr1_2
=
ip4addr
>>
24
;
ip4addr
=
ip4addr
<<
8
;
u32
addr1_3
=
ip4addr
>>
24
;
// 提取第三部分IP地址
u32
addr1_3
=
ip4addr
>>
24
;
ip4addr
=
ip4addr
<<
8
;
u32
addr1_4
=
ip4addr
>>
24
;
// 提取第四部分IP地址
u32
addr1_4
=
ip4addr
>>
24
;
snprintf
(
str
,
buf_len
,
"%u.%u.%u.%u"
,
addr1_1
,
addr1_2
,
addr1_3
,
addr1_4
);
}
void
upf_create_gtpu_tunnel
(
const
u32
n3_local_ip
,
const
u32
n3_remote_ip
,
const
u32
teid
,
char
*
gtpu_name
)
{
#define BUF_LEN 1024
vlib_main_t
*
vm
=
&
vlib_global_main
;
u8
*
buf
=
NULL
;
char
n3_local
[
UPF_BUF
]
=
{
0
};
char
n3_remote
[
UPF_BUF
]
=
{
0
};
vlib_main_t
*
vm
=
&
vlib_global_main
;
char
n3_local
[
1024
]
=
{
0
};
char
n3_remote
[
1024
]
=
{
0
};
upf_ip4_to_str
(
n3_local_ip
,
n3_local
,
1024
);
upf_ip4_to_str
(
n3_remote_ip
,
n3_remote
,
1024
);
upf_ip4_to_str
(
n3_local_ip
,
n3_local
,
UPF_BUF
);
upf_ip4_to_str
(
n3_remote_ip
,
n3_remote
,
UPF_BUF
);
char
cmd
[
BUF_LEN
]
=
{
0
}
;
snprintf
(
cmd
,
BUF_LEN
,
GTPU_TUNNEL
,
n3_local
,
n3_remote
,
teid
);
snprintf
(
cmd
,
UPF_BUF
,
GTPU_TUNNEL
,
n3_local
,
n3_remote
,
teid
);
unformat_input_t
sub_input
;
vec_resize
(
buf
,
BUF_LEN
);
vec_resize
(
buf
,
UPF_BUF
);
//vec_copy(buf, cmd);
...
...
@@ -105,7 +103,7 @@ void upf_create_gtpu_tunnel(const u32 n3_local_ip, const u32 n3_remote_ip, const
unformat_init_vector
(
&
sub_input
,
buf
);
vlib_cli_input
(
vm
,
&
sub_input
,
0
,
0
);
clib_upf_debug
(
um
->
log_fd
,
"len:%d,name:%s"
,
sub_input
.
index
,
sub_input
.
buffer
);
//
clib_upf_debug(um->log_fd, "len:%d,name:%s", sub_input.index, sub_input.buffer);
strncpy
(
gtpu_name
,
(
char
*
)
sub_input
.
buffer
,
sub_input
.
index
);
...
...
@@ -115,19 +113,17 @@ void upf_create_gtpu_tunnel(const u32 n3_local_ip, const u32 n3_remote_ip, const
}
void
upf_create_ip_route
(
const
u32
ue_ip
,
const
char
*
gtpu_name
)
{
#define BUF_LEN 1024
vlib_main_t
*
vm
=
&
vlib_global_main
;
u8
*
buf
=
NULL
;
char
cmd
[
BUF_LEN
]
=
{
0
};
char
ueaddr
[
BUF_LEN
]
=
{
0
};
upf_ip4_to_str
(
ue_ip
,
ueaddr
,
BUF_LEN
);
char
cmd
[
UPF_BUF
]
=
{
0
};
char
ueaddr
[
UPF_BUF
]
=
{
0
};
snprintf
(
cmd
,
BUF_LEN
,
IP_ROUTE
,
ueaddr
,
gtpu_name
);
vlib_main_t
*
vm
=
&
vlib_global_main
;
upf_ip4_to_str
(
ue_ip
,
ueaddr
,
UPF_BUF
);
snprintf
(
cmd
,
UPF_BUF
,
IP_ROUTE
,
ueaddr
,
gtpu_name
);
unformat_input_t
sub_input
;
vec_resize
(
buf
,
BUF_LEN
);
vec_resize
(
buf
,
UPF_BUF
);
strncpy
((
char
*
)
buf
,
cmd
,
strlen
(
cmd
));
clib_upf_debug
(
um
->
log_fd
,
"
\n\n
***** Startup Config *****
\n\n
%s
\n
***** End Startup Config *****
\n\n
"
,
cmd
);
...
...
@@ -142,7 +138,7 @@ void upf_create_ip_route(const u32 ue_ip, const char *gtpu_name)
}
}
static
void
static
void
upf_ip_udp_gtpu_rewrite
(
/*upf_far_forward_t * ff */
upf_far_t
*
ff
,
u32
fib_index
,
int
is_ip4
)
{
union
...
...
@@ -157,8 +153,8 @@ upf_ip_udp_gtpu_rewrite (/*upf_far_forward_t * ff */upf_far_t *ff, u32 fib_index
vec_validate_aligned
(
r
.
rw
,
len
-
1
,
CLIB_CACHE_LINE_BYTES
);
char
n3_local
[
1024
]
=
{
0
};
char
n3_remote
[
1024
]
=
{
0
};
//
char n3_local[1024] = {0};
//
char n3_remote[1024] = {0};
udp_header_t
*
udp
=
NULL
;
gtpu_header_t
*
gtpu
=
NULL
;
...
...
@@ -185,8 +181,8 @@ upf_ip_udp_gtpu_rewrite (/*upf_far_forward_t * ff */upf_far_t *ff, u32 fib_index
ip
->
dst_address
=
ff
->
forward
.
outer_header_creation
.
ip
.
ip4
;
upf_ip4_to_str
(
clib_net_to_host_u32
(
ip
->
src_address
.
data_u32
),
n3_local
,
1024
);
upf_ip4_to_str
(
clib_net_to_host_u32
(
ip
->
dst_address
.
data_u32
),
n3_remote
,
1024
);
//
upf_ip4_to_str(clib_net_to_host_u32(ip->src_address.data_u32), n3_local, 1024);
//
upf_ip4_to_str(clib_net_to_host_u32(ip->dst_address.data_u32), n3_remote, 1024);
/* we fix up the ip4 header length and checksum after-the-fact */
ip
->
checksum
=
ip4_header_checksum
(
ip
);
...
...
@@ -214,7 +210,7 @@ upf_ip_udp_gtpu_rewrite (/*upf_far_forward_t * ff */upf_far_t *ff, u32 fib_index
gtpu
->
type
=
GTPU_TYPE_GTPU
;
gtpu
->
teid
=
clib_host_to_net_u32
(
ff
->
forward
.
outer_header_creation
.
teid
);
clib_upf_debug
(
um
->
log_fd
,
"src_ip:%s, dst_ip:%s, ff:%p"
,
n3_local
,
n3_remote
,
ff
);
//
clib_upf_debug(um->log_fd,"src_ip:%s, dst_ip:%s, ff:%p", n3_local, n3_remote, ff);
ff
->
forward
.
rewrite
=
r
.
rw
;
...
...
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