Commit Graph

24 Commits

Author SHA1 Message Date
Eng Zer Jun c55a4ac779
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated in Go 1.16. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-08-27 14:56:57 +08:00
Sebastiaan van Stijn 686be57d0a
Update to Go 1.17.0, and gofmt with Go 1.17
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-24 23:33:27 +02:00
Brian Goff 00b2c13a1b Fix some windows issues in libnetwork tests
Fix build constraints for linux-only network drivers

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-01 23:48:23 +00:00
Brian Goff a0a473125b Fix libnetwork imports
After moving libnetwork to this repo, we need to update all the import
paths for libnetwork to point to docker/docker/libnetwork instead of
docker/libnetwork.
This change implements that.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-01 21:51:23 +00:00
Sebastiaan van Stijn 02d313ca15 drivers/bridge: skip kernel version check
All distros that are supported by Docker now have at least
kernel version 3.10, so this check should no longer be needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-08-31 20:44:51 +02:00
Sebastiaan van Stijn 27345e8f8f log error instead if disabling IPv6 router advertisement failed
Previously, failing to disable IPv6 router advertisement prevented the daemon to
start.

An issue was reported by a user that started docker using `systemd-nspawn "machine"`,
which produced an error;

    failed to start daemon: Error initializing network controller:
    Error creating default "bridge" network: libnetwork:
    Unable to disable IPv6 router advertisement:
    open /proc/sys/net/ipv6/conf/docker0/accept_ra: read-only file system

This patch changes the error to a log-message instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-06-12 19:32:18 +02:00
Samuel Karp e65003a722 bridge: disable IPv6 router advertisements
Signed-off-by: Samuel Karp <skarp@amazon.com>
(cherry picked from commit 9489546c44d94d37337191c263879a7ac075a331)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-06-02 12:06:39 +02:00
Tomas Janousek 6038ef390d bridge: Fix hwaddr set race between us and udev
systemd and udev in their default configuration attempt to set a
persistent MAC address for network interfaces that don't have one
already [systemd-def-link]. We set the address only after creating the
interface, so there is a race between us and udev. There are several
outcomes (that actually occur, this race is very much not a theoretical
one):

* We set the address before udev gets to the networking rules, so udev
  sees `/sys/devices/virtual/net/docker0/addr_assign_type = 3`
  (NET_ADDR_SET). This means there's no need to assign a different
  address and everything is fine.

* udev reads `/sys/devices/virtual/net/docker0/addr_assign_type` before
  we set the address, gets `1` (NET_ADDR_RANDOM), and proceeds to
  generate and set a persistent address.

  Old versions of udev (pre-v242, i.e. without [udev-patch]) would then
  fail to generate an address, spit out "Could not generate persistent
  MAC address for docker0: No such file or directory" (see [udev-issue],
  and everything would be probably fine as well.

  Current version of udev (with [udev-patch]) will generate an address
  just fine and then race us setting it. As udev does more work than we,
  the most probable outcome is that udev will overwrite the address we
  set and possibly cause some trouble later on.

On a clean Debian Buster (from Vagrant) VM with systemd/udev 242 from
Debian Experimental, `docker network create net1` up to `net7` resulted
in 3 bridges having a 02:42: address and 4 bridges having a seemingly
random (actually generated from interface name) address. With systemd
241, the result would be all bridges having a 02:42:, but some "Could
not generate persistent MAC address for" messages in the log.

The fix is to revert the MAC address setting fix from 6901ea51dc,
as it is no longer necessary with current netlink [netlink-addr-add],
and set the address atomically when creating the bridge interface, not
after that.

[systemd-def-link]: a166cd3aac/network/99-default.link
[udev-patch]: 6d36464065
[udev-issue]: https://github.com/systemd/systemd/issues/3374
[netlink-addr-add]: 7d9b424492

...

Do note that a similar race happens when creating veth devices as well.
I wasn't able to reproduce getting a wrong (non-02:42:) address,
possibly because the address is set by docker later, maybe only after
the interface is moved to another network namespace (but I'm just
guessing here). Still, different timings result in various error
messages being logged ("link_config: could not get ethtool features for
vethd9c938e" and the like) depending on when the interface disappears
from the primary network namespace. I'm not sure how to fix this and I
don't intend to dig deeper into this.

Signed-off-by: Tomas Janousek <tomi@nomi.cz>
2019-05-19 19:38:35 +02:00
Derek McGowan 710e0664c4 Update logrus to v1.0.1
Fix case sensitivity issue
Update docker and runc vendors

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-08-07 11:20:47 -07:00
Alessandro Boch 6d3fa9e0f2 Migrate libnetwork to use netlink.Handle
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-06-08 21:05:36 -07:00
Madhu Venugopal a41025e9c0 Fixed a few more issues observed during docker integration
- DisableBridgeCreation is misleading. change it to DefaultBridge
- Dont fail the init if localstore cannot be initialized
- added a convenience function to get endpoint for a container

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-25 09:40:42 -07:00
Madhu Venugopal a42e5f0663 Flip the default for the flag AllowNonDefaultBridge in bridge driver
Replaced it with DisableBridgeCreation and it can be used ONLY in
a special case for docker0 bridge from docker, instead of calling it
from all other case.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-24 02:18:35 -07:00
Madhu Venugopal 6901ea51dc Prefer Netlink calls over ioctl
As seen in https://github.com/docker/docker/issues/14738 there is
general instability in the later kernels under race conditions when ioctl
calls are used in parallel with netlink calls for various operations.
(We are yet to narrow down to the exact root-cause on the kernel).

For those older kernels which doesnt support some of the netlink APIs,
we can fallback to using ioctl calls. Hence bringing back the original
code that used netlink (https://github.com/docker/libnetwork/pull/349).

Also, there was an existing bug in bridge creation using netlink which
was setting bridge mac during bridge creation. That operation is not
supported in the netlink library (and doesnt throw an error either).
Included a fix for that condition by setting the bridge mac after
creating the bridge.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-07-30 09:10:22 -07:00
Alessandro Boch c266c843a7 Incorrect kernel version check in bridge
- Kernel version check logic was wrong

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-07-30 06:51:43 -07:00
Alexander Morozov 55e7175f64 Remove dependency on libcontainer
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-07-16 13:26:26 -07:00
Jana Radhakrishnan 885056b243 Use ioctls to create bridge
The netlink way of creating bridge has problems in older
kernels like the one used on RHEL 6 (which is a supported
one). So trying to use ioctl method to create bridge
so that it works on any version.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-07-02 09:27:53 -07:00
Alessandro Boch 5d9c59e523 Support network options in rest api
- Also unexporting configuration structures in bridge
- Changes in dnet/network.go to set bridge name = network name

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-23 20:12:29 -07:00
Jana Radhakrishnan 94a9f12280 Moved most of the driver configuration to network configuration.
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-06 17:43:24 +00:00
Jana Radhakrishnan e91ed59cb2 Changed all the naked error returns in bridge driver to proper error
types, except the naked error returns which were just prefixing
strings to previously returned error strings.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-04-17 02:50:22 +00:00
Jana Radhakrishnan e797f80ad4 Added driver specific config support
- Added api enhancement to pass driver specific config
  - Refactored simple bridge driver code for driver specific config
  - Added an undocumented option to add non-default bridges without
    manual pre-provisioning to help libnetwork testing
  - Reenabled libnetwork test to do api testing
  - Updated README.md

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-04-15 18:32:07 +00:00
Jana Radhakrishnan 68ae284db5 Libnetwork refactor for container network model
- Added controller, network, endpoint and sandbox interfaces
    - Created netutils package for miscallaneous network utilities
    - Created driverapi package to break cyclic dependency b/w driver and libnetwork
    - Made libnetwork multithread safe
    - Made bridge driver multithread safe
    - Fixed README.md

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-04-13 21:40:50 +00:00
Alessandro Boch 68d223a0e0 Issue #18: IP Allocator rework
- Move ipallocator package into libnetwork
- Also ported network utility functions and their tests in libnetwork:
  docker/daemon/networkdriver/utilg.go => libnetwork/utils.go
  docker/daemon/networkdriver/network_test.go => libnetwork/utils_test.go
- Changed drivers/setup_device.go and setup_ipv4.go to reuse functions in
  utils.go, instead of redefining internally.
- Modified utils to use vishvananda/netlink instead of libcontainer/netlink

Signed-off-by: Alessandro Boch <aboch@socketplane.io>
2015-03-24 13:57:59 -07:00
Arnaud Porterie 6424c7a875 Remove golint warnings
Fix all golint warnings, mostly by making exported types internal.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
2015-03-04 13:29:28 -08:00
Arnaud Porterie 8ca185e2ee Move bridge to drivers/
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
2015-02-24 11:29:06 -08:00
Renamed from libnetwork/bridge/setup_device.go (Browse further)