moby / moby/libnetwork

[macvlan] Same parent and gateway for multiple networks

Open
#2,384 4 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.2k
Forks
875
PR merge metrics
No merged PRs in 30d

Description

Hi,

We are struggling with an issue with macvlan driver.

We wonder why we can't have multiple macvlan docker network with the same parent ?

This check forbids it in libnetwork/drivers/macvlan/macvlan_network.go :

 func (d *driver) createNetwork(config *configuration) error {
       networkList := d.getNetworks()
       for _, nw := range networkList {
               if config.Parent == nw.config.Parent {
                       return fmt.Errorf("network %s is already using parent interface %s",
                               getDummyName(stringid.TruncateID(nw.config.ID)), config.Parent)
               }
       }

And, also, why we can't have the same gateway for multiple macvlan docker networks ?

// Convert IP ordinal for this subnet into IP address
               return generateAddress(ordinal, base), nil
        case bitseq.ErrBitAllocated:
               return nil, ipamapi.ErrIPAlreadyAllocated

Our use case is the following :

  • 3 dockers nodes in Swarm mode
  • A public /28 RIPE routed to a private virtual network on each node
  • Mount public IP directly in containers

Our problem :

  • We want to specify the public IP of a container.
    -> IPAM in Swarm does not allow to specify ipv4_address param in compose file (normal behaviour with --scale)

    -> So we thought about creating one macvlan network with same parent interface, same gateway, and an --ip-range with the /32 we want.

We made some patch on the two files specified, and it works.

Is it a viable solution, and could we remove safely those checks?

Thank you !

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in libnetwork/drivers/macvlan/macvlan_network.go, examining the parent-interface check in createNetwork and the referenced IPAM address-allocation path. Trace how shared parents, gateways, and IP ranges are validated, then determine the safety requirements for supporting the described Swarm setup and add tests that define the accepted behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.