Destroy ipsets prefixed weave- only (issue #2751)

This commit is contained in:
Stephan Austermühle authored and Marc Carré committed 2017-03-14 17:56:59 +00:00
1 parent 56fd45f7ea
commit dc2925263c
4 files changed
+59 -16

No files matched your search

+12 -4
View File
@@ -80,14 +80,22 @@ func resetIPTables(ipt *iptables.IPTables) error {
}
func resetIPSets(ips ipset.Interface) error {
// TODO should restrict ipset operations to the `weave-` prefix:
// Remove ipsets prefixed `weave-` only
if err := ips.FlushAll(); err != nil {
sets, err := ips.List(npc.IpsetNamePrefix)
if (err != nil) {
common.Log.Errorf("Failed to retrieve list of ipsets")
return err
}
if err := ips.DestroyAll(); err != nil {
return err
common.Log.Debugf("Got list of ipsets: %v", sets)
for _, s := range sets {
common.Log.Debugf("Destroying ipsets '%s'", string(s))
if err := ips.Destroy(s); err != nil {
common.Log.Errorf("Failed to destroy ipset '%s'", string(s))
return err
}
}
return nil