Skip to content

Commit bddbb3c

Browse files
committed
fixup
1 parent afc9662 commit bddbb3c

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

config/config.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
http-address: "192.0.2.1"
88
http-port: "8080"
99
controller-uri: "http://192.0.2.2:8080"
10+
backbone-ip: "fd00::01"
1011

1112
linux-headend-set-source-address: "fd00:51D5:0000::"
1213
ipv4-headend-prefix: "10.0.200.3/32"
@@ -25,7 +26,7 @@ headends:
2526
- "fd00:51D5:0000:4::"
2627
source-address-prefix: "fd00:51D5:000:1:9999::/80"
2728
- name: "linux test"
28-
to: "10.0.300.0/24"
29+
to: "10.0.100.0/24"
2930
provider: "Linux"
3031
behavior: "H.Encaps"
3132
policy:

internal/app/setup.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (s *Setup) AddTasks() {
6363
// 0.3 http server
6464
// 0.4 controller registry
6565
if s.config.Locator != nil {
66-
s.RegisterTask("ctrl.registry", tasks.NewControllerRegistry(s.config.ControllerURI, s.config.BackboneAddress, *s.config.Locator, httpURI))
66+
s.RegisterTask("ctrl.registry", tasks.NewControllerRegistry(s.config.ControllerURI, s.config.BackboneIP, *s.config.Locator, httpURI))
6767
}
6868

6969
// 1. ifaces
@@ -272,10 +272,11 @@ func (s *Setup) Exit() {
272272

273273
// 0.2. unregister from controller
274274
if s.config.Locator != nil {
275-
if err := s.RunInitTask("ctrl.registry"); err != nil {
275+
if err := s.RunExitTask("ctrl.registry"); err != nil {
276276
fmt.Println(err)
277277
}
278278
}
279+
279280
// 1. ip rules
280281
// 1.1 rule to rttable nextmn-gtp4
281282
if s.config.GTP4HeadendPrefix != nil {
@@ -293,7 +294,7 @@ func (s *Setup) Exit() {
293294
// 2 endpoints + headends
294295
// 2. nextmn gtp4 headends
295296
for _, h := range s.config.Headends.FilterWithBehavior(config.ProviderNextMN, config.H_M_GTP4_D) {
296-
t_name := fmt.Sprintf("nextmn.headend/%s", h.Name)
297+
t_name := fmt.Sprintf("nextmn.headend.gtp4/%s", h.Name)
297298
if err := s.RunExitTask(t_name); err != nil {
298299
fmt.Println(err)
299300
}

internal/config/config.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package config
66

77
import (
88
"io/ioutil"
9+
"net/netip"
910
"path/filepath"
1011

1112
"gopkg.in/yaml.v3"
@@ -33,13 +34,13 @@ type SRv6Config struct {
3334

3435
// interface with controller
3536
HTTPAddress string `yaml:"http-address"`
36-
HTTPPort *string `yaml:"http-port,omitemty"` // default: 80
37+
HTTPPort *string `yaml:"http-port,omitempty"` // default: 80
3738
// TODO: use a better type for this information
38-
ControllerURI string `yaml:controller-uri"` // example: http://192.0.2.2/8080
39+
ControllerURI string `yaml:"controller-uri"` // example: http://192.0.2.2/8080
3940

4041
// Backbone IPv6 address
4142
// TODO: use a better type for this information
42-
BackboneAddress string
43+
BackboneIP netip.Addr `yaml:"backbone-ip"`
4344

4445
// headends
4546
LinuxHeadendSetSourceAddress *string `yaml:"linux-headend-set-source-address,omitempty"`

internal/tasks/controller-registry.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"encoding/json"
1010
"fmt"
1111
"net/http"
12+
"net/netip"
1213
)
1314

1415
// ControllerRegistry registers and unregisters into controller
@@ -17,12 +18,12 @@ type ControllerRegistry struct {
1718
RemoteControlURI string // URI of the controller
1819
LocalControlURI string // URI of the router, used to control it
1920
Locator string
20-
Backbone string
21+
Backbone netip.Addr
2122
Resource string
2223
}
2324

2425
// Create a new ControllerRegistry
25-
func NewControllerRegistry(remoteControlURI string, backbone string, locator string, localControlURI string) *ControllerRegistry {
26+
func NewControllerRegistry(remoteControlURI string, backbone netip.Addr, locator string, localControlURI string) *ControllerRegistry {
2627
return &ControllerRegistry{
2728
WithState: NewState(),
2829
RemoteControlURI: remoteControlURI,
@@ -37,7 +38,7 @@ func NewControllerRegistry(remoteControlURI string, backbone string, locator str
3738
func (t *ControllerRegistry) RunInit() error {
3839
data := map[string]string{
3940
"locator": t.Locator,
40-
"backbone": t.Backbone,
41+
"backbone": t.Backbone.String(),
4142
"control": t.LocalControlURI,
4243
}
4344
json_data, err := json.Marshal(data)
@@ -54,7 +55,7 @@ func (t *ControllerRegistry) RunInit() error {
5455
return fmt.Errorf("HTTP Bad request\n")
5556
}
5657
if resp.StatusCode >= 500 {
57-
return fmt.Errorf("HTTP Control Server: internal error %v\n", resp.Body)
58+
return fmt.Errorf("HTTP Control Server: internal error\n")
5859
}
5960
if resp.StatusCode == 201 { // created
6061
t.Resource = resp.Header.Get("Location")

main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ func main() {
6565
}(ch, setup)
6666
setup.AddTasks()
6767
if err := setup.Run(); err != nil {
68-
fmt.Println("Error while running, exiting…")
69-
log.Fatal(err)
68+
fmt.Println("Error while running, exiting…:", err)
69+
setup.Exit()
7070
os.Exit(2)
7171
}
7272
return nil

0 commit comments

Comments
 (0)