diff --git a/cmd/vxlan.go b/cmd/vxlan.go index d32586d22..56cd2b2a1 100644 --- a/cmd/vxlan.go +++ b/cmd/vxlan.go @@ -108,8 +108,7 @@ var vxlanCreateCmd = &cobra.Command{ return fmt.Errorf("not a VxlanStitched link") } - // deploy the vxlan with existing link. The first endpoint is the host endpoint - err = vxl.DeployWithExistingVeth(ctx, vxl.GetEndpoints()[0]) + err = vxl.DeployWithExistingVeth(ctx) if err != nil { return err } diff --git a/links/link_vxlan.go b/links/link_vxlan.go index 349556225..4dacc284b 100644 --- a/links/link_vxlan.go +++ b/links/link_vxlan.go @@ -85,23 +85,10 @@ func (lr *LinkVxlanRaw) resolveStitchedVxlan(params *ResolveParams) (Link, error return nil, err } - var vethLink *LinkVEth - var stitchEp Endpoint - - // if the endpoint is host, we don't need to create the veth link - // the stitch endpoint is just a host endpoint with the passed interface name - if lr.Endpoint.Node == "host" { - // a fake endpoint used only to print the host interface name in the outputs - // it is not deployed as it meant to exist - epHost := NewEndpointHost(NewEndpointGeneric(vxlanLink.localEndpoint.GetNode(), params.VxlanIfaceNameOverwrite, nil)) - vethLink, stitchEp, err = nil, epHost, nil - } else { - // otherwise we need to create the veth link - vethLink, stitchEp, err = lr.resolveStitchedVEthComponent(params) - if err != nil { - return nil, err - } - + // prepare the veth struct + vethLink, stitchEp, err := lr.resolveStitchedVEthComponent(params) + if err != nil { + return nil, err } // return the stitched vxlan link @@ -241,7 +228,7 @@ func (l *LinkVxlan) deployVxlanInterface() error { // retrieve the parent interface netlink handle parentIface, err := netlink.LinkByName(l.remoteEndpoint.parentIface) if err != nil { - return err + return fmt.Errorf("error looking up vxlan parent interface %s: %w", l.remoteEndpoint.parentIface, err) } // create the Vxlan struct @@ -269,14 +256,14 @@ func (l *LinkVxlan) deployVxlanInterface() error { // add the link err = netlink.LinkAdd(&vxlanconf) if err != nil { - return err + return fmt.Errorf("error adding vxlan link %s: %w", l.localEndpoint.String(), err) } // fetch the mtu from the actual state for templated config generation if l.MTU == 0 { interf, err := netlink.LinkByName(l.localEndpoint.GetRandIfaceName()) if err != nil { - return err + return fmt.Errorf("error looking up local vxlan endpoint of %s : %w", l.localEndpoint.String(), err) } l.MTU = interf.Attrs().MTU } diff --git a/links/link_vxlan_stitched.go b/links/link_vxlan_stitched.go index 9a8a54421..451ec7d67 100644 --- a/links/link_vxlan_stitched.go +++ b/links/link_vxlan_stitched.go @@ -36,8 +36,8 @@ func NewVxlanStitched(vxlan *LinkVxlan, veth *LinkVEth, vethStitchEp Endpoint) * // DeployWithExistingVeth provisions the stitched vxlan link whilst the // veth interface does already exist, hence it is not created as part of this // deployment. -func (l *VxlanStitched) DeployWithExistingVeth(ctx context.Context, ep Endpoint) error { - return l.internalDeploy(ctx, ep, true) +func (l *VxlanStitched) DeployWithExistingVeth(ctx context.Context) error { + return l.internalDeploy(ctx, nil, true) } // Deploy provisions the stitched vxlan link with all its underlying sub-links.