Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixe golint & gofmt #64

Merged
merged 2 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nl/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func SetupVeth(contVethName, hostVethName string, mtu int, hostNS ns.NetNS) (net
return ifaceFromNetlinkLink(hostVeth), ifaceFromNetlinkLink(contVeth), nil
}

// AddRoute is a function for add route
func AddRoute(ipn *net.IPNet, gwIP string, dev string) error {
link, err := netlink.LinkByName(dev)
if err != nil {
Expand All @@ -91,7 +92,6 @@ func AddRoute(ipn *net.IPNet, gwIP string, dev string) error {
if gwIP != "" {
gw := net.ParseIP(gwIP)
return ip.AddRoute(ipn, gw, link)
} else {
return ip.AddRoute(ipn, nil, link)
}
return ip.AddRoute(ipn, nil, link)
}
14 changes: 7 additions & 7 deletions nl/link_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package nl

import (
"net"
"os"
"testing"
"net"

"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
Expand Down Expand Up @@ -97,9 +97,9 @@ func TestAddRoute(t *testing.T) {
Mask: net.CIDRMask(4, 32),
},
gwIP: "",
dev: "lo",
dev: "lo",
},
wantErr: true,
wantErr: true,
}, {
name: "Test lo interface with 0.0.0.0",
args: args{
Expand All @@ -108,9 +108,9 @@ func TestAddRoute(t *testing.T) {
Mask: net.CIDRMask(4, 32),
},
gwIP: "0.0.0.0",
dev: "lo",
dev: "lo",
},
wantErr: true,
wantErr: true,
}, {
name: "Test unknow interface",
args: args{
Expand All @@ -119,9 +119,9 @@ func TestAddRoute(t *testing.T) {
Mask: net.CIDRMask(24, 32),
},
gwIP: "0.0.0.0",
dev: "unknow",
dev: "unknow",
},
wantErr: true,
wantErr: true,
},
}
for _, tt := range tests {
Expand Down
5 changes: 5 additions & 0 deletions nl/netlink_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ import (
"log"
)

// NlEventHandler is the structure for netlink event handler
type NlEventHandler struct {
stop chan struct{}
LinkDeleteHandler []linkReceiver
}

type linkReceiver func(lu netlink.LinkUpdate) bool

// New will return an new netlink event handler
func New() *NlEventHandler {
return &NlEventHandler{
stop: make(chan struct{}),
}
}

// AddDeletedLinkHandler will add DeletedLinkHandler
func (nl *NlEventHandler) AddDeletedLinkHandler(handler linkReceiver) {
nl.LinkDeleteHandler = append(nl.LinkDeleteHandler, handler)
}

// TrackNetlink will track netlink
func (nl *NlEventHandler) TrackNetlink() error {

stop := make(chan struct{})
Expand Down Expand Up @@ -53,6 +57,7 @@ func (nl *NlEventHandler) TrackNetlink() error {
}
}

// Stop will stop netlink
func (nl *NlEventHandler) Stop() {
if nl.stop == nil {
return
Expand Down
2 changes: 1 addition & 1 deletion openvswitch/ovs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func New() *OVSManager {
}
}

// CreateBridge
// CreateBridge is a function for create bridge
// userspace datapath
// ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
// kernel datapath
Expand Down