netconfig: flush nftables ruleset, replace DHCPv6 address
This commit is contained in:
parent
19aa03bf58
commit
03b2345eb2
@ -106,6 +106,13 @@ func TestNetconfig(t *testing.T) {
|
||||
t.Fatalf("netconfig.Apply: %v", err)
|
||||
}
|
||||
|
||||
// Apply twice to ensure the absence of errors when dealing with
|
||||
// already-configured interfaces, addresses, routes, … (and ensure
|
||||
// nftables rules are replaced, not appendend to).
|
||||
if err := netconfig.Apply(tmp, filepath.Join(tmp, "root")); err != nil {
|
||||
t.Fatalf("netconfig.Apply: %v", err)
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(filepath.Join(tmp, "root", "etc", "resolv.conf"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -142,8 +142,8 @@ func applyDhcp6(dir string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := netlink.AddrAdd(link, addr); err != nil {
|
||||
return fmt.Errorf("AddrAdd(%v): %v", addr, err)
|
||||
if err := netlink.AddrReplace(link, addr); err != nil {
|
||||
return fmt.Errorf("AddrReplace(%v): %v", addr, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@ -359,7 +359,7 @@ func applyPortForwardings(dir string, c *nftables.Conn, nat *nftables.Table, pre
|
||||
func applyFirewall(dir string) error {
|
||||
c := &nftables.Conn{}
|
||||
|
||||
// TODO: currently, each iteration adds a nftables.Rule — clear before?
|
||||
c.FlushRuleset()
|
||||
|
||||
nat := c.AddTable(&nftables.Table{
|
||||
Family: nftables.TableFamilyIPv4,
|
||||
|
Loading…
x
Reference in New Issue
Block a user