Commit a3328e2
committed
fix: try to make UFFD handlers more robust
According to our UFFD protocol, UFFD handlers negotiate with Firecracker
during initialization and wait for it to send over a UDS the UFFD file
descriptor along with the memory mappings that are being handled over
the UFFD.
During this handshake, our (testing only/not production grade) UFFD
handlers issue what essentially is a `recvmsg` that should return with
the UFFD fd and the mappings. Some times instead of the file descriptor,
the `recvmsg` wrapper returns a `None` value for the file descriptor.
When this happens, the UFFD handler crashes and Firecracker process
hangs.
According to `man recv(2)`:
```
Datagram sockets in various domains (e.g., the UNIX and Internet
domains) permit zero-length datagrams. When such a datagram is
received, the return value is 0.
```
which means it is possible to receive a zero-length message (we are
communicating with Firecracker over a UDS).
Add logic to our UFFD handlers to retry the negotiation with Firecracker
up to 5 times before giving up. This helps making them (slightly) more
robust. Also, we add some logging in the receive logic so that we can
inspect failures post-mortem.
Signed-off-by: Babis Chalios <[email protected]>1 parent 431b829 commit a3328e2
1 file changed
+32
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
61 | 70 | | |
62 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
63 | 74 | | |
64 | 75 | | |
65 | 76 | | |
66 | 77 | | |
67 | | - | |
68 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
69 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
70 | 93 | | |
71 | 94 | | |
72 | 95 | | |
| |||
0 commit comments