Commit 2a678030 authored by Luhan Wang's avatar Luhan Wang

fix TEID bugs

parent 9f1b612a
......@@ -9,3 +9,4 @@
/scripts/yq
/src/vppe/build/external/vpp-ext-deps_20.05-8_amd64*
*.pyc
set interface state GigabitEthernet2/4/0 up
set interface ip address GigabitEthernet2/4/0 192.168.30.10/24
set interface state GigabitEthernet0/9/0 up
set interface ip address GigabitEthernet0/9/0 192.168.122.78/24
create gtpu tunnel src 192.168.122.78 dst 192.168.122.1 teid 1 encap-vrf-id 0 decap-next node ip4-lookup
ip route add 192.169.0.0/24 via gtpu_tunnel0
set interface state GigabitEthernet2/5/0 up
set interface ip address GigabitEthernet2/5/0 192.168.50.10/24
ip route add 0.0.0.0/0 via GigabitEthernet2/5/0
set interface state GigabitEthernet0/a/0 up
set interface ip address GigabitEthernet0/a/0 192.168.30.10/24
ip route add 0.0.0.0/0 via GigabitEthernet0/a/0
......
gnb: 192.168.30.10
smf : 192.168.2.58
upf : 192.168.2.123
gnb: 192.168.122.78
smf : 192.168.122.197
upf : 192.168.122.88
logSize : 100
......@@ -31,7 +31,7 @@ cpu {
## Set logical CPU core where main thread runs, if main core is not set
## VPP will use core 1 if available
main-core 14
main-core 3
## Set logical CPU core(s) where worker threads are running
#corelist-workers 2-3
......@@ -97,8 +97,8 @@ dpdk {
#82576 1G
dev 0000:02:04.0
dev 0000:02:05.0
dev 0000:00:09.0
dev 0000:00:0a.0
## Whitelist specific interface by specifying PCI address and in
## addition specify custom parameters for this interface
......
......@@ -61,7 +61,7 @@ function init_configure(){
DPDK_ENTRY=$($current/yq r $yaml vpp.ip_link.gtpu_entry)
DPDK_ENTRY_PCI=$($current/yq r $yaml vpp.startup.pci_addr_id_entry)
DPDK_EXPORT_PCI=$($current/yq r $yaml vpp.startup.pci_addr_id_export)
dpdk_export_pci=$($CURRent/yq r $yaml vpp.startup.pci_addr_id_export)
DRIVE=$($current/yq r $yaml vpp.startup.drive)
}
......@@ -241,7 +241,7 @@ function main() {
shift
;;
--close)
close_vpp
close_vpp
close_n4
close_arp
# unbind
......
# Created by .ignore support plugin (hsz.mobi)
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="dataSourceStorageLocal">
<data-source name="n4" uuid="7e4f659a-4bf0-4452-8335-c266af6bc8a1">
<database-info product="SQLite" version="3.31.1" jdbc-version="2.1" driver-name="SQLite JDBC" driver-version="3.31.1" dbms="SQLITE" exact-version="3.31.1" exact-driver-version="3.31">
<identifier-quote-string>&quot;</identifier-quote-string>
</database-info>
<case-sensitivity plain-identifiers="mixed" quoted-identifiers="mixed" />
<secret-storage>master_key</secret-storage>
<auth-provider>no-auth</auth-provider>
<schema-mapping>
<introspection-scope>
<node kind="schema" qname="@" />
</introspection-scope>
</schema-mapping>
</data-source>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="n4" uuid="7e4f659a-4bf0-4452-8335-c266af6bc8a1">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/n4.db</jdbc-url>
</data-source>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<dataSource name="n4">
<database-model serializer="dbm" dbms="SQLITE" family-id="SQLITE" format-version="4.18">
<root id="1">
<ServerVersion>3.31.1</ServerVersion>
</root>
<schema id="2" parent="1" name="main">
<Current>1</Current>
</schema>
<collation id="3" parent="1" name="BINARY"/>
<collation id="4" parent="1" name="NOCASE"/>
<collation id="5" parent="1" name="RTRIM"/>
<table id="6" parent="2" name="association"/>
<table id="7" parent="2" name="sqlite_master">
<System>1</System>
</table>
<table id="8" parent="2" name="sqlite_sequence">
<System>1</System>
</table>
<column id="9" parent="6" name="id">
<Position>1</Position>
<DataType>INTEGER|0s</DataType>
<NotNull>1</NotNull>
<SequenceIdentity>1</SequenceIdentity>
</column>
<column id="10" parent="6" name="i_pv4">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
</column>
<column id="11" parent="6" name="flags">
<Position>3</Position>
<DataType>INTEGER|0s</DataType>
</column>
<column id="12" parent="6" name="version">
<Position>4</Position>
<DataType>INTEGER|0s</DataType>
<DefaultExpression>1</DefaultExpression>
</column>
<index id="13" parent="6" name="UQE_association_i_pv4">
<ColNames>i_pv4</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
<key id="14" parent="6">
<ColNames>id</ColNames>
<Primary>1</Primary>
</key>
<column id="15" parent="7" name="type">
<Position>1</Position>
<DataType>text|0s</DataType>
</column>
<column id="16" parent="7" name="name">
<Position>2</Position>
<DataType>text|0s</DataType>
</column>
<column id="17" parent="7" name="tbl_name">
<Position>3</Position>
<DataType>text|0s</DataType>
</column>
<column id="18" parent="7" name="rootpage">
<Position>4</Position>
<DataType>int|0s</DataType>
</column>
<column id="19" parent="7" name="sql">
<Position>5</Position>
<DataType>text|0s</DataType>
</column>
<column id="20" parent="8" name="name">
<Position>1</Position>
</column>
<column id="21" parent="8" name="seq">
<Position>2</Position>
</column>
</database-model>
</dataSource>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/upf-n4.iml" filepath="$PROJECT_DIR$/.idea/upf-n4.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
......@@ -18,7 +18,7 @@ import (
//var c conf.Config
var (
add = flag.String("c", "/home/wu/GOPATH/src/n4/conf/n4_config.yaml", "n4 configure file address")
add = flag.String("c", "/home/wu/GOPATH/src/n4/conf/conf.yaml", "n4 configure file address")
)
func main() {
......
gnb: 192.168.10.10
smf: 192.168.2.189
upf: 192.168.2.216
logSize: 100
\ No newline at end of file
gnb: 192.168.10.10
smf: 192.168.2.63
upf: 192.168.2.135
logSize: 100
\ No newline at end of file
#!/bin/bash
#echo $1
#echo $2
#vppctl -s /run/vpp/cli.sock create gtpu tunnel src 192.168.10.10 dst "$1" teid "$2" encap-vrf-id 0 decap-next node ip4-lookup
function create_tunnel() {
gnb_gtpu="$1"
teid="$2"
vppctl -s /run/vpp/cli.sock create gtpu tunnel src 192.168.10.10 dst $gnb_gtpu teid $teid encap-vrf-id 0 decap-next node ip4-lookup
exit 0
}
function ip_route() {
ue_ip="$1"
gtpu_name="$2"
vppctl -s /run/vpp/cli.sock ip route add $ue_ip/32 via $gtpu_name
exit 0
}
function main() {
until [ -z "$1" ]; do
case "$1" in
--create_tunnel)
create_tunnel "$2" "$3"
shift
;;
--ip_route)
ip_route "$2" "$3"
shift
;;
esac
done
exit 0
}
main "$@"
#!/bin/bash
commit_id=`git rev-parse HEAD`
commit_date=`git log --pretty=format:"%cd" $commit_id -1`
sed -i "1 i\\$commit_date" n4.log
cat n4.log
......@@ -12,7 +12,6 @@ import (
"n4/pkg/pfcp/ie"
"n4/pkg/pfcp/message"
"n4/pkg/upf/vpp"
"n4/pkg/util"
"n4/pkg/vpp/binapi/upf"
"net"
"strconv"
......@@ -20,32 +19,25 @@ import (
"time"
)
var (
ueUpTeid map[string]uint32
ueDownTeid map[string]uint32
var ueUpTeid map[string]uint32
ueSeid map[uint64]string
var ueDownTeid map[string]uint32
upTeid uint32
var ueSeid map[uint64]string
seid uint64
var upTeid uint32
gnbTeid int
var seid uint64
smfUpf map[uint64]uint64
var smfUpf map[uint64]uint64
upfSmf map[uint64]uint64
var upfSmf map[uint64]uint64
createUeIndex map[string]int
var createUeIndex map[string]int
updateUeIndex map[string]int
var updateUeIndex map[string]int
gNBIPIndex map[string]int
gNBIPTunnel map[string]string
modReqIP string // modification request ip
)
var modReqIP string // modification request ip
func init() {
ueDownTeid = make(map[string]uint32)
......@@ -55,8 +47,6 @@ func init() {
upfSmf = make(map[uint64]uint64)
createUeIndex = make(map[string]int)
updateUeIndex = make(map[string]int)
gNBIPIndex = make(map[string]int)
gNBIPTunnel = make(map[string]string)
seid = 0
}
......@@ -220,7 +210,7 @@ func handleSessionEstablishmentMsg(config *conf.Config, msgContent message.Messa
}),
},
}
startTime := time.Now()
log.Info("开始时间:" + time.Now().String())
reply := &upf.UpfSseReqReply{}
log.Info("SEID: %x", smfUpf[fseid.SEID])
......@@ -229,7 +219,9 @@ func handleSessionEstablishmentMsg(config *conf.Config, msgContent message.Messa
log.Info("UE IP Address:%s, index:%d", ueipaddress.IPv4Address, createUeIndex[ueipaddress.IPv4Address.String()])
log.Info("FAR ID:%d ", farid)
vpp.TunnelVpp(req, reply)
endTime := time.Now()
log.Info("结束时间:" + time.Now().String())
log.Info("处理时间:" + endTime.Sub(startTime).String())
//config := conf.Config{}
// Response to SMF data
......@@ -287,19 +279,17 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
forwardingParameters, _ := createFAR[2].ForwardingParameters()
//destinationInterface, _ := forwardingParameters[0].DestinationInterface()
outerHeaderCreation, _ := forwardingParameters[1].OuterHeaderCreation()
ueIP := ueipaddress.IPv4Address.String()
gnbIP := outerHeaderCreation.IPv4Address.String()
log.Info("SEID:%d", msg.SEID())
log.Info("TEID 0x%x", outerHeaderCreation.TEID)
log.Info("UE IP: %s", ueSeid[msg.SEID()])
log.Info(" FAR ID:%d", farid)
log.Info("UE IPv4:%s", ueIP)
log.Info("GNB GTPU IP:%s", gnbIP)
cause := ie.NewCause(ie.CauseRequestAccepted)
pdrid_2 := ie.NewPacketDetectionRuleID(2)
createdPDR := ie.NewCreatedPDR(pdrid_2)
startTime := time.Now()
log.Info("开始时间:" + time.Now().String())
req := &upf.UpfSsmCreateReq{
CpSeid: msg.SEID(),
Teid: outerHeaderCreation.TEID,
......@@ -310,6 +300,9 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
reply := &upf.UpfSsmCreateReq{}
vpp.TunnelVpp(req, reply)
endTime := time.Now()
log.Info("结束时间:" + time.Now().String())
log.Info("处理时间:" + endTime.Sub(startTime).String())
response, _ = message.NewSessionModificationResponse(upfSmf[msg.SEID()], msg.Header.SequenceNumber, 0, cause, createdPDR).Marshal()
} else {
......@@ -334,6 +327,8 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
log.Info("ueip %s:index %d", ueip, updateUeIndex[ueip])
log.Info("TEID 0x%x", outerHeaderCreation.TEID)
startTime := time.Now()
log.Info("开始时间:" + time.Now().String())
req := &upf.UpfSsmReq{
CpSeid: msg.SEID(),
TrafficEndpointID: upf.BuptPfcpRemoveTrafficEndpoint{
......@@ -372,7 +367,9 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
cause := ie.NewCause(ie.CauseRequestAccepted)
vpp.TunnelVpp(req, reply)
endTime := time.Now()
log.Info("结束时间:" + time.Now().String())
log.Info("处理时间:" + endTime.Sub(startTime).String())
log.Info("------------------------------outerHeaderCreation teid %d--------------------------", outerHeaderCreation.TEID)
response, _ = message.NewSessionModificationResponse(upfSmf[msg.SEID()], msg.Header.SequenceNumber, 0, cause).Marshal()
}
......
......@@ -5,21 +5,19 @@
package util
import (
"bytes"
"n4/pkg/log"
"os"
"os/exec"
)
func ExecShell(parameter ...string) string {
var (
err error
out []byte
)
func Exec_shell(s string) {
cmd := exec.Command("/bin/bash", "-c", s)
var out bytes.Buffer
cmd := exec.Command("/opt/5gc/upf/n4-beta/vpp_config.sh", parameter[0], parameter[1], parameter[2])
if out, err = cmd.Output(); err != nil {
log.Fatal(err.Error())
os.Exit(1)
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
log.Error(err.Error())
}
return string(out)
log.Info("%s", out.String())
}
......@@ -15,12 +15,13 @@ It consists of:
package upf
import (
bytes "bytes"
context "context"
"bytes"
"context"
"io"
"strconv"
struc "github.com/lunixbochs/struc"
io "io"
api "n4/pkg/vpp/api"
strconv "strconv"
)
const (
......@@ -29,7 +30,7 @@ const (
// APIVersion is the API version of this module.
APIVersion = "2.0.0"
// VersionCrc is the CRC of this module.
VersionCrc = 0x9722fbb8
VersionCrc = 0x5b132877
)
// AddressFamily represents VPP binary API enum 'address_family'.
......@@ -518,8 +519,6 @@ type BuptPfcpOuterHeaderCreation struct {
Teid uint32
IP BuptNodeValue
Port uint16
CTag uint32
STag uint32
}
func (*BuptPfcpOuterHeaderCreation) GetTypeName() string { return "bupt_pfcp_outer_header_creation" }
......@@ -765,7 +764,7 @@ func (u *BuptNodeValue) GetIP6() (a IP6Address) {
// BuptPfcpFarForwardAction represents VPP binary API union 'bupt_pfcp_far_forward_action'.
type BuptPfcpFarForwardAction struct {
XXX_UnionData [16]byte
XXX_UnionData [8]byte
}
func (*BuptPfcpFarForwardAction) GetTypeName() string { return "bupt_pfcp_far_forward_action" }
......@@ -983,13 +982,11 @@ type UpfSsmCreateReq struct {
Teid uint32
Ueip uint32
FarID uint16
GnbIP uint32
Port uint16
}
func (m *UpfSsmCreateReq) Reset() { *m = UpfSsmCreateReq{} }
func (*UpfSsmCreateReq) GetMessageName() string { return "upf_ssm_create_req" }
func (*UpfSsmCreateReq) GetCrcString() string { return "0e94f637" }
func (*UpfSsmCreateReq) GetCrcString() string { return "6c704bda" }
func (*UpfSsmCreateReq) GetMessageType() api.MessageType { return api.RequestMessage }
// UpfSsmCreateReqReply represents VPP binary API message 'upf_ssm_create_req_reply'.
......
......@@ -166,14 +166,6 @@
[
"u16",
"port"
],
[
"u32",
"c_tag"
],
[
"u32",
"s_tag"
]
],
[
......@@ -498,16 +490,8 @@
"u16",
"far_id"
],
[
"u32",
"gnb_ip"
],
[
"u16",
"port"
],
{
"crc": "0x0e94f637"
"crc": "0x6c704bda"
}
],
[
......@@ -1317,7 +1301,7 @@
"type": "vl_api_ip6_prefix_t"
}
},
"vl_api_version": "0x9722fbb8",
"vl_api_version": "0x5b132877",
"imports": [
"vnet/interface_types.api",
"vnet/ip/ip_types.api"
......
#!/bin/bash
gdb --args ./build-root/install-vpp_debug-native/vpp/bin/vpp -c ./startup_debug.conf
......@@ -2554,7 +2554,8 @@ ip4_rewrite_inline_with_gso (vlib_main_t * vm,
{
bupt_gtpu4_header->ver_flags = gtpu_dl->ver_flags;
bupt_gtpu4_header->type = gtpu_dl->type;
bupt_gtpu4_header->teid = gtpu_dl->dl_teid;
//bupt_gtpu4_header->teid = clib_net_to_host_u32(gtpu_dl->dl_teid);
bupt_gtpu4_header->teid = clib_net_to_host_u32(gtpu_dl->dl_teid);
bupt_gtpu4_header->sequence = gtpu_dl->sequence ;
bupt_gtpu4_header->pdu_number = gtpu_dl->pdu_number;
......
......@@ -3,25 +3,26 @@ unix {
log /var/log/upf/vpp/vpp.log
full-coredump
gid vpp
interactive
cli-listen /run/vpp/cli.sock
#exec test_wzy.sh
#cli-listen localhost:5002
#exec @/work/gtpu_ext/vpp_0618/config_system.sh@
exec /work/modify_teid/Buptvppe/config_system.sh
#exec /work96/test_mul_thread/upf_v0.4/upf-vpp/src/Buptvppe/config_system_v1.sh
#monitor_url http://192.168.2.216:8878/status/vpp
exec /opt/5gc/config_system.sh
logsize 100
}
api-trace {
on
#save-api-table /tmp/save_api_table
}
api-segment {
gid vpp
}
logging
{
default-log-level info
default-syslog-log-level info
}
cpu {
## In the VPP there is one main thread and optionally the user can create worker(s)
## The main thread and worker thread(s) can be pinned to CPU core(s) manually or automatically
......@@ -30,11 +31,11 @@ cpu {
## Set logical CPU core where main thread runs, if main core is not set
## VPP will use core 1 if available
main-core 2
main-core 3
## Set logical CPU core(s) where worker threads are running
#corelist-workers 7,8,9,10
#corelist-io 5,6
#corelist-workers 2-3
#corelist-io 3,4
## Automatic pinning of thread(s) to CPU core(s)
......@@ -42,12 +43,12 @@ cpu {
## Skipped CPU core(s) are not used for pinning main thread and working thread(s).
## The main thread is automatically pinned to the first available CPU core and worker(s)
## are pinned to next free CPU core(s) after core assigned to main thread
#skip-cores 4
# skip-cores 4
## Specify a number of workers to be created
## Workers are pinned to N consecutive CPU cores while skipping "skip-cores" CPU core(s)
## and main thread's CPU core
#workers 4
#workers 2
## Set scheduling policy and priority of main and worker threads
......@@ -60,36 +61,32 @@ cpu {
scheduler-priority 50
}
buffers {
# buffers {
## Increase number of buffers allocated, needed only in scenarios with
## large number of interfaces and worker threads. Value is per numa node.
## Default is 16384 (8192 if running unpriviledged)
buffers-per-numa 128000
#buffers-per-numa 2560000
# buffers-per-numa 128000
## Size of buffer data area
## Default is 2048
#default data-size 2048
default data-size 2048
}
# default data-size 2048
# }
dpdk {
## Change default settings for all interfaces
dev default {
## Number of receive queues, enables RSS
## Default is 1
num-rx-queues 1
## Number of transmit queues, Default is equal
## to number of worker threads or 1 if no workers treads
num-tx-queues 1
## Number of descriptors in transmit and receive rings
## increasing or reducing number can impact performance
## Default is 1024 for both rx and tx
num-rx-desc 1024
num-tx-desc 1024
# num-rx-desc 512
# num-tx-desc 512
## VLAN strip offload mode for interface
## Default is off
......@@ -98,29 +95,10 @@ dpdk {
## Whitelist specific interface by specifying PCI address
#82576 1G
#dev 0000:09:00.0 {
# vlan-strip-offload off
# num-rx-queues 1
# num-tx-queues 1
#}
# dev 0000:09:00.1 {
# vlan-strip-offload off
# num-rx-queues 1
# num-tx-queues 1
#}
#dev 0000:02:00.0 {
# num-rx-queues 1
# num-rx-queues 1
#}
dev 0000:06:00.1
dev 0000:06:00.0
#dev 0000:02:00.0
#dev 0000:05:00.0
#82576 1G
dev 0000:00:09.0
dev 0000:00:0a.0
## Whitelist specific interface by specifying PCI address and in
## addition specify custom parameters for this interface
......@@ -130,8 +108,8 @@ dpdk {
## Change UIO driver used by VPP, Options are: igb_uio, vfio-pci,
## uio_pci_generic or auto (default)
# uio-driver vfio-pci
uio-driver igb_uio
uio-driver vfio-pci
#uio-driver igb_uio
## Disable multi-segment buffers, improves performance but
## disables Jumbo MTU support
......@@ -139,8 +117,7 @@ dpdk {
## Change hugepages allocation per-socket, needed only if there is need for
## larger number of mbufs. Default is 256M on each detected CPU socket
#socket-mem 2048,2048
socket-mem 1024
socket-mem 2048,2048
## Disables UDP / TCP TX checksum offload. Typically needed for use
## faster vector PMDs (together with no-multi-seg)
......@@ -148,11 +125,8 @@ dpdk {
}
plugins {
path /work/modify_teid/Buptvppe/build-root/install-vpp_debug-native/vpp/lib/vpp_plugins/
#plugin default { enable }
path ./build-root/install-vpp_debug-native/vpp/lib/vpp_plugins
plugin dpdk_plugin.so { enable }
plugin gtpu_plugin.so { enable }
plugin upf_plugin.so { enable }
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment