Giter Site home page Giter Site logo

upf's Introduction

free5GC-UPF

Get Started

Prerequisites

Libraries used in UPF

sudo apt-get -y update
sudo apt-get -y install git gcc g++ cmake go libmnl-dev autoconf libtool libyaml-dev
go get github.com/sirupsen/logrus

Linux kernel module 5G GTP-U (Linux kernel version = 5.0.0-23-generic or version >= 5.4)

git clone https://github.com/free5gc/gtp5g.git
cd gtp5g
git checkout v0.3.2
make
sudo make install

Build

mkdir build
cd build
cmake ..
make -j`nproc`

Test

cd build/bin
./testutlt

Edit configuration file

After building from sources, edit ./build/config/upfcfg.yaml

Setup environment

[Option 1] Set up when reboot

  • (Must) IPv4 forwarding
# Uncomment lines under /etc/sysctl.conf as below
net.ipv4.ip_forward=1
  • (Recommend) Forwarding chain in iptables can forward packet
sudo apt install iptables-persistent netfilter-persistent
sudo iptables -A FORWARD -j ACCEPT
sudo netfilter-persistent save
sudo systemctl enable netfilter-persistent
sudo systemctl restart netfilter-persistent
  • (Recommend) Close ubuntu firewall
sudo systemctl stop ufw
sudo systemctl disable ufw
  • (Optional) Using NAT for UE to access data network
sudo apt install iptables-persistent netfilter-persistent
sudo iptables -t nat -A POSTROUTING -o <DN_Interface_Name> -j MASQUERADE
sudo netfilter-persistent save
sudo systemctl enable netfilter-persistent
sudo systemctl restart netfilter-persistent

[Option 2] Set up in runtime

# (Must) IPv4 forwarding
sudo sysctl -a | grep forward        # check sys rule
sudo sysctl -w net.ipv4.ip_forward=1

# (Recommend) Forwarding chain in iptables can forward packet
sudo iptables -A FORWARD -j ACCEPT

# (Recommend) Close ubuntu firewall
sudo systemctl stop ufw
sudo systemctl disable ufw

# (Optional) Using NAT for UE to access data network
sudo iptables -t nat -A POSTROUTING -o <DN_Interface_Name> -j MASQUERADE

Run

cd build
sudo -E ./bin/free5gc-upfd

To show usage: ./bin/free5gc-upfd -h

Clean the Environment (if needed)

Remove POSIX message queues

ls /dev/mqueue/
rm /dev/mqueue/*

Remove gtp devices

sudo ip l del upfgtp

upf's People

Contributors

calee0219 avatar chuchuuu avatar edingroot avatar frankie88888 avatar free5gc-org avatar ianchen0119 avatar kishiguro avatar louisroyer avatar matsumu-y avatar mohammedyaqub avatar muthuramanecs03g avatar nathalie21005 avatar parkjop avatar ryuichinamba-fj avatar shugo-h avatar susumu-yamazaki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

upf's Issues

len bug in _TlvBuildMessage()

In the _TlvBuildMessage function of pfcp_message.c, about line 437:

*lenPtr = htons(bufOffset);

should be:

*(((uint16_t *)(*bufBlkPtr)->buf)+1) = htons(bufOffset);

Otherwise, in case of len is more than 64 (BufblkBuf will be increaded to 128), the lenPtr will be zero. I reproduced this issue by simulating a larger message.

With kernel 5.4.0-73-generic(ubuntu 18.04) or newer, gtp5g failed to decap UL gtp pkts larger than 144 bytes

I have set "dbg_trace_lvl = 4;", but there were still no useful kernel messages dumped. And free5gc UPF also had no error message to see the reason why drop the UL GTP packets.
I have printed out "sk_buff->data" to kernel message, and I found "sk_buff->data" was corrupted since the byte of "next extention header type". Is there any workaround to solve this issue, instead of replacing the kernel?(it's OK with Linux kernel 5.4.0-42)
The ping test was performed with "free5gc 3.0.5"(5.4.0-73-generic or 5.4.0-77-generic) and "UERANSIM-3.2.1"(5.8.0-59-generic).
[12658.461182] upfgtp:[gtp5g] gtp5g_dellink: deregistered 5G GTP interface
[12663.635080] gtp5g: enable gtp5g on 11, 5
[12663.638400] upfgtp:[gtp5g] gtp5g_newlink: Registered a new 5G GTP interface
[12679.993822] upfgtp:[gtp5g] gtp5g_gnl_add_far: FAR-Add: id[2] success
[12679.993997] upfgtp:[gtp5g] gtp5g_gnl_add_far: FAR-Add: id[4] success
[12679.994422] upfgtp:[gtp5g] gtp5g_gnl_add_pdr: PDR-Add: id[1] success
[12679.994756] upfgtp:[gtp5g] gtp5g_gnl_add_pdr: PDR-Add: id[3] success
[12680.028290] upfgtp:[gtp5g] gtp5g_gnl_add_far: FAR-Add: update id[4] success
[12697.260816] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12697.260865] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12763.867799] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12763.867820] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12764.870294] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12764.870315] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12765.873635] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12765.873656] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12766.874944] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12766.874965] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12767.875578] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12767.875600] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12768.880723] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12768.880743] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12769.881218] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12769.881238] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12770.884266] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12770.884286] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12771.885505] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12771.885526] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12772.887002] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12772.887024] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12773.889643] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12773.889665] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12774.891166] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12774.891198] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12775.895024] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12775.895055] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12776.896408] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12776.896424] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12777.898152] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12777.898173] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12778.899750] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12778.899781] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12779.902446] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12779.902477] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12780.903726] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12780.903749] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)
[12781.906110] [gtp5g] gtp5g_push_header: SKBLen(96) GTP-U V1(8) Opt(4) DL_PDU(4)
[12781.906143] [gtp5g] gtp5g_push_header: QER Found GTP-U Flg(48) GTPU-L(96) SkbLen(104)

session->smfSeid error

In the UpfSessionAddByMessage function, below line is wrong:
session->smfSeid = (uint64_t)request->cPFSEID.value;

It should be like this:
PfcpFSeid *fSeid = (PfcpFSeid *)request->cPFSEID.value;
session->smfSeid = htobe64(fSeid->seid);

Two UPFs on same host not working (any more)

Hi,
I'm running two UPFs on the same host listening on the same interface (but on different IPs).

Unfortunately only the UPF started second will receive GTP packets. I assume the second UPF is kicking out the first UPF. I already tried the newest version of upf from the main branch together with the newest kernel module (v0.3.1).

Can someone confirm this bug?

I started them as follows:

sudo -E NFs/upf/build/bin/free5gc-upfd -f config/upfcfg_ralf.yaml &
PID_LIST+=($!)
sleep 1

sudo -E NFs/upf/build/bin/free5gc-upfd -f config/upfcfg_ims_ralf.yaml & 
PID_LIST+=($!)
sleep 1

upfcfg_ims_ralf.yaml.txt
upfcfg_ralf.yaml.txt

globalXactId maintenance error

In the PfcpXactLocalCreate function, below line:
xact->transactionId = (globalXactId == PFCP_MAX_XACT_ID ? PFCP_MIN_XACT_ID : globalXactId + 1);

should be:
xact->transactionId = (globalXactId = (globalXactId == PFCP_MAX_XACT_ID ? PFCP_MIN_XACT_ID : globalXactId + 1));

otherwise, globalXactId will NOT +1

Compile Time Errors and Segmentation Fault while running testutlt

According to the documentation while running the separate testutlt binary causes Compile Time Errors and Undefined Behavior through gdb seg fault occurs due to TestTerminate() .

mkdir build
cd build
cmake ..
make -j`nproc`
cd build/bin
./testutlt

The following is the Output.

[1/14][YamlTest] : status OK
[2/14][TimerTest] : status OK
[3/14][TimeTest] : 2022-03-31T12:49:38+05:30 [ERRO][UPF][Util] TimeConvert GMT error: need 2019-08-22 14:24:47.445585 [234 Thu], not 2019-08-22 11:54:47.445585 [234 Thu]
2022-03-31T12:49:38+05:30 [ERRO][UPF][Util] TestTime_3 fail
status error
[4/14][ThreadTest] : status OK
[5/14][PoolTest] : 2022-03-31T12:49:38+05:30 [WARN][UPF][Util] Pool is empty
2022-03-31T12:49:38+05:30 [ERRO][UPF][Util] Pool is full, it may not belong to this pool
status OK
[6/14][NetworkTest] : status OK
[7/14][MqTest] : status OK
[8/14][ListTest] : status OK
[9/14][IndexTest] : status OK
[10/14][HashTest] : status OK
[11/14][EventTest] : status OK
[12/14][DebugTest] : 2022-03-31T12:49:52+05:30 [ERRO][UPF][Util] 
status OK
[13/14][BuffTest] : status OK
[14/14][3gppTypesTest] : status OK
inside `testTerminate()`
Segmentation fault

Below is the function which causes seg fault and memory leak.
Following is the source path lib/utlt/src/utlt_test.c

Status TestTerminate() {

    for (TestNode *it = ListFirst(&testSelf.node); it != NULL; it = ListNext(it)) {
        ListRemove(it);
        free(it);
    }

    testSelf.finishCase = 0;
    testSelf.totalCase = 0;

    return STATUS_OK;
}

And memory leaks.

LEAK SUMMARY:
==20635==    definitely lost: 68,224 bytes in 8 blocks
==20635==    indirectly lost: 0 bytes in 0 blocks
==20635==      possibly lost: 2,016 bytes in 7 blocks
==20635==    still reachable: 5,168 bytes in 15 blocks
==20635==         suppressed: 0 bytes in 0 blocks
==20635== Reachable blocks (those to which a pointer was found) are not shown.

As a request would you please look into this @free5gc-org.

PFCPAssociationReleaseRequest IE in PFCPAssociationUpdateRequest

In the PFCPAssociationUpdateRequest struct of pfcp_message.h, it should not use "PFCPAssociationReleaseRequest", "PFCPAssociationReleaseRequest" struct is a message name, not an IE. It should define a new TLV for this IE, and also in the ieDescriptionTable, the "111" (the T of PFCPAssociationReleaseRequest), should also be changed (sizeof())

UPF not refactored in go

Hi there,

I was just wondering what could be the reason that UPF solely is left out in c where all other NFs are in go?
P.S. I am newbee to free5GC, no idea on inner functioning (each NF internal architecture), is there any document I can refer to get those details?

utlt_buff revise

I modified UTLT in lib / utlt / src/utlt_ buff. c file, but the source file is missing in cmake. Has anyone made it successfully?

PfcpFTeid struct typos

PfcpFTeid struct:

typedef struct _PfcpFTeid {
ENDIAN5(uint8_t spare:4;,
uint8_t chid:1;,
uint8_t ch:1;,
uint8_t v6:1;,
uint8_t v4:1;)
uint32_t teid;
union {
union {
/* GTP_F_TEID_IPV4 /
struct in_addr addr4;
/
GTP_F_TEID_IPV6 /
struct in6_addr addr6;
/
GTP_F_TEID_BOTH */
struct {
struct in_addr addr4;
struct in6_addr addr6;
} dualStack;
};
uint8_t chooseId;
};
} attribute ((packed)) PfcpFTeid;

It should be like this:

typedef struct _PfcpFTeid {
ENDIAN5(uint8_t spare:4;,
uint8_t chid:1;,
uint8_t ch:1;,
uint8_t v6:1;,
uint8_t v4:1;)
union {
struct {
uint32_t teid;
union {
/* GTP_F_TEID_IPV4 /
struct in_addr addr4;
/
GTP_F_TEID_IPV6 /
struct in6_addr addr6;
/
GTP_F_TEID_BOTH */
struct {
struct in_addr addr4;
struct in6_addr addr6;
} dualStack;
};
} channel;
uint8_t chooseId;
};
} attribute ((packed)) PfcpFTeid;

Because from the standard, teid may be not present in case of chooseId is present.

CPU load 100%+ for free5gc-upf (free5gc 3.0.4)

you once mentioned : "We’ll change the message queue to blocking in the next stage" in forum.
however,it's still in O_NONBLOCK. (upf_init.c)
static Status EventQueueInit(void *data) {
Self()->eventQ = EventQueueCreate(O_RDWR | O_NONBLOCK);
if change the value to O_RDWR | 0,the cpu load will be decrease to a reasonable value like 7%.
but,upf was terminated without any notification to logger in this status.

PfcpOuterHdr bug

This struct has bugs, since teid may be not present in case of udp/ip, and also port.

Actually this is the similar issue as F-TEID bug created by me several days ago.

UPF throw errors when more than 10 UE's are connected

Hi @free5gc-org,

I am facing an error from UPF when I am trying to add more than 10 UEs, the UPF is going down.
This issue can be fixed by multiple the buffer size by 32 which is by modifying this file /lib/utlt/src/utlt_buff.c under upf folder.
Can I take a branch and push the changes to this project?

Regards,
Nathalie wehbe

Test UPF in respect to adding/removing PDRs

I would like to ask whether there is a way to test UPF only, without the involvement of other 5G Core components (e.g. amf, smf, nssf, ..).

I have a kubernetes cluster hosted on ubuntu 20.04 worker nodes installed with gtp5g kernel module. I would like to call into UpfN4HandleSessionEstablishmentRequest from a test suite, without the need to install and configure the rest of the 5G core components and then to observe that one end of the tunnel, on the UPF side, get properly created.

Thanks.

Error While building UPF Build

hi , i am facing library linkage error while building build for UPF .
/usr/bin/ld: cannot find -lfree5GC_lib
collect2: error: ld returned 1 exit status
src/CMakeFiles/free5GC_UPF_main.dir/build.make:302: recipe for target 'src/home/anshu/cn/core_network/demo/free5GC-ARM/src/upf/build/bin/free5gc-upfd' failed
make[2]: *** [src/home/anshu/cn/core_network/demo/free5GC-ARM/src/upf/build/bin/free5gc-upfd] Error 1
CMakeFiles/Makefile2:123: recipe for target 'src/CMakeFiles/free5GC_UPF_main.dir/all' failed
make[1]: *** [src/CMakeFiles/free5GC_UPF_main.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Can you please help me how can i resolve this error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.