fix: use generic set in pkg/util/iptables

This commit is contained in:
21kyu
2023-11-08 15:21:59 +00:00
parent e4b74dd12f
commit fec63d5ea0
4 changed files with 44 additions and 36 deletions

View File

@@ -446,7 +446,6 @@ func iptablesRestoreCommand(protocol Protocol) string {
return cmdIP6TablesRestore
}
return cmdIPTablesRestore
}
func iptablesCommand(protocol Protocol) string {
@@ -509,10 +508,10 @@ func (runner *runner) checkRuleWithoutCheck(table Table, chain Chain, args ...st
tmpField = trimhex(tmpField)
argsCopy = append(argsCopy, strings.Fields(tmpField)...)
}
argset := sets.NewString(argsCopy...)
argset := sets.New(argsCopy...)
for _, line := range strings.Split(string(out), "\n") {
var fields = strings.Fields(line)
fields := strings.Fields(line)
// Check that this is a rule for the correct chain, and that it has
// the correct number of argument (+2 for "-A <chain name>")
@@ -528,7 +527,7 @@ func (runner *runner) checkRuleWithoutCheck(table Table, chain Chain, args ...st
}
// TODO: This misses reorderings e.g. "-x foo ! -y bar" will match "! -x foo -y bar"
if sets.NewString(fields...).IsSuperset(argset) {
if sets.New(fields...).IsSuperset(argset) {
return true, nil
}
klog.V(5).InfoS("DBG: fields is not a superset of args", "fields", fields, "arguments", args)
@@ -603,7 +602,6 @@ func (runner *runner) Monitor(canary Chain, tables []Table, reloadFunc func(), i
}
return true, nil
}, stopCh)
if err != nil {
// stopCh was closed
for _, table := range tables {