f-76: vm: filtrage nftables par tap, champ dhcp_server, watchdog #76
Chaque NIC a sa chaîne pre-tap<id>, posée avant le tap et retirée après : MAC, ARP et IPv4 source limités à ceux de la NIC (0.0.0.0 pour le client DHCP et la sonde ARP), réponses DHCP refusées sauf si dhcp_server, seuls IPv4, ARP et IPv6 émis. Le watchdog vérifie la chaîne de chaque NIC. Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
d98e42e0a8
commit
74bfda7004
16 changed files with 295 additions and 15 deletions
|
|
@ -16,6 +16,7 @@ import (
|
|||
"git.g3e.fr/syonad/two/internal/metadata"
|
||||
"git.g3e.fr/syonad/two/internal/netif"
|
||||
"git.g3e.fr/syonad/two/internal/netns"
|
||||
"git.g3e.fr/syonad/two/internal/nft"
|
||||
"git.g3e.fr/syonad/two/internal/qmp"
|
||||
"git.g3e.fr/syonad/two/internal/state"
|
||||
|
||||
|
|
@ -79,6 +80,17 @@ func StopVM(db *badger.DB, name string, cfg *configuration.Config) error {
|
|||
}
|
||||
}
|
||||
|
||||
if err := netns.Call(nic.vpcName, func() error {
|
||||
for _, n := range d.nics {
|
||||
if err := nft.DeletePort(n.tapPort().Name); err != nil {
|
||||
return fmt.Errorf("interface %d: %w", n.index, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return fmt.Errorf("unfilter taps: %w", err)
|
||||
}
|
||||
|
||||
if err := removeDHCPFiles(d, name, backend); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue