f-57: netif: MAC anycast de la gateway et création d'un macvlan #57
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
5d314e45e1
commit
fe8c83b1d6
4 changed files with 103 additions and 2 deletions
|
|
@ -8,8 +8,11 @@ import (
|
|||
const (
|
||||
locallyAdministered byte = 0x02
|
||||
|
||||
RoleRouter byte = 0x02
|
||||
RoleHostGateway byte = 0x03
|
||||
RoleAnycastGateway byte = 0x01
|
||||
RoleRouter byte = 0x02
|
||||
RoleHostGateway byte = 0x03
|
||||
|
||||
MaxVNI = 1<<24 - 1
|
||||
)
|
||||
|
||||
func HostMAC(role byte, vtep net.IP) (net.HardwareAddr, error) {
|
||||
|
|
@ -19,3 +22,10 @@ func HostMAC(role byte, vtep net.IP) (net.HardwareAddr, error) {
|
|||
}
|
||||
return net.HardwareAddr{locallyAdministered, role, ip[0], ip[1], ip[2], ip[3]}, nil
|
||||
}
|
||||
|
||||
func AnycastMAC(vni int) (net.HardwareAddr, error) {
|
||||
if vni < 1 || vni > MaxVNI {
|
||||
return nil, fmt.Errorf("vni %d out of range 1-%d", vni, MaxVNI)
|
||||
}
|
||||
return net.HardwareAddr{locallyAdministered, RoleAnycastGateway, 0x00, byte(vni >> 16), byte(vni >> 8), byte(vni)}, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue