diff --git a/daemon/libnetwork/drivers/ipvlan/ipvlan_joinleave.go b/daemon/libnetwork/drivers/ipvlan/ipvlan_joinleave.go index 60950e85f0..aec8947b82 100644 --- a/daemon/libnetwork/drivers/ipvlan/ipvlan_joinleave.go +++ b/daemon/libnetwork/drivers/ipvlan/ipvlan_joinleave.go @@ -41,10 +41,6 @@ func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinf if err != nil { return err } - endpoint := n.endpoint(eid) - if endpoint == nil { - return fmt.Errorf("could not find endpoint with id %s", eid) - } // generate a name for the iface that will be renamed to eth0 in the sbox containerIfName, err := netutils.GenerateIfaceName(ns.NlHandle(), vethPrefix, vethLen) if err != nil { @@ -55,12 +51,15 @@ func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinf if err != nil { return err } - // bind the generated iface name to the endpoint - endpoint.srcName = vethName ep := n.endpoint(eid) if ep == nil { return fmt.Errorf("could not find endpoint with id %s", eid) } + // bind the generated iface name to the endpoint + // + // TODO(thaJeztah): this should really be done under a lock. + ep.srcName = vethName + if !n.config.Internal { switch n.config.IpvlanMode { case modeL3, modeL3S: diff --git a/daemon/libnetwork/drivers/macvlan/macvlan_joinleave.go b/daemon/libnetwork/drivers/macvlan/macvlan_joinleave.go index a447591b96..cf3e38bc61 100644 --- a/daemon/libnetwork/drivers/macvlan/macvlan_joinleave.go +++ b/daemon/libnetwork/drivers/macvlan/macvlan_joinleave.go @@ -29,10 +29,6 @@ func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinf if err != nil { return err } - endpoint := n.endpoint(eid) - if endpoint == nil { - return fmt.Errorf("could not find endpoint with id %s", eid) - } // generate a name for the iface that will be renamed to eth0 in the sbox containerIfName, err := netutils.GenerateIfaceName(ns.NlHandle(), vethPrefix, vethLen) if err != nil { @@ -43,12 +39,15 @@ func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinf if err != nil { return err } - // bind the generated iface name to the endpoint - endpoint.srcName = vethName ep := n.endpoint(eid) if ep == nil { return fmt.Errorf("could not find endpoint with id %s", eid) } + // bind the generated iface name to the endpoint + // + // TODO(thaJeztah): this should really be done under a lock. + ep.srcName = vethName + // parse and match the endpoint address with the available v4 subnets if !n.config.Internal { if len(n.config.Ipv4Subnets) > 0 {