Skip to content

Commit da27daf

Browse files
microadamtgross
authored andcommitted
networking: Ensure CNI iptables rules are appended to chain and not forced to be first
1 parent c91bd23 commit da27daf

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

client/allocrunner/networking_bridge_linux.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (b *bridgeNetworkConfigurator) ensureForwardingRules() error {
7575
return err
7676
}
7777

78-
if err := ensureFirstChainRule(ipt, cniAdminChainName, b.generateAdminChainRule()); err != nil {
78+
if err := appendChainRule(ipt, cniAdminChainName, b.generateAdminChainRule()); err != nil {
7979
return err
8080
}
8181

@@ -105,12 +105,11 @@ func ensureChain(ipt *iptables.IPTables, table, chain string) error {
105105
return err
106106
}
107107

108-
// ensureFirstChainRule ensures the given rule exists as the first rule in the chain
109-
func ensureFirstChainRule(ipt *iptables.IPTables, chain string, rule []string) error {
108+
// appendChainRule adds the given rule to the chain
109+
func appendChainRule(ipt *iptables.IPTables, chain string, rule []string) error {
110110
exists, err := ipt.Exists("filter", chain, rule...)
111111
if !exists && err == nil {
112-
// iptables rules are 1-indexed
113-
err = ipt.Insert("filter", chain, 1, rule...)
112+
err = ipt.Append("filter", chain, rule...)
114113
}
115114
return err
116115
}

0 commit comments

Comments
 (0)