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
|
|
@ -58,3 +58,43 @@ func TestHostMACRejectsANonIPv4VTEP(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnycastMAC(t *testing.T) {
|
||||
cases := map[int]string{
|
||||
1: "02:01:00:00:00:01",
|
||||
2911: "02:01:00:00:0b:5f",
|
||||
70000: "02:01:00:01:11:70",
|
||||
MaxVNI: "02:01:00:ff:ff:ff",
|
||||
0x123456: "02:01:00:12:34:56",
|
||||
}
|
||||
for vni, want := range cases {
|
||||
got, err := AnycastMAC(vni)
|
||||
if err != nil {
|
||||
t.Fatalf("VNI %d : erreur inattendue %v", vni, err)
|
||||
}
|
||||
if got.String() != want {
|
||||
t.Errorf("VNI %d : %s, %s attendu", vni, got, want)
|
||||
}
|
||||
if got[0]&0x02 == 0 || got[0]&0x01 != 0 {
|
||||
t.Errorf("VNI %d : %s n'est pas une MAC unicast administrée localement", vni, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnycastMACRefusesOutOfRangeVNI(t *testing.T) {
|
||||
for _, vni := range []int{0, -1, MaxVNI + 1} {
|
||||
if _, err := AnycastMAC(vni); err == nil {
|
||||
t.Errorf("VNI %d : une erreur était attendue", vni)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnycastMACDiffersFromHostMACs(t *testing.T) {
|
||||
anycast, _ := AnycastMAC(2911)
|
||||
for _, role := range []byte{RoleRouter, RoleHostGateway} {
|
||||
host, _ := HostMAC(role, net.ParseIP("192.168.14.11"))
|
||||
if host[1] == anycast[1] {
|
||||
t.Errorf("rôle %#x : même octet de rôle que la MAC anycast (%s, %s)", role, host, anycast)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue