Skip to content

Commit 816408d

Browse files
committed
Fix BSID match
1 parent 8d999b5 commit 816408d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/netfunc/headend-gtp4.go

+13
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,23 @@ func (h HeadendGTP4) Handle(packet []byte) ([]byte, error) {
8383
isInnerHeaderIPv4 := false
8484

8585
var bsid *config.Bsid
86+
87+
// find a policy matching criterias
8688
for _, p := range h.policy {
89+
// catch-all policy (should be last policy in list)
8790
if p.Match == nil {
8891
bsid = &p.Bsid
8992
break
9093
}
94+
95+
// otherwise, teid is mandatory
9196
if p.Match.Teid != nil {
9297
if *p.Match.Teid != teid {
98+
// teid doesn't match
9399
continue
94100
}
95101
if p.Match.InnerHeaderIPv4SrcPrefix != nil {
102+
// teid matches, and we need to check the prefix
96103
if !isInnerHeaderIPv4 {
97104
// init innerHeaderIPv4
98105
inner, ok := payload.(*layers.IPv4)
@@ -110,9 +117,15 @@ func (h HeadendGTP4) Handle(packet []byte) ([]byte, error) {
110117
return nil, fmt.Errorf("Malformed matching criteria (inner Header IPv4 Prefix): %s", err)
111118
}
112119
if prefix.Contains(innerHeaderIPv4) {
120+
// prefix matches
113121
bsid = &p.Bsid
114122
break
115123
}
124+
// prefix doesn't match: continue
125+
} else {
126+
// teid matches, and no prefix to check
127+
bsid = &p.Bsid
128+
break
116129
}
117130
}
118131
}

0 commit comments

Comments
 (0)