From c16cff9805427c5db34b43de3155769b362f596e Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Fri, 1 Oct 2021 18:07:50 +0200 Subject: [PATCH] Allow setting sysctls on a particular interface Signed-off-by: Piotr Skamruk [ commit c16cff9805427c5db34b43de3155769b362f596e in upstream repo https://github.com/containernetworking/plugins ] Signed-off-by: Steven Webster --- plugins/meta/tuning/tuning.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/meta/tuning/tuning.go b/plugins/meta/tuning/tuning.go index 7b56944..d9eef83 100644 --- a/plugins/meta/tuning/tuning.go +++ b/plugins/meta/tuning/tuning.go @@ -325,6 +325,11 @@ func cmdAdd(args *skel.CmdArgs) error { err = ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { for key, value := range tuningConf.SysCtl { + // If the key contains `IFNAME` - substitute it with args.IfName + // to allow setting sysctls on a particular interface, on which + // other operations (like mac/mtu setting) are performed + key = strings.Replace(key, "IFNAME", args.IfName, 1) + fileName := filepath.Join("/proc/sys", strings.Replace(key, ".", "/", -1)) fileName = filepath.Clean(fileName) -- 2.29.2