Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flow description should accept token "assigned" #41

Merged
merged 4 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/davecgh/go-spew v1.1.1
github.com/free5gc/go-gtp5gnl v1.4.6-0.20230629034810-9a49c0a5ee2f
github.com/free5gc/util v1.0.5-0.20230823103219-e511c4fd20ef
github.com/free5gc/util v1.0.5-0.20231012123940-85f4557167be
github.com/hashicorp/go-version v1.6.0
github.com/khirono/go-genl v1.0.1
github.com/khirono/go-nl v1.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/free5gc/go-gtp5gnl v1.4.6-0.20230629034810-9a49c0a5ee2f h1:+D0L2ixhbg6Iy/oQEAJQLmOU/w1mmndqVF78GdjX1yo=
github.com/free5gc/go-gtp5gnl v1.4.6-0.20230629034810-9a49c0a5ee2f/go.mod h1:TT5aXB90NuSPMehuIK9lV2yJFnq6Qjw37ZqNB1QAKh0=
github.com/free5gc/util v1.0.5-0.20230823103219-e511c4fd20ef h1:ne0EMnst7wbLoaY2Uvn/2Kvp/KkXKMQJcaIJQKFe+a4=
github.com/free5gc/util v1.0.5-0.20230823103219-e511c4fd20ef/go.mod h1:l2Jrml4vojDomW5jdDJhIS60KdbrE9uPYhyAq/7OnF4=
github.com/free5gc/util v1.0.5-0.20231012123940-85f4557167be h1:SglM1KIL+bR50hPzbvxVwNW44+yHR2tq9nTpLra75UE=
github.com/free5gc/util v1.0.5-0.20231012123940-85f4557167be/go.mod h1:d+79g84a3YHhzvjJ2IhurrBOavOA8xWIQ/GCywPXqQk=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
Expand Down
2 changes: 1 addition & 1 deletion internal/forwarder/flowdesc.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func ParseFlowDesc(s string) (*FlowDesc, error) {
}

func ParseFlowDescIPNet(s string) (*net.IPNet, error) {
if s == "any" {
if s == "any" || s == "assigned" {
return &net.IPNet{
IP: net.IPv6zero,
Mask: net.CIDRMask(0, 128),
Expand Down
31 changes: 23 additions & 8 deletions internal/forwarder/gtp5g.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,15 @@ func (g *Gtp5g) Link() *Gtp5gLink {
return g.link
}

func (g *Gtp5g) newFlowDesc(s string) (nl.AttrList, error) {
func (g *Gtp5g) newFlowDesc(s string, swapSrcDst bool) (nl.AttrList, error) {
var attrs nl.AttrList
fd, err := ParseFlowDesc(s)
if err != nil {
return nil, err
}
if swapSrcDst {
fd.Src, fd.Dst = fd.Dst, fd.Src
}
switch fd.Action {
case "permit":
attrs = append(attrs, nl.Attr{
Expand Down Expand Up @@ -249,7 +252,7 @@ func convertSlice(ports [][]uint16) []byte {
return b
}

func (g *Gtp5g) newSdfFilter(i *ie.IE) (nl.AttrList, error) {
func (g *Gtp5g) newSdfFilter(i *ie.IE, srcIf uint8) (nl.AttrList, error) {
var attrs nl.AttrList

v, err := i.SDFFilter()
Expand All @@ -258,7 +261,8 @@ func (g *Gtp5g) newSdfFilter(i *ie.IE) (nl.AttrList, error) {
}

if v.HasFD() {
fd, err := g.newFlowDesc(v.FlowDescription)
swapSrcDst := (srcIf == ie.SrcInterfaceAccess)
fd, err := g.newFlowDesc(v.FlowDescription, swapSrcDst)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -311,9 +315,17 @@ func (g *Gtp5g) newPdi(i *ie.IE) (nl.AttrList, error) {
if err != nil {
return nil, err
}

var srcIf uint8
var sdfIEs []*ie.IE
for _, x := range ies {
switch x.Type {
case ie.SourceInterface:
v, err := x.SourceInterface()
if err != nil {
break
}
srcIf = v
case ie.FTEID:
v, err := x.FTEID()
if err != nil {
Expand Down Expand Up @@ -343,15 +355,18 @@ func (g *Gtp5g) newPdi(i *ie.IE) (nl.AttrList, error) {
Value: nl.AttrBytes(v.IPv4Address),
})
case ie.SDFFilter:
v, err := g.newSdfFilter(x)
if err != nil {
break
}
sdfIEs = append(sdfIEs, x)
case ie.ApplicationID:
}
}

for _, x := range sdfIEs {
v, err := g.newSdfFilter(x, srcIf)
if err == nil {
attrs = append(attrs, nl.Attr{
Type: gtp5gnl.PDI_SDF_FILTER,
Value: v,
})
case ie.ApplicationID:
}
}

Expand Down
Loading