Skip to content

Commit 87718c9

Browse files
roffemurali-reddy
authored andcommitted
make NSC set net.ipv4.vs.conn_reuse_mode=0 (#577)
* make IPVS proxier set net/ipv4/vs/conn_reuse_mode to 0 by default, which will fix the IPVS low throughput issue * better error message * check and inform if to old kernel to use feature
1 parent c39c13b commit 87718c9

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pkg/controllers/proxy/network_services_controller.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"github.com/vishvananda/netlink"
3131
"github.com/vishvananda/netns"
3232
"golang.org/x/net/context"
33-
3433
api "k8s.io/api/core/v1"
3534
"k8s.io/apimachinery/pkg/util/sets"
3635
"k8s.io/client-go/kubernetes"
@@ -295,6 +294,11 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
295294
return errors.New("Failed to do sysctl net.ipv4.vs.expire_quiescent_template=1 due to: %s" + err.Error())
296295
}
297296

297+
err = ensureIpvsConnReuseMode()
298+
if err != nil {
299+
return fmt.Errorf("failed to set net.ipv4.vs.conn_reuse_mode=0: %s", err)
300+
}
301+
298302
// loop forever unitl notified to stop on stopCh
299303
for {
300304
select {
@@ -1405,6 +1409,19 @@ func ensureIpvsConntrack() error {
14051409
return ioutil.WriteFile("/proc/sys/net/ipv4/vs/conntrack", []byte(strconv.Itoa(1)), 0640)
14061410
}
14071411

1412+
func ensureIpvsConnReuseMode() error {
1413+
sysctlPath := "/proc/sys/net/ipv4/vs/conn_reuse_mode"
1414+
if _, err := os.Stat(sysctlPath); err != nil {
1415+
if os.IsNotExist(err) {
1416+
glog.Infof("%s not found, skipping setting net.ipv4.vs.conn_reuse_mode=0 (non fatal error, feature introduced into kernel in 4.1)", sysctlPath)
1417+
return nil
1418+
}
1419+
glog.Errorf("skipping setting net.ipv4.vs.conn_reuse_mode=0, error stating: %s : %s", sysctlPath, err.Error())
1420+
return nil
1421+
}
1422+
return ioutil.WriteFile("sysctlPath", []byte(strconv.Itoa(0)), 0640)
1423+
}
1424+
14081425
func ensureIpvsExpireNodestConn() error {
14091426
return ioutil.WriteFile("/proc/sys/net/ipv4/vs/expire_nodest_conn", []byte(strconv.Itoa(1)), 0640)
14101427
}

0 commit comments

Comments
 (0)