f-89: watchdog: subnet public_ip contrôlé comme bridge #89

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-10-30 01:01:20 +01:00
commit 74c50ec3ab
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
2 changed files with 24 additions and 4 deletions

View file

@ -16,8 +16,9 @@ import (
) )
const ( const (
modeVxlan = "vxlan" modeVxlan = "vxlan"
modeBridge = "bridge" modeBridge = "bridge"
modePublicIP = "public_ip"
) )
func subnetIfaceNames(subnetName string) (hostVeth, nsVeth, bridge string, err error) { func subnetIfaceNames(subnetName string) (hostVeth, nsVeth, bridge string, err error) {
@ -83,7 +84,7 @@ func checkSubnet(db *badger.DB, name string, backend dhcpbackend.Backend, u unit
n.Notify(kindSubnet, name, p+" (host)") n.Notify(kindSubnet, name, p+" (host)")
} }
checkVxlanIface(db, name, n) checkVxlanIface(db, name, n)
case modeBridge: case modeBridge, modePublicIP:
default: default:
n.Notify(kindSubnet, name, fmt.Sprintf("unknown mode %q", mode)) n.Notify(kindSubnet, name, fmt.Sprintf("unknown mode %q", mode))
} }
@ -92,7 +93,7 @@ func checkSubnet(db *badger.DB, name string, backend dhcpbackend.Backend, u unit
switch mode { switch mode {
case modeVxlan: case modeVxlan:
checkAnycastGateway(db, name, vpc, bridge, n) checkAnycastGateway(db, name, vpc, bridge, n)
case modeBridge: case modeBridge, modePublicIP:
checkBridgeGateway(db, name, vpc, nsVeth, n) checkBridgeGateway(db, name, vpc, nsVeth, n)
} }

View file

@ -132,6 +132,25 @@ func TestCheckSubnets_ModeBridgeNeVerifiePasDeVxlan(t *testing.T) {
} }
} }
func TestCheckSubnets_ModePublicIPEstConnuEtSansVxlan(t *testing.T) {
db := newTestDB(t)
seedSubnet(t, db, "pub-203a42", "vp-admin", modePublicIP)
r := &recorder{}
if err := CheckSubnets(db, dnsmasqConfig(), newFakeUnits(), r); err != nil {
t.Fatalf("erreur inattendue: %v", err)
}
for _, c := range r.calls {
if strings.Contains(c.problem, "unknown mode") || strings.Contains(c.problem, "vxlan") || strings.Contains(c.problem, "(host)") {
t.Errorf("un subnet public_ip est contrôlé comme bridge : %q", c.problem)
}
}
if !r.hasProblemContaining("vp-admin_br-203a42.conf") {
t.Errorf("témoin : le contrôle DHCP du subnet public_ip doit avoir lieu, obtenu %v", r.calls)
}
}
func TestCheckSubnets_ModeVxlanSansVxlanID(t *testing.T) { func TestCheckSubnets_ModeVxlanSansVxlanID(t *testing.T) {
db := newTestDB(t) db := newTestDB(t)
seedSubnet(t, db, "br-000042", "vp-admin", modeVxlan) seedSubnet(t, db, "br-000042", "vp-admin", modeVxlan)