Skip to content

Commit

Permalink
fix(nsc): remove previous TCPMSS rules
Browse files Browse the repository at this point in the history
  • Loading branch information
aauren committed May 27, 2024
1 parent b1070f1 commit defdf64
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/controllers/proxy/network_services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,26 @@ func (nsc *NetworkServicesController) cleanupMangleTableRule(ip string, protocol
}
}

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

return nil
}

Expand Down

0 comments on commit defdf64

Please sign in to comment.