rsmnl_linux/
if_link.rs

1// name conversion rule:
2// struct - translate snake to camel
3// anon enum - remove IFLA_ and to camel, excluding just IFLA
4use errno::Errno;
5use libc::c_int;
6
7use mnl::{Attr, AttrTbl, MsgVec, Result};
8// use linux::ipv6;
9
10// This struct should be in sync with struct rtnl_link_stats64
11#[repr(C)]
12#[derive(Debug, Clone, Copy)]
13pub struct RtnlLinkStats {
14    pub rx_packets: u32, // total packets received
15    pub tx_packets: u32, // total packets transmitted
16    pub rx_bytes: u32,   // total bytes received
17    pub tx_bytes: u32,   // total bytes transmitted
18    pub rx_errors: u32,  // bad packets received
19    pub tx_errors: u32,  // packet transmit problems
20    pub rx_dropped: u32, // no space in linux buffers
21    pub tx_dropped: u32, // no space available in linux
22    pub multicast: u32,  // multicast packets received
23    pub collisions: u32,
24
25    // detailed rx_errors:
26    pub rx_length_errors: u32,
27    pub rx_over_errors: u32,   // receiver ring buff overflow
28    pub rx_crc_errors: u32,    // recved pkt with crc error
29    pub rx_frame_errors: u32,  // recv'd frame alignment error
30    pub rx_fifo_errors: u32,   // recv'r fifo overrun
31    pub rx_missed_errors: u32, // receiver missed packet
32
33    // detailed tx_errors
34    pub tx_aborted_errors: u32,
35    pub tx_carrier_errors: u32,
36    pub tx_fifo_errors: u32,
37    pub tx_heartbeat_errors: u32,
38    pub tx_window_errors: u32,
39
40    // for cslip etc
41    pub rx_compressed: u32,
42    pub tx_compressed: u32,
43    pub rx_nohandler: u32, // dropped, no handler found
44}
45
46// The main device statistics structure
47#[repr(C)]
48#[derive(Debug, Clone, Copy)]
49pub struct RtnlLinkStats64 {
50    pub rx_packets: u64, // total packets received
51    pub tx_packets: u64, // total packets transmitted
52    pub rx_bytes: u64,   // total bytes received
53    pub tx_bytes: u64,   // total bytes transmitted
54    pub rx_errors: u64,  // bad packets received
55    pub tx_errors: u64,  // packet transmit problems
56    pub rx_dropped: u64, // no space in linux buffers
57    pub tx_dropped: u64, // no space available in linux
58    pub multicast: u64,  // multicast packets received
59    pub collisions: u64,
60
61    // detailed rx_errors:
62    pub rx_length_errors: u64,
63    pub rx_over_errors: u64,   // receiver ring buff overflow
64    pub rx_crc_errors: u64,    // recved pkt with crc error
65    pub rx_frame_errors: u64,  // recv'd frame alignment error
66    pub rx_fifo_errors: u64,   // recv'r fifo overrun
67    pub rx_missed_errors: u64, // receiver missed packet
68
69    // detailed tx_errors
70    pub tx_aborted_errors: u64,
71    pub tx_carrier_errors: u64,
72    pub tx_fifo_errors: u64,
73    pub tx_heartbeat_errors: u64,
74    pub tx_window_errors: u64,
75
76    // for cslip etc
77    pub rx_compressed: u64,
78    pub tx_compressed: u64,
79    pub rx_nohandler: u64, // dropped, no handler found
80}
81
82#[repr(C)]
83#[derive(Debug, Clone, Copy)]
84pub struct RtnlLinkIfmap {
85    pub mem_start: u64,
86    pub mem_end: u64,
87    pub base_addr: u64,
88    pub irq: u16,
89    pub dma: u8,
90    pub port: u8,
91}
92
93// IFLA_AF_SPEC
94//   Contains nested attributes for address family specific attributes.
95//   Each address family may create a attribute with the address family
96//   number as type and create its own attribute structure in it.
97//
98//   Example:
99//   [IFLA_AF_SPEC] = {
100//       [AF_INET] = {
101//           [IFLA_INET_CONF] = ...,
102//       },
103//       [AF_INET6] = {
104//           [IFLA_INET6_FLAGS] = ...,
105//           [IFLA_INET6_CONF] = ...,
106//       }
107//   }
108#[repr(u16)]
109#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
110#[tbname = "IflaTbl"]
111pub enum Ifla {
112    // IFLA_
113    Unspec = 0,
114    #[nla_type(bytes, address)]
115    Address,
116
117    #[nla_type(bytes, broadcast)]
118    Broadcast,
119
120    #[nla_type(str, ifname)]
121    Ifname,
122
123    #[nla_type(u32, mtu)]
124    Mtu,
125
126    #[nla_type(u32, link)]
127    Link,
128
129    #[nla_type(str, qdisc)]
130    Qdisc,
131
132    #[nla_type(RtnlLinkStats, stats)]
133    Stats,
134
135    Cost,
136
137    Priority,
138
139    #[nla_type(u32, master)]
140    Master,
141
142    #[nla_type(bytes, wireless)]
143    Wireless,
144
145    Protinfo,
146    Txqlen,
147    Map,
148    Weight,
149    Operstate,
150    Linkmode,
151    Linkinfo,
152    NetNsPid,
153    Ifalias,
154    NumVf,
155    VfinfoList,
156    Stats64,
157    VfPorts,
158    PortSelf,
159    AfSpec,
160    Group,
161    NetNsFd,
162    ExtMask,
163    Promiscuity,
164    NumTxQueues,
165    NumRxQueues,
166    Carrier,
167    PhysPortId,
168    CarrierChanges,
169    PhysSwitchId,
170    LinkNetnsid,
171    PhysPortName,
172    ProtoDown,
173    GsoMaxSegs,
174    GsoMaxSize,
175    Pad,
176    Xdp,
177    Event,
178    NewNetnsid,
179    IfNetnsid,
180    CarrierUpCount,
181    CarrierDownCount,
182    NewIfindex,
183    MinMtu,
184    MaxMtu,
185    PropList,
186    AltIfname,
187    PermAddress,
188    ProtoDownReason,
189    _MAX,
190}
191
192#[repr(u16)]
193#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
194pub enum ProtoDownReason {
195    // IFLA_PROTO_DOWN_REASON_
196    Unspec,
197    Mask,  /* u32, mask for reason bits */
198    Value, /* u32, reason bit value */
199    _MAX,
200}
201
202#[repr(u16)]
203#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
204#[tbname = "InetTbl"]
205pub enum Inet {
206    // IFLA_INET_
207    Unspec = 0,
208    Conf,
209    _MAX,
210}
211
212// ifi_flags.
213//
214//   IFF_* flags.
215//
216//   The only change is:
217//   IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are
218//   more not changeable by user. They describe link media
219//   characteristics and set by device driver.
220//
221//   Comments:
222//   - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
223//   - If neither of these three flags are set;
224//     the interface is NBMA.
225//
226//   - IFF_MULTICAST does not mean anything special:
227//   multicasts can be used on all not-NBMA links.
228//   IFF_MULTICAST means that this media uses special encapsulation
229//   for multicast frames. Apparently, all IFF_POINTOPOINT and
230//   IFF_BROADCAST devices are able to use multicasts too.
231//
232
233// IFLA_LINK.
234//   For usual devices it is equal ifi_index.
235//   If it is a "virtual interface" (f.e. tunnel), ifi_link
236//   can point to real physical interface (f.e. for bandwidth calculations),
237//   or maybe 0, what means, that real media is unknown (usual
238//   for IPIP tunnels, when route to endpoint is allowed to change)
239
240// Subtype attributes for IFLA_PROTINFO
241#[repr(u16)]
242#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
243#[tbname = "IflaInet6Tbl"]
244pub enum Inet6 {
245    // IFLA_INET6_
246    Unspec = 0,
247
248    #[nla_type(u32, flags)]
249    Flags, // link flags
250
251    Conf,  // sysctl parameters
252    Stats, // statistics
253    Mcast, // MC things. What of them?
254
255    #[nla_type(IflaCacheinfo, cacheinfo)]
256    Cacheinfo, // time values and max reasm size
257    Icmp6stats,  // statistics (icmpv6)
258    Token,       // device token
259    AddrGenMode, // implicit address generator mode
260    _MAX,
261}
262
263#[repr(u32)]
264#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
265pub enum In6AddrGenMode {
266    // IN6_ADDR_GEN_MODE_
267    Eui64 = 0,
268    None,
269    StablePrivacy,
270    Random,
271}
272pub const IN6_ADDR_GEN_MODE_EUI64: u32 = In6AddrGenMode::Eui64 as u32;
273pub const IN6_ADDR_GEN_MODE_NONE: u32 = In6AddrGenMode::None as u32;
274pub const IN6_ADDR_GEN_MODE_STABLE_PRIVACY: u32 = In6AddrGenMode::StablePrivacy as u32;
275pub const IN6_ADDR_GEN_MODE_RANDOM: u32 = In6AddrGenMode::Random as u32;
276
277// Bridge section
278#[repr(u16)]
279#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
280#[tbname = "BrTbl"]
281pub enum Br {
282    // IFLA_BR_
283    Unspec = 0,
284    ForwardDelay,
285    HelloTime,
286    MasAge,
287    AgeingTime,
288    StpState,
289    Priority,
290    VlanFiltering,
291    VlanProtocol,
292    GroupFwdMask,
293    RootId,
294    BridgeId,
295    RootPort,
296    RootPathCost,
297    TopologyChange,
298    TopologyChangeDetedted,
299    HelloTimer,
300    TcnTimer,
301    TopologyChangeTimer,
302    GcTimer,
303    GroupAddr,
304    FdbFlush,
305    McastRouter,
306    McastSnooping,
307    McastQueryUseIfaddr,
308    McastQuerier,
309    McastHashElasticity,
310    McastHashMax,
311    McastLastMemberCnt,
312    McastStartupQueryCnt,
313    McastLastMemberIntvl,
314    McastMembershipIntvl,
315    McastQuerierIntvl,
316    McastQueryIntvl,
317    McastQueryResponseIntvl,
318    McastStartupQueryIntvl,
319    NfCallIptables,
320    NfCallIp6Tables,
321    NfCallArptables,
322    VlanDefaultPvid,
323    Pad,
324    VlanStatsEnabled,
325    McastStatsEnabled,
326    McastIgmpVersion,
327    McastMldVersion,
328    VlanStatsPerPort,
329    MultiBoolopt,
330    _MAX,
331}
332
333#[repr(C)]
334#[derive(Debug, Clone, Copy)]
335pub struct IflaBridgeId {
336    pub prio: [u8; 2usize],
337    pub addr: [u8; 6usize],
338}
339
340// XXX: unused?
341#[repr(C)]
342#[derive(Debug, Clone, Copy)]
343pub enum BridgeMode {
344    // BRIDGE_MODE_
345    Unspec = 0,
346    Hairpin = 1,
347}
348pub const BRIDGE_MODE_UNSPEC: c_int = BridgeMode::Unspec as c_int;
349pub const BRIDGE_MODE_HAIRPIN: c_int = BridgeMode::Hairpin as c_int;
350
351#[repr(u16)]
352#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
353#[tbname = "BrportTbl"]
354pub enum Brport {
355    // IFLA_BRPORT_
356    Unspec = 0,
357
358    #[nla_type(u8, state)]
359    State, // Spanning tree state
360
361    #[nla_type(u16, priority)]
362    Priority, // "             priority
363
364    #[nla_type(u32, cost)]
365    Cost, // "             cost
366
367    #[nla_type(u8, mode)]
368    Mode, // mode (hairpin)
369
370    #[nla_type(u8, guard)]
371    Guard, // bpdu guard
372
373    #[nla_type(u8, protect)]
374    Protect, // root port protection
375
376    #[nla_type(u8, fast_leave)]
377    FastLeave, // multicast fast leave
378
379    #[nla_type(u8, learning)]
380    Learning, // mac learning
381
382    #[nla_type(u8, flood)]
383    UnicastFlood, // flood unicast traffic
384
385    #[nla_type(u8, proxyarp)]
386    Proxyarp, // proxy ARP
387
388    LearningSync, // mac learning sync from device
389
390    #[nla_type(u8, proxyarp_wifi)]
391    ProxyarpWifi, // proxy ARP for Wi-Fi
392
393    #[nla_type(IflaBridgeId, root_id)]
394    RootId, // designated root
395
396    #[nla_type(IflaBridgeId, bridge_id)]
397    BridgeId, // designated bridge
398
399    #[nla_type(u16, designated_port)]
400    DesignatedPort,
401
402    #[nla_type(u16, designated_cost)]
403    DesignatedCost,
404
405    #[nla_type(u16, id)]
406    Id,
407
408    #[nla_type(u16, no)]
409    No,
410
411    #[nla_type(u8, topology_change_ack)]
412    TopologyChangeAck,
413
414    #[nla_type(u8, config_pending)]
415    ConfigPending,
416
417    #[nla_type(u64, message_age_timer)]
418    MessageAgeTimer,
419
420    #[nla_type(u64, forward_delay_timer)]
421    ForwardDelayTimer,
422
423    #[nla_type(u64, hold_timer)]
424    HoldTimer,
425
426    Flush,
427
428    #[nla_type(u8, multicast_router)]
429    MulticastRouter,
430
431    Pad,
432
433    #[nla_type(u8, mcast_flood)]
434    McastFlood,
435
436    #[nla_type(u8, mcast_to_unicast)]
437    McastToUnicast,
438
439    #[nla_type(u8, vlan_tunnel)]
440    VlanTunnel,
441
442    #[nla_type(u8, bcast_flood)]
443    BcastFlood,
444
445    #[nla_type(u16, group_fwd_mask)]
446    GroupFwdMask,
447
448    #[nla_type(u8, neigh_suppress)]
449    NeighSuppress,
450
451    #[nla_type(u8, isolated)]
452    Isolated,
453
454    #[nla_type(u32, backup_port)]
455    BackupPort,
456
457    #[nla_type(u8, mrp_ring_open)]
458    MrpRingOpen,
459
460    #[nla_type(u8, mrp_in_open)]
461    MrpInOpen,
462
463    _MAX,
464}
465
466#[repr(C)]
467#[derive(Debug, Clone, Copy)]
468pub struct IflaCacheinfo {
469    pub max_reasm_len: u32,
470    pub tstamp: u32,
471    pub reachable_time: u32,
472    pub retrans_time: u32,
473}
474
475#[repr(u16)]
476#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
477#[tbname = "InfoTbl"]
478pub enum Info {
479    // IFLA_INFO_
480    Unspec = 0,
481    Kind,
482    Data,
483    Xstats,
484    SlaveKind,
485    SlaveData,
486    _MAX,
487}
488
489// VLAN section
490#[repr(u16)]
491#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
492#[tbname = "VlanTbl"]
493pub enum Vlan {
494    // IFLA_VLAN_
495    Unspec = 0,
496    Id,
497    Flags,
498    EgressQos,
499    IngressQos,
500    Protocol,
501    _MAX,
502}
503
504#[repr(C)]
505#[derive(Debug, Clone, Copy)]
506pub struct IflaVlanFlags {
507    pub flags: u32,
508    pub mask: u32,
509}
510
511#[repr(u16)]
512#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
513#[tbname = "VlanQosTbl"]
514pub enum VlanQos {
515    // IFLA_VLAN_QOS_
516    Unspec = 0,
517    Mapping,
518    _MAX,
519}
520
521#[repr(C)]
522#[derive(Debug, Clone, Copy)]
523pub struct IflaVlanQosMapping {
524    pub from: u32,
525    pub to: u32,
526}
527
528// MACVLAN section
529#[repr(u16)]
530#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
531#[tbname = "MacvlanTbl"]
532pub enum Macvlan {
533    // IFLA_MACVLAN_
534    Unspec = 0,
535    Mode,
536    Flags,
537    MacaddrMode,
538    Macaddr,
539    MacaddrData,
540    MacaddrCount,
541    _MAX,
542}
543
544#[repr(u32)]
545#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
546pub enum MacvlanMode {
547    // MACVLAN_MODE_
548    Private = 1,  // don't talk to other macvlans
549    Vepa = 2,     // talk to other ports through ext bridge
550    Bridge = 4,   // talk to bridge ports directly
551    Passthru = 8, // take over the underlying device
552    Source = 16,  // use source MAC address list to assign
553}
554pub const MACVLAN_MODE_PRIVATE: u32 = MacvlanMode::Private as u32;
555pub const MACVLAN_MODE_VEPA: u32 = MacvlanMode::Vepa as u32;
556pub const MACVLAN_MODE_BRIDGE: u32 = MacvlanMode::Bridge as u32;
557pub const MACVLAN_MODE_PASSTHRU: u32 = MacvlanMode::Passthru as u32;
558pub const MACVLAN_MODE_SOURCE: u32 = MacvlanMode::Source as u32;
559
560#[repr(u32)]
561#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
562pub enum MacvlanMacaddrMode {
563    // MACVLAN_MACADDR_
564    Add = 0,
565    Del,
566    Flush,
567    Set,
568}
569pub const MACVLAN_MACADDR_ADD: u32 = MacvlanMacaddrMode::Add as u32;
570pub const MACVLAN_MACADDR_DEL: u32 = MacvlanMacaddrMode::Del as u32;
571pub const MACVLAN_MACADDR_FLUSH: u32 = MacvlanMacaddrMode::Flush as u32;
572pub const MACVLAN_MACADDR_SET: u32 = MacvlanMacaddrMode::Set as u32;
573
574// VRF section
575#[repr(u16)]
576#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
577#[tbname = "VrfTbl"]
578pub enum Vrf {
579    // IFLA_VRF_
580    Unspec,
581    Table,
582    _MAX,
583}
584
585#[repr(u16)]
586#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
587#[tbname = "VrfPortTbl"]
588pub enum VrfPort {
589    // IFLA_VRF_PORT_
590    Unspec = 0,
591    Table,
592    _MAX,
593}
594
595// MACSEC section
596#[repr(u16)]
597#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
598#[tbname = "MacsecTbl"]
599pub enum Macsec {
600    // IFLA_MACSEC_
601    Unspec = 0,
602    Sci,
603    Port,
604    IcvLen,
605    CipherSuite,
606    Window,
607    EncodingSa,
608    Encrypt,
609    Protect,
610    IncSci,
611    Es,
612    Scb,
613    ReplayProtect,
614    Validation,
615    Pad,
616    Offload,
617    _MAX,
618}
619
620// XFRM section
621#[repr(u16)]
622#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
623#[tbname = "XfrmTbl"]
624pub enum Xfrm {
625    // IFLA_XFRM_
626    Unspec = 0,
627    Link,
628    IfId,
629    _MAX,
630}
631
632#[repr(u8)]
633#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
634pub enum MacsecValidationType {
635    // MACSEC_VALIDATE_
636    Disabled = 0,
637    Check = 1,
638    Strict = 2,
639    _END,
640}
641pub const MACSEC_VALIDATE_DISABLED: u8 = MacsecValidationType::Disabled as u8;
642pub const MACSEC_VALIDATE_CHECK: u8 = MacsecValidationType::Check as u8;
643pub const MACSEC_VALIDATE_STRICT: u8 = MacsecValidationType::Strict as u8;
644pub const __MACSEC_VALIDATE_END: u8 = MacsecValidationType::_END as u8;
645pub const MACSEC_VALIDATE_MAX: u8 = __MACSEC_VALIDATE_END - 1;
646
647#[repr(C)]
648#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
649pub enum MacsecOffload {
650    // MACSEC_OFFLOAD_
651    Off = 0,
652    Phy = 1,
653    Mac = 2,
654    _END,
655}
656pub const MACSEC_OFFLOAD_OFF: c_int = MacsecOffload::Off as c_int;
657pub const MACSEC_OFFLOAD_PHY: c_int = MacsecOffload::Phy as c_int;
658pub const MACSEC_OFFLOAD_MAC: c_int = MacsecOffload::Mac as c_int;
659pub const __MACSEC_OFFLOAD_END: c_int = MacsecOffload::_END as c_int;
660pub const MACSEC_OFFLOAD_MAX: c_int = __MACSEC_OFFLOAD_END - 1;
661
662// IPVLAN section
663#[repr(u16)]
664#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
665#[tbname = "IpvlanTbl"]
666pub enum Ipvlan {
667    // IFLA_IPVLAN_
668    Unspec = 0,
669    Mode,
670    Flags,
671    _MAX,
672}
673
674#[repr(u16)]
675#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
676pub enum IpvlanMode {
677    // IPVLAN_MODE_
678    L2 = 0,
679    L3,
680    L3S,
681    MAX,
682}
683pub const IPVLAN_MODE_L2: u16 = IpvlanMode::L2 as u16;
684pub const IPVLAN_MODE_L3: u16 = IpvlanMode::L3 as u16;
685pub const IPVLAN_MODE_L3S: u16 = IpvlanMode::L3S as u16;
686pub const IPVLAN_MODE_MAX: u16 = IpvlanMode::MAX as u16;
687
688pub const IPVLAN_F_PRIVATE: u16 = 0x01;
689pub const IPVLAN_F_VEPA: u16 = 0x02;
690
691// VXLAN section
692#[repr(u16)]
693#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
694#[tbname = "VxlanTbl"]
695pub enum Vxlan {
696    // IFLA_VXLAN_
697    Unspec = 0,
698    Id,
699    Group, // group or remote address
700    Link,
701    Local,
702    Ttl,
703    Tos,
704    Learning,
705    Ageing,
706    Limit,
707    PortRange, // source port
708    Proxy,
709    Rsc,
710    L2Miss,
711    L3Miss,
712    Port, // destination port
713    Group6,
714    Local6,
715    UdpCsum,
716    UdpZeroCsum6Tx,
717    UdpZeroCsum6Rx,
718    RemcsumTx,
719    RemcsumRx,
720    Gbp,
721    RemcsumNopartial,
722    CollectMetadata,
723    Label,
724    Gpe,
725    TtlInherit,
726    Df,
727    _MAX,
728}
729
730#[repr(C)]
731#[derive(Debug, Clone, Copy)]
732pub struct IflaVxlanPortRange {
733    pub low: u16,
734    pub high: u16,
735}
736
737#[repr(C)]
738#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
739pub enum IflaVxlanDf {
740    // VXLAN_DF_
741    Unset = 0,
742    Set,
743    Inherit,
744    _END,
745}
746pub const VXLAN_DF_UNSET: c_int = IflaVxlanDf::Unset as c_int;
747pub const VXLAN_DF_SET: c_int = IflaVxlanDf::Set as c_int;
748pub const VXLAN_DF_INHERIT: c_int = IflaVxlanDf::Inherit as c_int;
749pub const __VXLAN_DF_END: c_int = IflaVxlanDf::_END as c_int;
750pub const VXLAN_DF_MAX: c_int = __VXLAN_DF_END - 1;
751
752// GENEVE section
753#[repr(u16)]
754#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
755#[tbname = "GeneveTbl"]
756pub enum Geneve {
757    // IFLA_GENEVE_
758    Unspec = 0,
759    Id,
760    Remote,
761    Ttl,
762    Tos,
763    Port,
764    CollectMetadata,
765    Remote6,
766    UdpCsum,
767    UdpZeroCsum6Tx,
768    UdpZeroCsum6Rx,
769    Label,
770    TtlInherit,
771    Df,
772    _MAX,
773}
774
775#[repr(C)]
776#[derive(Debug, Clone, Copy)]
777pub enum IflaGeneveDf {
778    // GENEVE_DF_
779    Unset = 0,
780    Set,
781    Inherit,
782    _END,
783}
784pub const GENEVE_DF_UNSET: c_int = IflaGeneveDf::Unset as c_int;
785pub const GENEVE_DF_SET: c_int = IflaGeneveDf::Set as c_int;
786pub const GENEVE_DF_INHERIT: c_int = IflaGeneveDf::Inherit as c_int;
787pub const __GENEVE_DF_END: c_int = IflaGeneveDf::_END as c_int;
788pub const GENEVE_DF_MAX: c_int = __GENEVE_DF_END - 1;
789
790// Bareudp section
791#[repr(u16)]
792#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
793#[tbname = "BareUdpTbl"]
794pub enum BareUdp {
795    // IFLA_BAREUDP_
796    Unspec,
797    Port,
798    Ethertype,
799    SrcportMin,
800    MultiprotoMode,
801    _MAX,
802}
803
804// PPP section
805#[repr(u16)]
806#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
807#[tbname = "PppTbl"]
808pub enum Ppp {
809    // IFLA_PPP_
810    Unspec = 0,
811    DevFd,
812    _MAX,
813}
814
815// GTP section
816#[repr(u32)]
817#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
818pub enum IflaGtpRole {
819    Ggsn = 0,
820    Sgsn,
821}
822pub const GTP_ROLE_GGSN: u32 = IflaGtpRole::Ggsn as u32;
823pub const GTP_ROLE_SGSN: u32 = IflaGtpRole::Sgsn as u32;
824
825#[repr(u16)]
826#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
827#[tbname = "GtpTbl"]
828pub enum Gtp {
829    // IFLA_GTP_
830    Unspec = 0,
831    Fd0,
832    Fd1,
833    PdpHashsize,
834    Role,
835    _MAX,
836}
837
838// Bonding section
839#[repr(u16)]
840#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
841#[tbname = "BondTbl"]
842pub enum Bond {
843    // IFLA_BOND_
844    Unspec = 0,
845    Mode,
846    ActiveSlave,
847    Miimon,
848    Updelay,
849    Downdelay,
850    UseCarrier,
851    ArpInterval,
852    ArpIpTarget,
853    ArpValidate,
854    ArpAllTargets,
855    Primary,
856    PrimaryReselect,
857    FailOverMac,
858    XmitHashPolicy,
859    ResendIgmp,
860    NumPeerNotif,
861    AllSlavesActive,
862    MinLinks,
863    LpInterval,
864    PacketsPerSlave,
865    AdLacpRate,
866    AdSelect,
867    AdInfo,
868    AdActorSysPrio,
869    AdUserPortKey,
870    AdActorSystem,
871    TlbDynamicLb,
872    PeerNotifDelay,
873    _MAX,
874}
875
876#[repr(u16)]
877#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
878#[tbname = "BondAdInfoTbl"]
879pub enum BondAdInfo {
880    // IFLA_BOND_AD_INFO_
881    Unspec = 0,
882    Aggregator,
883    NumPorts,
884    ActorKey,
885    PartnerKey,
886    PartnerMac,
887    _MAX,
888}
889
890#[repr(u16)]
891#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
892#[tbname = "BondSlaveTbl"]
893pub enum BondBondSlave {
894    // IFLA_BOND_SLAVE_
895    Unspec = 0,
896    State,
897    MiiStatus,
898    LinkFailureCount,
899    PermHwaddr,
900    QueueId,
901    AdAggregatorId,
902    AdActorOperPortState,
903    AdPartnerOperPortState,
904    _MAX,
905}
906
907// SR-IOV virtual function management section
908#[repr(u16)]
909#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
910#[tbname = "VfInfoTbl"]
911pub enum VfInfo {
912    // IFLA_VF_INFO_
913    Unspec = 0,
914    Info = 1, // XXX: origin - IFLA_VF_INFO
915    _MAX,
916}
917
918#[repr(u16)]
919#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
920#[tbname = "VfTbl"]
921pub enum Vf {
922    // IFLA_VF_
923    Unspec = 0,
924    Mac,        // Hardware queue specific attributes
925    Vlan,       // VLAN ID and QoS
926    TxRate,     // Max TX Bandwidth Allocation
927    Spoofchk,   // Spoof Checking on/off switch
928    LinkState,  // link state enable/disable/auto switch
929    Rate,       // Min and Max TX Bandwidth Allocation
930    RssQueryEn, // RSS Redirection Table and Hash Key query
931    // on/off switch
932    Stats,      // network device statistics
933    Trust,      // Trust VF
934    IbNodeGuid, // VF Infiniband node GUID
935    IbPortGuid, // VF Infiniband port GUID
936    VlanList,   // nested list of vlans, option for QinQ
937    Broadcast,  // VF broadcast
938    _MAX,
939}
940
941#[repr(C)]
942#[derive(Debug, Clone, Copy)]
943pub struct IflaVfMac {
944    pub vf: u32,
945    pub mac: [u8; 32usize], // MAX_ADDR_LEN
946}
947
948#[repr(C)]
949#[derive(Debug, Clone, Copy)]
950pub struct IflaVfBroadcast {
951    pub broadcast: [u8; 32usize],
952}
953
954#[repr(C)]
955#[derive(Debug, Clone, Copy)]
956pub struct IflaVfVlan {
957    pub vf: u32,
958    pub vlan: u32, // 0 - 4095, 0 disables VLAN filter
959    pub qos: u32,
960}
961
962#[repr(u16)]
963#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
964#[tbname = "VfVlanInfoTbl"]
965pub enum VfVlanInfo {
966    // IFLA_VF_VLAN_INFO_
967    Unspec = 0,
968    Info, // VLAN ID, QoS and VLAN protocol
969    // XXX: original - IFLA_VF_VLAN_INFO
970    _MAX,
971}
972
973pub const MAX_VLAN_LIST_LEN: usize = 1;
974
975#[repr(C)]
976#[derive(Debug, Clone, Copy)]
977pub struct IflaVfVlanInfo {
978    pub vf: u32,
979    pub vlan: u32, // 0 - 4095, 0 disables VLAN filter
980    pub qos: u32,
981    pub vlan_proto: u16, // VLAN protocol either 802.1Q or 802.1ad
982}
983
984#[repr(C)]
985#[derive(Debug, Clone, Copy)]
986pub struct IflaVfTxRate {
987    pub vf: u32,
988    pub rate: u32, // Max TX bandwidth in Mbps, 0 disables throttling
989}
990
991#[repr(C)]
992#[derive(Debug, Clone, Copy)]
993pub struct IflaVfRate {
994    pub vf: u32,
995    pub min_tx_rate: u32, // Min Bandwidth in Mbps
996    pub max_tx_rate: u32, // Max Bandwidth in Mbps
997}
998
999#[repr(C)]
1000#[derive(Debug, Clone, Copy)]
1001pub struct IflaVfSpoofchk {
1002    pub vf: u32,
1003    pub setting: u32,
1004}
1005
1006#[repr(C)]
1007#[derive(Debug, Clone, Copy)]
1008pub struct IflaVfGuid {
1009    pub vf: u32,
1010    pub guid: u64,
1011}
1012
1013#[repr(u32)]
1014#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1015pub enum VfLinkState {
1016    // IFLA_VF_LINK_STATE_
1017    Auto = 0, // link state of the uplink
1018    Enable,   // link always up
1019    Disable,  // link always down
1020    _MAX,
1021}
1022pub const IFLA_VF_LINK_STATE_AUTO: u32 = VfLinkState::Auto as u32;
1023pub const IFLA_VF_LINK_STATE_ENABLE: u32 = VfLinkState::Enable as u32;
1024pub const IFLA_VF_LINK_STATE_DISABLE: u32 = VfLinkState::Disable as u32;
1025pub const __IFLA_VF_LINK_STATE_MAX: u32 = VfLinkState::_MAX as u32;
1026
1027#[repr(C)]
1028#[derive(Debug, Clone, Copy)]
1029pub struct IflaVfLinkState {
1030    pub vf: u32,
1031    pub link_state: u32,
1032}
1033
1034#[repr(C)]
1035#[derive(Debug, Clone, Copy)]
1036pub struct IflaVfRssQueryEn {
1037    pub vf: u32,
1038    pub setting: u32,
1039}
1040
1041#[repr(u16)]
1042#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
1043#[tbname = "VfStatsTbl"]
1044pub enum VfStats {
1045    // IFLA_VF_STATS_
1046    RxPackets = 0,
1047    TxPackets,
1048    RxBytes,
1049    TxBytes,
1050    Broadcast,
1051    Multicast,
1052    Pad,
1053    RxDropped,
1054    TxDropped,
1055    _MAX,
1056}
1057
1058#[repr(C)]
1059#[derive(Debug, Clone, Copy)]
1060pub struct ifla_vf_trust {
1061    pub vf: u32,
1062    pub setting: u32,
1063}
1064
1065// XXXXXXXX: here
1066
1067// VF ports management section
1068//
1069//	Nested layout of set/get msg is:
1070//
1071//		[IFLA_NUM_VF]
1072//		[IFLA_VF_PORTS]
1073//			[IFLA_VF_PORT]
1074//				[IFLA_PORT_*], ...
1075//			[IFLA_VF_PORT]
1076//				[IFLA_PORT_*], ...
1077//			...
1078//		[IFLA_PORT_SELF]
1079//			[IFLA_PORT_*], ...
1080#[repr(u16)]
1081#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
1082#[tbname = "VfPortTbl"]
1083pub enum VfPort {
1084    // IFLA_VF_PORT_
1085    Unspec,
1086    Port, // nest
1087    _MAX,
1088}
1089
1090#[repr(u16)]
1091#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
1092#[tbname = "PortTbl"]
1093pub enum Port {
1094    // IFLA_PORT_
1095    Unspec = 0,
1096    Vf,           // __u32
1097    Profile,      // string
1098    VsiType,      // 802.1Qbg (pre-)standard VDP
1099    InstanceUuid, // binary UUID
1100    HostUuid,     // binary UUID
1101    Request,      // __u8
1102    Response,     // __u16, output only
1103    _MAX = 8,
1104}
1105pub const PORT_PROFILE_MAX: usize = 40;
1106pub const PORT_UUID_MAX: usize = 16;
1107pub const PORT_SELF_VF: c_int = -1;
1108
1109#[repr(u8)]
1110#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1111pub enum PortRequest {
1112    // PORT_REQUEST_
1113    Preassociate = 0,
1114    PreassociateRr,
1115    Associate,
1116    Disassociate,
1117}
1118pub const PORT_REQUEST_PREASSOCIATE: u8 = PortRequest::Preassociate as u8;
1119pub const PORT_REQUEST_PREASSOCIATE_RR: u8 = PortRequest::PreassociateRr as u8;
1120pub const PORT_REQUEST_ASSOCIATE: u8 = PortRequest::Associate as u8;
1121pub const PORT_REQUEST_DISASSOCIATE: u8 = PortRequest::Disassociate as u8;
1122
1123#[repr(u16)]
1124#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1125pub enum PortResponse {
1126    // PORT_VDP_RESPONSE_, PORT_PROFILE_RESPONSE
1127    VdpSuccess = 0,
1128    VdpInvalidFormat,
1129    VdpInsufficientResources,
1130    VdpUnusedVtid,
1131    VdpVtidViolation,
1132    VdpVtidVersionVioaltion,
1133    VdpOutOfSync,
1134    // 0x08-0xFF reserved for future VDP use
1135    ProfileSuccess = 0x100,
1136    ProfileInprogress,
1137    ProfileInvalid,
1138    ProfileBadstate,
1139    ProfileInsufficientResources,
1140    ProfileError,
1141}
1142pub const PORT_VDP_RESPONSE_SUCCESS: u16 = PortResponse::VdpSuccess as u16;
1143pub const PORT_VDP_RESPONSE_INVALID_FORMAT: u16 = PortResponse::VdpInvalidFormat as u16;
1144pub const PORT_VDP_RESPONSE_INSUFFICIENT_RESOURCES: u16 =
1145    PortResponse::VdpInsufficientResources as u16;
1146pub const PORT_VDP_RESPONSE_UNUSED_VTID: u16 = PortResponse::VdpUnusedVtid as u16;
1147pub const PORT_VDP_RESPONSE_VTID_VIOLATION: u16 = PortResponse::VdpVtidViolation as u16;
1148pub const PORT_VDP_RESPONSE_VTID_VERSION_VIOALTION: u16 =
1149    PortResponse::VdpVtidVersionVioaltion as u16;
1150pub const PORT_VDP_RESPONSE_OUT_OF_SYNC: u16 = PortResponse::VdpOutOfSync as u16;
1151pub const PORT_PROFILE_RESPONSE_SUCCESS: u16 = PortResponse::ProfileSuccess as u16;
1152pub const PORT_PROFILE_RESPONSE_INPROGRESS: u16 = PortResponse::ProfileInprogress as u16;
1153pub const PORT_PROFILE_RESPONSE_INVALID: u16 = PortResponse::ProfileInvalid as u16;
1154pub const PORT_PROFILE_RESPONSE_BADSTATE: u16 = PortResponse::ProfileBadstate as u16;
1155pub const PORT_PROFILE_RESPONSE_INSUFFICIENT_RESOURCES: u16 =
1156    PortResponse::ProfileInsufficientResources as u16;
1157pub const PORT_PROFILE_RESPONSE_ERROR: u16 = PortResponse::ProfileError as u16;
1158
1159#[repr(C)]
1160#[derive(Debug, Clone, Copy)]
1161pub struct ifla_port_vsi {
1162    pub vsi_mgr_id: u8,
1163    pub vsi_type_id: [u8; 3usize],
1164    pub vsi_type_version: u8,
1165    pub pad: [u8; 3usize],
1166}
1167
1168// IPoIB section
1169#[repr(u16)]
1170#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
1171#[tbname = "IopbTbl"]
1172pub enum Ipoib {
1173    // IFLA_IPOIB_
1174    Unspec,
1175    Pkey,
1176    Mode,
1177    Umcast,
1178    _MAX,
1179}
1180
1181#[repr(u16)]
1182#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1183pub enum IpoibMode {
1184    // IPOIB_MODE_
1185    Datagram = 0,  // using unreliable datagram QPs
1186    Connected = 1, // using connected QPs
1187}
1188pub const IPOIB_MODE_DATAGRAM: u16 = IpoibMode::Datagram as u16;
1189pub const IPOIB_MODE_CONNECTED: u16 = IpoibMode::Connected as u16;
1190
1191// HSR/PRP section, both uses same interface */
1192// Different redundancy protocols for hsr device */
1193#[repr(u8)]
1194#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1195pub enum HsrProtocol {
1196    // HSR_PROTOCOL_
1197    Hsr,
1198    Prp,
1199    MAX,
1200}
1201pub const HSR_PROTOCOL_HSR: u8 = HsrProtocol::Hsr as u8;
1202pub const HSR_PROTOCOL_PRP: u8 = HsrProtocol::Prp as u8;
1203pub const HSR_PROTOCOL_MAX: u8 = HsrProtocol::MAX as u8;
1204
1205#[repr(u16)]
1206#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
1207#[tbname = "HsrTbl"]
1208pub enum Hsr {
1209    Unspec,
1210    Slave1,
1211    Slave2,
1212    MulticastSpec,   // Last byte of supervision addr
1213    SupervisionAddr, // Supervision frame multicast addr
1214    SeqNr,
1215    Version, // HSR version
1216    _MAX,
1217}
1218
1219// STATS section
1220#[repr(C)]
1221#[derive(Debug, Clone, Copy)]
1222pub struct IfStatsMsg {
1223    pub family: u8,
1224    _pad1: u8,
1225    _pad2: u16,
1226    pub ifindex: u32,
1227    pub filter_mask: u32,
1228}
1229
1230// A stats attribute can be netdev specific or a global stat.
1231// For netdev stats, lets use the prefix IFLA_STATS_LINK_
1232#[repr(u16)]
1233#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
1234#[tbname = "StatsTbl"]
1235pub enum Stats {
1236    // IFLA_STATS_
1237    Unspec, // also used as 64bit pad attribute
1238    Link64,
1239    LinkXstats,
1240    LinkXstatsSlave,
1241    LinkOffloadXstats,
1242    AfSpec,
1243    _MAX,
1244}
1245
1246pub const fn ifla_stats_filter_bit(attr: u16) -> u16 {
1247    1 << (attr - 1)
1248}
1249
1250// These are embedded into IFLA_STATS_LINK_XSTATS:
1251// [IFLA_STATS_LINK_XSTATS]
1252// -> [LINK_XSTATS_TYPE_xxx]
1253//    -> [rtnl link type specific attributes]
1254#[repr(u16)]
1255#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
1256#[tbname = "LinkXstatsTyepTbl"]
1257pub enum LinkXstatsType {
1258    // LINK_XSTATS_
1259    Unspec,
1260    Bridge,
1261    Bond,
1262    _MAX,
1263}
1264
1265// These are stats embedded into IFLA_STATS_LINK_OFFLOAD_XSTATS
1266#[repr(u16)]
1267#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
1268#[tbname = "OffloadXstatsTbl"]
1269pub enum OffloadXstats {
1270    // IFLA_OFFLOAD_XSTATS_
1271    Unspec,
1272    CpuHit, // struct rtnl_link_stats64
1273    _MAX,
1274}
1275
1276// XDP section
1277pub const XDP_FLAGS_UPDATE_IF_NOEXIST: u32 = 1 << 0;
1278pub const XDP_FLAGS_SKB_MODE: u32 = 1 << 1;
1279pub const XDP_FLAGS_DRV_MODE: u32 = 1 << 2;
1280pub const XDP_FLAGS_HW_MODE: u32 = 1 << 3;
1281pub const XDP_FLAGS_MODES: u32 = XDP_FLAGS_SKB_MODE | XDP_FLAGS_DRV_MODE | XDP_FLAGS_HW_MODE;
1282pub const XDP_FLAGS_MASK: u32 = XDP_FLAGS_UPDATE_IF_NOEXIST | XDP_FLAGS_MODES;
1283
1284// These are stored into IFLA_XDP_ATTACHED on dump.
1285#[repr(u8)]
1286#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1287pub enum XdpAttached {
1288    None = 0,
1289    Drv,
1290    Skb,
1291    Hw,
1292    Multi,
1293}
1294pub const XDP_ATTACHED_NONE: u8 = XdpAttached::None as u8;
1295pub const XDP_ATTACHED_DRV: u8 = XdpAttached::Drv as u8;
1296pub const XDP_ATTACHED_SKB: u8 = XdpAttached::Skb as u8;
1297pub const XDP_ATTACHED_HW: u8 = XdpAttached::Hw as u8;
1298pub const XDP_ATTACHED_MULTI: u8 = XdpAttached::Multi as u8;
1299
1300#[repr(u16)]
1301#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
1302#[tbname = "XdpTbl"]
1303pub enum Xdp {
1304    // IFLA_XDP_
1305    Unspec,
1306    Fd,
1307    Attached,
1308    Flags,
1309    ProgId,
1310    DrvProgId,
1311    SkbProgId,
1312    HwProgId,
1313    ExpectedFd,
1314    _MAX,
1315}
1316
1317#[repr(u32)]
1318#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1319pub enum Event {
1320    // IFLA_EVENT_
1321    None,
1322    Reboot,          // internal reset / reboot
1323    Features,        // change in offload features
1324    BondingFailover, // change in active slave
1325    NotifyPeers,     // re-sent grat. arp/ndisc
1326    IgmpResend,      // re-sent IGMP JOIN
1327    BondingOptions,  // change in bonding options
1328}
1329pub const IFLA_EVENT_NONE: u32 = Event::None as u32;
1330pub const IFLA_EVENT_REBOOT: u32 = Event::Reboot as u32;
1331pub const IFLA_EVENT_FEATURES: u32 = Event::Features as u32;
1332pub const IFLA_EVENT_BONDING_FAILOVER: u32 = Event::BondingFailover as u32;
1333pub const IFLA_EVENT_NOTIFY_PEERS: u32 = Event::NotifyPeers as u32;
1334pub const IFLA_EVENT_IGMP_RESEND: u32 = Event::IgmpResend as u32;
1335pub const IFLA_EVENT_BONDING_OPTIONS: u32 = Event::BondingOptions as u32;
1336
1337// tun section
1338#[repr(u16)]
1339#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
1340#[tbname = "TunTbl"]
1341pub enum Tun {
1342    // IFLA_TUN_
1343    Unspec,
1344    Owner,
1345    Group,
1346    Type,
1347    Pi,
1348    VnetHdr,
1349    Persist,
1350    MultiQueue,
1351    NumQueues,
1352    NumDisabledQueues,
1353    _MAX,
1354}
1355
1356// rmnet section
1357pub const RMNET_FLAGS_INGRESS_DEAGGREGATION: u32 = 1 << 0;
1358pub const RMNET_FLAGS_INGRESS_MAP_COMMANDS: u32 = 1 << 1;
1359pub const RMNET_FLAGS_INGRESS_MAP_CKSUMV4: u32 = 1 << 2;
1360pub const RMNET_FLAGS_EGRESS_MAP_CKSUMV4: u32 = 1 << 3;
1361
1362#[repr(u16)]
1363#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
1364#[tbname = "RmnetTbl"]
1365pub enum Rmnet {
1366    // IFLA_RMNET_
1367    Unspec,
1368    MuxId,
1369    Flags,
1370    _MAX,
1371}
1372
1373#[repr(C)]
1374#[derive(Debug, Clone, Copy)]
1375pub struct IflaRmnetFlags {
1376    flags: u32,
1377    mask: u32,
1378}