diff --git a/SPEC.md b/SPEC.md index eee34ee4..ef3fe73a 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 d6d069f5..c1392571 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 { diff --git a/pkg/types/100/types_test.go b/pkg/types/100/types_test.go index 3bd50bd7..e74060c6 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 ¤t.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 ee0a829c..235f08cf 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 = ¤t.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 e0ece71d..2ddf5eb4 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{