linux-support 0.0.25

Comprehensive Linux support for namespaces, cgroups, processes, scheduling, parsing /proc, parsing /sys, signals, hyper threads, CPUS, NUMA nodes, unusual file descriptors, PCI devices and much, much more
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
// This file is part of linux-support. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-support/master/COPYRIGHT. No part of linux-support, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
// Copyright © 2020 The developers of linux-support. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-support/master/COPYRIGHT.


/// Used for `RTM_NEWLINK`, `RTM_DELLINK`, `RTM_GETLINK` and `RTM_SETLINK`.
///
/// Nearly all of these are readable from `RTM_GETLINK`.
///
/// See Linux header `if_link.h`.
///
/// From the function `rtnl_ensure_unique_netns()` in `rtnelink.c` in the Linux source:-
///
/// * The attributes `IFLA_NET_NS_PID`, `IFLA_NET_NS_FD` and `IFLA_TARGET_NETNSID` are mutually exclusive; only one must be present in `RTM_NEWLINK`, `RTM_SETLINK` or `RTM_DELLINK` unless;
/// * To refer *only* by net namespace identifier (`netns id`), one of `IFLA_NET_NS_PID` or `IFLA_NET_NS_FD` must be present;
#[non_exhaustive]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u16)]
pub(crate) enum IFLA
{
	/// Should never be returned by `rtnetlink.c`.
	#[allow(dead_code)]
	IFLA_UNSPEC = 0,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_ADDRESS = 1,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_BROADCAST = 2,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_DELLINK` if `ifi_index` is `None` in `ifinfomsg`.
	/// Used in `RTM_SETLINK` (to change name).
	/// Used in request to `RTM_GETLINK` if `if_index` in `ifinfomsg` is `None`.
	#[allow(dead_code)]
	IFLA_IFNAME = 3,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_MTU = 4,
	
	/// ?Used for bonded ('linked') devices.
	///
	/// If present then `IFLA_LINK_NETNSID` should be present.
	///
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_LINK = 5,
	
	/// Used in `RTM_GETLINK`.
	///
	/// Size is `IFNAMSIZ`.
	#[allow(dead_code)]
	IFLA_QDISC = 6,
	
	/// Legacy 32-bit stats; still used but `IFLA_STATS64` is preferred.
	///
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_STATS = 7,
	
	/// Unused by Route Netlink.
	#[deprecated]
	#[allow(dead_code)]
	IFLA_COST = 8,
	
	/// Unused by Route Netlink.
	#[deprecated]
	#[allow(dead_code)]
	IFLA_PRIORITY = 9,
	
	/// Used for bonded ('linked') devices.
	///
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_MASTER = 10,
	
	/// Wireless Extension event - see `wireless.h`.
	///
	/// Used in `RTM_NEWLINK` when an event is sent.
	#[allow(dead_code)]
	IFLA_WIRELESS = 11,
	
	/// Nested.
	///
	/// See enum `IFLA_INET6`.
	///
	/// Protocol specific information for a link.
	///
	/// Explicitly *not supported* in `RTM_NEWLINK`.
	/// Used in `RTM_GETLINK` but only for `PF_BRIDGE`.
	#[allow(dead_code)]
	IFLA_PROTINFO = 12,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_TXQLEN = 13,
	
	/// Used in `RTM_GETLINK`.
	/// Explicitly *not supported* in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_MAP = 14,
	
	/// An `u32`.
	///
	/// Space is reserved for this but it does not seem to be used.
	#[deprecated]
	#[allow(dead_code)]
	IFLA_WEIGHT = 15,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	IFLA_OPERSTATE = 16,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	IFLA_LINKMODE = 17,
	
	/// Used for bonded ('linked') devices.
	///
	/// Nested.
	///
	/// See enum `IFLA_INFO` (eg for `IFLA_INFO_KIND`, `IFLA_INFO_DATA`, `IFLA_INFO_SLAVE_KIND` or `IFLA_INFO_SLAVE_DATA`).
	///
	/// See also `IFLA_LINK` and `IFLA_LINK_NETNSID`.
	///
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_LINKINFO = 18,
	
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	/// Used in `RTM_DELLINK`.
	#[allow(dead_code)]
	IFLA_NET_NS_PID = 19,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_SETLINK` (to change alias).
	#[allow(dead_code)]
	IFLA_IFALIAS = 20,
	
	/// Used as part of PCI Virtual Function (VF) control (read about SR-IOV Physical Function).
	///
	/// Number of PCI Virtual Functions (VF) if device has SR-IOV Physical Function.
	///
	/// Used in `RTM_GETLINK`; `IFLA_VFINFO_LIST` will be populated if this is present.
	#[allow(dead_code)]
	IFLA_NUM_VF = 21,
	
	/// Used as part of PCI Virtual Function (VF) control (read about SR-IOV Physical Function).
	///
	/// Nested.
	///
	/// See enum `IFLA_VF_INFO`.
	///
	/// Used in `RTM_GETLINK`; `IFLA_NUM_VF` will be populated if this is present.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_VFINFO_LIST = 22,
	
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_STATS64 = 23,
	
	/// Used as part of PCI Virtual Function (VF) control (read about SR-IOV Physical Function).
	///
	/// Nested.
	///
	/// See enum `IFLA_VF_PORT`.
	///
	/// Used in conjunction with `IFLA_PORT_SELF`.
	///
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_VF_PORTS = 24,
	
	/// Used as part of PCI Virtual Function (VF) control (read about SR-IOV Physical Function).
	///
	/// Nested.
	///
	/// See enum `IFLA_?`.
	///
	/// Used in conjunction with `IFLA_VF_PORTS`.
	///
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_PORT_SELF = 25,
	
	/// Address family ?
	///
	/// Nested.
	///
	/// See enum `IFLA_?`.
	///
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_SETLINK`.
	///
	/// A nested list of families (eg `AF_INET`).
	/// In practice only `AF_INET` and `AF_INET6` (see `inet6_fill_link_af()` are supported.
	///
	/// For `AF_INET6`:-
	///
	/// * The enum is `IFLA_INET6`.
	/// * Values include:-
	/// 	* `IFLA_INET6_FLAGS`
	/// 	* `IFLA_INET6_CACHEINFO`
	/// 	* `IFLA_INET6_CONF`
	/// 	* `IFLA_INET6_STATS`
	/// 	* `IFLA_INET6_ICMP6STATS`
	/// 	* `IFLA_INET6_ADDR_GEN_MODE`
	///
	/// Each families attribute is itself nested.
	#[allow(dead_code)]
	IFLA_AF_SPEC = 26,
	
	/// Group the device belongs to.
	///
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	/// Used in `RTM_DELLINK` if `ifi_index` is `None` in `ifinfomsg` and `IFLA_IFNAME` and `IFLA_ALT_IFNAAME` are not specified.
	#[allow(dead_code)]
	IFLA_GROUP = 27,
	
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	/// Used in `RTM_DELLINK`.
	#[allow(dead_code)]
	IFLA_NET_NS_FD = 28,
	
	/// "Extended infomation mask, PCI Virtual Functions, etc".
	/// 
	/// `u32`.
	/// 
	/// Used in request to `RTM_GETLINK` if `if_index` in `ifinfomsg` is `None`.
	#[allow(dead_code)]
	IFLA_EXT_MASK = 29,
	
	/// Promiscuity count: > 0 means acts PROMISC.
	///
	/// Refers to ethernet promiscuity.
	/// Required to be `> 0` to receive port mirrored frames.
	///
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_PROMISCUITY = 30,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	#[allow(dead_code)]
	IFLA_NUM_TX_QUEUES = 31,
	
	/// Only if the Linux kernel was configured for Receive Packet Steering (RPS) with `CONFIG_RPS`.
	///
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	#[allow(dead_code)]
	IFLA_NUM_RX_QUEUES = 32,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_CARRIER = 33,
	
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_PHYS_PORT_ID = 34,
	
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_CARRIER_CHANGES = 35,
	
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_PHYS_SWITCH_ID = 36,
	
	/// ?Used for bonded ('linked') devices.
	///
	/// If present then `IFLA_LINK` should be present.
	///
	/// See also `IFLA_LINKINFO`.
	///
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_LINK_NETNSID = 37,
	
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_PHYS_PORT_NAME = 38,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_PROTO_DOWN = 39,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_GSO_MAX_SEGS = 40,
	
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_GSO_MAX_SIZE = 41,
	
	/// Internal usage by `rtnelink.c` only.
	#[allow(dead_code)]
	IFLA_PAD = 42,
	
	/// Nested.
	///
	/// See enum `IFLA_XDP`.
	///
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_SETLINK`.
	IFLA_XDP = 43,
	
	/// Used in `RTM_GETLINK` when an event is sent.
	#[allow(dead_code)]
	IFLA_EVENT = 44,
	
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_NEW_NETNSID = 45,
	
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_SETLINK`.
	/// Used in `RTM_DELLINK`.
	/// Used in request to `RTM_GETLINK` if `if_index` in `ifinfomsg` is `None`.
	#[allow(dead_code)]
	IFLA_TARGET_NETNSID = 46,
	
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_CARRIER_UP_COUNT = 47,
	
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_CARRIER_DOWN_COUNT = 48,
	
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_NEW_IFINDEX = 49,
	
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_MIN_MTU = 50,
	
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_MAX_MTU = 51,
	
	/// Nested.
	///
	/// See enum `IFLA_?`.
	///
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_NEWLINKPROP`.
	/// Used in `RTM_DELLINKPROP`.
	///
	/// Currently just a list of `IFLA_ALT_IFNAME`.
	#[allow(dead_code)]
	IFLA_PROP_LIST = 52,
	
	/// Alternative network interface name.
	///
	/// Used in `RTM_NEWLINK`.
	/// Used in `RTM_DELLINK` if `ifi_index` is `None` in `ifinfomsg` and `IFLA_IFNAME` not specified.
	/// Used in request to `RTM_GETLINK` if `if_index` in `ifinfomsg` is `None`.
	#[allow(dead_code)]
	IFLA_ALT_IFNAME = 53,
	
	/// Permanent hardware address ('burned in' MAC).
	///
	/// Used in `RTM_GETLINK`.
	#[allow(dead_code)]
	IFLA_PERM_ADDRESS = 54,
	
	/// Nested.
	///
	/// See enum `IFLA_PROTO_DOWN_REASON` with value `IFLA_PROTO_DOWN_REASON_VALUE` (a `NonZeroU32`).
	///
	/// Only present if `IFLA_PROTO_DOWN` is present *and* `IFLA_PROTO_DOWN_REASON_VALUE` is non-zero.
	/// Used in `RTM_GETLINK`.
	/// Used in `RTM_SETLINK`.
	#[allow(dead_code)]
	IFLA_PROTO_DOWN_REASON = 55,
}

impl From<u16> for IFLA
{
	#[inline(always)]
	fn from(value: u16) -> Self
	{
		unsafe { transmute(value) }
	}
}

impl NetlinkAttributeType for IFLA
{
	#[inline(always)]
	fn to_u16(self) -> u16
	{
		self as u16
	}
}

impl IFLA
{
	const __IFLA_MAX: u16 = 55;
	
	#[allow(dead_code)]
	#[deprecated]
	pub(crate) const IFLA_IF_NETNSID: Self = IFLA::IFLA_TARGET_NETNSID;
	
	#[allow(dead_code)]
	pub(crate) const IFLA_MAX: Self = unsafe { transmute(Self::__IFLA_MAX - 1) };
}