Commit 52732b3
Merge
Per [1] and [2], an "ACK" message is a variant of Error (`NLMSG_ERROR`)
message with a zero value error code and a "NACK" message is a variant
with a non-zero error code.
At TOT, the `NetlinkPayload::Ack` is meant to be the "ACK" message and
the `NetlinkPayload::Error` is meant to be the NACK message. The
`NetlinkPayload::Ack` an `NetlinkPayload::Error` variants both hold
`ErrorMessage`. This creates an opportunity for misuse and subtle bugs
where a `NetlinkPayload::Ack` can hold an `ErrorMessage` with a non-zero
code or an `NetlinkPayload::Error` can hold an `ErrorMessage` with a
zero value code.
This change improves the alignment of `NetlinkPayload` with documented
message types[2] (`NLMSG_*`) and improves type-safety by making it
difficult to misinterpret an "ACK" as a "NACK" or a "NACK" as an "ACK".
With this change, applications must check if `ErrorMessage.code` is
`None` to validate success instead of checking if
`NetlinkMessage.payload` is `NetlinkPayload::Ack`. Similarly,
applications must check if `ErrorMessage.code` is `Some(e)` to check if
the request failed (with error code `e`) instead of checking if
`NetlinkMessage.payload` is `NetlinkPayload::Error`.
[1]: https://datatracker.ietf.org/doc/html/rfc3549#section-2.3.2.2
[2]: https://kernel.org/doc/html/next/userspace-api/netlink/intro.html#netlink-message-types
Fixes #15.NetlinkPayload::{Ack,Error}
1 parent 3514766 commit 52732b3
3 files changed
+104
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
51 | 55 | | |
52 | | - | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| |||
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
80 | 90 | | |
81 | 91 | | |
82 | 92 | | |
83 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
84 | 104 | | |
85 | 105 | | |
86 | 106 | | |
87 | | - | |
88 | | - | |
89 | 107 | | |
90 | 108 | | |
91 | 109 | | |
92 | 110 | | |
93 | 111 | | |
94 | 112 | | |
95 | | - | |
| 113 | + | |
96 | 114 | | |
97 | 115 | | |
98 | 116 | | |
| |||
119 | 137 | | |
120 | 138 | | |
121 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
122 | 145 | | |
123 | 146 | | |
124 | 147 | | |
125 | 148 | | |
126 | 149 | | |
127 | 150 | | |
128 | | - | |
| 151 | + | |
129 | 152 | | |
130 | 153 | | |
131 | 154 | | |
| |||
149 | 172 | | |
150 | 173 | | |
151 | 174 | | |
152 | | - | |
| 175 | + | |
153 | 176 | | |
154 | 177 | | |
155 | 178 | | |
| |||
158 | 181 | | |
159 | 182 | | |
160 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
161 | 220 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 104 | + | |
109 | 105 | | |
110 | 106 | | |
111 | 107 | | |
| |||
138 | 134 | | |
139 | 135 | | |
140 | 136 | | |
141 | | - | |
142 | 137 | | |
143 | 138 | | |
144 | 139 | | |
| |||
157 | 152 | | |
158 | 153 | | |
159 | 154 | | |
160 | | - | |
161 | 155 | | |
162 | 156 | | |
163 | 157 | | |
| |||
179 | 173 | | |
180 | 174 | | |
181 | 175 | | |
182 | | - | |
| 176 | + | |
183 | 177 | | |
184 | 178 | | |
185 | 179 | | |
| |||
240 | 234 | | |
241 | 235 | | |
242 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
243 | 267 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
| 35 | + | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| |||
0 commit comments