@@ -148,22 +148,55 @@ func newProxyServer(
148148 return nil , fmt .Errorf ("unable to read IPTables MasqueradeBit from config" )
149149 }
150150
151- // TODO this has side effects that should only happen when Run() is invoked.
152- proxier , err = iptables .NewProxier (
153- iptInterface ,
154- utilsysctl .New (),
155- execer ,
156- config .IPTables .SyncPeriod .Duration ,
157- config .IPTables .MinSyncPeriod .Duration ,
158- config .IPTables .MasqueradeAll ,
159- int (* config .IPTables .MasqueradeBit ),
160- config .ClusterCIDR ,
161- hostname ,
162- nodeIP ,
163- recorder ,
164- healthzServer ,
165- config .NodePortAddresses ,
166- )
151+ if utilfeature .DefaultFeatureGate .Enabled (features .IPv6DualStack ) {
152+ klog .V (0 ).Info ("creating dualStackProxier for iptables." )
153+
154+ // Create iptables handlers for both families, one is already created
155+ // Always ordered as IPv4, IPv6
156+ var ipt [2 ]utiliptables.Interface
157+ if iptInterface .IsIpv6 () {
158+ ipt [1 ] = iptInterface
159+ ipt [0 ] = utiliptables .New (execer , utiliptables .ProtocolIpv4 )
160+ } else {
161+ ipt [0 ] = iptInterface
162+ ipt [1 ] = utiliptables .New (execer , utiliptables .ProtocolIpv6 )
163+ }
164+
165+ // TODO this has side effects that should only happen when Run() is invoked.
166+ proxier , err = iptables .NewDualStackProxier (
167+ ipt ,
168+ utilsysctl .New (),
169+ execer ,
170+ config .IPTables .SyncPeriod .Duration ,
171+ config .IPTables .MinSyncPeriod .Duration ,
172+ config .IPTables .MasqueradeAll ,
173+ int (* config .IPTables .MasqueradeBit ),
174+ cidrTuple (config .ClusterCIDR ),
175+ hostname ,
176+ nodeIPTuple (config .BindAddress ),
177+ recorder ,
178+ healthzServer ,
179+ config .NodePortAddresses ,
180+ )
181+ } else { // Create a single-stack proxier.
182+ // TODO this has side effects that should only happen when Run() is invoked.
183+ proxier , err = iptables .NewProxier (
184+ iptInterface ,
185+ utilsysctl .New (),
186+ execer ,
187+ config .IPTables .SyncPeriod .Duration ,
188+ config .IPTables .MinSyncPeriod .Duration ,
189+ config .IPTables .MasqueradeAll ,
190+ int (* config .IPTables .MasqueradeBit ),
191+ config .ClusterCIDR ,
192+ hostname ,
193+ nodeIP ,
194+ recorder ,
195+ healthzServer ,
196+ config .NodePortAddresses ,
197+ )
198+ }
199+
167200 if err != nil {
168201 return nil , fmt .Errorf ("unable to create proxier: %v" , err )
169202 }
@@ -174,6 +207,7 @@ func newProxyServer(
174207 klog .V (0 ).Info ("creating dualStackProxier for ipvs." )
175208
176209 // Create iptables handlers for both families, one is already created
210+ // Always ordered as IPv4, IPv6
177211 var ipt [2 ]utiliptables.Interface
178212 if iptInterface .IsIpv6 () {
179213 ipt [1 ] = iptInterface
0 commit comments