From 1d693287b90133387844a804370092939e35f757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A5=96=E5=BB=BA?= Date: Tue, 16 Apr 2024 17:13:30 +0800 Subject: [PATCH] cni: add mtu in add result (#3922) Signed-off-by: zhangzujian --- cmd/cni/cni.go | 1 + pkg/daemon/handler.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/cni/cni.go b/cmd/cni/cni.go index 4289ce7d7fb..48b540c5f9f 100644 --- a/cmd/cni/cni.go +++ b/cmd/cni/cni.go @@ -85,6 +85,7 @@ func generateCNIResult(cniResponse *request.CniResponse, netns string) current.R podIface := current.Interface{ Name: cniResponse.PodNicName, Mac: cniResponse.MacAddress, + Mtu: cniResponse.Mtu, Sandbox: netns, } switch cniResponse.Protocol { diff --git a/pkg/daemon/handler.go b/pkg/daemon/handler.go index 6d42cc1a723..6e3e89af75f 100644 --- a/pkg/daemon/handler.go +++ b/pkg/daemon/handler.go @@ -226,6 +226,7 @@ func (csh cniServerHandler) handleAdd(req *restful.Request, resp *restful.Respon return } + var mtu int routes = append(podRequest.Routes, routes...) if strings.HasSuffix(podRequest.Provider, util.OvnProvider) && subnet != "" { podSubnet, err := csh.Controller.subnetsLister.Get(subnet) @@ -270,7 +271,6 @@ func (csh cniServerHandler) handleAdd(req *restful.Request, resp *restful.Respon detectIPConflict = false } - var mtu int if podSubnet.Spec.Mtu > 0 { mtu = int(podSubnet.Spec.Mtu) } else { @@ -368,6 +368,7 @@ func (csh cniServerHandler) handleAdd(req *restful.Request, resp *restful.Respon CIDR: cidr, PodNicName: podNicName, Routes: routes, + Mtu: mtu, } if isDefaultRoute { response.Gateway = gw