Move egress logging rule beside drop rule

Otherwise we might log a blocked connection even though the packet
was not dropped.
This commit is contained in:
Bryan Boreham committed 2020-08-26 10:02:32 +00:00
1 parent 30ce219794
commit 8c52698222
2 files changed
+5 -3

No files matched your search

+5 -2
View File
@@ -158,12 +158,15 @@ func (npc *controller) AddNetworkPolicy(ctx context.Context, obj interface{}) er
return err
}
if egressNetworkPolicy {
npc.defaultEgressDrop = true
if err := npc.ipt.Append(TableFilter, chains.EgressChain,
"-m", "state", "--state", "NEW", "-m", "mark", "!", "--mark", EgressMark, "-j", "NFLOG", "--nflog-group", "86"); err != nil {
return fmt.Errorf("Failed to add iptable egress log rule: %w", err)
}
if err := npc.ipt.Append(TableFilter, chains.EgressChain,
"-m", "mark", "!", "--mark", EgressMark, "-j", "DROP"); err != nil {
npc.defaultEgressDrop = false
return fmt.Errorf("Failed to add iptable rule to drop egress traffic from the pods by default due to %s", err.Error())
}
npc.defaultEgressDrop = true
}
}