Skip to content

Commit defdf64

Browse files
committed
fix(nsc): remove previous TCPMSS rules
1 parent b1070f1 commit defdf64

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pkg/controllers/proxy/network_services_controller.go

+20
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,26 @@ func (nsc *NetworkServicesController) cleanupMangleTableRule(ip string, protocol
16941694
}
16951695
}
16961696

1697+
// Previous versions of MTU args were this way, we will clean then up for the next couple of versions to ensure
1698+
// that old mangle table rules don't stick around
1699+
// TODO: remove after v2.4.X or above
1700+
for firstArg, chain := range map[string]string{"-s": "POSTROUTING", "-d": "PREROUTING"} {
1701+
prevMTUArgs := []string{firstArg, ip, "-m", tcpProtocol, "-p", tcpProtocol, "--tcp-flags", "SYN,RST", "SYN",
1702+
"-j", "TCPMSS", "--set-mss", strconv.Itoa(tcpMSS)}
1703+
klog.V(2).Infof("looking for mangle rule with: %s -t mangle %s", chain, prevMTUArgs)
1704+
exists, err = iptablesCmdHandler.Exists("mangle", chain, prevMTUArgs...)
1705+
if err != nil {
1706+
return fmt.Errorf("failed to cleanup iptables command to set up TCPMSS due to %v", err)
1707+
}
1708+
if exists {
1709+
klog.V(2).Infof("removing mangle rule with: iptables -D %s -t mangle %s", chain, prevMTUArgs)
1710+
err = iptablesCmdHandler.Delete("mangle", chain, prevMTUArgs...)
1711+
if err != nil {
1712+
return fmt.Errorf("failed to cleanup iptables command to set up TCPMSS due to %v", err)
1713+
}
1714+
}
1715+
}
1716+
16971717
return nil
16981718
}
16991719

0 commit comments

Comments
 (0)