Skip to content

Commit

Permalink
add expectedMaxGtp5gVersion to prevent using non-compatible gtp5g
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-ywliu committed Nov 18, 2022
1 parent 6392d88 commit a6fdea8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions internal/forwarder/gtp5g.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
)

const (
expectedGtp5gVersion string = "0.6.6"
SOCKPATH string = "/tmp/free5gc_unix_sock"
expectedMinGtp5gVersion string = "0.6.6"
expectedMaxGtp5gVersion string = "0.6.6"
SOCKPATH string = "/tmp/free5gc_unix_sock"
)

type Gtp5g struct {
Expand Down Expand Up @@ -113,18 +114,22 @@ func (g *Gtp5g) checkVersion() error {
}

// compare version
expVer, err := version.NewVersion(expectedGtp5gVersion)
expMinVer, err := version.NewVersion(expectedMinGtp5gVersion)
if err != nil {
return errors.Wrapf(err, "parse expectedGtp5gVersion err")
return errors.Wrapf(err, "parse expectedMinGtp5gVersion err")
}
expMaxVer, err := version.NewVersion(expectedMaxGtp5gVersion)
if err != nil {
return errors.Wrapf(err, "parse expectedMaxGtp5gVersion err")
}
nowVer, err := version.NewVersion(gtp5gVer)
if err != nil {
return errors.Wrapf(err, "Unable to parse gtp5g version(%s)", nowVer)
}
if nowVer.LessThan(expVer) {
if nowVer.LessThan(expMinVer) || nowVer.GreaterThan(expMaxVer) {
return errors.Errorf(
"gtp5g version should be >= %s, please upgrade it",
expectedGtp5gVersion)
"gtp5g version should be %s >= verion >= %s , please update it",
expectedMaxGtp5gVersion, expectedMinGtp5gVersion)
}

return nil
Expand Down

0 comments on commit a6fdea8

Please sign in to comment.