mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-10-03 14:01:04 +02:00
Clean original iptables rule if --random-fully is supported
This commit is contained in:
parent
8d424ea09b
commit
68dba40d58
@ -1276,6 +1276,16 @@ func (nsc *NetworkServicesController) deleteBadMasqueradeIptablesRules() error {
|
||||
{"-m", "ipvs", "--ipvs", "--vdir", "ORIGINAL", "--vmethod", "MASQ", "-m", "comment", "--comment", "", "!", "-s", nsc.podCidr, "!", "-d", nsc.podCidr, "-j", "MASQUERADE"},
|
||||
}
|
||||
|
||||
// If random fully is supported remove the original rules as well
|
||||
if iptablesCmdHandler.HasRandomFully() {
|
||||
argsBad = append(argsBad, []string{"-m", "ipvs", "--ipvs", "--vdir", "ORIGINAL", "--vmethod", "MASQ", "-m", "comment", "--comment", "", "-j", "SNAT", "--to-source", nsc.nodeIP.String()})
|
||||
|
||||
if len(nsc.podCidr) > 0 {
|
||||
argsBad = append(argsBad, []string{"-m", "ipvs", "--ipvs", "--vdir", "ORIGINAL", "--vmethod", "MASQ", "-m", "comment", "--comment", "",
|
||||
"!", "-s", nsc.podCidr, "!", "-d", nsc.podCidr, "-j", "SNAT", "--to-source", nsc.nodeIP.String()})
|
||||
}
|
||||
}
|
||||
|
||||
for _, args := range argsBad {
|
||||
exists, err := iptablesCmdHandler.Exists("nat", "POSTROUTING", args...)
|
||||
if err != nil {
|
||||
|
@ -91,6 +91,16 @@ func (nrc *NetworkRoutingController) deleteBadPodEgressRules() error {
|
||||
if nrc.isIpv6 {
|
||||
podEgressArgsBad = podEgressArgsBad6
|
||||
}
|
||||
|
||||
// If random fully is supported remove the original rule as well
|
||||
if iptablesCmdHandler.HasRandomFully() {
|
||||
if !nrc.isIpv6 {
|
||||
podEgressArgsBad = append(podEgressArgsBad, podEgressArgs4)
|
||||
} else {
|
||||
podEgressArgsBad = append(podEgressArgsBad, podEgressArgs6)
|
||||
}
|
||||
}
|
||||
|
||||
for _, args := range podEgressArgsBad {
|
||||
exists, err := iptablesCmdHandler.Exists("nat", "POSTROUTING", args...)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user