Skip to content

Commit

Permalink
Fix BSID match
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed Feb 2, 2024
1 parent 8d999b5 commit 816408d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/netfunc/headend-gtp4.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,23 @@ func (h HeadendGTP4) Handle(packet []byte) ([]byte, error) {
isInnerHeaderIPv4 := false

var bsid *config.Bsid

// find a policy matching criterias
for _, p := range h.policy {
// catch-all policy (should be last policy in list)
if p.Match == nil {
bsid = &p.Bsid
break
}

// otherwise, teid is mandatory
if p.Match.Teid != nil {
if *p.Match.Teid != teid {
// teid doesn't match
continue
}
if p.Match.InnerHeaderIPv4SrcPrefix != nil {
// teid matches, and we need to check the prefix
if !isInnerHeaderIPv4 {
// init innerHeaderIPv4
inner, ok := payload.(*layers.IPv4)
Expand All @@ -110,9 +117,15 @@ func (h HeadendGTP4) Handle(packet []byte) ([]byte, error) {
return nil, fmt.Errorf("Malformed matching criteria (inner Header IPv4 Prefix): %s", err)
}
if prefix.Contains(innerHeaderIPv4) {
// prefix matches
bsid = &p.Bsid
break
}
// prefix doesn't match: continue
} else {
// teid matches, and no prefix to check
bsid = &p.Bsid
break
}
}
}
Expand Down

0 comments on commit 816408d

Please sign in to comment.