From 82b19f0a3cdbb496b07e05235325df53f3fc020b Mon Sep 17 00:00:00 2001 From: Steven Webster Date: Tue, 28 Jun 2022 13:17:09 -0400 Subject: [PATCH] cni plugins: add IFNAME key support to the tuning plugin This commit backports IFNAME key support from v1.1.1 of the k8s containernetworking-plugins: https://github.com/containernetworking/plugins/commit/c16cff9805427c5db34b43de3155769b362f596e IFNAME key support allows one to use the keyword 'IFNAME' in a network attachment definition using the tuning plugin. Without this, the actual interface name (whether specified in the pod spec, or the default 'net') must be specified. Example: apiVersion: "k8s.cni.cncf.io/v1" kind: NetworkAttachmentDefinition metadata: name: hd0 spec: config: '{ "cniVersion": "0.3.1", "plugins": [ { "name": "hd0", "type": "host-device", "device": "eth1000" }, { "type": "tuning", "sysctl": { "net.ipv6.conf.IFNAME.accept_ra": "0" } } ] }' The above example would disable the processing of IPv6 router advertisements on the interface associated with the network attachment definition, regardless of what the interface has been named in the container. Note: Currently, StarlingX supports v1.0.1 of the containernetworking-plugins. Once the plugins have been up-revved to v1.1.1, this patch can be removed. Testing: - Ensure patch is applied and build successful on CentOS and Debian - Perform a functional test of the tuning plugin using the IFNAME key on CentOS and Debian Story: 2010114 Task: 45693 Signed-off-by: Steven Webster Change-Id: I4fc617390b25bcf74a2a319fcb4409a0633c4a31 --- kubernetes/cni/plugins/centos/build_srpm.data | 2 +- .../centos/containernetworking-plugins.spec | 8 ++++- ...ng-sysctls-on-a-particular-interface.patch | 32 +++++++++++++++++++ ...ng-sysctls-on-a-particular-interface.patch | 32 +++++++++++++++++++ kubernetes/cni/plugins/debian/patches/series | 1 + 5 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 kubernetes/cni/plugins/centos/files/0001-Allow-setting-sysctls-on-a-particular-interface.patch create mode 100644 kubernetes/cni/plugins/debian/patches/0001-Allow-setting-sysctls-on-a-particular-interface.patch create mode 100644 kubernetes/cni/plugins/debian/patches/series diff --git a/kubernetes/cni/plugins/centos/build_srpm.data b/kubernetes/cni/plugins/centos/build_srpm.data index 5414e0582..dab75dc8b 100644 --- a/kubernetes/cni/plugins/centos/build_srpm.data +++ b/kubernetes/cni/plugins/centos/build_srpm.data @@ -1,2 +1,2 @@ -COPY_LIST="${CGCS_BASE}/downloads/containernetworking-plugins-v1.0.1.tar.gz" +COPY_LIST="${CGCS_BASE}/downloads/containernetworking-plugins-v1.0.1.tar.gz ${FILES_BASE}/*" TIS_PATCH_VER=PKG_GITREVCOUNT diff --git a/kubernetes/cni/plugins/centos/containernetworking-plugins.spec b/kubernetes/cni/plugins/centos/containernetworking-plugins.spec index 486084d61..900f551a2 100644 --- a/kubernetes/cni/plugins/centos/containernetworking-plugins.spec +++ b/kubernetes/cni/plugins/centos/containernetworking-plugins.spec @@ -31,6 +31,8 @@ URL: https://%{provider_prefix} Source0: %{project}-%{repo}-v%{version}.tar.gz ExclusiveArch: aarch64 %{arm} ppc64le s390x x86_64 %{ix86} +Patch0001: 0001-Allow-setting-sysctls-on-a-particular-interface.patch + %if 0%{?fedora} BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} %else @@ -51,7 +53,8 @@ when the container is deleted. %{?enable_gotoolset110} %prep -%autosetup -n %{project}-%{repo}-v%{version} +%setup -q -n %{project}-%{repo}-v%{version} +%patch0001 -p1 rm -rf plugins/main/windows %build @@ -123,6 +126,9 @@ install -p -m 0755 bin/* %{buildroot}/var/opt/cni/bin /var/opt/cni/bin/* %changelog +* Mon Jun 27 2022 Steven Webster +- tuning: Support for IFNAME key + * Mon Jun 06 2022 Dan Voiculeasa - Update install directory to /var/opt/cni/bin. diff --git a/kubernetes/cni/plugins/centos/files/0001-Allow-setting-sysctls-on-a-particular-interface.patch b/kubernetes/cni/plugins/centos/files/0001-Allow-setting-sysctls-on-a-particular-interface.patch new file mode 100644 index 000000000..bd46bbf6f --- /dev/null +++ b/kubernetes/cni/plugins/centos/files/0001-Allow-setting-sysctls-on-a-particular-interface.patch @@ -0,0 +1,32 @@ +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 + diff --git a/kubernetes/cni/plugins/debian/patches/0001-Allow-setting-sysctls-on-a-particular-interface.patch b/kubernetes/cni/plugins/debian/patches/0001-Allow-setting-sysctls-on-a-particular-interface.patch new file mode 100644 index 000000000..bd46bbf6f --- /dev/null +++ b/kubernetes/cni/plugins/debian/patches/0001-Allow-setting-sysctls-on-a-particular-interface.patch @@ -0,0 +1,32 @@ +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 + diff --git a/kubernetes/cni/plugins/debian/patches/series b/kubernetes/cni/plugins/debian/patches/series new file mode 100644 index 000000000..ae712c033 --- /dev/null +++ b/kubernetes/cni/plugins/debian/patches/series @@ -0,0 +1 @@ +0001-Allow-setting-sysctls-on-a-particular-interface.patch