From 13d9bdb63556c122987486c9c3f8938d00ef34e1 Mon Sep 17 00:00:00 2001 From: Benjamin Hesmans Date: Mon, 23 Feb 2015 11:32:22 +0100 Subject: [PATCH] wip on per ns sysctl Signed-off-by: Benjamin Hesmans --- src/mpExperience.py | 59 ++++++++++++++++++++++++++++++++++++--------- src/mpParamXp.py | 10 ++++++-- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/mpExperience.py b/src/mpExperience.py index a7b0f98..178c236 100644 --- a/src/mpExperience.py +++ b/src/mpExperience.py @@ -62,14 +62,27 @@ class MpExperience: def saveSysctl(self): self.sysctlBUP = {} - for k in MpParamXp.sysctlKey: - sysctlKey = MpParamXp.sysctlKey[k] + self._saveSysctl(MpParamXp.sysctlKey, self.sysctlBUP) + self.sysctlBUPC = {} + self._saveSysctl(MpParamXp.sysctlKeyClient, self.sysctlBUPC, + ns = True, who = self.mpConfig.client) + self.sysctlBUPS = {} + self._saveSysctl(MpParamXp.sysctlKeyServer, self.sysctlBUPS, + ns = True, who = self.mpConfig.server) + + def _saveSysctl(self, sysctlDic, sysctlBUP, ns = False, who = None): + for k in sysctlDic: + sysctlKey = sysctlDic[k] cmd = self.cmdReadSysctl(sysctlKey) - val = self.mpTopo.notNSCommand(cmd) + if not ns: + val = self.mpTopo.notNSCommand(cmd) + else: + val = self.mpTopo.commandTo(who, cmd) if val == "Error": print("oooops can't get sysctl " + sysctlKey) else: - self.sysctlBUP[k] = val.split(" ",2)[2][:-1] + sysctlBUP[k] = val.split(" ",2)[2][:-1] + def cmdReadSysctl(self, key): s = "sysctl " + key @@ -81,23 +94,47 @@ class MpExperience: return s def writeSysctl(self): - for k in self.sysctlBUP: - sysctlKey = MpParamXp.sysctlKey[k] + self._writeSysctl(MpParamXp.sysctlKey, self.sysctlBUP) + self._writeSysctl(MpParamXp.sysctlKeyClient, self.sysctlBUPC, + ns = True, who = self.mpConfig.client) + self._writeSysctl(MpParamXp.sysctlKeyServer, self.sysctlBUPS, + ns = True, who = self.mpConfig.server) + + def _writeSysctl(self, sysctlDic, sysctlBUP, ns = False, who = None): + for k in sysctlBUP: + sysctlKey = sysctlDic[k] sysctlValue = self.xpParam.getParam(k) cmd = self.cmdWriteSysctl(sysctlKey,sysctlValue) - val = self.mpTopo.notNSCommand(cmd) + if not ns: + val = self.mpTopo.notNSCommand(cmd) + else: + val = self.mpTopo.commandTo(who, cmd) if val == "Error": print("oooops can't set sysctl " + sysctlKey) + def backUpSysctl(self): - for k in self.sysctlBUP: - sysctlKey = MpParamXp.sysctlKey[k] - sysctlValue = self.sysctlBUP[k] + self._backUpSysctl(MpParamXp.sysctlKey, self.sysctlBUP) + self._backUpSysctl(MpParamXp.sysctlKeyClient, self.sysctlBUPC, + ns = True, who = self.mpConfig.client) + self._backUpSysctl(MpParamXp.sysctlKeyServer, self.sysctlBUPS, + ns = True, who = self.mpConfig.server) + + + def _backUpSysctl(self, sysctlDic, sysctlBUP, ns = False, who = None): + for k in sysctlBUP: + sysctlKey = sysctlKey[k] + sysctlValue = sysctlBUP[k] cmd = self.cmdWriteSysctl(sysctlKey,sysctlValue) - val = self.mpTopo.notNSCommand(cmd) + if not ns: + val = self.mpTopo.notNSCommand(cmd) + else: + val = self.mpTopo.commandTo(who, cmd) + if val == "Error": print("oooops can't set sysctl " + sysctlKey) + def runTcpDump(self): #todo : replace filename by cst cpcap = self.xpParam.getParam(MpParamXp.CLIENTPCAP) diff --git a/src/mpParamXp.py b/src/mpParamXp.py index 2626f13..0b7b70d 100644 --- a/src/mpParamXp.py +++ b/src/mpParamXp.py @@ -5,6 +5,8 @@ class MpParamXp(MpParam): RMEM = "rmem" SCHED = "sched" KERNELPM = "kpm" + KERNELPMC = "kpmc" #kernel path manager client / server + KERNELPMS = "kpms" CLIENTPCAP = "clientPcap" SERVERPCAP = "serverPcap" XPTYPE = "xpType" @@ -26,13 +28,17 @@ class MpParamXp(MpParam): sysctlKey[KERNELPM] = "net.mptcp.mptcp_path_manager" sysctlKey[SCHED] = "net.mptcp.mptcp_scheduler" - sysctlListClient = [] - sysctlListServer = [] + sysctlKeyClient = {} + sysctlKeyClient[KERNELPMC] = "net.mptcp.mptcp_path_manager" + sysctlKeyServer = {} + sysctlKeyServer[KERNELPMS] = "net.mptcp.mptcp_path_manager" defaultValue = {} defaultValue[RMEM] = "10240 87380 16777216" defaultValue[KERNELPM] = "fullmesh" + defaultValue[KERNELPMC] = "fullmesh" + defaultValue[KERNELPMS] = "fullmesh" defaultValue[SCHED] = "default" defaultValue[CLIENTPCAP] = "no"