-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: request UPF to allocate F-TEID (#334)
* feat: request upf to allocate f-teid Signed-off-by: Guillaume Belanger <[email protected]> * fix: also implement for downlink pdr Signed-off-by: Guillaume Belanger <[email protected]> * fix: set fteid with downlink tunnel Signed-off-by: Guillaume Belanger <[email protected]> * fix: write f-teid to proper variable Signed-off-by: Guillaume Belanger <[email protected]> * chore: add unit tests Signed-off-by: Guillaume Belanger <[email protected]> * chore: add copyright info Signed-off-by: Guillaume Belanger <[email protected]> * chore: bump version Signed-off-by: Guillaume Belanger <[email protected]> * chore: use different ports to avoid conflicts Signed-off-by: Guillaume Belanger <[email protected]> * chore: re-add newline to version file Signed-off-by: Guillaume Belanger <[email protected]> * feat: store upf generated f-teid when using pfcp adapter Signed-off-by: Guillaume Belanger <[email protected]> * chore: bump go version to v1.23 Signed-off-by: Guillaume Belanger <[email protected]> * chore: add missing lock statement Signed-off-by: Guillaume Belanger <[email protected]> * chore: defer mutex unlock right away Signed-off-by: Guillaume Belanger <[email protected]> --------- Signed-off-by: Guillaume Belanger <[email protected]>
- Loading branch information
Showing
10 changed files
with
356 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.7.1-dev | ||
2.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// Copyright 2024 Canonical Ltd. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package context_test | ||
|
||
import ( | ||
"net" | ||
"testing" | ||
|
||
"github.com/omec-project/smf/context" | ||
) | ||
|
||
func TestActivateUpLinkPdr(t *testing.T) { | ||
smContext := &context.SMContext{ | ||
PDUAddress: &context.UeIpAddr{ | ||
Ip: net.IPv4(192, 168, 1, 1), | ||
}, | ||
Dnn: "internet", | ||
} | ||
|
||
defQER := &context.QER{} | ||
|
||
dpNode := &context.DataPathNode{ | ||
UPF: &context.UPF{}, | ||
UpLinkTunnel: &context.GTPTunnel{ | ||
PDR: map[string]*context.PDR{ | ||
"default": { | ||
Precedence: 0, | ||
FAR: &context.FAR{}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
err := dpNode.ActivateUpLinkPdr(smContext, defQER, 10) | ||
if err != nil { | ||
t.Errorf("expected no error, got %v", err) | ||
} | ||
|
||
pdr := dpNode.UpLinkTunnel.PDR["default"] | ||
if pdr == nil { | ||
t.Fatalf("expected pdr to be not nil") | ||
} | ||
|
||
if pdr.PDI.SourceInterface.InterfaceValue != context.SourceInterfaceAccess { | ||
t.Errorf("expected SourceInterface to be %v, got %v", context.SourceInterfaceAccess, pdr.PDI.SourceInterface.InterfaceValue) | ||
} | ||
if pdr.PDI.LocalFTeid == nil { | ||
t.Errorf("expected pdr.PDI.LocalFTeid to be not nil") | ||
} | ||
if !pdr.PDI.LocalFTeid.Ch { | ||
t.Errorf("expected pdr.PDI.LocalFTeid.Ch to be true") | ||
} | ||
if pdr.PDI.UEIPAddress == nil { | ||
t.Errorf("expected pdr.PDI.UEIPAddress to be not nil") | ||
} | ||
if !pdr.PDI.UEIPAddress.V4 { | ||
t.Errorf("expected pdr.PDI.UEIPAddress.V4 to be true") | ||
} | ||
if !pdr.PDI.UEIPAddress.Ipv4Address.Equal(net.IP{192, 168, 1, 1}) { | ||
t.Errorf("expected pdr.PDI.UEIPAddress.Ipv4Address to be %v, got %v", net.IP{192, 168, 1, 1}, pdr.PDI.UEIPAddress.Ipv4Address) | ||
} | ||
if string(pdr.PDI.NetworkInstance) != "internet" { | ||
t.Errorf("expected pdr.PDI.NetworkInstance to be 'internet', got %v", string(pdr.PDI.NetworkInstance)) | ||
} | ||
} | ||
|
||
func TestActivateDlLinkPdr(t *testing.T) { | ||
smContext := &context.SMContext{ | ||
PDUAddress: &context.UeIpAddr{ | ||
Ip: net.IP{192, 168, 1, 1}, | ||
}, | ||
Dnn: "internet", | ||
Tunnel: &context.UPTunnel{ | ||
ANInformation: struct { | ||
IPAddress net.IP | ||
TEID uint32 | ||
}{ | ||
IPAddress: net.IP{10, 0, 0, 1}, | ||
TEID: 12345, | ||
}, | ||
}, | ||
} | ||
|
||
defQER := &context.QER{} | ||
|
||
dpNode := &context.DataPathNode{ | ||
UPF: &context.UPF{}, | ||
DownLinkTunnel: &context.GTPTunnel{ | ||
PDR: map[string]*context.PDR{ | ||
"default": { | ||
Precedence: 0, | ||
FAR: &context.FAR{}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
dataPath := &context.DataPath{ | ||
FirstDPNode: dpNode, | ||
} | ||
|
||
err := dpNode.ActivateDlLinkPdr(smContext, defQER, 10, dataPath) | ||
if err != nil { | ||
t.Fatalf("expected no error, got %v", err) | ||
} | ||
|
||
pdr := dpNode.DownLinkTunnel.PDR["default"] | ||
if pdr == nil { | ||
t.Fatalf("expected pdr to be not nil") | ||
} | ||
|
||
if pdr.PDI.SourceInterface.InterfaceValue != context.SourceInterfaceCore { | ||
t.Errorf("expected SourceInterface to be %v, got %v", context.SourceInterfaceCore, pdr.PDI.SourceInterface.InterfaceValue) | ||
} | ||
if pdr.PDI.UEIPAddress == nil { | ||
t.Errorf("expected pdr.PDI.UEIPAddress to be not nil") | ||
} | ||
if !pdr.PDI.UEIPAddress.V4 { | ||
t.Errorf("expected pdr.PDI.UEIPAddress.V4 to be true") | ||
} | ||
if !pdr.PDI.UEIPAddress.Ipv4Address.Equal(net.IP{192, 168, 1, 1}) { | ||
t.Errorf("expected pdr.PDI.UEIPAddress.Ipv4Address to be %v, got %v", net.IP{192, 168, 1, 1}, pdr.PDI.UEIPAddress.Ipv4Address) | ||
} | ||
} |
Oops, something went wrong.