f-57: subnet: gateway anycast sur macvlan, adresse d'émission sur le bridge, MAC anycast confinée au netns #57
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
fe8c83b1d6
commit
6c35ebdff4
7 changed files with 239 additions and 4 deletions
43
internal/ebtables/ebtables_test.go
Normal file
43
internal/ebtables/ebtables_test.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package ebtables
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConfineRules(t *testing.T) {
|
||||
want := []string{
|
||||
"-t nat -A PREROUTING --in-interface v-s9r1-i -s 02:01:00:00:0b:5f -j DROP",
|
||||
"-t filter -A FORWARD --out-interface v-s9r1-i -s 02:01:00:00:0b:5f -j DROP",
|
||||
"-t filter -A OUTPUT --out-interface v-s9r1-i -s 02:01:00:00:0b:5f -j DROP",
|
||||
}
|
||||
rules := confineRules("v-s9r1-i", "02:01:00:00:0b:5f")
|
||||
if len(rules) != len(want) {
|
||||
t.Fatalf("%d règles, %d attendues", len(rules), len(want))
|
||||
}
|
||||
for i, rule := range rules {
|
||||
if got := strings.Join(withAction("-A", rule), " "); got != want[i] {
|
||||
t.Errorf("règle %d : %q, %q attendu", i, got, want[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteUsesTheSameRules(t *testing.T) {
|
||||
for _, rule := range confineRules("v-x-i", "02:01:00:00:00:01") {
|
||||
added := withAction("-A", rule)
|
||||
deleted := withAction("-D", rule)
|
||||
if strings.Replace(strings.Join(added, " "), " -A ", " -D ", 1) != strings.Join(deleted, " ") {
|
||||
t.Errorf("ajout %v et suppression %v divergent", added, deleted)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithActionDoesNotAlterTheRule(t *testing.T) {
|
||||
rule := confineRules("v-x-i", "02:01:00:00:00:01")[0]
|
||||
before := strings.Join(rule, " ")
|
||||
withAction("-A", rule)
|
||||
withAction("-D", rule)
|
||||
if strings.Join(rule, " ") != before {
|
||||
t.Errorf("la règle a été modifiée : %q devenu %q", before, strings.Join(rule, " "))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue