From d9a31ca80c61c1592be9e4eb1d41c607a76cb4bd Mon Sep 17 00:00:00 2001 From: Sebastian Sch Date: Thu, 1 Feb 2024 14:13:14 +0200 Subject: [PATCH] Add MTU to CNI result This commit allow CNIs to expose the MTU of interface Signed-off-by: Sebastian Sch --- SPEC.md | 1 + pkg/types/100/types.go | 1 + pkg/types/100/types_test.go | 2 ++ 3 files changed, 4 insertions(+) diff --git a/SPEC.md b/SPEC.md index dcd10783..c2586a4c 100644 --- a/SPEC.md +++ b/SPEC.md @@ -567,6 +567,7 @@ Plugins must output a JSON object with the following keys upon a successful `ADD - `interfaces`: An array of all interfaces created by the attachment, including any host-level interfaces: - `name` (string): The name of the interface. - `mac` (string): The hardware address of the interface (if applicable). + - `mtu`: The MTU of the interface (if applicable). - `sandbox` (string): The isolation domain reference (e.g. path to network namespace) for the interface, or empty if on the host. For interfaces created inside the container, this should be the value passed via `CNI_NETNS`. - `socketPath` (string, optional): An absolute path to a socket file corresponding to this interface, if applicable. - `pciID` (string, optional): The platform-specific identifier of the PCI device corresponding to this interface, if applicable. diff --git a/pkg/types/100/types.go b/pkg/types/100/types.go index c1392571..f58b9120 100644 --- a/pkg/types/100/types.go +++ b/pkg/types/100/types.go @@ -270,6 +270,7 @@ func (r *Result) PrintTo(writer io.Writer) error { type Interface struct { Name string `json:"name"` Mac string `json:"mac,omitempty"` + Mtu int `json:"mtu,omitempty"` Sandbox string `json:"sandbox,omitempty"` SocketPath string `json:"socketPath,omitempty"` PciID string `json:"pciID,omitempty"` diff --git a/pkg/types/100/types_test.go b/pkg/types/100/types_test.go index e74060c6..1ba39437 100644 --- a/pkg/types/100/types_test.go +++ b/pkg/types/100/types_test.go @@ -52,6 +52,7 @@ func testResult() *current.Result { { Name: "eth0", Mac: "00:11:22:33:44:55", + Mtu: 1500, Sandbox: "/proc/3553/ns/net", PciID: "8086:9a01", SocketPath: "/path/to/vhost/fd", @@ -107,6 +108,7 @@ var _ = Describe("Current types operations", func() { { "name": "eth0", "mac": "00:11:22:33:44:55", + "mtu": 1500, "sandbox": "/proc/3553/ns/net", "pciID": "8086:9a01", "socketPath": "/path/to/vhost/fd"