Skip to content

Commit

Permalink
push vxlan interface to container, rename and bring it up
Browse files Browse the repository at this point in the history
  • Loading branch information
steiler committed Aug 17, 2023
1 parent 68d9170 commit 711fdec
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions links/link_vxlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ func (l *LinkVxlan) Deploy(ctx context.Context) error {
// create the Vxlan struct
vxlanconf := netlink.Vxlan{
LinkAttrs: netlink.LinkAttrs{
Name: l.LocalEndpoint.GetRandIfaceName(),
TxQLen: 1000,
Name: l.LocalEndpoint.GetRandIfaceName(),
TxQLen: 1000,
HardwareAddr: l.RemoteEndpoint.mac,
},
VxlanId: l.RemoteEndpoint.vni,
VtepDevIndex: parentIface.Attrs().Index,
Expand All @@ -124,17 +125,27 @@ func (l *LinkVxlan) Deploy(ctx context.Context) error {
if l.RemoteEndpoint.udpPort != 0 {
vxlanconf.Port = l.RemoteEndpoint.udpPort
}

// define the MTU if defined in the input
if l.MTU != 0 {
vxlanconf.LinkAttrs.MTU = l.MTU
}

// add the link
err = netlink.LinkAdd(&vxlanconf)
if err != nil {
return nil
}

return nil
// retrieve the Link by name
mvInterface, err := netlink.LinkByName(l.LocalEndpoint.GetRandIfaceName())
if err != nil {
return fmt.Errorf("failed to lookup %q: %v", l.LocalEndpoint.GetRandIfaceName(), err)
}

// add the link to the Node Namespace
err = l.LocalEndpoint.GetNode().AddLinkToContainer(ctx, mvInterface, SetNameMACAndUpInterface(mvInterface, l.LocalEndpoint))
return err
}

func (l *LinkVxlan) Remove(_ context.Context) error {
Expand Down

0 comments on commit 711fdec

Please sign in to comment.