npc: Steer traffic for egress processing
We need two rules: * `-A INPUT -i weave -j WEAVE-NPC-EGRESS`: applies to packets destined to a local node. * `-A FORWARD -i weave -j WEAVE-NPC-EGRESS`: the rest. It can match an ingress packet.
This commit is contained in:
1 parent
8904a4b144
commit
688328dc57
2 files changed
+19
-2
No files matched your search
+15
-2
@@ -457,11 +457,24 @@ func configureIPTables(config *BridgeConfig, ips ipset.Interface) error {
|
||||
}
|
||||
|
||||
if config.NPC {
|
||||
// Steer traffic via the NPC
|
||||
_ = ipt.NewChain("filter", "WEAVE-NPC") // ignore error because it might already exist
|
||||
// Steer traffic via the NPC.
|
||||
// Ignore error because chains might already exist
|
||||
// TODO(brb): use constants for WEAVE-NPC* chains
|
||||
_ = ipt.NewChain("filter", "WEAVE-NPC")
|
||||
_ = ipt.NewChain("filter", "WEAVE-NPC-EGRESS")
|
||||
|
||||
// TODO(brb): this rule might slow down packet processing; consider removing at it applies only
|
||||
// to node-local traffic.
|
||||
if err = ipt.AppendUnique("filter", "INPUT", "-i", config.WeaveBridgeName, "-j", "WEAVE-NPC-EGRESS"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If WEAVE-NPC chain doesn't exist then creating a rule in the chain will fail
|
||||
fwdRules = append(fwdRules,
|
||||
[][]string{
|
||||
{"-i", config.WeaveBridgeName,
|
||||
"-m", "comment", "--comment", "NOTE: this must go before '-j KUBE-FORWARD'",
|
||||
"-j", "WEAVE-NPC-EGRESS"},
|
||||
{"-o", config.WeaveBridgeName,
|
||||
"-m", "comment", "--comment", "NOTE: this must go before '-j KUBE-FORWARD'",
|
||||
"-j", "WEAVE-NPC"},
|
||||
|
||||
@@ -496,6 +496,10 @@ destroy_bridge() {
|
||||
run_iptables -t filter -D FORWARD -o $BRIDGE -m state --state NEW -j NFLOG --nflog-group 86 2>/dev/null || true
|
||||
run_iptables -t filter -D FORWARD -o $BRIDGE -j DROP 2>/dev/null || true
|
||||
run_iptables -X WEAVE-NPC >/dev/null 2>&1 || true
|
||||
run_iptables -F WEAVE-NPC-EGRESS >/dev/null 2>&1 || true
|
||||
run_iptables -t filter -D FORWARD -o $BRIDGE -j WEAVE-NPC-EGRESS 2>/dev/null || true
|
||||
run_iptables -t filter -D INPUT -i $BRIDGE -j WEAVE-NPC-EGRESS 2>/dev/null || true
|
||||
run_iptables -X WEAVE-NPC-EGRESS >/dev/null 2>&1 || true
|
||||
|
||||
run_iptables -F WEAVE-EXPOSE >/dev/null 2>&1 || true
|
||||
run_iptables -t filter -D FORWARD -o $BRIDGE -j WEAVE-EXPOSE 2>/dev/null || true
|
||||
|
||||
Reference in new issue
Block a user