You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proposed "netdevices" field provides a declarative way to
specify which host network devices should be moved into a container's
network namespace.
This approach is similar than the existing "devices" field used for block
devices but uses a dictionary keyed by the interface name instead.
The proposed scheme is based on the existing representation of network
device by the `struct net_device`
https://docs.kernel.org/networking/netdevices.html.
This proposal focuses solely on moving existing network devices into
the container namespace. It does not cover the complexities of
network configuration or network interface creation, emphasizing the
separation of device management and network configuration.
Signed-off-by: Antonio Ojea <[email protected]>
Linux network devices are entities that send and receive data packets.
195
+
They are not represented as files in the /dev directory, unlike block devices, network devices are represented with the [`net_device`][net_device] data structure in the Linux kernel.
196
+
Network devices can belong to only one network namespace and use a set of operations distinct from regular file operations. Examples of network devices include Ethernet cards, loopback devices, and virtual devices like bridges, VLANs, and MACVLANs.
197
+
198
+
This schema focuses solely on moving existing network devices identified by name from the host network namespace into the container network namespace. It does not cover the complexities of network device creation or network configuration, such as IP address assignment, routing, and DNS setup.
199
+
200
+
**`netDevices`** (object, OPTIONAL) set of network devices that MUST be made available in the container. The runtime is responsible for providing these devices; the underlying mechanism is implementation-defined.
201
+
202
+
The runtime MUST check that is possible to move the network interface to the container namespace and MUST [generate an error](runtime.md#errors) if the check fails.
203
+
204
+
The runtime MUST set the network device state to "up" after moving it to the network namespace to allow the container to send and receive network traffic through that device.
205
+
206
+
For proper container termination, the runtime must first set the device's state to "down" and then move it out of the namespace before the namespace is deleted. This ensures the device is inactive and avoids conflicts. If the container abnormally terminates and the runtime does not participate in the termination process, these steps might be skipped, and the kernel will handle the process, described in [network_namespaces(7)][net_namespaces.7] "When a network namespace is freed (i.e., when the last process in the namespace terminates), its physical network devices are moved back to the initial network namespace" . Notice that after deleting a network namespace, all its migratable network devices are moved to the default network namespace, but virtual devices (veth, macvlan, ...) are destroyed.
207
+
208
+
The name of the network device is the entry key.
209
+
Entry values are objects with the following properties:
210
+
211
+
***`name`***(string, OPTIONAL)* - the name of the network device inside the container namespace. If not specified, the host name is used. The network device name is unique per network namespace, if an existing network device with the same name exists that rename operation will fail. The runtime MAY check that the name is unique before the rename operation.
212
+
The runtime, when participating on the container termination, must revert back the original name to guarantee the idempotence of operations, so a container that moves an interface and renames it can be created and destroyed multiple times with the same result.
213
+
214
+
### Example
215
+
216
+
#### Moving a device with a renamed interface inside the container:
217
+
218
+
```json
219
+
"netDevices": {
220
+
"eth0" : {
221
+
"name": "container_eth0"
222
+
}
223
+
}
224
+
```
225
+
226
+
This configuration will move the device named "eth0" from the host into the container's network namespace. Inside the container, the device will be named "container_eth0".
227
+
192
228
## <aname="configLinuxControlGroups" />Control groups
193
229
194
230
Also known as cgroups, they are used to restrict resource usage for a container and handle device access.
@@ -982,6 +1018,8 @@ subset of the available options.
Copy file name to clipboardexpand all lines: features-linux.md
+14
Original file line number
Diff line number
Diff line change
@@ -228,3 +228,17 @@ Irrelevant to the availability of Intel RDT on the host operating system.
228
228
}
229
229
}
230
230
```
231
+
232
+
## <aname="linuxFeaturesNetDevices" />NetDevices
233
+
234
+
**`netDevices`** (object, OPTIONAL) represents the runtime's implementation status of Linux network devices.
235
+
236
+
***`enabled`** (bool, OPTIONAL) represents whether the runtime supports the capability to move Linux network devices into the container's network namespace.
0 commit comments