Skip to content

Commit

Permalink
Make Headend policy no longer mandatory
Browse files Browse the repository at this point in the history
Policy is not required for NextMN-ctrl
  • Loading branch information
louisroyer committed Jun 21, 2024
1 parent 925ea79 commit 5818c1b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/config/headend.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Headend struct {
To string `yaml:"to"` // IP Prefix this Headend will handle (can be the same as GTP4HeadendPrefix if you have a single Headend)
Provider Provider `yaml:"provider"`
Behavior HeadendBehavior `yaml:"behavior"`
Policy []Policy `yaml:"policy"`
Policy *[]Policy `yaml:"policy,omitempty"`
SourceAddressPrefix *string `yaml:"source-address-prefix"`
MTU *string `yaml:mtu,omitempty"` // suggested value is 1400 (same as UERANSIM) if the path includes a End.M.GTP4.E
}
Expand Down
5 changes: 4 additions & 1 deletion internal/netfunc/headend.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ func NewHeadend(he *config.Headend, ttl uint8, hopLimit uint8, debug bool) (netf
}
switch he.Behavior {
case config.H_M_GTP4_D:
policy := he.Policy
if he.Policy == nil {
return nil, fmt.Errorf("Policy is nil")
}
policy := *he.Policy
if he.SourceAddressPrefix == nil {
return nil, fmt.Errorf("Missing source-address-prefix")
}
Expand Down
4 changes: 2 additions & 2 deletions internal/tasks/linux-headend.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (t *TaskLinuxHeadend) RunInit() error {
return fmt.Errorf("No policy set for this headend")
}
seglist := ""
for _, p := range t.headend.Policy {
for _, p := range *t.headend.Policy {
if p.Match == nil {
seglist = p.Bsid.ToIPRoute2()
break
Expand Down Expand Up @@ -74,7 +74,7 @@ func (t *TaskLinuxHeadend) RunExit() error {
return fmt.Errorf("No policy set for this headend")
}
seglist := ""
for _, p := range t.headend.Policy {
for _, p := range *t.headend.Policy {
if p.Match == nil {
seglist = p.Bsid.ToIPRoute2()
break
Expand Down

0 comments on commit 5818c1b

Please sign in to comment.