Skip to content

Commit

Permalink
Set branch mac address for vlan branch eni when creating the vlan.
Browse files Browse the repository at this point in the history
  • Loading branch information
fenxiong authored and ofiliz committed May 30, 2019
1 parent d90eebe commit f09fd7c
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions network/eni/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ func (branch *Branch) AttachToLink(setMACAddress bool) error {
la := netlink.NewLinkAttrs()
la.Name = branch.linkName
la.ParentIndex = branch.trunk.linkIndex
if setMACAddress && branch.macAddress != nil {
// Set VLAN link MAC address to customer branch ENI MAC address.
la.HardwareAddr = branch.macAddress
} else {
log.Debugf("Skip setting hardware address for branch [%s] overrideMAC: %t",
branch.linkName, setMACAddress)
}

vlanLink := &netlink.Vlan{LinkAttrs: la, VlanId: branch.isolationID}

log.Infof("Creating vlan link for branch [%s]: %+v", branch.linkName, vlanLink)
Expand All @@ -67,18 +75,6 @@ func (branch *Branch) AttachToLink(setMACAddress bool) error {
}

branch.linkIndex = vlanLink.Index
if setMACAddress && branch.macAddress != nil {
// Set VLAN link MAC address to customer branch ENI MAC address.
if err := netlink.LinkSetHardwareAddr(vlanLink, branch.macAddress); err != nil {
log.Errorf("Failed to set MAC address for branch [%s] %v: %v",
branch.linkName, branch.macAddress, err)
return err
}
return nil
}

log.Debugf("Skip setting hardware address for branch [%s] overrideMAC: %t",
branch.linkName, setMACAddress)
return nil
}

Expand Down

0 comments on commit f09fd7c

Please sign in to comment.