mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Rename iptables IsIpv6 to IsIPv6
This commit is contained in:
parent
ef934a2c5e
commit
efb24d44c6
@ -199,7 +199,7 @@ func newProxyServer(
|
|||||||
// Create iptables handlers for both families, one is already created
|
// Create iptables handlers for both families, one is already created
|
||||||
// Always ordered as IPv4, IPv6
|
// Always ordered as IPv4, IPv6
|
||||||
var ipt [2]utiliptables.Interface
|
var ipt [2]utiliptables.Interface
|
||||||
if iptInterface.IsIpv6() {
|
if iptInterface.IsIPv6() {
|
||||||
ipt[1] = iptInterface
|
ipt[1] = iptInterface
|
||||||
ipt[0] = utiliptables.New(execer, utiliptables.ProtocolIpv4)
|
ipt[0] = utiliptables.New(execer, utiliptables.ProtocolIpv4)
|
||||||
} else {
|
} else {
|
||||||
@ -267,7 +267,7 @@ func newProxyServer(
|
|||||||
// Create iptables handlers for both families, one is already created
|
// Create iptables handlers for both families, one is already created
|
||||||
// Always ordered as IPv4, IPv6
|
// Always ordered as IPv4, IPv6
|
||||||
var ipt [2]utiliptables.Interface
|
var ipt [2]utiliptables.Interface
|
||||||
if iptInterface.IsIpv6() {
|
if iptInterface.IsIPv6() {
|
||||||
ipt[1] = iptInterface
|
ipt[1] = iptInterface
|
||||||
ipt[0] = utiliptables.New(execer, utiliptables.ProtocolIpv4)
|
ipt[0] = utiliptables.New(execer, utiliptables.ProtocolIpv4)
|
||||||
} else {
|
} else {
|
||||||
|
@ -223,7 +223,7 @@ func (f *fakeIPTables) DeleteRule(tableName utiliptables.Table, chainName utilip
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeIPTables) IsIpv6() bool {
|
func (f *fakeIPTables) IsIPv6() bool {
|
||||||
return f.protocol == utiliptables.ProtocolIpv6
|
return f.protocol == utiliptables.ProtocolIpv6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ func ensureKubeHostportChains(iptables utiliptables.Interface, natInterfaceName
|
|||||||
if natInterfaceName != "" && natInterfaceName != "lo" {
|
if natInterfaceName != "" && natInterfaceName != "lo" {
|
||||||
// Need to SNAT traffic from localhost
|
// Need to SNAT traffic from localhost
|
||||||
localhost := "127.0.0.0/8"
|
localhost := "127.0.0.0/8"
|
||||||
if iptables.IsIpv6() {
|
if iptables.IsIPv6() {
|
||||||
localhost = "::1/128"
|
localhost = "::1/128"
|
||||||
}
|
}
|
||||||
args = []string{"-m", "comment", "--comment", "SNAT for localhost access to hostports", "-o", natInterfaceName, "-s", localhost, "-j", "MASQUERADE"}
|
args = []string{"-m", "comment", "--comment", "SNAT for localhost access to hostports", "-o", natInterfaceName, "-s", localhost, "-j", "MASQUERADE"}
|
||||||
|
@ -90,7 +90,7 @@ func (hm *hostportManager) Add(id string, podPortMapping *PodPortMapping, natInt
|
|||||||
podIP := podPortMapping.IP.String()
|
podIP := podPortMapping.IP.String()
|
||||||
isIpv6 := utilnet.IsIPv6(podPortMapping.IP)
|
isIpv6 := utilnet.IsIPv6(podPortMapping.IP)
|
||||||
|
|
||||||
if isIpv6 != hm.iptables.IsIpv6() {
|
if isIpv6 != hm.iptables.IsIPv6() {
|
||||||
return fmt.Errorf("HostPortManager IP family mismatch: %v, isIPv6 - %v", podIP, isIpv6)
|
return fmt.Errorf("HostPortManager IP family mismatch: %v, isIPv6 - %v", podIP, isIpv6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ func (h *hostportSyncer) SyncHostports(natInterfaceName string, activePodPortMap
|
|||||||
klog.V(4).Infof("syncHostportsRules took %v", time.Since(start))
|
klog.V(4).Infof("syncHostportsRules took %v", time.Since(start))
|
||||||
}()
|
}()
|
||||||
|
|
||||||
hostportPodMap, err := gatherAllHostports(activePodPortMappings, h.iptables.IsIpv6())
|
hostportPodMap, err := gatherAllHostports(activePodPortMappings, h.iptables.IsIPv6())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ func NewProxier(ipt utiliptables.Interface,
|
|||||||
|
|
||||||
serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder)
|
serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder)
|
||||||
|
|
||||||
isIPv6 := ipt.IsIpv6()
|
isIPv6 := ipt.IsIPv6()
|
||||||
proxier := &Proxier{
|
proxier := &Proxier{
|
||||||
portsMap: make(map[utilproxy.LocalPort]utilproxy.Closeable),
|
portsMap: make(map[utilproxy.LocalPort]utilproxy.Closeable),
|
||||||
serviceMap: make(proxy.ServiceMap),
|
serviceMap: make(proxy.ServiceMap),
|
||||||
@ -1468,7 +1468,7 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Failed to get node ip address matching nodeport cidr")
|
klog.Errorf("Failed to get node ip address matching nodeport cidr")
|
||||||
} else {
|
} else {
|
||||||
isIPv6 := proxier.iptables.IsIpv6()
|
isIPv6 := proxier.iptables.IsIPv6()
|
||||||
for address := range addresses {
|
for address := range addresses {
|
||||||
// TODO(thockin, m1093782566): If/when we have dual-stack support we will want to distinguish v4 from v6 zero-CIDRs.
|
// TODO(thockin, m1093782566): If/when we have dual-stack support we will want to distinguish v4 from v6 zero-CIDRs.
|
||||||
if utilproxy.IsZeroCIDR(address) {
|
if utilproxy.IsZeroCIDR(address) {
|
||||||
|
@ -2090,8 +2090,8 @@ func (proxier *Proxier) getLegacyBindAddr(activeBindAddrs map[string]bool, curre
|
|||||||
legacyAddrs := make(map[string]bool)
|
legacyAddrs := make(map[string]bool)
|
||||||
isIpv6 := utilnet.IsIPv6(proxier.nodeIP)
|
isIpv6 := utilnet.IsIPv6(proxier.nodeIP)
|
||||||
for _, addr := range currentBindAddrs {
|
for _, addr := range currentBindAddrs {
|
||||||
addrIsIpv6 := utilnet.IsIPv6(net.ParseIP(addr))
|
addrIsIPv6 := utilnet.IsIPv6(net.ParseIP(addr))
|
||||||
if addrIsIpv6 && !isIpv6 || !addrIsIpv6 && isIpv6 {
|
if addrIsIPv6 && !isIpv6 || !addrIsIPv6 && isIpv6 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, ok := activeBindAddrs[addr]; !ok {
|
if _, ok := activeBindAddrs[addr]; !ok {
|
||||||
|
@ -66,8 +66,8 @@ type detectLocalByCIDR struct {
|
|||||||
// NewDetectLocalByCIDR implements the LocalTrafficDetector interface using a CIDR. This can be used when a single CIDR
|
// NewDetectLocalByCIDR implements the LocalTrafficDetector interface using a CIDR. This can be used when a single CIDR
|
||||||
// range can be used to capture the notion of local traffic.
|
// range can be used to capture the notion of local traffic.
|
||||||
func NewDetectLocalByCIDR(cidr string, ipt utiliptables.Interface) (LocalTrafficDetector, error) {
|
func NewDetectLocalByCIDR(cidr string, ipt utiliptables.Interface) (LocalTrafficDetector, error) {
|
||||||
if utilnet.IsIPv6CIDRString(cidr) != ipt.IsIpv6() {
|
if utilnet.IsIPv6CIDRString(cidr) != ipt.IsIPv6() {
|
||||||
return nil, fmt.Errorf("CIDR %s has incorrect IP version: expect isIPv6=%t", cidr, ipt.IsIpv6())
|
return nil, fmt.Errorf("CIDR %s has incorrect IP version: expect isIPv6=%t", cidr, ipt.IsIPv6())
|
||||||
}
|
}
|
||||||
_, _, err := net.ParseCIDR(cidr)
|
_, _, err := net.ParseCIDR(cidr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -55,8 +55,8 @@ type Interface interface {
|
|||||||
EnsureRule(position RulePosition, table Table, chain Chain, args ...string) (bool, error)
|
EnsureRule(position RulePosition, table Table, chain Chain, args ...string) (bool, error)
|
||||||
// DeleteRule checks if the specified rule is present and, if so, deletes it.
|
// DeleteRule checks if the specified rule is present and, if so, deletes it.
|
||||||
DeleteRule(table Table, chain Chain, args ...string) error
|
DeleteRule(table Table, chain Chain, args ...string) error
|
||||||
// IsIpv6 returns true if this is managing ipv6 tables.
|
// IsIPv6 returns true if this is managing ipv6 tables.
|
||||||
IsIpv6() bool
|
IsIPv6() bool
|
||||||
// Protocol returns the IP family this instance is managing,
|
// Protocol returns the IP family this instance is managing,
|
||||||
Protocol() Protocol
|
Protocol() Protocol
|
||||||
// SaveInto calls `iptables-save` for table and stores result in a given buffer.
|
// SaveInto calls `iptables-save` for table and stores result in a given buffer.
|
||||||
@ -321,7 +321,7 @@ func (runner *runner) DeleteRule(table Table, chain Chain, args ...string) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (runner *runner) IsIpv6() bool {
|
func (runner *runner) IsIPv6() bool {
|
||||||
return runner.protocol == ProtocolIpv6
|
return runner.protocol == ProtocolIpv6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,8 +101,8 @@ func (*FakeIPTables) DeleteRule(table iptables.Table, chain iptables.Chain, args
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsIpv6 is part of iptables.Interface
|
// IsIPv6 is part of iptables.Interface
|
||||||
func (f *FakeIPTables) IsIpv6() bool {
|
func (f *FakeIPTables) IsIPv6() bool {
|
||||||
return f.protocol == iptables.ProtocolIpv6
|
return f.protocol == iptables.ProtocolIpv6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user