Skip to content
This repository has been archived by the owner on Mar 28, 2018. It is now read-only.

Networking: Adding Base Networking Support for CC using iproute2 #44

Merged
merged 46 commits into from
Aug 5, 2016

Conversation

mcastelino
Copy link
Contributor

@mcastelino mcastelino commented Jul 21, 2016

Networking: Basic Networking Support

Support for a single network docker container. Support the default docker networks none and bridge.

docker net=none and docker net=bridge

This commit includes support for

  • Discovering the first docker CNM created network interface with a valid IPv4 address
    • Discovering IPv4 address, subnet, MAC address and default gateway
  • Sending IP Configuration Parameters into the guest kernel
  • Sending in the hostname to the guest kernel
  • Creation of a single tap interface that can be used to connect the VM to a single container network
  • Configuration of the MAC address via QEMU
  • Quick and dirty iproute2 implementation that creates and integration
    bridge and connects it to the container interface (veth)
    and the tap interface (tap)
  • Reprogramming of the veth MAC to one that does not conflict with the MAC that is now assigned to the tap within the VM

Limitations:

  • Multiple networks are not supported
  • IPv4+IPv6 containers are not supported due the kernel command line limitations.
  • Setup latency is high due to the use of iproute2 commands
  • Does not propagate routes from the namespace into the VM

Future Work:
This implementation uses shell invocation vs netlink commands.
A future refined implementation will use netlink based interface to configure networking.
Future implementation will use a cloud-init based configuration that allows for IPv4 and IPv6 support

Overall Flow

  • From the parent process, create the netns (this will propagate into the child)
  • Fork the parent process and have the child wait on its networking configuration pipe
  • Capture the child pid in the parent
  • From the parent process:
    a. Create state file (include the PID)
    b. Run hooks (sending PID to docker)
    - Docker CNM now populate the namespace with networking
    c. Create the network
    • Do this by scanning the network namespace in the parent
    • And create the appropriate plumbing
      d. Build the netcfg (key=value) concatenated network string
      • This uses what we scanned and what we created
        d. Send the netcfg to the child
        e. From the child process, receive the netcfg blob, parse it and add it to the process arguments
        f. From the child process, execve(qemu).
    • The child process arguments will contain the networking ones.
    • We have to wait to launch qemu till we get the network parameters as the parameters
      are needed to specify the tap interface(s) to be used by QEMU and to wait for the
      values of the kernel networking
      parameters

Note: In theory we can send the pid of the parent itself, but by doing so we may cause docker to record the pid somewhere, and this may cause issues elsewhere.

jodh-intel and others added 30 commits July 14, 2016 17:47
Signed-off-by: James Hunt <james.o.hunt@intel.com>
Signed-off-by: James Hunt <james.o.hunt@intel.com>
Signed-off-by: James Hunt <james.o.hunt@intel.com>
Signed-off-by: James Hunt <james.o.hunt@intel.com>
Support for a single network docker container
docker net=none and docker net=bridge

This commit includes support for

- Discovering the docker CNM created network interface
    - its IPv4, IPv6 and MAC address
- Sending IP Configuration Parameters into the guest kernel
- Sending in the hostname to the guest kernel
- Creation of a single tap interface that can be used to
  connect the VM to a single container network
- Configuration of the MAC address via QEMU
- Quick and dirty implementation that creates and integration
  bridge and connects it to the container interface (veth)
  and the tap interface (tap)
- Reprogramming of the veth MAC to one that does not conflict
  with the MAC that is now assigned to the tap within the VM

Limitations:
IPv4+IPv6 containers are not supported due the kernel command
line limitations.

This implementation uses shell invocation vs netlink commands.
A future refined implementation will use netlink based interface
to configure networking.

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
Ensure that argv[0] is set to to the name of the hook.
This enables docker reexec code to handle the hook properly.

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
Enable support for --net=none

In this case no external networking is enabled.

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
Free the network configuration parameters

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
*/

if ( config->net.ip_address != NULL ) {
return ( g_strdup_printf("ip=%s:::%s:%s:%s:off::",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan to get a deafult gateway is use the namespace interface as well ? I've created an issue about this #55

gorozco1 and others added 2 commits July 28, 2016 17:50
* With the new code for networking libnetlink header is needed to
  build cc-oci-runtime, which is include in iproute2 package.
DOCS: Add iproute-dev dependency to build cc-oci-runtime
Signed-off-by: James Hunt <james.o.hunt@intel.com>
cc_oci_replace_string() was being called twice for @netdev@,
@NETDEV_PARAMS@, @NetDevice@ and @NETDEVICE_PARAMS@.

Signed-off-by: James Hunt <james.o.hunt@intel.com>
static gboolean
cc_oci_tap_create(const gchar *tap) {
struct ifreq ifr;
int fd;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a check like the following:

if (! tap) {

    return false;
}

Add additional validation and documentation for internal
functions. Fix some formatting issues

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
@mcastelino mcastelino self-assigned this Aug 4, 2016
mcastelino and others added 2 commits August 4, 2016 21:22
Discover the first valid IPv4 enabled interface within the
container namespace, connect it to the integration bridge
and pass the IP address, subnet and the default gateway associated
with this interface into the container using kernel command
line parameters.

If the container has multiple IPv4 enabled interfaces only the
first interface will be discovered and added to the container.

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
Networking - Default Gateway Support
@mcastelino mcastelino changed the title WIP: Adding Base Networking Support for CC Networking: Adding Base Networking Support for CC using iproute2 Aug 4, 2016
mcastelino and others added 2 commits August 4, 2016 22:08
Latest ubuntu and hence travis does not support libnetlink.
Remove the libnetlink depenency for now

Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
Networking: Remove netlink dependency
@jodh-intel
Copy link
Contributor

LGTM. Tested and lookups and external connectivity now work for me. +1.

@sameo
Copy link

sameo commented Aug 5, 2016

Looks good to me as well.

@sameo sameo merged commit edf18d8 into master Aug 5, 2016
@jodh-intel jodh-intel deleted the networking branch August 5, 2016 10:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants