From 5e675f26f768bc61d98238b9854069e95e6156f5 Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Mon, 21 May 2018 08:40:06 +0200 Subject: [PATCH] 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. --- npc/rule.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/npc/rule.go b/npc/rule.go index b34ac11a..f875af5e 100644 --- a/npc/rule.go +++ b/npc/rule.go @@ -39,8 +39,9 @@ func newRuleSpec(policyType policyType, proto *string, srcHost *selectorSpec, ds args = append(args, "--dport", *dstPort) } args = append(args, "-j", "ACCEPT") - args = append(args, "-m", "comment", "--comment", fmt.Sprintf("%s -> %s", srcComment, dstComment)) - // TODO(brb) embed policyType into key + // NOTE: if you remove the comment bellow, then 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, " ") return &ruleSpec{key, args, policyType}