Skip to content

Commit

Permalink
Merge pull request #1 from docker/master
Browse files Browse the repository at this point in the history
up to date
  • Loading branch information
smarkm authored Jun 25, 2019
2 parents 5ac07ab + 62a13ae commit 3866ae1
Show file tree
Hide file tree
Showing 706 changed files with 156,045 additions and 52,910 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ RUN go get golang.org/x/lint/golint \
golang.org/x/tools/cmd/cover \
github.com/mattn/goveralls \
github.com/gordonklaus/ineffassign \
github.com/client9/misspell/cmd/misspell \
honnef.co/go/tools/cmd/gosimple
github.com/client9/misspell/cmd/misspell

WORKDIR /go/src/github.com/docker/libnetwork

Expand Down
33 changes: 10 additions & 23 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
[Org]
[Org."Core maintainers"]
people = [
"abhi",
"aboch",
"ctelfer",
"chenchun",
"euanh",
"fcrisciani",
"mavenugo",
"selansen",
]

[people]
Expand All @@ -27,25 +25,10 @@

# ADD YOURSELF HERE IN ALPHABETICAL ORDER

[people.abhi]
Name = "Abhinandan Prativadi Bayankaram"
Email = "[email protected]"
GitHub = "abhi"

[people.aboch]
Name = "Alessandro Boch"
Email = "[email protected]"
GitHub = "aboch"

[people.ctelfer]
Name = "Christopher Telfer"
Email = "[email protected]"
GitHub = "ctelfer"

[people.chenchun]
Name = "Chun Chen"
Email = "[email protected]"
GitHub = "chenchun"
[people.euanh]
Name = "Euan Harris"
Email = "[email protected]"
GitHub = "euanh"

[people.fcrisciani]
Name = "Flavio Crisciani"
Expand All @@ -57,3 +40,7 @@
Email = "[email protected]"
GitHub = "mavenugo"

[people.selansen]
Name = "Elangovan Sivanandam"
Email = "[email protected]"
GitHub = "selansen"
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all all-local build build-local clean cross cross-local gosimple vet lint misspell check check-local check-code check-format unit-tests protobuf protobuf-local check-protobuf
.PHONY: all all-local build build-local clean cross cross-local vet lint misspell check check-local check-code check-format unit-tests protobuf protobuf-local check-protobuf
SHELL=/bin/bash

dockerbuildargs ?= --target dev - < Dockerfile
Expand Down Expand Up @@ -115,7 +115,7 @@ check: builder

check-local: check-code check-format

check-code: check-protobuf lint gosimple vet ineffassign
check-code: check-protobuf lint vet ineffassign

check-format: fmt misspell

Expand Down Expand Up @@ -164,10 +164,6 @@ ineffassign: ## run ineffassign
@echo "🐳 $@"
@test -z "$$(ineffassign . | grep -v vendor/ | grep -v ".pb.go:" | grep -v ".mock.go" | tee /dev/stderr)"

gosimple: ## run gosimple
@echo "🐳 $@"
@test -z "$$(gosimple . | grep -v vendor/ | grep -v ".pb.go:" | grep -v ".mock.go" | tee /dev/stderr)"

# check-protobuf rebuilds .pb.go files and fails if they have changed
check-protobuf: PROTOC_CHECK=1
check-protobuf: $(PB_FILES)
Expand Down
2 changes: 1 addition & 1 deletion cmd/dnet/dnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func startTestDriver() error {
}

func newDnetConnection(val string) (*dnetConnection, error) {
url, err := opts.ParseHost(false, val)
url, err := opts.ParseHost(false, false, val)
if err != nil {
return nil, err
}
Expand Down
20 changes: 10 additions & 10 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ func (c *controller) clusterAgentInit() {
}
}
case cluster.EventNodeLeave:
keysAvailable = false
c.agentOperationStart()
c.Lock()
c.keys = nil
Expand Down Expand Up @@ -706,11 +705,17 @@ const overlayDSROptionString = "dsr"
// NewNetwork creates a new network of the specified network type. The options
// are network specific and modeled in a generic way.
func (c *controller) NewNetwork(networkType, name string, id string, options ...NetworkOption) (Network, error) {
var (
cap *driverapi.Capability
err error
t *network
)

if id != "" {
c.networkLocker.Lock(id)
defer c.networkLocker.Unlock(id)

if _, err := c.NetworkByID(id); err == nil {
if _, err = c.NetworkByID(id); err == nil {
return nil, NetworkNameError(id)
}
}
Expand Down Expand Up @@ -739,15 +744,10 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
}

network.processOptions(options...)
if err := network.validateConfiguration(); err != nil {
if err = network.validateConfiguration(); err != nil {
return nil, err
}

var (
cap *driverapi.Capability
err error
)

// Reset network types, force local scope and skip allocation and
// plumbing for configuration networks. Reset of the config-only
// network drivers is needed so that this special network is not
Expand Down Expand Up @@ -794,11 +794,11 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
// From this point on, we need the network specific configuration,
// which may come from a configuration-only network
if network.configFrom != "" {
t, err := c.getConfigNetwork(network.configFrom)
t, err = c.getConfigNetwork(network.configFrom)
if err != nil {
return nil, types.NotFoundErrorf("configuration network %q does not exist", network.configFrom)
}
if err := t.applyConfigurationTo(network); err != nil {
if err = t.applyConfigurationTo(network); err != nil {
return nil, types.InternalErrorf("Failed to apply configuration: %v", err)
}
defer func() {
Expand Down
24 changes: 12 additions & 12 deletions drivers/overlay/ov_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"strconv"
"strings"
"sync"
"syscall"

"github.com/docker/docker/pkg/reexec"
"github.com/docker/libnetwork/datastore"
Expand All @@ -27,6 +26,7 @@ import (
"github.com/vishvananda/netlink"
"github.com/vishvananda/netlink/nl"
"github.com/vishvananda/netns"
"golang.org/x/sys/unix"
)

var (
Expand Down Expand Up @@ -97,18 +97,18 @@ func setDefaultVlan() {
}

// make sure the sysfs mount doesn't propagate back
if err = syscall.Unshare(syscall.CLONE_NEWNS); err != nil {
if err = unix.Unshare(unix.CLONE_NEWNS); err != nil {
logrus.Errorf("unshare failed, %v", err)
os.Exit(1)
}

flag := syscall.MS_PRIVATE | syscall.MS_REC
if err = syscall.Mount("", "/", "", uintptr(flag), ""); err != nil {
flag := unix.MS_PRIVATE | unix.MS_REC
if err = unix.Mount("", "/", "", uintptr(flag), ""); err != nil {
logrus.Errorf("root mount failed, %v", err)
os.Exit(1)
}

if err = syscall.Mount("sysfs", "/sys", "sysfs", 0, ""); err != nil {
if err = unix.Mount("sysfs", "/sys", "sysfs", 0, ""); err != nil {
logrus.Errorf("mounting sysfs failed, %v", err)
os.Exit(1)
}
Expand Down Expand Up @@ -427,7 +427,7 @@ func populateVNITbl() {
}
defer ns.Close()

nlh, err := netlink.NewHandleAt(ns, syscall.NETLINK_ROUTE)
nlh, err := netlink.NewHandleAt(ns, unix.NETLINK_ROUTE)
if err != nil {
logrus.Errorf("Could not open netlink handle during vni population for ns %s: %v", path, err)
return nil
Expand Down Expand Up @@ -583,7 +583,7 @@ func (n *network) setupSubnetSandbox(s *subnet, brName, vxlanName string) error

if ok {
deleteVxlanByVNI(path, s.vni)
if err := syscall.Unmount(path, syscall.MNT_FORCE); err != nil {
if err := unix.Unmount(path, unix.MNT_FORCE); err != nil {
logrus.Errorf("unmount of %s failed: %v", path, err)
}
os.Remove(path)
Expand Down Expand Up @@ -693,7 +693,7 @@ func (n *network) cleanupStaleSandboxes() {
if strings.Contains(n.id, pattern) {
// Delete all vnis
deleteVxlanByVNI(path, 0)
syscall.Unmount(path, syscall.MNT_DETACH)
unix.Unmount(path, unix.MNT_DETACH)
os.Remove(path)

// Now that we have destroyed this
Expand Down Expand Up @@ -755,12 +755,12 @@ func (n *network) initSandbox(restore bool) error {

var nlSock *nl.NetlinkSocket
sbox.InvokeFunc(func() {
nlSock, err = nl.Subscribe(syscall.NETLINK_ROUTE, syscall.RTNLGRP_NEIGH)
nlSock, err = nl.Subscribe(unix.NETLINK_ROUTE, unix.RTNLGRP_NEIGH)
if err != nil {
return
}
// set the receive timeout to not remain stuck on the RecvFrom if the fd gets closed
tv := syscall.NsecToTimeval(soTimeout.Nanoseconds())
tv := unix.NsecToTimeval(soTimeout.Nanoseconds())
err = nlSock.SetReceiveTimeout(&tv)
})
n.nlSocket = nlSock
Expand Down Expand Up @@ -803,7 +803,7 @@ func (n *network) watchMiss(nlSock *nl.NetlinkSocket, nsPath string) {
return
}
// When the receive timeout expires the receive will return EAGAIN
if err == syscall.EAGAIN {
if err == unix.EAGAIN {
// we continue here to avoid spam for timeouts
continue
}
Expand All @@ -812,7 +812,7 @@ func (n *network) watchMiss(nlSock *nl.NetlinkSocket, nsPath string) {
}

for _, msg := range msgs {
if msg.Header.Type != syscall.RTM_GETNEIGH && msg.Header.Type != syscall.RTM_NEWNEIGH {
if msg.Header.Type != unix.RTM_GETNEIGH && msg.Header.Type != unix.RTM_NEWNEIGH {
continue
}

Expand Down
4 changes: 3 additions & 1 deletion drivers/overlay/overlay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"testing"
"time"

"golang.org/x/sys/unix"

"github.com/docker/docker/pkg/plugingetter"
"github.com/docker/libkv/store/consul"
"github.com/docker/libnetwork/datastore"
Expand Down Expand Up @@ -150,7 +152,7 @@ func TestNetlinkSocket(t *testing.T) {
t.Fatal()
}
// set the receive timeout to not remain stuck on the RecvFrom if the fd gets closed
tv := syscall.NsecToTimeval(soTimeout.Nanoseconds())
tv := unix.NsecToTimeval(soTimeout.Nanoseconds())
err = nlSock.SetReceiveTimeout(&tv)
if err != nil {
t.Fatal()
Expand Down
34 changes: 32 additions & 2 deletions firewall_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,52 @@ package libnetwork

import (
"github.com/docker/libnetwork/iptables"
"github.com/docker/libnetwork/netlabel"
"github.com/sirupsen/logrus"
)

const userChain = "DOCKER-USER"

func (c *controller) arrangeUserFilterRule() {
c.Lock()
arrangeUserFilterRule()

if c.hasIPTablesEnabled() {
arrangeUserFilterRule()
}

c.Unlock()

iptables.OnReloaded(func() {
c.Lock()
arrangeUserFilterRule()

if c.hasIPTablesEnabled() {
arrangeUserFilterRule()
}

c.Unlock()
})
}

func (c *controller) hasIPTablesEnabled() bool {
// Locking c should be handled in the calling method.
if c.cfg == nil || c.cfg.Daemon.DriverCfg[netlabel.GenericData] == nil {
return false
}

genericData, ok := c.cfg.Daemon.DriverCfg[netlabel.GenericData]
if !ok {
return false
}

optMap := genericData.(map[string]interface{})
enabled, ok := optMap["EnableIPTables"].(bool)
if !ok {
return false
}

return enabled
}

// This chain allow users to configure firewall policies in a way that persists
// docker operations/restarts. Docker will not delete or modify any pre-existing
// rules from the DOCKER-USER filter chain.
Expand Down
11 changes: 5 additions & 6 deletions ipvs/ipvs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
package ipvs

import (
"fmt"
"net"
"syscall"
"time"

"fmt"

"github.com/vishvananda/netlink/nl"
"github.com/vishvananda/netns"
"golang.org/x/sys/unix"
)

const (
Expand Down Expand Up @@ -98,16 +97,16 @@ func New(path string) (*Handle, error) {
}
defer n.Close()

sock, err := nl.GetNetlinkSocketAt(n, netns.None(), syscall.NETLINK_GENERIC)
sock, err := nl.GetNetlinkSocketAt(n, netns.None(), unix.NETLINK_GENERIC)
if err != nil {
return nil, err
}
// Add operation timeout to avoid deadlocks
tv := syscall.NsecToTimeval(netlinkSendSocketTimeout.Nanoseconds())
tv := unix.NsecToTimeval(netlinkSendSocketTimeout.Nanoseconds())
if err := sock.SetSendTimeout(&tv); err != nil {
return nil, err
}
tv = syscall.NsecToTimeval(netlinkRecvSocketsTimeout.Nanoseconds())
tv = unix.NsecToTimeval(netlinkRecvSocketsTimeout.Nanoseconds())
if err := sock.SetReceiveTimeout(&tv); err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 3866ae1

Please sign in to comment.