Skip to content

Commit

Permalink
Implement Endpoints
Browse files Browse the repository at this point in the history
- End.M.GTP6.D
- End.M.GTP6.E
  • Loading branch information
louisroyer committed Jun 5, 2023
1 parent 81472f8 commit 5a9db84
Show file tree
Hide file tree
Showing 10 changed files with 509 additions and 50 deletions.
4 changes: 4 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ endpoints:
- sid: "fd00:51D5:0000:1:1::/80"
behavior: "End"

policy:
segments-list:
- "fd00:51D5:0000:2::"
- "fd00:51D5:0000:3::"
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ module github.com/louisroyer/nextmn-srv6
go 1.19

require (
github.com/google/gopacket v1.1.19
github.com/louisroyer/gopacket-srv6 v0.0.5
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
github.com/urfave/cli/v2 v2.25.1
github.com/wmnsk/go-gtp v0.8.6
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 // indirect
github.com/vishvananda/netlink v1.1.0 // indirect
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3 // indirect
golang.org/x/sys v0.8.0 // indirect
)
32 changes: 32 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
github.com/louisroyer/gopacket-srv6 v0.0.4 h1:ICfvXcUYdh6McY59zn2kwN9lpMWUQrV3kd+iPhWjLNg=
github.com/louisroyer/gopacket-srv6 v0.0.4/go.mod h1:AifV+WVuFi3c9fOohh2EgERRJJY2BO1AVPf0GRdrNzo=
github.com/louisroyer/gopacket-srv6 v0.0.5 h1:DyyL9u6XwTeULsPKq5zs+MYyo0oZjN5Kas1N1SCXmzE=
github.com/louisroyer/gopacket-srv6 v0.0.5/go.mod h1:AifV+WVuFi3c9fOohh2EgERRJJY2BO1AVPf0GRdrNzo=
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 h1:TG/diQgUe0pntT/2D9tmUCz4VNwm9MfrtPr0SU2qSX8=
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8/go.mod h1:P5HUIBuIWKbyjl083/loAegFkfbFNx5i2qEP4CNbm7E=
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg=
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/wmnsk/go-gtp v0.8.6 h1:Z2lHnNlQ49jdySoWpcZPOsGPFjDb+5BQm9rO9Nn47E0=
github.com/wmnsk/go-gtp v0.8.6/go.mod h1:7Ja5ik6qMx451Oa4LXdXYl53277fL/X7Ob8nCb5T6TY=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3 h1:EN5+DfgmRMvRUrMGERW2gQl3Vc+Z7ZMnI/xdEpPSf0c=
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14 changes: 12 additions & 2 deletions runtime/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,23 @@ type IPRoute2 struct {
PostInitHook *string `yaml:"post-init-hook,omitempty"` // script to execute after interfaces are configured
}

type BehaviorOptions struct {
SourceAddress *string `yaml:"set-source-address,omitempty"` // mandatory for End.M.GTP6.(E|D)
}

type Endpoint struct {
Sid string `yaml:"sid"` // example of sid: fd00:51D5:0000:1:1:11/80
Behavior string `yaml:"behavior"` // example of behavior: End.DX4
Sid string `yaml:"sid"` // example of sid: fd00:51D5:0000:1:1:11/80
Behavior string `yaml:"behavior"` // example of behavior: End.DX4
Options *BehaviorOptions `yaml:"options,omitempty"`
}

type SRv6Config struct {
IPRoute2 *IPRoute2 `yaml:"iproute2"`
Locator string `yaml:"locator` // example of locator: fd00:51D5:0000:1::/64
Endpoints []*Endpoint `yaml:"endpoints"`
Policy *Policy `yaml:"policy"` // temporary field
}

type Policy struct { // temporary field
SegmentsList []string `yaml:"segments-list"` // temporary field
}
3 changes: 2 additions & 1 deletion runtime/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ const RTTableFileName = "/etc/iproute2/rt_tables.d/nextmn-srv6.conf"
const RTTableName = "nextmn-srv6"
const RTProtoFileName = "/etc/iproute2/rt_protos.d/nextmn-srv6.conf"
const RTProtoName = "nextmn-srv6"
const nextmnSRTunName = "nextmn-sr"
const NextmnSRTunName = "nextmn-sr"
const LinuxSRLinkName = "linux-sr"
const GTPU_PORT = "2152"
15 changes: 0 additions & 15 deletions runtime/linux-sr.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@
// SPDX-License-Identifier: MIT
package srv6

import "strings"

func linuxSRInit() error {
if err := linuxSRCreateIface(); err != nil {
return err
}
if err := linuxSRConfigTunSrc(); err != nil {
return err
}
if err := linuxSRCreateEndpoints(); err != nil {
return err
}
Expand Down Expand Up @@ -42,16 +37,6 @@ func linuxSRCreateEndpoints() error {
return nil
}

func linuxSRConfigTunSrc() error {
// Locator is in CIDR notation, we need to remove the mask
src := strings.Split(SRv6.Locator, "/")[0]
err := runIP("sr", "tunsrc", "set", src)
if err != nil {
return err
}
return nil
}

func linuxSRCreateIface() error {
if err := runIP("link", "add", LinuxSRLinkName, "type", "dummy"); err != nil {
return err
Expand Down
Loading

0 comments on commit 5a9db84

Please sign in to comment.