Merge pull request #669 from containernetworking/jell/per_if_sysctl

Allow setting sysctls on a particular interface
This commit is contained in:
Matt Dupre 2021-11-24 09:07:17 -08:00 committed by GitHub
commit 57e95c5dfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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))
// Refuse to modify sysctl parameters that don't belong