Skip to content

Commit 85a92ab

Browse files
committed
Update go-pfcp-networking
1 parent 1563ff0 commit 85a92ab

File tree

9 files changed

+36
-21
lines changed

9 files changed

+36
-21
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/adrg/xdg v0.5.3
77
github.com/gin-gonic/gin v1.10.0
88
github.com/gofrs/uuid v4.4.0+incompatible
9-
github.com/nextmn/go-pfcp-networking v0.0.38
9+
github.com/nextmn/go-pfcp-networking v0.0.39
1010
github.com/nextmn/json-api v0.0.14
1111
github.com/nextmn/logrus-formatter v0.0.1
1212
github.com/nextmn/rfc9433 v0.0.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
5252
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
5353
github.com/nextmn/go-pfcp-networking v0.0.38 h1:C7HgLh6UUbqfoTHl/uvUcYNZUBPSur68rOHdLUnpx9Q=
5454
github.com/nextmn/go-pfcp-networking v0.0.38/go.mod h1:KYoKLiltDmHL2YMU5mz2k/E1xMoz4TpmzTz6Nr5u5gA=
55+
github.com/nextmn/go-pfcp-networking v0.0.39 h1:8LDz3O0pjQ3PPLGDnds3z369mB7xBEkTtLqAzMMrtFE=
56+
github.com/nextmn/go-pfcp-networking v0.0.39/go.mod h1:KYoKLiltDmHL2YMU5mz2k/E1xMoz4TpmzTz6Nr5u5gA=
5557
github.com/nextmn/json-api v0.0.14 h1:m4uHOVcXsxkXoxbrhqemLTRG4T86eYkejjirew1nDUU=
5658
github.com/nextmn/json-api v0.0.14/go.mod h1:CQXeNPj9MDGsEExtnqJFIGjLgZAKsmOoO2fy+mep7Ak=
5759
github.com/nextmn/logrus-formatter v0.0.1 h1:Bsf78jjiEESc+rV8xE6IyKj4frDPGMwXFNrLQzm6A1E=

internal/app/http.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
// Copyright 2023 Louis Royer and the NextMN-SRv6-ctrl contributors. All rights reserved.
1+
// Copyright 2023 Louis Royer and the NextMN contributors. All rights reserved.
22
// Use of this source code is governed by a MIT-style license that can be
33
// found in the LICENSE file.
44
// SPDX-License-Identifier: MIT
5+
56
package app
67

78
import (
89
"context"
910
"fmt"
1011
"net"
1112
"net/http"
13+
"net/netip"
1214
"sync"
1315
"time"
1416

@@ -32,7 +34,7 @@ type RouterRegistry struct {
3234
pfcpSrv *pfcp_networking.PFCPEntityUP
3335
}
3436

35-
func NewHttpServerEntity(httpAddr string, pfcp *pfcp_networking.PFCPEntityUP) *HttpServerEntity {
37+
func NewHttpServerEntity(httpAddr netip.AddrPort, pfcp *pfcp_networking.PFCPEntityUP) *HttpServerEntity {
3638
rr := RouterRegistry{
3739
routers: make(n4tosrv6.RouterMap),
3840
pfcpSrv: pfcp,
@@ -48,7 +50,7 @@ func NewHttpServerEntity(httpAddr string, pfcp *pfcp_networking.PFCPEntityUP) *H
4850
e := HttpServerEntity{
4951
routers: &rr,
5052
srv: &http.Server{
51-
Addr: httpAddr,
53+
Addr: httpAddr.String(),
5254
Handler: r,
5355
},
5456
}

internal/app/rules-pusher.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Copyright 2024 Louis Royer and the NextMN-SRv6-ctrl contributors. All rights reserved.
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
22
// Use of this source code is governed by a MIT-style license that can be
33
// found in the LICENSE file.
44
// SPDX-License-Identifier: MIT
5+
56
package app
67

78
import (
@@ -13,15 +14,16 @@ import (
1314
"net/netip"
1415
"sync"
1516

16-
"github.com/sirupsen/logrus"
17-
"github.com/wmnsk/go-pfcp/ie"
18-
1917
pfcp_networking "github.com/nextmn/go-pfcp-networking/pfcp"
2018
pfcpapi "github.com/nextmn/go-pfcp-networking/pfcp/api"
2119
"github.com/nextmn/go-pfcp-networking/pfcputil"
20+
"github.com/nextmn/json-api/jsonapi"
2221
"github.com/nextmn/json-api/jsonapi/n4tosrv6"
2322
"github.com/nextmn/rfc9433/encoding"
2423
"github.com/nextmn/srv6-ctrl/internal/config"
24+
25+
"github.com/sirupsen/logrus"
26+
"github.com/wmnsk/go-pfcp/ie"
2527
)
2628

2729
const UserAgent = "go-github-nextmn-srv6-ctrl"
@@ -48,8 +50,8 @@ func NewRulesPusher(config *config.CtrlConfig) *RulesPusher {
4850
}
4951
}
5052

51-
func (pusher *RulesPusher) pushSingleRule(client http.Client, uri string, data []byte) error {
52-
req, err := http.NewRequest(http.MethodPost, uri+"/rules", bytes.NewBuffer(data))
53+
func (pusher *RulesPusher) pushSingleRule(ctx context.Context, client http.Client, uri jsonapi.ControlURI, data []byte) error {
54+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, uri.JoinPath("rules").String(), bytes.NewBuffer(data))
5355
if err != nil {
5456
logrus.WithError(err).Error("could not create http request")
5557
return err
@@ -76,7 +78,7 @@ func (pusher *RulesPusher) pushSingleRule(client http.Client, uri string, data [
7678
return nil
7779
}
7880

79-
func (pusher *RulesPusher) pushRTRRule(ue_ip string) error {
81+
func (pusher *RulesPusher) pushRTRRule(ctx context.Context, ue_ip string) error {
8082
i, ok := pusher.ues.Load(ue_ip)
8183
infos := i.(*ueInfos)
8284
infos.Lock()
@@ -137,7 +139,7 @@ func (pusher *RulesPusher) pushRTRRule(ue_ip string) error {
137139
wg.Add(1)
138140
go func() error {
139141
defer wg.Done()
140-
return pusher.pushSingleRule(client, r.ControlURI, rule_json)
142+
return pusher.pushSingleRule(ctx, client, r.ControlURI, rule_json)
141143
}()
142144

143145
}
@@ -191,7 +193,7 @@ func (pusher *RulesPusher) pushRTRRule(ue_ip string) error {
191193
wg.Add(1)
192194
go func() error {
193195
defer wg.Done()
194-
return pusher.pushSingleRule(client, r.ControlURI, rule_json)
196+
return pusher.pushSingleRule(ctx, client, r.ControlURI, rule_json)
195197
}()
196198

197199
}
@@ -317,7 +319,7 @@ func (pusher *RulesPusher) updateRoutersRules(ctx context.Context, msgType pfcpu
317319
wg.Add(1)
318320
go func() {
319321
defer wg.Done()
320-
pusher.pushRTRRule(ip.(string))
322+
pusher.pushRTRRule(ctx, ip.(string))
321323
// TODO: check pushRTRRule return code and send pfcp error on failure
322324
}()
323325
return true

internal/app/setup.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Copyright 2024 Louis Royer and the NextMN-SRv6-ctrl contributors. All rights reserved.
1+
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
22
// Use of this source code is governed by a MIT-style license that can be
33
// found in the LICENSE file.
44
// SPDX-License-Identifier: MIT
5+
56
package app
67

78
import (

internal/app/upf.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Copyright 2023 Louis Royer and the NextMN-SRv6-ctrl contributors. All rights reserved.
1+
// Copyright 2023 Louis Royer and the NextMN contributors. All rights reserved.
22
// Use of this source code is governed by a MIT-style license that can be
33
// found in the LICENSE file.
44
// SPDX-License-Identifier: MIT
5+
56
package app
67

78
import (

internal/config/control.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
package config
77

88
import (
9+
"net/netip"
10+
911
"github.com/nextmn/json-api/jsonapi"
1012
)
1113

1214
type Control struct {
1315
Uri jsonapi.ControlURI `yaml:"uri"` // may contain domain name instead of ip address
14-
BindAddr string `yaml:"bind-addr"` // in the form `ip:port`
16+
BindAddr netip.AddrPort `yaml:"bind-addr"` // in the form `ip:port`
1517
}

internal/config/rule.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66
package config
77

8+
import (
9+
"github.com/nextmn/json-api/jsonapi"
10+
)
11+
812
type Rule struct {
9-
ControlURI string `yaml:"control-uri"` // e.g. http://srgw.local:8080
10-
Enabled bool `yaml:"enabled"`
11-
SegmentsList []string `yaml:"segments-list"` // Segment[0] is the ultimate node, Segment[n-1] is the next hop ; Segment[0] can be a prefix (for downlink)
13+
ControlURI jsonapi.ControlURI `yaml:"control-uri"` // e.g. http://srgw.local:8080
14+
Enabled bool `yaml:"enabled"`
15+
SegmentsList []string `yaml:"segments-list"` // Segment[0] is the ultimate node, Segment[n-1] is the next hop ; Segment[0] can be a prefix (for downlink)
1216
}

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Copyright 2023 Louis Royer and the NextMN-SRv6-ctrl contributors. All rights reserved.
1+
// Copyright 2023 Louis Royer and the NextMN contributors. All rights reserved.
22
// Use of this source code is governed by a MIT-style license that can be
33
// found in the LICENSE file.
44
// SPDX-License-Identifier: MIT
5+
56
package main
67

78
import (

0 commit comments

Comments
 (0)