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:
GnomeZworc 2026-10-13 14:27:34 +02:00
commit fe8c83b1d6
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
4 changed files with 103 additions and 2 deletions

View file

@ -0,0 +1,25 @@
package netif
import (
"net"
"testing"
"github.com/vishvananda/netlink"
)
func TestMacvlanLink(t *testing.T) {
mac, _ := AnycastMAC(2911)
link := macvlanLink("gw-sn1", 7, mac)
if link.Name != "gw-sn1" || link.ParentIndex != 7 {
t.Errorf("nom ou parent inattendu : %s, %d", link.Name, link.ParentIndex)
}
if link.HardwareAddr.String() != "02:01:00:00:0b:5f" {
t.Errorf("MAC %s, 02:01:00:00:0b:5f attendue", link.HardwareAddr)
}
if link.Mode != netlink.MACVLAN_MODE_BRIDGE {
t.Errorf("mode %v, bridge attendu", link.Mode)
}
if link.Flags&net.FlagUp != 0 {
t.Error("le macvlan doit être créé éteint")
}
}