Skip to content

Commit fd65052

Browse files
committed
Add an OPENSHIFT-OUTPUT-FILTERING chain for admins to use
1 parent 5de6326 commit fd65052

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/sdn/plugin/node_iptables.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ type NodeIPTables struct {
2727
mu sync.Mutex // Protects concurrent access to syncIPTableRules()
2828
}
2929

30+
const (
31+
OutputFilteringChain iptables.Chain = "OPENSHIFT-OUTPUT-FILTERING"
32+
)
33+
3034
func newNodeIPTables(clusterNetworkCIDR string, syncPeriod time.Duration) *NodeIPTables {
3135
return &NodeIPTables{
3236
ipt: iptables.New(kexec.New(), utildbus.New(), iptables.ProtocolIpv4),
@@ -78,6 +82,10 @@ func (n *NodeIPTables) syncIPTableRules() error {
7882
}()
7983
glog.V(3).Infof("Syncing openshift iptables rules")
8084

85+
if _, err := n.ipt.EnsureChain(iptables.TableFilter, OutputFilteringChain); err != nil {
86+
return fmt.Errorf("failed to ensure chain %q exists: %v", OutputFilteringChain, err)
87+
}
88+
8189
rules := n.getStaticNodeIPTablesRules()
8290
for _, rule := range rules {
8391
_, err := n.ipt.EnsureRule(iptables.Prepend, iptables.Table(rule.table), iptables.Chain(rule.chain), rule.args...)
@@ -99,5 +107,6 @@ func (n *NodeIPTables) getStaticNodeIPTablesRules() []FirewallRule {
99107
{"filter", "INPUT", []string{"-i", "docker0", "-m", "comment", "--comment", "traffic from docker", "-j", "ACCEPT"}},
100108
{"filter", "FORWARD", []string{"-d", n.clusterNetworkCIDR, "-j", "ACCEPT"}},
101109
{"filter", "FORWARD", []string{"-s", n.clusterNetworkCIDR, "-j", "ACCEPT"}},
110+
{"filter", "FORWARD", []string{"-i", TUN, "!", "-o", TUN, "-m", "comment", "--comment", "administrator overrides", "-j", string(OutputFilteringChain)}},
102111
}
103112
}

0 commit comments

Comments
 (0)