100 Commits
Author SHA1 Message Date
Jing Chen 63f6dd704d Install CNI plugins from the containerd repo.
Remove the legacy settings, the minimum supported CNI version is 0.4.0.

PiperOrigin-RevId: 736255397
2025-03-12 13:57:52 -07:00
Jing Chen c16484e6e8 Reduce the number of containerd tests in buildkite pipelines.
PiperOrigin-RevId: 735553455
2025-03-10 16:40:47 -07:00
Jing Chen 521cc86a91 Use the minimum recommended version of cri-tools for containerd tests.
PiperOrigin-RevId: 733575043
2025-03-04 21:34:30 -08:00
Jing Chen c822fc9ed0 Update gVisor's containerd quick start.
Adding ctr instructions for an easier verification.

PiperOrigin-RevId: 733017114
2025-03-03 12:25:27 -08:00
Jing Chen 53d6f3dd2a Use github.com/containerd/log in gVisor shim.
The package github.com/containerd/containerd/log is removed in containerd 2.0.

PiperOrigin-RevId: 724255233
2025-02-07 01:42:37 -08:00
Jing Chen 902a56c6c5 Use github.com/containerd/errdefs in gVisor shim.
The github.com/containerd/containerd/errdefs is deprecated.

PiperOrigin-RevId: 723750415
2025-02-05 19:45:54 -08:00
Jing Chen 02f5a55b40 Test gVisor with containerd 1.7.25.
PiperOrigin-RevId: 723309152
2025-02-04 18:49:28 -08:00
Jing Chen 4a09ec772e Allow crypto/tls in go runtime tests.
Fix #11338

PiperOrigin-RevId: 722699441
2025-02-03 10:06:02 -08:00
Jing Chen a500a2c751 Defalke test target pkg/tcpip/stack:bridge_test.
There is a race in the test between WritePacketToRemote and FindFDBEntry, even
though it rarely happens, we just enforce FindFDBEntry to wait for
WritePacketToRemote's completion here.

PiperOrigin-RevId: 721747159
2025-01-31 06:10:20 -08:00
Jing Chen c88ffa321e Returns ENOBUFS when writing to a veth device whose buffer is full.
A task is stuck when it keeps sendMsg w/o any recvMsg  until  the number of
message exceeds the buffer limit. The change also significantly bumps the
limit from 64 to 1000 for a larger buffer.

Reported-by: syzbot+8788f5c1ba95e12ab07d@syzkaller.appspotmail.com
Reported-by: syzbot+67759fceac0c30ece991@syzkaller.appspotmail.com
PiperOrigin-RevId: 704904404
2024-12-10 17:35:54 -08:00
Jing Chen 0a0f202662 Refresh gVisor tests and docs to tell that privilege container is not needed.
Docker container and privileged container can be started w/ a limited
number of capabilities from our experiment.

PiperOrigin-RevId: 704601261
2024-12-10 01:26:21 -08:00
Jing Chen 54eb79b6e8 Acquire rlock when reading link address from the bridge.
It happens along with the other issue when the veth device buffer is full,
then the task is stuck and still have the bridge's lock (RLock) via
DeliverNetworkPacket. When the second task reads the bridge's MAC address,
it waits forever for the first task to release the rlock. Using RLock can
allow the concurrent access to the MAC address, it dones't have to be
blocked until the messages are sent.

Reported-by: syzbot+1d6d1d8f47eae4e308dc@syzkaller.appspotmail.com
PiperOrigin-RevId: 704163976
2024-12-08 23:47:51 -08:00
Jing Chen 6666e9fc85 Extract ipv4 address only when starting docker in gVisor.
The address will be used to set up filter rules.

PiperOrigin-RevId: 697883823
2024-11-18 22:55:38 -08:00
Jing Chen c1b24d4a8d Fix wrong benchmark image path.
PiperOrigin-RevId: 696976987
2024-11-15 13:06:23 -08:00
Jing Chen 39a6242b54 Allow DOCKER_FORCE_PUSH for test images.
The push-* command skips rebuild and image push w/ `latest` tag when a image
tag exists remotely. Most of gVisor test images have never got a chance to be
tagged because they already exist when `DOCKER_PUSH_AS_LATEST` was introduced.

We shouldn't enable DOCKER_FORCE_PUSH in our pipelines, it is better to be a
one off tool when the `latest` tag of an image is missing from remote repos.

PiperOrigin-RevId: 696823576
2024-11-15 03:02:36 -08:00
Jing Chen 45b346e8fd Use AR images on the domain pkg.dev.
Use pkg.dev consistently since GCR is deprecated. We don't have to
manage mirrored image repos for gcr.io and pkg.dev.

PiperOrigin-RevId: 695791369
2024-11-12 10:46:11 -08:00
Jing Chen 54359c5b5f Run website-deploy at amd64 buildkite agents only.
The gVisor's test image jekyll is available on x86_64 only.

PiperOrigin-RevId: 694603592
2024-11-08 12:45:39 -08:00
Jing Chen 155cdcb458 Make buildkite push images with gcr.io at release pipeline.
GCR will be deprecated, while the prefix `gcr.io` will be
be hosted via Artifact Registry. By adding this one extra step,
all test images will be accessible via both `gcr.io` and
`pkg.dev`.

PiperOrigin-RevId: 694278137
2024-11-07 16:07:11 -08:00
Jing Chen 94db2b2de7 Implement a basic bridge FDB by leanrning.
Bridge uses bridge FDB to decide which port(s) it forwards the
received packets to.

The bridge FDB, when the bridge receives a packet, records the packet's source
MAC address and the bridge port where the packet is received. The received
packet's source MAC address will be the lookup key to the bridge FDB.

When deciding a forward port, the bridge looks for a FDB key which matches
the packet's destination MAC address, the associated port from the FDB will
forward the packet. Otherwise, the packet will flood to all available bridge
ports.

The FDB will never be garbage collected until the nic device is removed
from the bridge.

PiperOrigin-RevId: 693143851
2024-11-04 17:25:34 -08:00
Jing Chen 17edc7260e Support TPU v6e w/ gVisor.
PiperOrigin-RevId: 687514246
2024-10-18 20:43:34 -07:00
Jing Chen 35d3c6eb73 Update MTU value for ethernet devices.
L2 MTU includes both payload and ethernet header. gVisor has supported setting
data link layer MTU, it will be  up to users to set up proper value for a
device's MTU if a larger value is expected.

By doing the change, gVisor will be consistent with runc:

```shell
# runc
root@cec4d7238802:/# ip link set dev lo mtu 1234
root@cec4d7238802:/# ip link list dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 1234 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

# runsc before the change.
root@7cd89278d414:/# ip link set dev lo mtu 1234
root@7cd89278d414:/# ip link list dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 1220
    link/loopback 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff

# runsc after the change.
root@e811c5851226:/# ip link set dev lo mtu 1234
root@e811c5851226:/# ip link list dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 1234
    link/loopback 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
```
PiperOrigin-RevId: 684746090
2024-10-11 01:36:07 -07:00
Jing Chen 5e8dd6482c Disallow setting a coordinator for a coordinator device.
The error code is based on the runc's behavior:

```shell
# ip link set dev br0 master br0
Error: Can not enslave a bridge to a bridge.
# echo $?
2
```

Reported-by: syzbot+9dcefbdcc9ecdeb4df96@syzkaller.appspotmail.com
PiperOrigin-RevId: 679761515
2024-09-27 16:13:45 -07:00
Jing Chen 4a583f62ed Remove a stale TODO which is not reproducible.
#cleanup

PiperOrigin-RevId: 679323555
2024-09-26 15:56:25 -07:00
Jing Chen 4a38681600 Upgrade containerd in gVisor, from v1.4.13 to v1.6.36.
PiperOrigin-RevId: 679295130
2024-09-26 14:34:06 -07:00
Jing Chen f681bcc095 Implement RTM_DELROUTE in netstack.
PiperOrigin-RevId: 675711612
2024-09-17 14:33:41 -07:00
Jing Chen ac417d1200 Update packetdrill-test.
The packetdrill-test will have a new base image, and uses the main branch.
The packetdrill-v2.0 branch has been over 6 years old, and it is not
compatible with the new ubuntu releases.

PiperOrigin-RevId: 668173595
2024-08-27 15:57:16 -07:00
Jing Chen c8cb440a5f Update how runsc's port-forward command is terminated.
It currently expects all 3 events to happen to exit the command, the container
is killed, local port forward is compeleted, a termination signal is caught.

One can only terminate the command expecting both termination signal
(e.g. ctrl + c) and the container being killed. Instead, the ideal behavior
is that the command exits on either of previous 2 events. The local port
forward goroutine is blocked until the context's cancel function is called.

Thus, we just have the waitgroup to wait for the completion of the local
port forward task.

PiperOrigin-RevId: 668168948
2024-08-27 15:45:56 -07:00
Jing Chen 29c24fb995 Upgrade gVisor images to use ubuntu:jammy as the base image.
ubuntu:jammy is 22.04, which is a LTS version.

This is the fourth wave.

PiperOrigin-RevId: 666915587
2024-08-23 14:08:15 -07:00
Jing Chen 16b019b78b Upgrade gVisor images to use ubuntu:jammy as the base image.
ubuntu:jammy is 22.04, which is a LTS version.

This is the third wave.

PiperOrigin-RevId: 666528422
2024-08-22 16:15:02 -07:00
Jing Chen 9bc24a33e9 Upgrade gVisor images to use ubuntu:jammy as the base image.
ubuntu:jammy is 22.04, which is a LTS version.

This is the second wave.

PiperOrigin-RevId: 666485330
2024-08-22 14:20:09 -07:00
Jing Chen 2687806e18 Upgrade gVisor images to use ubuntu:jammy as the base image.
ubuntu:jammy is 22.04, which is a LTS version.

This is the first wave.

PiperOrigin-RevId: 666412528
2024-08-22 10:54:17 -07:00
Jing Chen bead437abf Update docker in gVisor document.
It makes the `--network=host` optional. Both `docker build` and
`docker run` can run without the option.

PiperOrigin-RevId: 662597905
2024-08-13 11:55:51 -07:00
Jing Chen 414df2de11 Add a panic that prints information about the sender before calling splitSeg.
It helps to know why splitSeg panics with a negative value.

PiperOrigin-RevId: 661021651
2024-08-08 16:22:50 -07:00
Jing Chen 6a506950b3 Start dockerd with the default bridge network in gVisor.
PiperOrigin-RevId: 653309522
2024-07-17 11:48:16 -07:00
Jing Chen 35309c96c0 Implement RTM_NEWROUTE in netstack to create/replace a route.
PiperOrigin-RevId: 650814137
2024-07-09 18:04:19 -07:00
Jing Chen b0ee04a097 Skip IFLA_TXQLEN and IFA_BROADCAST in gVisor.
The attributes are expected by Dockerd to start. In gVisor, skipping
the attributes is good enough to run the Docker workloads.

PiperOrigin-RevId: 650362257
2024-07-08 13:49:26 -07:00
Jing Chen 096478a2ff Fix the MAC address parse in IFLA_ADDRESS and add the tests.
PiperOrigin-RevId: 650333797
2024-07-08 12:19:08 -07:00
Jing Chen 222258a585 Support RTM_SETLINK in gVisor.
RTM_NEWLINK is the preferred way to change a link's configs. RTM_SETLINK is
needed by setting up Docker in gVisor.

PiperOrigin-RevId: 649789500
2024-07-06 00:49:54 -07:00
Jing Chen 5e89d40761 Test renaming a link name in setlink_test.sh
PiperOrigin-RevId: 648834200
2024-07-02 14:01:51 -07:00
Jing Chen 6dd4ef415b Implement IFLA_MTU which changes a link's MTU.
PiperOrigin-RevId: 648618069
2024-07-02 00:36:40 -07:00
Jing Chen 090d9a33d4 Expose a link's MTU when dump the link in netlink tests.
It is primarily used to test RTM_[SET|NEW]LINK with IFLA_MTU.

PiperOrigin-RevId: 648489368
2024-07-01 14:39:37 -07:00
Jing Chen 59adcc9b1e Implement IFLA_IFNAME which specifies an interface's name.
IFLA_IFNAME is used to set an interface's name when being used
with RTM_NEWLINK and RTM_SETLINK. RTM_NEWLINK is the preferred way, it
is backwards compatible with RTM_SETLINK. For gVisor, when RTM_SETLINK is
introduced, it shall just share the implementation.

PiperOrigin-RevId: 647833657
2024-06-28 17:02:31 -07:00
Jing Chen 8ef3239b0b Add SetMTU to change the mtu of device.
The method will be primarily used with RTM_[NEW|SET]LINK when IFLA_MTU
is present.

PiperOrigin-RevId: 646264847
2024-06-24 16:58:13 -07:00
Jing Chen cd3efc6519 Support IFLA_ADDRESS which changes a device's hardware address.
PiperOrigin-RevId: 645611089
2024-06-21 23:56:13 -07:00
Jing Chen 14c6ef6d52 Lock the mutex when reading a LinkAddress.
PiperOrigin-RevId: 645543579
2024-06-21 17:17:10 -07:00
Jing Chen 6bcd9e04ae Remove duplicate implementation of creating random MAC address.
PiperOrigin-RevId: 645460859
2024-06-21 12:06:04 -07:00
Jing Chen 2c5c7869d9 Add SetLinkAddress method to NetworkLinkEndpoint interface.
The method will be primarily used by IFLA_ADDRESS.

PiperOrigin-RevId: 642492748
2024-06-11 21:40:39 -07:00
Jing Chen a4349dab65 Update TODO bug id in order to close docker in gvisor bug.
PiperOrigin-RevId: 638730275
2024-05-30 11:50:04 -07:00
Jing Chen 79331f35cf Create utility for integer-based proc files.
PiperOrigin-RevId: 635890464
2024-05-21 12:26:14 -07:00
Jing Chen 4a8e821f8b Remove Logf from unit tests.
PiperOrigin-RevId: 633110930
2024-05-13 00:16:02 -07:00
Jing Chen cf5c4c9cbf Replace reflect.DeepEqual with [slices/maps].Equal.
They are faster on slice/map comparisons.

PiperOrigin-RevId: 633080355
2024-05-12 21:20:18 -07:00
Jing Chen 0b9173a110 Avoid allocating a new Credentials when the capabilities don't change.
PiperOrigin-RevId: 627190108
2024-04-22 16:31:46 -07:00
Jing Chen 56cd46057b Export network stats via runsc events.
The stats have been collected via cAdvisor which is being deprecated.

This change dosen't migrate the metric.

PiperOrigin-RevId: 625835710
2024-04-17 16:10:17 -07:00
Jing Chen 7ff0b64d6e Add pciDeviceFD mmap and initialize it with the corresponding host FD.
It removes kernfs.CachedMappable from pciDeviceFD.

PiperOrigin-RevId: 624296998
2024-04-12 14:45:22 -07:00
Jing Chen 7e9c01f12a Add Dockerfile and K8S deployments for a basic TPU pytorch workflow.
PiperOrigin-RevId: 620968670
2024-04-01 15:25:12 -07:00
Jing Chen 32afe881c5 Update tpuproxy package for a more consistent gVisor naming convention.
PiperOrigin-RevId: 620321751
2024-03-29 13:13:39 -07:00
Jing Chen 88ee65f3a8 Implement pass through ioctl VFIO_IOMMU_UNMAP_DMA.
PiperOrigin-RevId: 620107765
2024-03-28 17:47:12 -07:00
Jing Chen 79dd2520ff Implement ioctl command VFIO_IOMMU_MAP_DMA.
PiperOrigin-RevId: 619691808
2024-03-27 16:10:41 -07:00
Jing Chen db85b6316f Fix Copybara's non-reversible transformations in gVisor.
PiperOrigin-RevId: 619663125
2024-03-27 14:47:38 -07:00
Jing Chen e902007771 Make vfio-pci devices mmappable backed by a host FD.
PiperOrigin-RevId: 619265846
2024-03-26 12:00:42 -07:00
Jing Chen cc37e536cb Increase the RLIMIT_MEMLOCK when TPUProxy is enabled.
PiperOrigin-RevId: 619045692
2024-03-25 20:30:08 -07:00
Jing Chen f94df6d1bf Implement VFIO-PCI TPU device's Pread and Pwrite to enable bus master at host.
PiperOrigin-RevId: 618998464
2024-03-25 16:50:53 -07:00
Jing Chen 81e6512014 Implmenet ioctl command VFIO_DEVICE_RESET.
PiperOrigin-RevId: 618077589
2024-03-21 23:44:42 -07:00
Jing Chen 628f1bad34 Implement the ioctl command VFIO_DEVICE_SET_IRQS.
PiperOrigin-RevId: 618047305
2024-03-21 20:43:12 -07:00
Jing Chen 24251f576d Implement pass through ioctl command VFIO_DEVICE_GET_IRQ_INFO.
PiperOrigin-RevId: 618034948
2024-03-21 19:40:16 -07:00
Jing Chen 8739b58b61 Implement pass through ioctl command VFIO_DEVICE_GET_REGION_INFO.
PiperOrigin-RevId: 617760440
2024-03-21 01:27:48 -07:00
Jing Chen 705fb540ec Implement pass through ioctl command VFIO_DEVICE_GET_INFO.
PiperOrigin-RevId: 617621125
2024-03-20 14:12:51 -07:00
Jing Chen 5a6aadda2f Change the way gVisor TPUProxy passes string arguments to IOCTL syscalls.
Passing the address of the string can't be recognized by the syscall, the
syscall expects the address to the first byte of the string which is
NUL-terminated.

PiperOrigin-RevId: 617430240
2024-03-20 01:25:38 -07:00
Jing Chen 9d2a513de1 Add more generic Ioctl helper functions for TPU pass through IOCTLs.
PiperOrigin-RevId: 617378718
2024-03-19 20:27:56 -07:00
Jing Chen 459348ddf8 Implement pass through ioctl command VFIO_GROUP_GET_DEVICE_FD.
PiperOrigin-RevId: 617246946
2024-03-19 11:53:38 -07:00
Jing Chen 586c38d700 Apply a image's file capabilities when creating a process from the image.
PiperOrigin-RevId: 616237209
2024-03-15 14:08:39 -07:00
Jing Chen d20b115010 Implement ioctl command VFIO_SET_IOMMU.
PiperOrigin-RevId: 616200912
2024-03-15 11:57:29 -07:00
Jing Chen 5c64bbab30 Implement ioctl command VFIO_CHECK_EXTENSION.
PiperOrigin-RevId: 615540633
2024-03-13 14:19:36 -07:00
Jing Chen 73f7d3d3f7 Implement ioctl command VFIO_GROUP_SET_CONTAINER.
PiperOrigin-RevId: 615514857
2024-03-13 12:57:32 -07:00
Jing Chen 26e0e5df83 Implement memmap.Mappable and memmap.File for vfioFd.
PiperOrigin-RevId: 615472230
2024-03-13 10:51:52 -07:00
Jing Chen 5fd40fc0be Implement memmap.Mappable and memmap.File for tpuFd.
PiperOrigin-RevId: 615250135
2024-03-12 19:19:44 -07:00
Jing Chen c8a50763f2 Add unimplemented methods for tpuFd from vfs.FileDescriptionImpl.
PiperOrigin-RevId: 614936899
2024-03-12 00:26:48 -07:00
Jing Chen 3cf3384220 Return a task image's file capability when the image is loaded to be executed.
PiperOrigin-RevId: 613732844
2024-03-07 16:06:34 -08:00
Jing Chen 5a740cb1b4 Add DirectFS to gofer's seccomp filter options.
Only when directfs is not enabled will allow xattr syscalls.

PiperOrigin-RevId: 613018126
2024-03-05 17:08:31 -08:00
Jing Chen 5ee7588184 Update TPU v5 unit tests to cover VFIO devices.
PiperOrigin-RevId: 612986266
2024-03-05 15:21:27 -08:00
Jing Chen eb62843a8d Add VFIO device for VFIO container.
PiperOrigin-RevId: 612606195
2024-03-04 15:28:38 -08:00
Jing Chen e7b59aa1b6 Implement Getxattr for directfs and lisafs.
It allows us to read the executable binary's security.capability.

PiperOrigin-RevId: 611364676
2024-02-29 00:01:31 -08:00
Jing Chen a4c27c0722 Add a function to decode file capabilities extended attributes.
The attributes are usually retrieved via API like Fgetxattr,
Getxattr in the form of a slice of bytes.

PiperOrigin-RevId: 605466585
2024-02-08 16:57:36 -08:00
Jing Chen a5f0778c38 Add a hello world docker image test for rust runtime.
PiperOrigin-RevId: 603161919
2024-01-31 14:38:10 -08:00
Jing Chen 23736c31c9 Add rust to tested images at gVisor's compatibility page.
PiperOrigin-RevId: 602277570
2024-01-28 22:29:18 -08:00
Jing Chen 056b797c6b Add path /sys/kernel/iommu_groups when TPU proxy is enabled.
PiperOrigin-RevId: 598941007
2024-01-16 13:36:15 -08:00
Jing Chen be48200c0e Re-order loads in BUILD files to make transformations reversible in Copybara.
PiperOrigin-RevId: 598898756
2024-01-16 11:21:40 -08:00
Jing Chen 21f697000c Create IOMMU symlink(s) for TPU devices.
The symlinks mirrors the relationship between TPU devices and its respective
IOMMU group and on the host.

Before the change, iommu_group has been treated as a normal file, which doesn't
create such symlink for the devices.

PiperOrigin-RevId: 597939650
2024-01-12 13:41:20 -08:00
Jing Chen 9e364f4c23 Mount IOMMU groups at chroot.
gVisor is expected to mirror VFIO devices as well as their respective IOMMU groups which VFIO module could operate on.

PiperOrigin-RevId: 597058388
2024-01-09 15:17:47 -08:00
Jing Chen d7a3ec8305 Allow vfio releted subdirectories to be mirrored by gVisor.
It expects to mirror sysfs device subdirectories like `vfio-dev` and `vfio#`

PiperOrigin-RevId: 588855389
2023-12-07 11:29:03 -08:00
Jing Chen 063000448f Make gVisor search for all potential registered TPU devices.
gVisor creates symlinks under /sys/class when the device presents.

PiperOrigin-RevId: 588222909
2023-12-05 16:30:22 -08:00
Jing Chen 126ee58746 Register TPU v5e devices when booting gVisor.
PiperOrigin-RevId: 587251672
2023-12-02 00:05:14 -08:00
Jing Chen 7b8b28e76c Add registerTPUDevice which registers all supported TPU devices.
The function could be generalized as a TPU interface's method, while a free function is good enough for now.

PiperOrigin-RevId: 587092506
2023-12-01 12:55:50 -08:00
Jing Chen d5fc150056 Add seccomp filters for TPU v5e.
Other rules like ioctl will be added as they are implemented.

PiperOrigin-RevId: 586437297
2023-11-29 13:31:48 -08:00
Jing Chen 77eff46290 Add an initial implementation for vfioDevice Open, which implements vfs.Device interface.
PiperOrigin-RevId: 586047954
2023-11-28 11:23:48 -08:00
Jing Chen 815dade355 Add vfioFD skeleton code for TPU v5e.
PiperOrigin-RevId: 585215723
2023-11-25 00:39:53 -08:00
Jing Chen 722ddab51e Mount VFIO based TPU device directories in chroot.
PiperOrigin-RevId: 584762449
2023-11-22 18:11:46 -08:00
Jing Chen e184849c0c Add function to extract TPU v5's minor device number.
PiperOrigin-RevId: 583486707
2023-11-17 14:26:59 -08:00
Jing Chen a1be003b6f Add a panic for no sufficient virtual memory space.
When using KVM platform at arm64 machines, gVisor will attempts to retrieve the largest possible task size and compares the size with the expected user space size. If the user space size is larger than the task size, it will lead to mmap failures, gVisor should returns an error.

PiperOrigin-RevId: 581146644
2023-11-10 00:23:33 -08:00
Jing Chen ea4f0073d4 Fix data race between getting mount options and updating mount options.
It is not ideal to access a mount's Flags directly, gVisor will access a mount's flags via MountOptions() which locks mount's mu to avoid data race.

PiperOrigin-RevId: 576059331
2023-10-24 01:43:16 -07:00