Repository: containernetworking/cni
Pull request #1069 (2024-02-19 16:39:20)

Add SocketPath/PciID to Interface struct 
This is to resolve: #1050 

coveralls: 
[![Coverage Status](https://coveralls.io/builds/65916010/badge)](https://coveralls.io/builds/65916010)

coverage: 70.133%. remained the same
when pulling **68bf78a36d5105ce5f5692998e9d07b37d57701a on MikeZappa87:spec/socketpci**
into **b62753aa2bfa365c1ceaff6f25774a8047c896b5 on containernetworking:main**.

squeed: Looks good; we need to add this to the spec, though.
MikeZappa87: > Looks good; we need to add this to the spec, though.

I can start on that right now. 

Patch:
diff --git a/SPEC.md b/SPEC.md
index eee34ee..ef3fe73 100644
--- a/SPEC.md
+++ b/SPEC.md
@@ -565,9 +565,11 @@ Plugins must output a JSON object with the following keys upon a successful `ADD
 
 - `cniVersion`: The same version supplied on input - the string "1.1.0"
 - `interfaces`: An array of all interfaces created by the attachment, including any host-level interfaces:
-    - `name`: The name of the interface.
-    - `mac`: The hardware address of the interface (if applicable).
-    - `sandbox`: 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`.
+    - `name` (string): The name of the interface.
+    - `mac` (string): The hardware address 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.
 - `ips`: IPs assigned by this attachment. Plugins may include IPs assigned external to the container.
     - `address` (string): an IP address in CIDR notation (eg "192.168.1.3/24").
     - `gateway` (string): the default gateway for this subnet, if one exists.
diff --git a/pkg/types/100/types.go b/pkg/types/100/types.go
index d6d069f..c139257 100644
--- a/pkg/types/100/types.go
+++ b/pkg/types/100/types.go
@@ -268,9 +268,11 @@ func (r *Result) PrintTo(writer io.Writer) error {
 
 // Interface contains values about the created interfaces
 type Interface struct {
-	Name    string `json:"name"`
-	Mac     string `json:"mac,omitempty"`
-	Sandbox string `json:"sandbox,omitempty"`
+	Name       string `json:"name"`
+	Mac        string `json:"mac,omitempty"`
+	Sandbox    string `json:"sandbox,omitempty"`
+	SocketPath string `json:"socketPath,omitempty"`
+	PciID      string `json:"pciID,omitempty"`
 }
 
 func (i *Interface) String() string {


Test patch:
diff --git a/pkg/types/100/types_test.go b/pkg/types/100/types_test.go
index 3bd50bd..e74060c 100644
--- a/pkg/types/100/types_test.go
+++ b/pkg/types/100/types_test.go
@@ -45,15 +45,16 @@ func testResult() *current.Result {
 	Expect(err).NotTo(HaveOccurred())
 	Expect(routev6).NotTo(BeNil())
 	Expect(routegwv6).NotTo(BeNil())
-
 	// Set every field of the struct to ensure source compatibility
 	return &current.Result{
 		CNIVersion: current.ImplementedSpecVersion,
 		Interfaces: []*current.Interface{
 			{
-				Name:    "eth0",
-				Mac:     "00:11:22:33:44:55",
-				Sandbox: "/proc/3553/ns/net",
+				Name:       "eth0",
+				Mac:        "00:11:22:33:44:55",
+				Sandbox:    "/proc/3553/ns/net",
+				PciID:      "8086:9a01",
+				SocketPath: "/path/to/vhost/fd",
 			},
 		},
 		IPs: []*current.IPConfig{
@@ -104,9 +105,11 @@ var _ = Describe("Current types operations", func() {
     "cniVersion": "` + current.ImplementedSpecVersion + `",
     "interfaces": [
         {
-            "name": "eth0",
-            "mac": "00:11:22:33:44:55",
-            "sandbox": "/proc/3553/ns/net"
+            "name":        "eth0",
+            "mac":         "00:11:22:33:44:55",
+            "sandbox":     "/proc/3553/ns/net",
+            "pciID": 	   "8086:9a01",
+            "socketPath":  "/path/to/vhost/fd"
         }
     ],
     "ips": [
diff --git a/pkg/types/types_test.go b/pkg/types/types_test.go
index ee0a829..235f08c 100644
--- a/pkg/types/types_test.go
+++ b/pkg/types/types_test.go
@@ -157,14 +157,15 @@ var _ = Describe("Types", func() {
 			ipv6, err := types.ParseCIDR("abcd:1234:ffff::cdde/64")
 			Expect(err).NotTo(HaveOccurred())
 			Expect(ipv6).NotTo(BeNil())
-
 			result = &current.Result{
 				CNIVersion: "1.0.0",
 				Interfaces: []*current.Interface{
 					{
-						Name:    "eth0",
-						Mac:     "00:11:22:33:44:55",
-						Sandbox: "/proc/3553/ns/net",
+						Name:       "eth0",
+						Mac:        "00:11:22:33:44:55",
+						Sandbox:    "/proc/3553/ns/net",
+						PciID:      "8086:9a01",
+						SocketPath: "/path/to/vhost/fd",
 					},
 				},
 				IPs: []*current.IPConfig{
diff --git a/pkg/version/version_test.go b/pkg/version/version_test.go
index e0ece71..2ddf5eb 100644
--- a/pkg/version/version_test.go
+++ b/pkg/version/version_test.go
@@ -39,9 +39,11 @@ var _ = Describe("Version operations", func() {
 				"cniVersion": "1.0.0",
 				"interfaces": [
 					{
-						"name": "eth0",
-						"mac": "00:11:22:33:44:55",
-						"sandbox": "/proc/3553/ns/net"
+						"name":        "eth0",
+						"mac":         "00:11:22:33:44:55",
+						"sandbox":     "/proc/3553/ns/net",
+						"pciID":       "8086:9a01",
+						"socketPath":  "/path/to/vhost/fd"
 					}
 				],
 				"ips": [
@@ -66,14 +68,15 @@ var _ = Describe("Version operations", func() {
 
 			err = version.ParsePrevResult(conf)
 			Expect(err).NotTo(HaveOccurred())
-
 			expectedResult := &cniv1.Result{
 				CNIVersion: "1.0.0",
 				Interfaces: []*cniv1.Interface{
 					{
-						Name:    "eth0",
-						Mac:     "00:11:22:33:44:55",
-						Sandbox: "/proc/3553/ns/net",
+						Name:       "eth0",
+						Mac:        "00:11:22:33:44:55",
+						Sandbox:    "/proc/3553/ns/net",
+						PciID:      "8086:9a01",
+						SocketPath: "/path/to/vhost/fd",
 					},
 				},
 				IPs: []*cniv1.IPConfig{