diff --git a/prog/weave-npc/main.go b/prog/weave-npc/main.go index 4a2f205f..e6818875 100644 --- a/prog/weave-npc/main.go +++ b/prog/weave-npc/main.go @@ -90,8 +90,17 @@ func resetIPSets(ips ipset.Interface) error { common.Log.Debugf("Got list of ipsets: %v", sets) + // Must remove references to ipsets by other ipsets before they're destroyed for _, s := range sets { - common.Log.Debugf("Destroying ipsets '%s'", string(s)) + common.Log.Debugf("Flushing ipset '%s'", string(s)) + if err := ips.Flush(s); err != nil { + common.Log.Errorf("Failed to flush ipset '%s'", string(s)) + return err + } + } + + for _, s := range sets { + common.Log.Debugf("Destroying ipset '%s'", string(s)) if err := ips.Destroy(s); err != nil { common.Log.Errorf("Failed to destroy ipset '%s'", string(s)) return err