diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5909477..2d707d6 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -29,7 +29,7 @@ jobs: export PATH=$PATH:$GOPATH/bin mkdir $GOPATH/src $GOPATH/pkg $GOPATH/bin go install honnef.co/go/tools/cmd/staticcheck@latest - NEW=$GOPATH/src/github.com/digitalocean/go-openvswitch + NEW=$GOPATH/src/github.com/danieldin95/go-openvswitch mkdir -p $NEW cp -r ./* $NEW cd $NEW diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ded8059..4bb6940 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,8 +5,8 @@ The `go-openvswitch` project makes use of the [GitHub Flow](https://guides.githu for contributions. If you'd like to contribute to the project, please -[open an issue](https://github.com/digitalocean/go-openvswitch/issues/new) or find an -[existing issue](https://github.com/digitalocean/go-openvswitch/issues) that you'd like +[open an issue](https://github.com/danieldin95/go-openvswitch/issues/new) or find an +[existing issue](https://github.com/danieldin95/go-openvswitch/issues) that you'd like to take on. This ensures that efforts are not duplicated, and that a new feature aligns with the focus of the rest of the repository. @@ -21,7 +21,7 @@ code meets the following criteria: In addition, if this is your first time contributing to the `go-openvswitch` project, add your name and email address to the -[AUTHORS](https://github.com/digitalocean/go-openvswitch/blob/master/AUTHORS) file +[AUTHORS](https://github.com/danieldin95/go-openvswitch/blob/master/AUTHORS) file under the "Contributors" section using the format: `First Last `. diff --git a/README.md b/README.md index b77fe41..257602c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -go-openvswitch [![Build Status](https://travis-ci.org/digitalocean/go-openvswitch.svg?branch=master)](https://travis-ci.org/digitalocean/go-openvswitch) [![GoDoc](https://godoc.org/github.com/digitalocean/go-openvswitch?status.svg)](https://godoc.org/github.com/digitalocean/go-openvswitch) [![Go Report Card](https://goreportcard.com/badge/github.com/digitalocean/go-openvswitch)](https://goreportcard.com/report/github.com/digitalocean/go-openvswitch) +go-openvswitch +[![Build Status](https://travis-ci.org/danieldin95/go-openvswitch.svg?branch=master)](https://travis-ci.org/danieldin95/go-openvswitch) +[![GoDoc](https://godoc.org/github.com/danieldin95/go-openvswitch?status.svg)](https://godoc.org/github.com/danieldin95/go-openvswitch) +[![Go Report Card](https://goreportcard.com/badge/github.com/danieldin95/go-openvswitch)](https://goreportcard.com/report/github.com/danieldin95/go-openvswitch) ============== Go packages which enable interacting with Open vSwitch and related tools. Apache 2.0 Licensed. @@ -7,4 +10,4 @@ Go packages which enable interacting with Open vSwitch and related tools. Apache - `ovsdb`: Package ovsdb implements an OVSDB client, as described in RFC 7047. - `ovsnl`: Package ovsnl enables interaction with the Linux Open vSwitch generic netlink interface. -See each package's README for additional information. \ No newline at end of file +See each package's README for additional information. diff --git a/go.mod b/go.mod index 8e622eb..41f398b 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/digitalocean/go-openvswitch +module github.com/danieldin95/go-openvswitch go 1.16 diff --git a/ovs/action.go b/ovs/action.go index faaf321..6bf17b7 100644 --- a/ovs/action.go +++ b/ovs/action.go @@ -502,8 +502,8 @@ type resubmitPortAction struct { // MarshalText implements Action. func (a *resubmitPortAction) MarshalText() ([]byte, error) { - // Largest valid port ID is 0xfffffeff per openflow spec. - if a.port < 0 || a.port > 0xfffffeff { + // Largest valid port ID is 0xfffeff per openflow spec. + if a.port < 0 || a.port > 0xfffeff { return nil, errResubmitPortInvalid } diff --git a/ovs/action_test.go b/ovs/action_test.go index 32e5b9d..7958b2f 100644 --- a/ovs/action_test.go +++ b/ovs/action_test.go @@ -401,12 +401,12 @@ func TestActionResubmitPort(t *testing.T) { action: "resubmit:1", }, { - desc: "max port (0xfffffeff)", - port: 0xfffffeff, - action: "resubmit:4294967039", + desc: "max port (0xfffeff)", + port: 0xfffeff, + action: "resubmit:16776959", }, { - desc: "max port+1 (0xfffffeff)", + desc: "max port+1 (0xfffeff)", port: 0xffffff00, err: errResubmitPortInvalid, }, diff --git a/ovs/datapath.go b/ovs/datapath.go index dad0318..853e12a 100644 --- a/ovs/datapath.go +++ b/ovs/datapath.go @@ -96,7 +96,7 @@ type CLI interface { // supported by the ovs-dpctl command type DataPathService struct { // We define here a CLI interface making easier to mock ovs-dpctl command - // as in github.com/digitalocean/go-openvswitch/ovs/datapath_test.go + // as in github.com/danieldin95/go-openvswitch/ovs/datapath_test.go CLI } diff --git a/ovs/datapath_test.go b/ovs/datapath_test.go index 8cc88ba..1ca5faa 100644 --- a/ovs/datapath_test.go +++ b/ovs/datapath_test.go @@ -334,6 +334,10 @@ func TestGetCTLimitsWithBinary(t *testing.T) { for _, tt := range tests { t.Run(tt.desc, func(t *testing.T) { results, err := tt.dp.GetCTLimits(tt.dpName, tt.zones) + if err != nil { + t.Errorf(err.Error()) + return + } switch tt.testCase { case validTest: if tt.want.defaultLimit["default"] != results.defaultLimit["default"] { diff --git a/ovs/matchparser.go b/ovs/matchparser.go index 4aa3492..9307044 100644 --- a/ovs/matchparser.go +++ b/ovs/matchparser.go @@ -38,7 +38,7 @@ func parseMatch(key string, value string) (Match, error) { case tpSRC, tpDST: return parsePort(key, value, math.MaxUint16) case conjID: - return parseIntMatch(key, value, math.MaxUint32) + return parseIntMatch(key, value, math.MaxInt32) case arpSPA: return ARPSourceProtocolAddress(value), nil case arpTPA: diff --git a/ovs/vswitch.go b/ovs/vswitch.go old mode 100644 new mode 100755 index 181ced2..1e74674 --- a/ovs/vswitch.go +++ b/ovs/vswitch.go @@ -233,6 +233,9 @@ type InterfaceOptions struct { // Type specifies the Open vSwitch interface type. Type InterfaceType + // Indicate whether enable bfd. + BfdEnable bool + // Peer specifies an interface to peer with when creating a patch interface. Peer string @@ -274,6 +277,19 @@ type InterfaceOptions struct { // tunneled traffic leaving this interface. Optionally it could be set to // "flow" which expects the flow to set tunnel ID. Key string + + // Specifies the usage of the Don't Fragment flag (DF) bit in outgoing packets + // with IPv4 headers. The value inherit causes the bit to be copied from + // the original IP header. The values unset and set cause the bit to be always unset + // or always set, respectively. By default, the bit is not set. + DfDefault string + + // Specifies the source IP address to use in outgoing packets. + LocalIP string + + // Specifies the UDP destination port to communicate to the remote + // VXLAN tunnel endpoint. + DstPort uint32 } // slice creates a string slice containing any non-zero option values from the @@ -285,6 +301,10 @@ func (i InterfaceOptions) slice() []string { s = append(s, fmt.Sprintf("type=%s", i.Type)) } + if i.BfdEnable { + s = append(s, "bfd:enable=true") + } + if i.Peer != "" { s = append(s, fmt.Sprintf("options:peer=%s", i.Peer)) } @@ -315,5 +335,17 @@ func (i InterfaceOptions) slice() []string { s = append(s, fmt.Sprintf("options:key=%s", i.Key)) } + if i.DfDefault != "" { + s = append(s, fmt.Sprintf("options:df_default=%s", i.DfDefault)) + } + + if i.LocalIP != "" { + s = append(s, fmt.Sprintf("options:local_ip=%s", i.LocalIP)) + } + + if i.DstPort > 0 { + s = append(s, fmt.Sprintf("options:dst_port=%d", i.DstPort)) + } + return s } diff --git a/ovs/vswitch_test.go b/ovs/vswitch_test.go index 8298537..01b6b72 100644 --- a/ovs/vswitch_test.go +++ b/ovs/vswitch_test.go @@ -857,6 +857,42 @@ func TestInterfaceOptions_slice(t *testing.T) { "options:key=flow", }, }, + { + desc: "flow based VxLAN tunnel", + i: InterfaceOptions{ + Type: InterfaceTypeVXLAN, + RemoteIP: "192.168.11.12", + Key: "flow", + DfDefault: "false", + LocalIP: "192.168.11.10", + DstPort: 8472, + }, + out: []string{ + "type=vxlan", + "options:remote_ip=192.168.11.12", + "options:key=flow", + "options:df_default=false", + "options:local_ip=192.168.11.10", + "options:dst_port=8472", + }, + }, + { + desc: "VxLAN tunnel with BFD enable", + i: InterfaceOptions{ + Type: InterfaceTypeVXLAN, + BfdEnable: true, + RemoteIP: "192.168.11.12", + LocalIP: "192.168.11.10", + DstPort: 8472, + }, + out: []string{ + "type=vxlan", + "bfd:enable=true", + "options:remote_ip=192.168.11.12", + "options:local_ip=192.168.11.10", + "options:dst_port=8472", + }, + }, { desc: "all options", i: InterfaceOptions{ diff --git a/ovsdb/client.go b/ovsdb/client.go index 2b6d58d..98f35fe 100644 --- a/ovsdb/client.go +++ b/ovsdb/client.go @@ -26,7 +26,7 @@ import ( "sync/atomic" "time" - "github.com/digitalocean/go-openvswitch/ovsdb/internal/jsonrpc" + "github.com/danieldin95/go-openvswitch/ovsdb/internal/jsonrpc" ) // A Client is an OVSDB client. Clients can be customized by using OptionFuncs diff --git a/ovsdb/client_integration_test.go b/ovsdb/client_integration_test.go index 7c23fe3..8569434 100644 --- a/ovsdb/client_integration_test.go +++ b/ovsdb/client_integration_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/digitalocean/go-openvswitch/ovsdb" + "github.com/danieldin95/go-openvswitch/ovsdb" "github.com/google/go-cmp/cmp" ) diff --git a/ovsdb/client_test.go b/ovsdb/client_test.go index c918e25..9857183 100644 --- a/ovsdb/client_test.go +++ b/ovsdb/client_test.go @@ -25,8 +25,8 @@ import ( "testing" "time" - "github.com/digitalocean/go-openvswitch/ovsdb" - "github.com/digitalocean/go-openvswitch/ovsdb/internal/jsonrpc" + "github.com/danieldin95/go-openvswitch/ovsdb" + "github.com/danieldin95/go-openvswitch/ovsdb/internal/jsonrpc" "github.com/google/go-cmp/cmp" ) diff --git a/ovsdb/example_test.go b/ovsdb/example_test.go index f593dd8..41b7dac 100644 --- a/ovsdb/example_test.go +++ b/ovsdb/example_test.go @@ -20,7 +20,7 @@ import ( "log" "time" - "github.com/digitalocean/go-openvswitch/ovsdb" + "github.com/danieldin95/go-openvswitch/ovsdb" ) // This example demonstrates basic usage of a Client. The Client connects to diff --git a/ovsdb/internal/jsonrpc/conn_test.go b/ovsdb/internal/jsonrpc/conn_test.go index 5755dfa..acb65e5 100644 --- a/ovsdb/internal/jsonrpc/conn_test.go +++ b/ovsdb/internal/jsonrpc/conn_test.go @@ -20,7 +20,7 @@ import ( "io" "testing" - "github.com/digitalocean/go-openvswitch/ovsdb/internal/jsonrpc" + "github.com/danieldin95/go-openvswitch/ovsdb/internal/jsonrpc" "github.com/google/go-cmp/cmp" ) diff --git a/ovsdb/rpc.go b/ovsdb/rpc.go index 55141ea..7bebe52 100644 --- a/ovsdb/rpc.go +++ b/ovsdb/rpc.go @@ -32,7 +32,7 @@ func (c *Client) ListDatabases(ctx context.Context) ([]string, error) { // Echo verifies that the OVSDB connection is alive, and can be used to keep // the connection alive. func (c *Client) Echo(ctx context.Context) error { - req := [1]string{"github.com/digitalocean/go-openvswitch/ovsdb"} + req := [1]string{"github.com/danieldin95/go-openvswitch/ovsdb"} var res [1]string if err := c.rpc(ctx, "echo", &res, req); err != nil { diff --git a/ovsdb/rpc_test.go b/ovsdb/rpc_test.go index a28acd2..1b60dd9 100644 --- a/ovsdb/rpc_test.go +++ b/ovsdb/rpc_test.go @@ -18,8 +18,8 @@ import ( "context" "testing" - "github.com/digitalocean/go-openvswitch/ovsdb" - "github.com/digitalocean/go-openvswitch/ovsdb/internal/jsonrpc" + "github.com/danieldin95/go-openvswitch/ovsdb" + "github.com/danieldin95/go-openvswitch/ovsdb/internal/jsonrpc" "github.com/google/go-cmp/cmp" ) @@ -70,7 +70,7 @@ func TestClientEchoError(t *testing.T) { } func TestClientEchoOK(t *testing.T) { - const echo = "github.com/digitalocean/go-openvswitch/ovsdb" + const echo = "github.com/danieldin95/go-openvswitch/ovsdb" c, _, done := testClient(t, func(req jsonrpc.Request) jsonrpc.Response { if diff := cmp.Diff("echo", req.Method); diff != "" { diff --git a/ovsnl/client.go b/ovsnl/client.go index 204af0e..d774ce5 100644 --- a/ovsnl/client.go +++ b/ovsnl/client.go @@ -20,7 +20,7 @@ import ( "strings" "unsafe" - "github.com/digitalocean/go-openvswitch/ovsnl/internal/ovsh" + "github.com/danieldin95/go-openvswitch/ovsnl/internal/ovsh" "github.com/mdlayher/genetlink" ) diff --git a/ovsnl/client_linux_integration_test.go b/ovsnl/client_linux_integration_test.go index 46d43d1..a33d407 100644 --- a/ovsnl/client_linux_integration_test.go +++ b/ovsnl/client_linux_integration_test.go @@ -21,7 +21,7 @@ import ( "os" "testing" - "github.com/digitalocean/go-openvswitch/ovsnl" + "github.com/danieldin95/go-openvswitch/ovsnl" "github.com/google/go-cmp/cmp" ) diff --git a/ovsnl/client_linux_test.go b/ovsnl/client_linux_test.go index 8384532..c8f3fae 100644 --- a/ovsnl/client_linux_test.go +++ b/ovsnl/client_linux_test.go @@ -21,7 +21,7 @@ import ( "os" "testing" - "github.com/digitalocean/go-openvswitch/ovsnl/internal/ovsh" + "github.com/danieldin95/go-openvswitch/ovsnl/internal/ovsh" "github.com/mdlayher/genetlink" "github.com/mdlayher/genetlink/genltest" "github.com/mdlayher/netlink" diff --git a/ovsnl/datapath.go b/ovsnl/datapath.go index 6751cde..8d2afc3 100644 --- a/ovsnl/datapath.go +++ b/ovsnl/datapath.go @@ -18,7 +18,7 @@ import ( "fmt" "unsafe" - "github.com/digitalocean/go-openvswitch/ovsnl/internal/ovsh" + "github.com/danieldin95/go-openvswitch/ovsnl/internal/ovsh" "github.com/mdlayher/genetlink" "github.com/mdlayher/netlink" "github.com/mdlayher/netlink/nlenc" diff --git a/ovsnl/datapath_linux_test.go b/ovsnl/datapath_linux_test.go index f533314..9f3691b 100644 --- a/ovsnl/datapath_linux_test.go +++ b/ovsnl/datapath_linux_test.go @@ -20,7 +20,7 @@ import ( "testing" "unsafe" - "github.com/digitalocean/go-openvswitch/ovsnl/internal/ovsh" + "github.com/danieldin95/go-openvswitch/ovsnl/internal/ovsh" "github.com/google/go-cmp/cmp" "github.com/mdlayher/genetlink" "github.com/mdlayher/genetlink/genltest"