npc: Embed policyType into rule

This ensures two rules with the same rulespec but of different
policyType will end up having different keys.

Sharing the same key would prevent from provisioning the rules.
This commit is contained in:
Martynas Pumputis authored and Martynas Pumputis committed 2018-07-24 10:06:23 +02:00
1 parent 497a9c7fd0
commit 5e675f26f7
1 file changed
+3 -2
+3 -2
View File
@@ -39,8 +39,9 @@ func newRuleSpec(policyType policyType, proto *string, srcHost *selectorSpec, ds
args = append(args, "--dport", *dstPort) args = append(args, "--dport", *dstPort)
} }
args = append(args, "-j", "ACCEPT") args = append(args, "-j", "ACCEPT")
args = append(args, "-m", "comment", "--comment", fmt.Sprintf("%s -> %s", srcComment, dstComment)) // NOTE: if you remove the comment bellow, then embed `policyType` into `key`.
// TODO(brb) embed policyType into key // Otherwise, the rule won't be provisioned if it exists for other policy type.
args = append(args, "-m", "comment", "--comment", fmt.Sprintf("%s -> %s (%s)", srcComment, dstComment, policyTypeStr(policyType)))
key := strings.Join(args, " ") key := strings.Join(args, " ")
return &ruleSpec{key, args, policyType} return &ruleSpec{key, args, policyType}