Skip to content

Commit 5a9db84

Browse files
committed
Implement Endpoints
- End.M.GTP6.D - End.M.GTP6.E
1 parent 81472f8 commit 5a9db84

10 files changed

+509
-50
lines changed

config/config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ endpoints:
88
- sid: "fd00:51D5:0000:1:1::/80"
99
behavior: "End"
1010

11+
policy:
12+
segments-list:
13+
- "fd00:51D5:0000:2::"
14+
- "fd00:51D5:0000:3::"

go.mod

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ module github.com/louisroyer/nextmn-srv6
33
go 1.19
44

55
require (
6+
github.com/google/gopacket v1.1.19
7+
github.com/louisroyer/gopacket-srv6 v0.0.5
8+
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
69
github.com/urfave/cli/v2 v2.25.1
10+
github.com/wmnsk/go-gtp v0.8.6
711
gopkg.in/yaml.v3 v3.0.1
812
)
913

1014
require (
1115
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
1216
github.com/russross/blackfriday/v2 v2.1.0 // indirect
13-
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 // indirect
17+
github.com/vishvananda/netlink v1.1.0 // indirect
18+
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect
1419
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
20+
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3 // indirect
1521
golang.org/x/sys v0.8.0 // indirect
1622
)

go.sum

+32
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,47 @@
11
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
22
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
3+
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
4+
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
5+
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
6+
github.com/louisroyer/gopacket-srv6 v0.0.4 h1:ICfvXcUYdh6McY59zn2kwN9lpMWUQrV3kd+iPhWjLNg=
7+
github.com/louisroyer/gopacket-srv6 v0.0.4/go.mod h1:AifV+WVuFi3c9fOohh2EgERRJJY2BO1AVPf0GRdrNzo=
8+
github.com/louisroyer/gopacket-srv6 v0.0.5 h1:DyyL9u6XwTeULsPKq5zs+MYyo0oZjN5Kas1N1SCXmzE=
9+
github.com/louisroyer/gopacket-srv6 v0.0.5/go.mod h1:AifV+WVuFi3c9fOohh2EgERRJJY2BO1AVPf0GRdrNzo=
10+
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
311
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
412
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
513
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 h1:TG/diQgUe0pntT/2D9tmUCz4VNwm9MfrtPr0SU2qSX8=
614
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8/go.mod h1:P5HUIBuIWKbyjl083/loAegFkfbFNx5i2qEP4CNbm7E=
715
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
816
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
17+
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=
18+
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
19+
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
20+
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg=
21+
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
22+
github.com/wmnsk/go-gtp v0.8.6 h1:Z2lHnNlQ49jdySoWpcZPOsGPFjDb+5BQm9rO9Nn47E0=
23+
github.com/wmnsk/go-gtp v0.8.6/go.mod h1:7Ja5ik6qMx451Oa4LXdXYl53277fL/X7Ob8nCb5T6TY=
924
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
1025
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
26+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
27+
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
28+
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
29+
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
30+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
31+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
32+
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3 h1:EN5+DfgmRMvRUrMGERW2gQl3Vc+Z7ZMnI/xdEpPSf0c=
33+
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
34+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
35+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
36+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
37+
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
38+
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1139
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
1240
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
41+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
42+
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
43+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
44+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1345
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1446
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
1547
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

runtime/config.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,23 @@ type IPRoute2 struct {
3131
PostInitHook *string `yaml:"post-init-hook,omitempty"` // script to execute after interfaces are configured
3232
}
3333

34+
type BehaviorOptions struct {
35+
SourceAddress *string `yaml:"set-source-address,omitempty"` // mandatory for End.M.GTP6.(E|D)
36+
}
37+
3438
type Endpoint struct {
35-
Sid string `yaml:"sid"` // example of sid: fd00:51D5:0000:1:1:11/80
36-
Behavior string `yaml:"behavior"` // example of behavior: End.DX4
39+
Sid string `yaml:"sid"` // example of sid: fd00:51D5:0000:1:1:11/80
40+
Behavior string `yaml:"behavior"` // example of behavior: End.DX4
41+
Options *BehaviorOptions `yaml:"options,omitempty"`
3742
}
3843

3944
type SRv6Config struct {
4045
IPRoute2 *IPRoute2 `yaml:"iproute2"`
4146
Locator string `yaml:"locator` // example of locator: fd00:51D5:0000:1::/64
4247
Endpoints []*Endpoint `yaml:"endpoints"`
48+
Policy *Policy `yaml:"policy"` // temporary field
49+
}
50+
51+
type Policy struct { // temporary field
52+
SegmentsList []string `yaml:"segments-list"` // temporary field
4353
}

runtime/constants.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ const RTTableFileName = "/etc/iproute2/rt_tables.d/nextmn-srv6.conf"
44
const RTTableName = "nextmn-srv6"
55
const RTProtoFileName = "/etc/iproute2/rt_protos.d/nextmn-srv6.conf"
66
const RTProtoName = "nextmn-srv6"
7-
const nextmnSRTunName = "nextmn-sr"
7+
const NextmnSRTunName = "nextmn-sr"
88
const LinuxSRLinkName = "linux-sr"
9+
const GTPU_PORT = "2152"

runtime/linux-sr.go

-15
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@
44
// SPDX-License-Identifier: MIT
55
package srv6
66

7-
import "strings"
8-
97
func linuxSRInit() error {
108
if err := linuxSRCreateIface(); err != nil {
119
return err
1210
}
13-
if err := linuxSRConfigTunSrc(); err != nil {
14-
return err
15-
}
1611
if err := linuxSRCreateEndpoints(); err != nil {
1712
return err
1813
}
@@ -42,16 +37,6 @@ func linuxSRCreateEndpoints() error {
4237
return nil
4338
}
4439

45-
func linuxSRConfigTunSrc() error {
46-
// Locator is in CIDR notation, we need to remove the mask
47-
src := strings.Split(SRv6.Locator, "/")[0]
48-
err := runIP("sr", "tunsrc", "set", src)
49-
if err != nil {
50-
return err
51-
}
52-
return nil
53-
}
54-
5540
func linuxSRCreateIface() error {
5641
if err := runIP("link", "add", LinuxSRLinkName, "type", "dummy"); err != nil {
5742
return err

0 commit comments

Comments
 (0)