Exemplo n.º 1
0
// Leave destroys a veth pair for the given endpoint ID.
func (d driver) Leave(req *dnet.LeaveRequest) error {
	if err := expectEndpoint(req.EndpointID); err != nil {
		return err
	}

	return network.DelVeth(req.EndpointID)
}
Exemplo n.º 2
0
// Join creates a Veth pair for the given endpoint ID, returning the interface info.
func (d driver) Join(req *dnet.JoinRequest) (*dnet.JoinResponse, error) {
	if err := expectNoEndpoint(req.EndpointID); err != nil {
		return nil, err
	}

	// We just need to create the Veth and tell Docker where it should go; Docker
	// will take care of moving it into the container and renaming it.
	tempPeer, err := network.AddVeth(req.EndpointID)
	if err != nil {
		network.DelVeth(req.EndpointID) // Just in case
		return nil, err
	}

	resp := &dnet.JoinResponse{}
	resp.InterfaceName = dnet.InterfaceName{SrcName: tempPeer, DstPrefix: innerVeth}
	resp.Gateway = ipdef.GatewayIP.String()
	return resp, nil
}