while doing ipset restore, ensure sets are flushed before adding entries

This commit is contained in:
Murali Reddy 2021-03-12 00:27:40 +05:30 committed by Aaron U'Ren
parent 187a3f23c5
commit 99cb40b086

View File

@ -403,6 +403,7 @@ func buildIPSetRestore(ipset *IPSet) string {
ipSetRestore := ""
for _, set := range ipset.Sets {
ipSetRestore += fmt.Sprintf("create %s %s\n", set.Name, strings.Join(set.Options[:], " "))
ipSetRestore += fmt.Sprintf("flush %s\n", set.Name)
for _, entry := range set.Entries {
ipSetRestore += fmt.Sprintf("add %s %s\n", set.Name, strings.Join(entry.Options[:], " "))
}