From 5687cef69a79e7a77c3d3e71b1d117f884d26d61 Mon Sep 17 00:00:00 2001 From: Birol Bilgin Date: Thu, 9 May 2024 13:27:32 +0200 Subject: [PATCH] Add Driver Package This commit introduces the 'driver' package, which contains specific implementations of the LinkDriver interface. It also includes the implementation of the Linux bond driver as LinkDriver and the bond slave driver as LinkSlaveDriver. Signed-off-by: Birol Bilgin --- driver/bond.go | 811 +++++++++++++++++++++++++++++++++++ driver/bond_live_test.go | 216 ++++++++++ driver/driver.go | 19 + driver/driver_test.go | 103 +++++ internal/unix/types_linux.go | 330 ++++++++------ internal/unix/types_other.go | 330 ++++++++------ 6 files changed, 1527 insertions(+), 282 deletions(-) create mode 100644 driver/bond.go create mode 100644 driver/bond_live_test.go create mode 100644 driver/driver.go create mode 100644 driver/driver_test.go diff --git a/driver/bond.go b/driver/bond.go new file mode 100644 index 0000000..f952153 --- /dev/null +++ b/driver/bond.go @@ -0,0 +1,811 @@ +package driver + +import ( + "fmt" + "net" + + "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/internal/unix" + "github.com/mdlayher/netlink" +) + +// BondMode specifies one of the bonding policies. +type BondMode uint8 + +const ( + // Round-robin policy: Transmit packets in sequential order from the first available slave through the last + // This is the default value + BondModeBalanceRR BondMode = iota + + // Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, + // the active slave fails. The bond’s MAC address is externally visible on only one port (network adapter) to + // avoid confusing the switch. + BondModeActiveBackup + + // XOR policy: Transmit based on the selected transmit hash policy. + // The default policy is BOND_XMIT_HASH_POLICY_LAYER2 + // Alternate transmit policies may be selected via the XmitHashPolicy option + BondModeBalanceXOR + + // Broadcast policy: transmits everything on all slave interfaces + BondModeBroadcast + + // IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. + // Utilizes all slaves in the active aggregator according to the 802.3ad specification + BondMode802_3AD + + // Adaptive transmit load balancing: channel bonding that does not require any special switch support + // Outgoing traffic is configured by TlbDynamicLb field + // Incoming traffic is received by the current slave. If the receiving slave fails, + // another slave takes over the MAC address of the failed receiving slave. + BondModeBalanceTLB + + // Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, + // and does not require any special switch support + BondModeBalanceALB + + BondModeUnknown +) + +func (b BondMode) String() string { + switch b { + case BondModeBalanceRR: + return "balance-rr" + case BondModeActiveBackup: + return "active-backup" + case BondModeBalanceXOR: + return "balance-xor" + case BondModeBroadcast: + return "broadcast" + case BondMode802_3AD: + return "802.3ad" + case BondModeBalanceTLB: + return "balance-tld" + case BondModeBalanceALB: + return "balance-alb" + default: + return fmt.Sprintf("unknown BondMode value (%d)", b) + } +} + +// BondArpValidate specifies whether or not ARP probes and replies should be validated in any mode that +// supports arp monitoring, or whether non-ARP traffic should be filtered (disregarded) for link monitoring purposes. +type BondArpValidate uint32 + +const ( + // No validation or filtering is performed + BondArpValidateNone BondArpValidate = iota + + // Validation is performed only for the active slave + BondArpValidateActive + + // Validation is performed only for backup slaves + BondArpValidateBackup + + // Validation is performed for all slaves + BondArpValidateAll + + // Filtering is applied to all slaves. No validation is performed + BondArpValidateFilter + + // Filtering is applied to all slaves, validation is performed only for the active slave + BondArpValidateFilterActive + + // Filtering is applied to all slaves, validation is performed only for backup slaves + BondArpValidateFilterBackup +) + +func (b BondArpValidate) String() string { + switch b { + case BondArpValidateNone: + return "none" + case BondArpValidateActive: + return "active" + case BondArpValidateBackup: + return "backup" + case BondArpValidateAll: + return "all" + case BondArpValidateFilter: + return "filter" + case BondArpValidateFilterActive: + return "filter_active" + case BondArpValidateFilterBackup: + return "filter_backup" + default: + return fmt.Sprintf("unknown BondArpValidate value (%d)", b) + } +} + +// BondArpAllTargets specifies the quantity of arp_ip_targets that must be reachable in order for the ARP monitor +// to consider a slave as being up. This option affects only active-backup mode for slaves with arp_validation enabled. +type BondArpAllTargets uint32 + +const ( + // Consider the slave up only when any of the arp_ip_targets is reachable + BondArpAllTargetsAny BondArpAllTargets = iota + + // Consider the slave up only when all of the arp_ip_targets are reachable + BondArpAllTargetsAll +) + +func (b BondArpAllTargets) String() string { + switch b { + case BondArpAllTargetsAny: + return "any" + case BondArpAllTargetsAll: + return "all" + default: + return fmt.Sprintf("unknown BondArpAllTargets value (%d)", b) + } +} + +// Specifies the reselection policy for the primary slave. This affects how the primary slave is +// chosen to become the active slave when failure of the active slave or recovery of the primary slave occurs. +// This option is designed to prevent flip-flopping between the primary slave and other slaves +type BondPrimaryReselect uint8 + +const ( + // The primary slave becomes the active slave whenever it comes back up, this is the default value + BondPrimaryReselectAlways BondPrimaryReselect = iota + + // The primary slave becomes the active slave when it comes back up, + // if the speed and duplex of the primary slave is better than the speed and duplex of the current active slave + BondPrimaryReselectBetter + + // The primary slave becomes the active slave only if the current active slave fails and the primary slave is up + BondPrimaryReselectFailure +) + +func (b BondPrimaryReselect) String() string { + switch b { + case BondPrimaryReselectAlways: + return "always" + case BondPrimaryReselectBetter: + return "better" + case BondPrimaryReselectFailure: + return "failure" + default: + return fmt.Sprintf("unknown BondPrimaryReselect value (%d)", b) + } +} + +// BondFailOverMac specifies whether active-backup mode should set all slaves to the same MAC address at enslavement +// (the traditional behavior), or, when enabled, perform special handling of the bond’s MAC address +// in accordance with the selected policy. +type BondFailOverMac uint8 + +const ( + // This setting disables fail_over_mac, and causes bonding to set all slaves of an active-backup bond + // to the same MAC address at enslavement time + BondFailOverMacNone BondFailOverMac = iota + + // The “active” fail_over_mac policy indicates that the MAC address of the bond should always be + // the MAC address of the currently active slave. The MAC address of the slaves is not changed; + // instead, the MAC address of the bond changes during a failover + BondFailOverMacActive + + // The “follow” fail_over_mac policy causes the MAC address of the bond to be selected normally + // (normally the MAC address of the first slave added to the bond) + // However, the second and subsequent slaves are not set to this MAC address while they are in a backup role; + // a slave is programmed with the bond’s MAC address at failover time + // (and the formerly active slave receives the newly active slave’s MAC address) + BondFailOverMacFollow +) + +func (b BondFailOverMac) String() string { + switch b { + case BondFailOverMacNone: + return "none" + case BondFailOverMacActive: + return "active" + case BondFailOverMacFollow: + return "follow" + default: + return fmt.Sprintf("unknown BondPrimaryReselect value (%d)", b) + } +} + +// BondXmitHashPolicy specifies the transmit hash policy to use for +// slave selection in balance-xor, 802.3ad, and tlb modes. +type BondXmitHashPolicy uint8 + +const ( + // Uses XOR of hardware MAC addresses and packet type ID field to generate the hash + BondXmitHashPolicyLayer2 BondXmitHashPolicy = iota + + // This policy uses upper layer protocol information, when available, to generate the hash + // This allows for traffic to a particular network peer to span multiple slaves, + // although a single connection will not span multiple slaves + BondXmitHashPolicyLayer3_4 + + // This policy uses a combination of layer2 and layer3 protocol information to generate the hash + // Uses XOR of hardware MAC addresses and IP addresses to generate the hash + BondXmitHashPolicyLayer2_3 + + // This policy uses the same formula as layer2+3 but it relies on skb_flow_dissect to obtain + // the header fields which might result in the use of inner headers if an encapsulation protocol is used + BondXmitHashPolicyEncap2_3 + + // This policy uses the same formula as layer3+4 but it relies on skb_flow_dissect to obtain + // the header fields which might result in the use of inner headers if an encapsulation protocol is used + BondXmitHashPolicyEncap3_4 + + // This policy uses a very rudimentary vlan ID and source mac hash to load-balance traffic per-vlan, + // with failover should one leg fail + BondXmitHashPolicyVlanSrcMAC +) + +func (b BondXmitHashPolicy) String() string { + switch b { + case BondXmitHashPolicyLayer2: + return "layer2" + case BondXmitHashPolicyLayer3_4: + return "layer3+4" + case BondXmitHashPolicyLayer2_3: + return "layer2+3" + case BondXmitHashPolicyEncap2_3: + return "encap2+3" + case BondXmitHashPolicyEncap3_4: + return "encap3+4" + case BondXmitHashPolicyVlanSrcMAC: + return "vlan+srcmac" + default: + return fmt.Sprintf("unknown BondXmitHashPolicy value (%d)", b) + } +} + +// BondAdLacpActive specifies whether to send LACPDU frames periodically. +type BondAdLacpActive uint8 + +const ( + // LACPDU frames acts as “speak when spoken to” + BondAdLacpActiveOff BondAdLacpActive = iota + + // LACPDU frames are sent along the configured links periodically with the rate configured with BondLacpRate + // This is the default value + BondAdLacpActiveOn +) + +func (b BondAdLacpActive) String() string { + switch b { + case BondAdLacpActiveOff: + return "off" + case BondAdLacpActiveOn: + return "on" + default: + return fmt.Sprintf("unknown BondLacpActive value (%d)", b) + } +} + +// Option specifying the rate in which we’ll ask our link partner to transmit LACPDU packets in 802.3ad mode. +type BondLacpRate uint8 + +const ( + // Request partner to transmit LACPDUs every 30 seconds + // This is the default value + BondLacpRateSlow BondLacpRate = iota + + // Request partner to transmit LACPDUs every 1 second + BondLacpRateFast +) + +func (b BondLacpRate) String() string { + switch b { + case BondLacpRateSlow: + return "slow" + case BondLacpRateFast: + return "fast" + default: + return fmt.Sprintf("unknown BondLacpRate value (%d)", b) + } +} + +// BondAdSelect specifies the 802.3ad aggregation selection logic to use. +type BondAdSelect uint8 + +const ( + // The active aggregator is chosen by largest aggregate bandwidth + // Reselection of the active aggregator occurs only when all slaves of the active aggregator + // are down or the active aggregator has no slaves + // This is the default value. + BondAdSelectStable BondAdSelect = iota + + // The active aggregator is chosen by largest aggregate bandwidth. + // Reselection occurs if: + // - A slave is added to or removed from the bond + // - Any slave’s link state changes + // - Any slave’s 802.3ad association state changes + // - The bond’s administrative state changes to up + BondAdSelectBandwidth + + // The active aggregator is chosen by the largest number of ports (slaves) + // Reselection rules are the same with BOND_AD_SELECT_BANDWIDTH + BondAdSelectCount +) + +func (b BondAdSelect) String() string { + switch b { + case BondAdSelectStable: + return "stable" + case BondAdSelectBandwidth: + return "bandwidth" + case BondAdSelectCount: + return "count" + default: + return fmt.Sprintf("unknown BondAdSelect value (%d)", b) + } +} + +// BondAdInfo specifies the 802.3ad aggregation information +type BondAdInfo struct { + AggregatorId uint16 + NumPorts uint16 + ActorKey uint16 + PartnerKey uint16 + PartnerMac net.HardwareAddr +} + +const bondMaxTargets = 16 + +// Bond implements LinkDriver for the bond driver +type Bond struct { + // For more detailed information see https://www.kernel.org/doc/html/latest/networking/bonding.html + + // Specifies the bonding policy. The default is balance-rr (round robin) + Mode BondMode + + // Specifies the new active slave for modes that support it (active-backup, balance-alb and balance-tlb) + ActiveSlave *uint32 + + // Specifies the MII link monitoring frequency in milliseconds + Miimon *uint32 + + // Specifies the time, in milliseconds, to wait before enabling a slave after a link recovery has been detected + UpDelay *uint32 + + // Specifies the time, in milliseconds, to wait before disabling a slave after a link failure has been detected + DownDelay *uint32 + + // Specify the delay, in milliseconds, between each peer notification + PeerNotifyDelay *uint32 + + // Specifies whether or not miimon should use MII or ETHTOOL + UseCarrier *uint8 + + // Specifies the ARP link monitoring frequency in milliseconds + ArpInterval *uint32 + + // Specifies the IP addresses to use as ARP monitoring peers when arp_interval is > 0 + ArpIpTargets []net.IP + + // Specifies the IPv6 addresses to use as IPv6 monitoring peers when arp_interval is > 0 + NsIP6Targets []net.IP + + // Specifies whether or not ARP probes and replies should be validated + ArpValidate *BondArpValidate + + // Specifies the quantity of arp_ip_targets that must be reachable in order for the ARP monitor to consider a slave as being up + ArpAllTargets *BondArpAllTargets + + // A device index specifying which slave is the primary device + Primary *uint32 + + // Specifies the reselection policy for the primary slave + PrimaryReselect *BondPrimaryReselect + + // Specifies whether active-backup mode should set all slaves to the same MAC address at enslavement, when enabled, or perform special handling + FailOverMac *BondFailOverMac + + // Selects the transmit hash policy to use for slave selection + XmitHashPolicy *BondXmitHashPolicy + + // Specifies the number of IGMP membership reports to be issued after a failover event + ResendIgmp *uint32 + + // Specify the number of peer notifications (gratuitous ARPs and unsolicited IPv6 Neighbor Advertisements) to be issued after a failover event + NumPeerNotif *uint8 + + // Specifies that duplicate frames (received on inactive ports) should be dropped (0) or delivered (1) + AllSlavesActive *uint8 + + // Specifies the minimum number of links that must be active before asserting carrier + MinLinks *uint32 + + // Specifies the number of seconds between instances where the bonding driver sends learning packets to each slaves peer switch + LpInterval *uint32 + + // Specify the number of packets to transmit through a slave before moving to the next one + PacketsPerSlave *uint32 + + // Option specifying whether to send LACPDU frames periodically + AdLacpActive *BondAdLacpActive + + // Option specifying the rate in which we’ll ask our link partner to transmit LACPDU packets + AdLacpRate *BondLacpRate + + // Specifies the 802.3ad aggregation selection logic to use + AdSelect *BondAdSelect + + // In an AD system, this specifies the system priority + AdActorSysPrio *uint16 + + // Defines the upper 10 bits of the port key + AdUserPortKey *uint16 + + // In an AD system, this specifies the mac-address for the actor in protocol packet exchanges + AdActorSystem net.HardwareAddr + + // Specifies if dynamic shuffling of flows is enabled in tlb or alb mode + TlbDynamicLb *uint8 + + // Specifies the number of arp_interval monitor checks that must fail in order for an interface to be marked down by the ARP monitor + MissedMax *uint8 + + // Specifies the 802.3ad aggregation information, this is read only value + AdInfo *BondAdInfo +} + +var _ rtnetlink.LinkDriver = &Bond{} + +func (b *Bond) New() rtnetlink.LinkDriver { + return &Bond{} +} + +func (b *Bond) Encode(ae *netlink.AttributeEncoder) error { + if b.Mode < BondModeUnknown { + ae.Uint8(unix.IFLA_BOND_MODE, uint8(b.Mode)) + } + if b.ActiveSlave != nil { + ae.Uint32(unix.IFLA_BOND_ACTIVE_SLAVE, *b.ActiveSlave) + } + if b.Miimon != nil { + ae.Uint32(unix.IFLA_BOND_MIIMON, *b.Miimon) + } + if b.UpDelay != nil { + ae.Uint32(unix.IFLA_BOND_UPDELAY, *b.UpDelay) + } + if b.DownDelay != nil { + ae.Uint32(unix.IFLA_BOND_DOWNDELAY, *b.DownDelay) + } + if b.PeerNotifyDelay != nil { + ae.Uint32(unix.IFLA_BOND_PEER_NOTIF_DELAY, *b.PeerNotifyDelay) + } + if b.UseCarrier != nil { + ae.Uint8(unix.IFLA_BOND_USE_CARRIER, *b.UseCarrier) + } + if b.ArpInterval != nil { + ae.Uint32(unix.IFLA_BOND_ARP_INTERVAL, *b.ArpInterval) + } + if b.ArpIpTargets != nil { + if lb := len(b.ArpIpTargets); lb > bondMaxTargets { + return fmt.Errorf("exceeded max ArpIpTargets %d, %d", bondMaxTargets, lb) + } + ae.Nested(unix.IFLA_BOND_ARP_IP_TARGET, func(nae *netlink.AttributeEncoder) error { + for i := range b.ArpIpTargets { + ip := b.ArpIpTargets[i].To4() + if ip == nil { + return fmt.Errorf("%s is not an ip4 address", ip) + } + nae.Bytes(uint16(i), ip) + } + return nil + }) + } + if b.NsIP6Targets != nil { + if lb := len(b.ArpIpTargets); lb > bondMaxTargets { + return fmt.Errorf("exceeded max NsIP6Targets %d, %d", bondMaxTargets, lb) + } + ae.Nested(unix.IFLA_BOND_NS_IP6_TARGET, func(nae *netlink.AttributeEncoder) error { + for i := range b.NsIP6Targets { + ip := b.NsIP6Targets[i].To16() + if ip == nil { + return fmt.Errorf("%s is not an ip6 address", ip) + } + nae.Bytes(uint16(i), ip) + } + return nil + }) + } + if b.ArpValidate != nil { + ae.Uint32(unix.IFLA_BOND_ARP_VALIDATE, uint32(*b.ArpValidate)) + } + if b.ArpAllTargets != nil { + ae.Uint32(unix.IFLA_BOND_ARP_ALL_TARGETS, uint32(*b.ArpAllTargets)) + } + if b.Primary != nil { + ae.Uint32(unix.IFLA_BOND_PRIMARY, *b.Primary) + } + if b.PrimaryReselect != nil { + ae.Uint8(unix.IFLA_BOND_PRIMARY_RESELECT, uint8(*b.PrimaryReselect)) + } + if b.FailOverMac != nil { + ae.Uint8(unix.IFLA_BOND_FAIL_OVER_MAC, uint8(*b.FailOverMac)) + } + if b.XmitHashPolicy != nil { + ae.Uint8(unix.IFLA_BOND_XMIT_HASH_POLICY, uint8(*b.XmitHashPolicy)) + } + if b.ResendIgmp != nil { + ae.Uint32(unix.IFLA_BOND_RESEND_IGMP, *b.ResendIgmp) + } + if b.NumPeerNotif != nil { + ae.Uint8(unix.IFLA_BOND_NUM_PEER_NOTIF, *b.NumPeerNotif) + } + if b.AllSlavesActive != nil { + ae.Uint8(unix.IFLA_BOND_ALL_SLAVES_ACTIVE, *b.AllSlavesActive) + } + if b.MinLinks != nil { + ae.Uint32(unix.IFLA_BOND_MIN_LINKS, *b.MinLinks) + } + if b.LpInterval != nil { + ae.Uint32(unix.IFLA_BOND_LP_INTERVAL, *b.LpInterval) + } + if b.PacketsPerSlave != nil { + ae.Uint32(unix.IFLA_BOND_PACKETS_PER_SLAVE, *b.PacketsPerSlave) + } + if b.AdLacpActive != nil { + ae.Uint8(unix.IFLA_BOND_AD_LACP_ACTIVE, uint8(*b.AdLacpActive)) + } + if b.AdLacpRate != nil { + ae.Uint8(unix.IFLA_BOND_AD_LACP_RATE, uint8(*b.AdLacpRate)) + } + if b.AdSelect != nil { + ae.Uint8(unix.IFLA_BOND_AD_SELECT, uint8(*b.AdSelect)) + } + if b.AdActorSysPrio != nil { + ae.Uint16(unix.IFLA_BOND_AD_ACTOR_SYS_PRIO, *b.AdActorSysPrio) + } + if b.AdUserPortKey != nil { + ae.Uint16(unix.IFLA_BOND_AD_USER_PORT_KEY, *b.AdUserPortKey) + } + if b.AdActorSystem != nil { + ae.Bytes(unix.IFLA_BOND_AD_ACTOR_SYSTEM, []byte(b.AdActorSystem)) + } + if b.TlbDynamicLb != nil { + ae.Uint8(unix.IFLA_BOND_TLB_DYNAMIC_LB, *b.TlbDynamicLb) + } + if b.MissedMax != nil { + ae.Uint8(unix.IFLA_BOND_MISSED_MAX, *b.MissedMax) + } + + return nil +} + +func (b *Bond) Decode(ad *netlink.AttributeDecoder) error { + for ad.Next() { + switch ad.Type() { + case unix.IFLA_BOND_MODE: + b.Mode = BondMode(ad.Uint8()) + case unix.IFLA_BOND_ACTIVE_SLAVE: + v := ad.Uint32() + b.ActiveSlave = &v + case unix.IFLA_BOND_MIIMON: + v := ad.Uint32() + b.Miimon = &v + case unix.IFLA_BOND_UPDELAY: + v := ad.Uint32() + b.UpDelay = &v + case unix.IFLA_BOND_DOWNDELAY: + v := ad.Uint32() + b.DownDelay = &v + case unix.IFLA_BOND_PEER_NOTIF_DELAY: + v := ad.Uint32() + b.PeerNotifyDelay = &v + case unix.IFLA_BOND_USE_CARRIER: + v := ad.Uint8() + b.UseCarrier = &v + case unix.IFLA_BOND_ARP_INTERVAL: + v := ad.Uint32() + b.ArpInterval = &v + case unix.IFLA_BOND_ARP_IP_TARGET: + ad.Nested(func(nad *netlink.AttributeDecoder) error { + for nad.Next() { + b.ArpIpTargets = append(b.ArpIpTargets, nad.Bytes()) + } + return nil + }) + case unix.IFLA_BOND_NS_IP6_TARGET: + ad.Nested(func(nad *netlink.AttributeDecoder) error { + for nad.Next() { + b.NsIP6Targets = append(b.NsIP6Targets, nad.Bytes()) + } + return nil + }) + case unix.IFLA_BOND_ARP_VALIDATE: + v := BondArpValidate(ad.Uint32()) + b.ArpValidate = &v + case unix.IFLA_BOND_ARP_ALL_TARGETS: + v := BondArpAllTargets(ad.Uint32()) + b.ArpAllTargets = &v + case unix.IFLA_BOND_PRIMARY: + v := ad.Uint32() + b.Primary = &v + case unix.IFLA_BOND_PRIMARY_RESELECT: + v := BondPrimaryReselect(ad.Uint8()) + b.PrimaryReselect = &v + case unix.IFLA_BOND_FAIL_OVER_MAC: + v := BondFailOverMac(ad.Uint8()) + b.FailOverMac = &v + case unix.IFLA_BOND_XMIT_HASH_POLICY: + v := BondXmitHashPolicy(ad.Uint8()) + b.XmitHashPolicy = &v + case unix.IFLA_BOND_RESEND_IGMP: + v := ad.Uint32() + b.ResendIgmp = &v + case unix.IFLA_BOND_NUM_PEER_NOTIF: + v := ad.Uint8() + b.NumPeerNotif = &v + case unix.IFLA_BOND_ALL_SLAVES_ACTIVE: + v := ad.Uint8() + b.AllSlavesActive = &v + case unix.IFLA_BOND_MIN_LINKS: + v := ad.Uint32() + b.MinLinks = &v + case unix.IFLA_BOND_LP_INTERVAL: + v := ad.Uint32() + b.LpInterval = &v + case unix.IFLA_BOND_PACKETS_PER_SLAVE: + v := ad.Uint32() + b.PacketsPerSlave = &v + case unix.IFLA_BOND_AD_LACP_ACTIVE: + v := BondAdLacpActive(ad.Uint8()) + b.AdLacpActive = &v + case unix.IFLA_BOND_AD_LACP_RATE: + v := BondLacpRate(ad.Uint8()) + b.AdLacpRate = &v + case unix.IFLA_BOND_AD_SELECT: + v := BondAdSelect(ad.Uint8()) + b.AdSelect = &v + case unix.IFLA_BOND_AD_ACTOR_SYS_PRIO: + v := ad.Uint16() + b.AdActorSysPrio = &v + case unix.IFLA_BOND_AD_USER_PORT_KEY: + v := ad.Uint16() + b.AdUserPortKey = &v + case unix.IFLA_BOND_AD_ACTOR_SYSTEM: + b.AdActorSystem = ad.Bytes() + case unix.IFLA_BOND_TLB_DYNAMIC_LB: + v := ad.Uint8() + b.TlbDynamicLb = &v + case unix.IFLA_BOND_MISSED_MAX: + v := ad.Uint8() + b.MissedMax = &v + case unix.IFLA_BOND_AD_INFO: + ad.Nested(func(nad *netlink.AttributeDecoder) error { + b.AdInfo = &BondAdInfo{} + for nad.Next() { + switch nad.Type() { + case unix.IFLA_BOND_AD_INFO_AGGREGATOR: + b.AdInfo.AggregatorId = nad.Uint16() + case unix.IFLA_BOND_AD_INFO_NUM_PORTS: + b.AdInfo.NumPorts = nad.Uint16() + case unix.IFLA_BOND_AD_INFO_ACTOR_KEY: + b.AdInfo.ActorKey = nad.Uint16() + case unix.IFLA_BOND_AD_INFO_PARTNER_KEY: + b.AdInfo.PartnerKey = nad.Uint16() + case unix.IFLA_BOND_AD_INFO_PARTNER_MAC: + b.AdInfo.PartnerMac = nad.Bytes() + } + } + return nil + }) + } + } + return nil +} + +func (*Bond) Kind() string { + return "bond" +} + +// BondSlaveState specifies bond slave state +type BondSlaveState uint8 + +const ( + BondStateActive BondSlaveState = iota + BondStateBackup +) + +func (b BondSlaveState) String() string { + switch b { + case BondStateActive: + return "ACTIVE" + case BondStateBackup: + return "BACKUP" + default: + return fmt.Sprintf("unknown BondSlaveState value %d", b) + } +} + +// BondSlaveMiiStatus MII link monitoring frequency status +type BondSlaveMiiStatus uint8 + +const ( + BondLinkUp BondSlaveMiiStatus = iota + BondLinkFail + BondLinkDown + BondLinkBack +) + +func (b BondSlaveMiiStatus) String() string { + switch b { + case BondLinkUp: + return "UP" + case BondLinkFail: + return "GOING_DOWN" + case BondLinkDown: + return "DOWN" + case BondLinkBack: + return "GOING_BACK" + default: + return fmt.Sprintf("unknown BondSlaveMiiStatus value %d", b) + } +} + +// BondSlave implements LinkSlaveDriver interface for bond driver +type BondSlave struct { + State *BondSlaveState + MiiStatus *BondSlaveMiiStatus + LinkFailureCount *uint32 + PermHardwareAddr net.HardwareAddr + QueueId *uint16 + Priority *int32 + AggregatorId *uint16 + AdActorOperPortState *uint8 + AdPartnerOperPortState *uint16 +} + +var _ rtnetlink.LinkSlaveDriver = &BondSlave{} + +func (b *BondSlave) New() rtnetlink.LinkDriver { + return &BondSlave{} +} + +func (b *BondSlave) Slave() {} + +func (b *BondSlave) Encode(ae *netlink.AttributeEncoder) error { + if b.QueueId != nil { + ae.Uint16(unix.IFLA_BOND_SLAVE_QUEUE_ID, *b.QueueId) + } + if b.Priority != nil { + ae.Int32(unix.IFLA_BOND_SLAVE_PRIO, *b.Priority) + } + return nil +} + +func (b *BondSlave) Decode(ad *netlink.AttributeDecoder) error { + for ad.Next() { + switch ad.Type() { + case unix.IFLA_BOND_SLAVE_STATE: + v := BondSlaveState(ad.Uint8()) + b.State = &v + case unix.IFLA_BOND_SLAVE_MII_STATUS: + v := BondSlaveMiiStatus(ad.Uint8()) + b.MiiStatus = &v + case unix.IFLA_BOND_SLAVE_LINK_FAILURE_COUNT: + v := ad.Uint32() + b.LinkFailureCount = &v + case unix.IFLA_BOND_SLAVE_PERM_HWADDR: + b.PermHardwareAddr = net.HardwareAddr(ad.Bytes()) + case unix.IFLA_BOND_SLAVE_QUEUE_ID: + v := ad.Uint16() + b.QueueId = &v + case unix.IFLA_BOND_SLAVE_PRIO: + v := ad.Int32() + b.Priority = &v + case unix.IFLA_BOND_SLAVE_AD_AGGREGATOR_ID: + v := ad.Uint16() + b.AggregatorId = &v + case unix.IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE: + v := ad.Uint8() + b.AdActorOperPortState = &v + case unix.IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE: + v := ad.Uint16() + b.AdPartnerOperPortState = &v + } + } + return nil +} + +func (*BondSlave) Kind() string { + return "bond" +} diff --git a/driver/bond_live_test.go b/driver/bond_live_test.go new file mode 100644 index 0000000..d6b853b --- /dev/null +++ b/driver/bond_live_test.go @@ -0,0 +1,216 @@ +//go:build integration +// +build integration + +package driver + +import ( + "fmt" + "net" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/jsimonetti/rtnetlink" + "github.com/mdlayher/netlink" +) + +func bondT(d rtnetlink.LinkDriver) *Bond { + b := d.(*Bond) + return &Bond{ + Mode: b.Mode, + Miimon: b.Miimon, + ArpInterval: b.ArpInterval, + ArpIpTargets: b.ArpIpTargets, + NsIP6Targets: b.NsIP6Targets, + } +} + +func bondSlaveT(d rtnetlink.LinkDriver) *BondSlave { + b := d.(*BondSlave) + return &BondSlave{ + State: b.State, + MiiStatus: b.MiiStatus, + Priority: b.Priority, + } +} + +func TestBond(t *testing.T) { + // establish a netlink connection + conn, err := rtnetlink.Dial(nil) + if err != nil { + t.Fatalf("failed to establish netlink socket: %v", err) + } + defer conn.Close() + + bns, clean, err := createNS("bns1") + if err != nil { + t.Fatal(err) + } + defer clean() + + // use ns for testing arp ip targets + connNS, err := rtnetlink.Dial(&netlink.Config{NetNS: int(bns.Value())}) + if err != nil { + t.Fatalf("failed to establish netlink socket to ns nkns: %v", err) + } + defer connNS.Close() + + var ( + ssa = BondStateActive + ssb = BondStateBackup + miiup = BondLinkUp + u325 uint32 = 5 + u32100 uint32 = 100 + u32 uint32 + i321 int32 = 1 + i32 int32 + ) + + tests := []struct { + name string + conn *rtnetlink.Conn + driver *Bond + bond *Bond + setSlave bool + dummy []BondSlave + }{ + { + name: "with default mode and miion is set", + conn: conn, + driver: &Bond{ + Miimon: &u32100, + }, + bond: &Bond{ + Mode: BondModeBalanceRR, + Miimon: &u32100, + ArpInterval: &u32, + }, + dummy: []BondSlave{ + { + State: &ssa, + MiiStatus: &miiup, + Priority: &i32, + }, + { + State: &ssa, + MiiStatus: &miiup, + Priority: &i32, + }, + }, + }, + { + name: "with active backup, and arp ip targets list", + conn: connNS, + driver: &Bond{ + Mode: BondModeActiveBackup, + ArpInterval: &u325, + ArpIpTargets: []net.IP{{192, 168, 222, 2}, {192, 168, 222, 3}}, + }, + bond: &Bond{ + Mode: BondModeActiveBackup, + Miimon: &u32, + ArpInterval: &u325, + ArpIpTargets: []net.IP{{192, 168, 222, 2}, {192, 168, 222, 3}}, + }, + setSlave: true, + dummy: []BondSlave{ + { + State: &ssb, + MiiStatus: &miiup, + Priority: &i32, + }, + { + State: &ssa, + MiiStatus: &miiup, + Priority: &i321, + }, + }, + }, + { + name: "with balanced xor, and arp ns ipv6 list", + conn: connNS, + driver: &Bond{ + Mode: BondModeBalanceXOR, + ArpInterval: &u325, + NsIP6Targets: []net.IP{ + {0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, + {0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}, + }, + }, + bond: &Bond{ + Mode: BondModeBalanceXOR, + Miimon: &u32, + ArpInterval: &u325, + NsIP6Targets: []net.IP{ + {0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, + {0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}, + }, + }, + dummy: []BondSlave{ + { + State: &ssa, + MiiStatus: &miiup, + Priority: &i32, + }, + { + State: &ssa, + MiiStatus: &miiup, + Priority: &i32, + }, + }, + }, + } + + for i, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + bondID := 1100 + uint32(i*10) + if err := setupInterface(tt.conn, fmt.Sprintf("b%d", bondID), bondID, 0, tt.driver); err != nil { + t.Fatalf("failed to setup bond interface: %v", err) + } + defer tt.conn.Link.Delete(bondID) + + msg, err := getInterface(tt.conn, bondID) + if err != nil { + t.Fatalf("failed to get primary netkit interface: %v", err) + } + if diff := cmp.Diff(tt.bond, bondT(msg.Attributes.Info.Data)); diff != "" { + t.Error(diff) + } + + slave1ID := 1101 + uint32(i*10) + if err := setupInterface(tt.conn, fmt.Sprintf("d%d", slave1ID), slave1ID, bondID, &rtnetlink.LinkData{Name: "dummy"}); err != nil { + t.Fatalf("failed to setup d%d interface: %v", slave1ID, err) + } + defer tt.conn.Link.Delete(slave1ID) + + slave2ID := 1102 + uint32(i*10) + if err := setupInterface(tt.conn, fmt.Sprintf("d%d", slave2ID), slave2ID, bondID, &rtnetlink.LinkData{Name: "dummy"}); err != nil { + t.Fatalf("failed to setup d1%d interface: %v", slave2ID, err) + } + defer tt.conn.Link.Delete(slave2ID) + + if tt.setSlave { + tt.conn.Link.Set(&rtnetlink.LinkMessage{ + Index: slave2ID, + Attributes: &rtnetlink.LinkAttributes{ + Info: &rtnetlink.LinkInfo{ + SlaveKind: "bond", + SlaveData: &BondSlave{ + Priority: &i321, + }, + }, + }, + }) + } + + for i, id := range []uint32{slave1ID, slave2ID} { + msg, err = getInterface(tt.conn, id) + if err != nil { + t.Fatalf("failed to get peer netkit interface: %v", err) + } + if diff := cmp.Diff(&tt.dummy[i], bondSlaveT(msg.Attributes.Info.SlaveData)); diff != "" { + t.Errorf("slave %d %s", i, diff) + } + } + }) + } +} diff --git a/driver/driver.go b/driver/driver.go new file mode 100644 index 0000000..6f7f2cb --- /dev/null +++ b/driver/driver.go @@ -0,0 +1,19 @@ +package driver + +import ( + "github.com/jsimonetti/rtnetlink" +) + +// init registers predefined drivers with the rtnetlink package. +// +// Currently, registering driver implementations that conflict with existing ones isn't supported. +// Since most users don't need this feature, we'll keep it as is. +// If required, we could consider implementing rtnetlink.UnregisterDriver to address this. +func init() { + for _, drv := range []rtnetlink.LinkDriver{ + &Bond{}, + &BondSlave{}, + } { + _ = rtnetlink.RegisterDriver(drv) + } +} diff --git a/driver/driver_test.go b/driver/driver_test.go new file mode 100644 index 0000000..d918e2c --- /dev/null +++ b/driver/driver_test.go @@ -0,0 +1,103 @@ +//go:build integration +// +build integration + +package driver + +import ( + "bytes" + "fmt" + "os/exec" + "testing" + + "github.com/jsimonetti/rtnetlink" + "golang.org/x/sys/unix" +) + +func getKernelVersion() (kernel, major, minor int, err error) { + var uname unix.Utsname + if err := unix.Uname(&uname); err != nil { + return 0, 0, 0, err + } + + end := bytes.IndexByte(uname.Release[:], 0) + versionStr := uname.Release[:end] + + if count, _ := fmt.Sscanf(string(versionStr), "%d.%d.%d", &kernel, &major, &minor); count < 2 { + err = fmt.Errorf("failed to parse kernel version from: %q", string(versionStr)) + } + return +} + +// kernelMinReq checks if the runtime kernel is sufficient +// for the test +func kernelMinReq(t *testing.T, kernel, major int) { + k, m, _, err := getKernelVersion() + if err != nil { + t.Fatalf("failed to get host kernel version: %v", err) + } + if k < kernel || k == kernel && m < major { + t.Skipf("host kernel (%d.%d) does not meet test's minimum required version: (%d.%d)", + k, m, kernel, major) + } +} + +// setupInterface create a interface for testing +func setupInterface(conn *rtnetlink.Conn, name string, index, master uint32, driver rtnetlink.LinkDriver) error { + attrs := &rtnetlink.LinkAttributes{ + Name: name, + Info: &rtnetlink.LinkInfo{Kind: driver.Kind(), Data: driver}, + } + flag := uint32(unix.IFF_UP) + if master > 0 { + attrs.Master = &master + flag = 0 + } + // construct an interface to test drivers + err := conn.Link.New(&rtnetlink.LinkMessage{ + Family: unix.AF_UNSPEC, + Index: index, + Flags: flag, + Change: flag, + Attributes: attrs, + }) + if err != nil { + conn.Link.Delete(index) + } + return err +} + +func getInterface(conn *rtnetlink.Conn, index uint32) (*rtnetlink.LinkMessage, error) { + interf, err := conn.Link.Get(index) + if err != nil { + conn.Link.Delete(interf.Index) + return nil, err + } + return &interf, err +} + +// creates a network namespace by utilizing ip commandline tool +// returns NetNS and clean function +func createNS(name string) (*rtnetlink.NetNS, func(), error) { + cmdPath, err := exec.LookPath("ip") + if err != nil { + return nil, nil, fmt.Errorf("getting ip command path failed, %w", err) + } + _, err = exec.Command(cmdPath, "netns", "add", name).Output() + if err != nil { + return nil, nil, fmt.Errorf("ip netns add %s, failed: %w", name, err) + } + + ns, err := rtnetlink.NewNetNS(name) + if err != nil { + return nil, nil, fmt.Errorf("reading ns %s, failed: %w", name, err) + } + return ns, func() { + if err := ns.Close(); err != nil { + fmt.Printf("closing ns file failed: %v", err) + } + _, err := exec.Command(cmdPath, "netns", "del", name).Output() + if err != nil { + fmt.Printf("removing netns %s failed, %v", name, err) + } + }, nil +} diff --git a/internal/unix/types_linux.go b/internal/unix/types_linux.go index 806aea0..1555b00 100644 --- a/internal/unix/types_linux.go +++ b/internal/unix/types_linux.go @@ -8,145 +8,193 @@ import ( ) const ( - AF_INET = linux.AF_INET - AF_INET6 = linux.AF_INET6 - AF_UNSPEC = linux.AF_UNSPEC - NETLINK_ROUTE = linux.NETLINK_ROUTE - SizeofIfAddrmsg = linux.SizeofIfAddrmsg - SizeofIfInfomsg = linux.SizeofIfInfomsg - SizeofNdMsg = linux.SizeofNdMsg - SizeofRtMsg = linux.SizeofRtMsg - SizeofRtNexthop = linux.SizeofRtNexthop - RTM_NEWADDR = linux.RTM_NEWADDR - RTM_DELADDR = linux.RTM_DELADDR - RTM_GETADDR = linux.RTM_GETADDR - RTM_NEWLINK = linux.RTM_NEWLINK - RTM_DELLINK = linux.RTM_DELLINK - RTM_GETLINK = linux.RTM_GETLINK - RTM_SETLINK = linux.RTM_SETLINK - RTM_NEWROUTE = linux.RTM_NEWROUTE - RTM_DELROUTE = linux.RTM_DELROUTE - RTM_GETROUTE = linux.RTM_GETROUTE - RTM_NEWNEIGH = linux.RTM_NEWNEIGH - RTM_DELNEIGH = linux.RTM_DELNEIGH - RTM_GETNEIGH = linux.RTM_GETNEIGH - IFA_UNSPEC = linux.IFA_UNSPEC - IFA_ADDRESS = linux.IFA_ADDRESS - IFA_LOCAL = linux.IFA_LOCAL - IFA_LABEL = linux.IFA_LABEL - IFA_BROADCAST = linux.IFA_BROADCAST - IFA_ANYCAST = linux.IFA_ANYCAST - IFA_CACHEINFO = linux.IFA_CACHEINFO - IFA_MULTICAST = linux.IFA_MULTICAST - IFA_FLAGS = linux.IFA_FLAGS - IFF_UP = linux.IFF_UP - IFF_BROADCAST = linux.IFF_BROADCAST - IFF_LOOPBACK = linux.IFF_LOOPBACK - IFF_POINTOPOINT = linux.IFF_POINTOPOINT - IFF_MULTICAST = linux.IFF_MULTICAST - IFLA_UNSPEC = linux.IFLA_UNSPEC - IFLA_ADDRESS = linux.IFLA_ADDRESS - IFLA_BROADCAST = linux.IFLA_BROADCAST - IFLA_IFNAME = linux.IFLA_IFNAME - IFLA_MTU = linux.IFLA_MTU - IFLA_LINK = linux.IFLA_LINK - IFLA_QDISC = linux.IFLA_QDISC - IFLA_OPERSTATE = linux.IFLA_OPERSTATE - IFLA_STATS = linux.IFLA_STATS - IFLA_STATS64 = linux.IFLA_STATS64 - IFLA_TXQLEN = linux.IFLA_TXQLEN - IFLA_GROUP = linux.IFLA_GROUP - IFLA_LINKINFO = linux.IFLA_LINKINFO - IFLA_LINKMODE = linux.IFLA_LINKMODE - IFLA_IFALIAS = linux.IFLA_IFALIAS - IFLA_MASTER = linux.IFLA_MASTER - IFLA_CARRIER = linux.IFLA_CARRIER - IFLA_CARRIER_CHANGES = linux.IFLA_CARRIER_CHANGES - IFLA_CARRIER_UP_COUNT = linux.IFLA_CARRIER_UP_COUNT - IFLA_CARRIER_DOWN_COUNT = linux.IFLA_CARRIER_DOWN_COUNT - IFLA_PHYS_PORT_ID = linux.IFLA_PHYS_PORT_ID - IFLA_PHYS_SWITCH_ID = linux.IFLA_PHYS_SWITCH_ID - IFLA_PHYS_PORT_NAME = linux.IFLA_PHYS_PORT_NAME - IFLA_INFO_KIND = linux.IFLA_INFO_KIND - IFLA_INFO_SLAVE_KIND = linux.IFLA_INFO_SLAVE_KIND - IFLA_INFO_DATA = linux.IFLA_INFO_DATA - IFLA_INFO_SLAVE_DATA = linux.IFLA_INFO_SLAVE_DATA - IFLA_NET_NS_PID = linux.IFLA_NET_NS_PID - IFLA_NET_NS_FD = linux.IFLA_NET_NS_FD - IFLA_XDP = linux.IFLA_XDP - IFLA_XDP_FD = linux.IFLA_XDP_FD - IFLA_XDP_ATTACHED = linux.IFLA_XDP_ATTACHED - IFLA_XDP_FLAGS = linux.IFLA_XDP_FLAGS - IFLA_XDP_PROG_ID = linux.IFLA_XDP_PROG_ID - IFLA_XDP_EXPECTED_FD = linux.IFLA_XDP_EXPECTED_FD - XDP_FLAGS_DRV_MODE = linux.XDP_FLAGS_DRV_MODE - XDP_FLAGS_SKB_MODE = linux.XDP_FLAGS_SKB_MODE - XDP_FLAGS_HW_MODE = linux.XDP_FLAGS_HW_MODE - XDP_FLAGS_MODES = linux.XDP_FLAGS_MODES - XDP_FLAGS_MASK = linux.XDP_FLAGS_MASK - XDP_FLAGS_REPLACE = linux.XDP_FLAGS_REPLACE - XDP_FLAGS_UPDATE_IF_NOEXIST = linux.XDP_FLAGS_UPDATE_IF_NOEXIST - LWTUNNEL_ENCAP_MPLS = linux.LWTUNNEL_ENCAP_MPLS - MPLS_IPTUNNEL_DST = linux.MPLS_IPTUNNEL_DST - MPLS_IPTUNNEL_TTL = linux.MPLS_IPTUNNEL_TTL - NDA_UNSPEC = linux.NDA_UNSPEC - NDA_DST = linux.NDA_DST - NDA_LLADDR = linux.NDA_LLADDR - NDA_CACHEINFO = linux.NDA_CACHEINFO - NDA_IFINDEX = linux.NDA_IFINDEX - RTA_UNSPEC = linux.RTA_UNSPEC - RTA_DST = linux.RTA_DST - RTA_ENCAP = linux.RTA_ENCAP - RTA_ENCAP_TYPE = linux.RTA_ENCAP_TYPE - RTA_PREFSRC = linux.RTA_PREFSRC - RTA_GATEWAY = linux.RTA_GATEWAY - RTA_OIF = linux.RTA_OIF - RTA_PRIORITY = linux.RTA_PRIORITY - RTA_TABLE = linux.RTA_TABLE - RTA_MARK = linux.RTA_MARK - RTA_EXPIRES = linux.RTA_EXPIRES - RTA_METRICS = linux.RTA_METRICS - RTA_MULTIPATH = linux.RTA_MULTIPATH - RTA_PREF = linux.RTA_PREF - RTAX_ADVMSS = linux.RTAX_ADVMSS - RTAX_FEATURES = linux.RTAX_FEATURES - RTAX_INITCWND = linux.RTAX_INITCWND - RTAX_INITRWND = linux.RTAX_INITRWND - RTAX_MTU = linux.RTAX_MTU - NTF_PROXY = linux.NTF_PROXY - RTN_UNICAST = linux.RTN_UNICAST - RT_TABLE_MAIN = linux.RT_TABLE_MAIN - RTPROT_BOOT = linux.RTPROT_BOOT - RTPROT_STATIC = linux.RTPROT_STATIC - RT_SCOPE_UNIVERSE = linux.RT_SCOPE_UNIVERSE - RT_SCOPE_HOST = linux.RT_SCOPE_HOST - RT_SCOPE_LINK = linux.RT_SCOPE_LINK - RTM_NEWRULE = linux.RTM_NEWRULE - RTM_GETRULE = linux.RTM_GETRULE - RTM_DELRULE = linux.RTM_DELRULE - FRA_UNSPEC = linux.FRA_UNSPEC - FRA_DST = linux.FRA_DST - FRA_SRC = linux.FRA_SRC - FRA_IIFNAME = linux.FRA_IIFNAME - FRA_GOTO = linux.FRA_GOTO - FRA_UNUSED2 = linux.FRA_UNUSED2 - FRA_PRIORITY = linux.FRA_PRIORITY - FRA_UNUSED3 = linux.FRA_UNUSED3 - FRA_UNUSED4 = linux.FRA_UNUSED4 - FRA_UNUSED5 = linux.FRA_UNUSED5 - FRA_FWMARK = linux.FRA_FWMARK - FRA_FLOW = linux.FRA_FLOW - FRA_TUN_ID = linux.FRA_TUN_ID - FRA_SUPPRESS_IFGROUP = linux.FRA_SUPPRESS_IFGROUP - FRA_SUPPRESS_PREFIXLEN = linux.FRA_SUPPRESS_PREFIXLEN - FRA_TABLE = linux.FRA_TABLE - FRA_FWMASK = linux.FRA_FWMASK - FRA_OIFNAME = linux.FRA_OIFNAME - FRA_PAD = linux.FRA_PAD - FRA_L3MDEV = linux.FRA_L3MDEV - FRA_UID_RANGE = linux.FRA_UID_RANGE - FRA_PROTOCOL = linux.FRA_PROTOCOL - FRA_IP_PROTO = linux.FRA_IP_PROTO - FRA_SPORT_RANGE = linux.FRA_SPORT_RANGE - FRA_DPORT_RANGE = linux.FRA_DPORT_RANGE + AF_INET = linux.AF_INET + AF_INET6 = linux.AF_INET6 + AF_UNSPEC = linux.AF_UNSPEC + NETLINK_ROUTE = linux.NETLINK_ROUTE + SizeofIfAddrmsg = linux.SizeofIfAddrmsg + SizeofIfInfomsg = linux.SizeofIfInfomsg + SizeofNdMsg = linux.SizeofNdMsg + SizeofRtMsg = linux.SizeofRtMsg + SizeofRtNexthop = linux.SizeofRtNexthop + RTM_NEWADDR = linux.RTM_NEWADDR + RTM_DELADDR = linux.RTM_DELADDR + RTM_GETADDR = linux.RTM_GETADDR + RTM_NEWLINK = linux.RTM_NEWLINK + RTM_DELLINK = linux.RTM_DELLINK + RTM_GETLINK = linux.RTM_GETLINK + RTM_SETLINK = linux.RTM_SETLINK + RTM_NEWROUTE = linux.RTM_NEWROUTE + RTM_DELROUTE = linux.RTM_DELROUTE + RTM_GETROUTE = linux.RTM_GETROUTE + RTM_NEWNEIGH = linux.RTM_NEWNEIGH + RTM_DELNEIGH = linux.RTM_DELNEIGH + RTM_GETNEIGH = linux.RTM_GETNEIGH + IFA_UNSPEC = linux.IFA_UNSPEC + IFA_ADDRESS = linux.IFA_ADDRESS + IFA_LOCAL = linux.IFA_LOCAL + IFA_LABEL = linux.IFA_LABEL + IFA_BROADCAST = linux.IFA_BROADCAST + IFA_ANYCAST = linux.IFA_ANYCAST + IFA_CACHEINFO = linux.IFA_CACHEINFO + IFA_MULTICAST = linux.IFA_MULTICAST + IFA_FLAGS = linux.IFA_FLAGS + IFF_UP = linux.IFF_UP + IFF_BROADCAST = linux.IFF_BROADCAST + IFF_LOOPBACK = linux.IFF_LOOPBACK + IFF_POINTOPOINT = linux.IFF_POINTOPOINT + IFF_MULTICAST = linux.IFF_MULTICAST + IFLA_UNSPEC = linux.IFLA_UNSPEC + IFLA_ADDRESS = linux.IFLA_ADDRESS + IFLA_BOND_UNSPEC = linux.IFLA_BOND_UNSPEC + IFLA_BOND_MODE = linux.IFLA_BOND_MODE + IFLA_BOND_ACTIVE_SLAVE = linux.IFLA_BOND_ACTIVE_SLAVE + IFLA_BOND_MIIMON = linux.IFLA_BOND_MIIMON + IFLA_BOND_UPDELAY = linux.IFLA_BOND_UPDELAY + IFLA_BOND_DOWNDELAY = linux.IFLA_BOND_DOWNDELAY + IFLA_BOND_USE_CARRIER = linux.IFLA_BOND_USE_CARRIER + IFLA_BOND_ARP_INTERVAL = linux.IFLA_BOND_ARP_INTERVAL + IFLA_BOND_ARP_IP_TARGET = linux.IFLA_BOND_ARP_IP_TARGET + IFLA_BOND_ARP_VALIDATE = linux.IFLA_BOND_ARP_VALIDATE + IFLA_BOND_ARP_ALL_TARGETS = linux.IFLA_BOND_ARP_ALL_TARGETS + IFLA_BOND_PRIMARY = linux.IFLA_BOND_PRIMARY + IFLA_BOND_PRIMARY_RESELECT = linux.IFLA_BOND_PRIMARY_RESELECT + IFLA_BOND_FAIL_OVER_MAC = linux.IFLA_BOND_FAIL_OVER_MAC + IFLA_BOND_XMIT_HASH_POLICY = linux.IFLA_BOND_XMIT_HASH_POLICY + IFLA_BOND_RESEND_IGMP = linux.IFLA_BOND_RESEND_IGMP + IFLA_BOND_NUM_PEER_NOTIF = linux.IFLA_BOND_NUM_PEER_NOTIF + IFLA_BOND_ALL_SLAVES_ACTIVE = linux.IFLA_BOND_ALL_SLAVES_ACTIVE + IFLA_BOND_MIN_LINKS = linux.IFLA_BOND_MIN_LINKS + IFLA_BOND_LP_INTERVAL = linux.IFLA_BOND_LP_INTERVAL + IFLA_BOND_PACKETS_PER_SLAVE = linux.IFLA_BOND_PACKETS_PER_SLAVE + IFLA_BOND_AD_LACP_RATE = linux.IFLA_BOND_AD_LACP_RATE + IFLA_BOND_AD_SELECT = linux.IFLA_BOND_AD_SELECT + IFLA_BOND_AD_INFO = linux.IFLA_BOND_AD_INFO + IFLA_BOND_AD_ACTOR_SYS_PRIO = linux.IFLA_BOND_AD_ACTOR_SYS_PRIO + IFLA_BOND_AD_USER_PORT_KEY = linux.IFLA_BOND_AD_USER_PORT_KEY + IFLA_BOND_AD_ACTOR_SYSTEM = linux.IFLA_BOND_AD_ACTOR_SYSTEM + IFLA_BOND_TLB_DYNAMIC_LB = linux.IFLA_BOND_TLB_DYNAMIC_LB + IFLA_BOND_PEER_NOTIF_DELAY = linux.IFLA_BOND_PEER_NOTIF_DELAY + IFLA_BOND_AD_LACP_ACTIVE = linux.IFLA_BOND_AD_LACP_ACTIVE + IFLA_BOND_MISSED_MAX = linux.IFLA_BOND_MISSED_MAX + IFLA_BOND_NS_IP6_TARGET = linux.IFLA_BOND_NS_IP6_TARGET + IFLA_BOND_AD_INFO_UNSPEC = linux.IFLA_BOND_AD_INFO_UNSPEC + IFLA_BOND_AD_INFO_AGGREGATOR = linux.IFLA_BOND_AD_INFO_AGGREGATOR + IFLA_BOND_AD_INFO_NUM_PORTS = linux.IFLA_BOND_AD_INFO_NUM_PORTS + IFLA_BOND_AD_INFO_ACTOR_KEY = linux.IFLA_BOND_AD_INFO_ACTOR_KEY + IFLA_BOND_AD_INFO_PARTNER_KEY = linux.IFLA_BOND_AD_INFO_PARTNER_KEY + IFLA_BOND_AD_INFO_PARTNER_MAC = linux.IFLA_BOND_AD_INFO_PARTNER_MAC + IFLA_BOND_SLAVE_UNSPEC = linux.IFLA_BOND_SLAVE_UNSPEC + IFLA_BOND_SLAVE_STATE = linux.IFLA_BOND_SLAVE_STATE + IFLA_BOND_SLAVE_MII_STATUS = linux.IFLA_BOND_SLAVE_MII_STATUS + IFLA_BOND_SLAVE_LINK_FAILURE_COUNT = linux.IFLA_BOND_SLAVE_LINK_FAILURE_COUNT + IFLA_BOND_SLAVE_PERM_HWADDR = linux.IFLA_BOND_SLAVE_PERM_HWADDR + IFLA_BOND_SLAVE_QUEUE_ID = linux.IFLA_BOND_SLAVE_QUEUE_ID + IFLA_BOND_SLAVE_AD_AGGREGATOR_ID = linux.IFLA_BOND_SLAVE_AD_AGGREGATOR_ID + IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE = linux.IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE + IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE = linux.IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE + IFLA_BOND_SLAVE_PRIO = linux.IFLA_BOND_SLAVE_PRIO + IFLA_BROADCAST = linux.IFLA_BROADCAST + IFLA_IFNAME = linux.IFLA_IFNAME + IFLA_MTU = linux.IFLA_MTU + IFLA_LINK = linux.IFLA_LINK + IFLA_QDISC = linux.IFLA_QDISC + IFLA_OPERSTATE = linux.IFLA_OPERSTATE + IFLA_STATS = linux.IFLA_STATS + IFLA_STATS64 = linux.IFLA_STATS64 + IFLA_TXQLEN = linux.IFLA_TXQLEN + IFLA_GROUP = linux.IFLA_GROUP + IFLA_LINKINFO = linux.IFLA_LINKINFO + IFLA_LINKMODE = linux.IFLA_LINKMODE + IFLA_IFALIAS = linux.IFLA_IFALIAS + IFLA_MASTER = linux.IFLA_MASTER + IFLA_CARRIER = linux.IFLA_CARRIER + IFLA_CARRIER_CHANGES = linux.IFLA_CARRIER_CHANGES + IFLA_CARRIER_UP_COUNT = linux.IFLA_CARRIER_UP_COUNT + IFLA_CARRIER_DOWN_COUNT = linux.IFLA_CARRIER_DOWN_COUNT + IFLA_PHYS_PORT_ID = linux.IFLA_PHYS_PORT_ID + IFLA_PHYS_SWITCH_ID = linux.IFLA_PHYS_SWITCH_ID + IFLA_PHYS_PORT_NAME = linux.IFLA_PHYS_PORT_NAME + IFLA_INFO_KIND = linux.IFLA_INFO_KIND + IFLA_INFO_SLAVE_KIND = linux.IFLA_INFO_SLAVE_KIND + IFLA_INFO_DATA = linux.IFLA_INFO_DATA + IFLA_INFO_SLAVE_DATA = linux.IFLA_INFO_SLAVE_DATA + IFLA_NET_NS_PID = linux.IFLA_NET_NS_PID + IFLA_NET_NS_FD = linux.IFLA_NET_NS_FD + IFLA_XDP = linux.IFLA_XDP + IFLA_XDP_FD = linux.IFLA_XDP_FD + IFLA_XDP_ATTACHED = linux.IFLA_XDP_ATTACHED + IFLA_XDP_FLAGS = linux.IFLA_XDP_FLAGS + IFLA_XDP_PROG_ID = linux.IFLA_XDP_PROG_ID + IFLA_XDP_EXPECTED_FD = linux.IFLA_XDP_EXPECTED_FD + XDP_FLAGS_DRV_MODE = linux.XDP_FLAGS_DRV_MODE + XDP_FLAGS_SKB_MODE = linux.XDP_FLAGS_SKB_MODE + XDP_FLAGS_HW_MODE = linux.XDP_FLAGS_HW_MODE + XDP_FLAGS_MODES = linux.XDP_FLAGS_MODES + XDP_FLAGS_MASK = linux.XDP_FLAGS_MASK + XDP_FLAGS_REPLACE = linux.XDP_FLAGS_REPLACE + XDP_FLAGS_UPDATE_IF_NOEXIST = linux.XDP_FLAGS_UPDATE_IF_NOEXIST + LWTUNNEL_ENCAP_MPLS = linux.LWTUNNEL_ENCAP_MPLS + MPLS_IPTUNNEL_DST = linux.MPLS_IPTUNNEL_DST + MPLS_IPTUNNEL_TTL = linux.MPLS_IPTUNNEL_TTL + NDA_UNSPEC = linux.NDA_UNSPEC + NDA_DST = linux.NDA_DST + NDA_LLADDR = linux.NDA_LLADDR + NDA_CACHEINFO = linux.NDA_CACHEINFO + NDA_IFINDEX = linux.NDA_IFINDEX + RTA_UNSPEC = linux.RTA_UNSPEC + RTA_DST = linux.RTA_DST + RTA_ENCAP = linux.RTA_ENCAP + RTA_ENCAP_TYPE = linux.RTA_ENCAP_TYPE + RTA_PREFSRC = linux.RTA_PREFSRC + RTA_GATEWAY = linux.RTA_GATEWAY + RTA_OIF = linux.RTA_OIF + RTA_PRIORITY = linux.RTA_PRIORITY + RTA_TABLE = linux.RTA_TABLE + RTA_MARK = linux.RTA_MARK + RTA_EXPIRES = linux.RTA_EXPIRES + RTA_METRICS = linux.RTA_METRICS + RTA_MULTIPATH = linux.RTA_MULTIPATH + RTA_PREF = linux.RTA_PREF + RTAX_ADVMSS = linux.RTAX_ADVMSS + RTAX_FEATURES = linux.RTAX_FEATURES + RTAX_INITCWND = linux.RTAX_INITCWND + RTAX_INITRWND = linux.RTAX_INITRWND + RTAX_MTU = linux.RTAX_MTU + NTF_PROXY = linux.NTF_PROXY + RTN_UNICAST = linux.RTN_UNICAST + RT_TABLE_MAIN = linux.RT_TABLE_MAIN + RTPROT_BOOT = linux.RTPROT_BOOT + RTPROT_STATIC = linux.RTPROT_STATIC + RT_SCOPE_UNIVERSE = linux.RT_SCOPE_UNIVERSE + RT_SCOPE_HOST = linux.RT_SCOPE_HOST + RT_SCOPE_LINK = linux.RT_SCOPE_LINK + RTM_NEWRULE = linux.RTM_NEWRULE + RTM_GETRULE = linux.RTM_GETRULE + RTM_DELRULE = linux.RTM_DELRULE + FRA_UNSPEC = linux.FRA_UNSPEC + FRA_DST = linux.FRA_DST + FRA_SRC = linux.FRA_SRC + FRA_IIFNAME = linux.FRA_IIFNAME + FRA_GOTO = linux.FRA_GOTO + FRA_UNUSED2 = linux.FRA_UNUSED2 + FRA_PRIORITY = linux.FRA_PRIORITY + FRA_UNUSED3 = linux.FRA_UNUSED3 + FRA_UNUSED4 = linux.FRA_UNUSED4 + FRA_UNUSED5 = linux.FRA_UNUSED5 + FRA_FWMARK = linux.FRA_FWMARK + FRA_FLOW = linux.FRA_FLOW + FRA_TUN_ID = linux.FRA_TUN_ID + FRA_SUPPRESS_IFGROUP = linux.FRA_SUPPRESS_IFGROUP + FRA_SUPPRESS_PREFIXLEN = linux.FRA_SUPPRESS_PREFIXLEN + FRA_TABLE = linux.FRA_TABLE + FRA_FWMASK = linux.FRA_FWMASK + FRA_OIFNAME = linux.FRA_OIFNAME + FRA_PAD = linux.FRA_PAD + FRA_L3MDEV = linux.FRA_L3MDEV + FRA_UID_RANGE = linux.FRA_UID_RANGE + FRA_PROTOCOL = linux.FRA_PROTOCOL + FRA_IP_PROTO = linux.FRA_IP_PROTO + FRA_SPORT_RANGE = linux.FRA_SPORT_RANGE + FRA_DPORT_RANGE = linux.FRA_DPORT_RANGE ) diff --git a/internal/unix/types_other.go b/internal/unix/types_other.go index ed3d876..de794c2 100644 --- a/internal/unix/types_other.go +++ b/internal/unix/types_other.go @@ -4,145 +4,193 @@ package unix const ( - AF_INET = 0x2 - AF_INET6 = 0xa - AF_UNSPEC = 0x0 - NETLINK_ROUTE = 0x0 - SizeofIfAddrmsg = 0x8 - SizeofIfInfomsg = 0x10 - SizeofNdMsg = 0xc - SizeofRtMsg = 0xc - SizeofRtNexthop = 0x8 - RTM_NEWADDR = 0x14 - RTM_DELADDR = 0x15 - RTM_GETADDR = 0x16 - RTM_NEWLINK = 0x10 - RTM_DELLINK = 0x11 - RTM_GETLINK = 0x12 - RTM_SETLINK = 0x13 - RTM_NEWROUTE = 0x18 - RTM_DELROUTE = 0x19 - RTM_GETROUTE = 0x1a - RTM_NEWNEIGH = 0x1c - RTM_DELNEIGH = 0x1d - RTM_GETNEIGH = 0x1e - IFA_UNSPEC = 0x0 - IFA_ADDRESS = 0x1 - IFA_LOCAL = 0x2 - IFA_LABEL = 0x3 - IFA_BROADCAST = 0x4 - IFA_ANYCAST = 0x5 - IFA_CACHEINFO = 0x6 - IFA_MULTICAST = 0x7 - IFA_FLAGS = 0x8 - IFF_UP = 0x1 - IFF_BROADCAST = 0x2 - IFF_LOOPBACK = 0x8 - IFF_POINTOPOINT = 0x10 - IFF_MULTICAST = 0x1000 - IFLA_UNSPEC = 0x0 - IFLA_ADDRESS = 0x1 - IFLA_BROADCAST = 0x2 - IFLA_IFNAME = 0x3 - IFLA_MTU = 0x4 - IFLA_LINK = 0x5 - IFLA_QDISC = 0x6 - IFLA_OPERSTATE = 0x10 - IFLA_STATS = 0x7 - IFLA_STATS64 = 0x17 - IFLA_TXQLEN = 0xd - IFLA_GROUP = 0x1b - IFLA_LINKINFO = 0x12 - IFLA_LINKMODE = 0x11 - IFLA_IFALIAS = 0x14 - IFLA_MASTER = 0xa - IFLA_CARRIER = 0x21 - IFLA_CARRIER_CHANGES = 0x23 - IFLA_CARRIER_UP_COUNT = 0x2f - IFLA_CARRIER_DOWN_COUNT = 0x30 - IFLA_PHYS_PORT_ID = 0x22 - IFLA_PHYS_SWITCH_ID = 0x24 - IFLA_PHYS_PORT_NAME = 0x26 - IFLA_INFO_KIND = 0x1 - IFLA_INFO_SLAVE_KIND = 0x4 - IFLA_INFO_DATA = 0x2 - IFLA_INFO_SLAVE_DATA = 0x5 - IFLA_NET_NS_PID = 0x13 - IFLA_NET_NS_FD = 0x1c - IFLA_XDP = 0x2b - IFLA_XDP_FD = 0x1 - IFLA_XDP_ATTACHED = 0x2 - IFLA_XDP_FLAGS = 0x3 - IFLA_XDP_PROG_ID = 0x4 - IFLA_XDP_EXPECTED_FD = 0x8 - XDP_FLAGS_DRV_MODE = 0x4 - XDP_FLAGS_SKB_MODE = 0x2 - XDP_FLAGS_HW_MODE = 0x8 - XDP_FLAGS_MODES = 0xe - XDP_FLAGS_MASK = 0x1f - XDP_FLAGS_REPLACE = 0x10 - XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 - LWTUNNEL_ENCAP_MPLS = 0x1 - MPLS_IPTUNNEL_DST = 0x1 - MPLS_IPTUNNEL_TTL = 0x2 - NDA_UNSPEC = 0x0 - NDA_DST = 0x1 - NDA_LLADDR = 0x2 - NDA_CACHEINFO = 0x3 - NDA_IFINDEX = 0x8 - RTA_UNSPEC = 0x0 - RTA_DST = 0x1 - RTA_ENCAP = 0x16 - RTA_ENCAP_TYPE = 0x15 - RTA_PREFSRC = 0x7 - RTA_GATEWAY = 0x5 - RTA_OIF = 0x4 - RTA_PRIORITY = 0x6 - RTA_TABLE = 0xf - RTA_MARK = 0x10 - RTA_EXPIRES = 0x17 - RTA_METRICS = 0x8 - RTA_MULTIPATH = 0x9 - RTA_PREF = 0x14 - RTAX_ADVMSS = 0x8 - RTAX_FEATURES = 0xc - RTAX_INITCWND = 0xb - RTAX_INITRWND = 0xe - RTAX_MTU = 0x2 - NTF_PROXY = 0x8 - RTN_UNICAST = 0x1 - RT_TABLE_MAIN = 0xfe - RTPROT_BOOT = 0x3 - RTPROT_STATIC = 0x4 - RT_SCOPE_UNIVERSE = 0x0 - RT_SCOPE_HOST = 0xfe - RT_SCOPE_LINK = 0xfd - RTM_NEWRULE = 0x20 - RTM_GETRULE = 0x22 - RTM_DELRULE = 0x21 - FRA_UNSPEC = 0x0 - FRA_DST = 0x1 - FRA_SRC = 0x2 - FRA_IIFNAME = 0x3 - FRA_GOTO = 0x4 - FRA_UNUSED2 = 0x5 - FRA_PRIORITY = 0x6 - FRA_UNUSED3 = 0x7 - FRA_UNUSED4 = 0x8 - FRA_UNUSED5 = 0x9 - FRA_FWMARK = 0xa - FRA_FLOW = 0xb - FRA_TUN_ID = 0xc - FRA_SUPPRESS_IFGROUP = 0xd - FRA_SUPPRESS_PREFIXLEN = 0xe - FRA_TABLE = 0xf - FRA_FWMASK = 0x10 - FRA_OIFNAME = 0x11 - FRA_PAD = 0x12 - FRA_L3MDEV = 0x13 - FRA_UID_RANGE = 0x14 - FRA_PROTOCOL = 0x15 - FRA_IP_PROTO = 0x16 - FRA_SPORT_RANGE = 0x17 - FRA_DPORT_RANGE = 0x18 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_UNSPEC = 0x0 + NETLINK_ROUTE = 0x0 + SizeofIfAddrmsg = 0x8 + SizeofIfInfomsg = 0x10 + SizeofNdMsg = 0xc + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 + RTM_NEWADDR = 0x14 + RTM_DELADDR = 0x15 + RTM_GETADDR = 0x16 + RTM_NEWLINK = 0x10 + RTM_DELLINK = 0x11 + RTM_GETLINK = 0x12 + RTM_SETLINK = 0x13 + RTM_NEWROUTE = 0x18 + RTM_DELROUTE = 0x19 + RTM_GETROUTE = 0x1a + RTM_NEWNEIGH = 0x1c + RTM_DELNEIGH = 0x1d + RTM_GETNEIGH = 0x1e + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFA_FLAGS = 0x8 + IFF_UP = 0x1 + IFF_BROADCAST = 0x2 + IFF_LOOPBACK = 0x8 + IFF_POINTOPOINT = 0x10 + IFF_MULTICAST = 0x1000 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BOND_UNSPEC = 0x0 + IFLA_BOND_MODE = 0x1 + IFLA_BOND_ACTIVE_SLAVE = 0x2 + IFLA_BOND_MIIMON = 0x3 + IFLA_BOND_UPDELAY = 0x4 + IFLA_BOND_DOWNDELAY = 0x5 + IFLA_BOND_USE_CARRIER = 0x6 + IFLA_BOND_ARP_INTERVAL = 0x7 + IFLA_BOND_ARP_IP_TARGET = 0x8 + IFLA_BOND_ARP_VALIDATE = 0x9 + IFLA_BOND_ARP_ALL_TARGETS = 0xa + IFLA_BOND_PRIMARY = 0xb + IFLA_BOND_PRIMARY_RESELECT = 0xc + IFLA_BOND_FAIL_OVER_MAC = 0xd + IFLA_BOND_XMIT_HASH_POLICY = 0xe + IFLA_BOND_RESEND_IGMP = 0xf + IFLA_BOND_NUM_PEER_NOTIF = 0x10 + IFLA_BOND_ALL_SLAVES_ACTIVE = 0x11 + IFLA_BOND_MIN_LINKS = 0x12 + IFLA_BOND_LP_INTERVAL = 0x13 + IFLA_BOND_PACKETS_PER_SLAVE = 0x14 + IFLA_BOND_AD_LACP_RATE = 0x15 + IFLA_BOND_AD_SELECT = 0x16 + IFLA_BOND_AD_INFO = 0x17 + IFLA_BOND_AD_ACTOR_SYS_PRIO = 0x18 + IFLA_BOND_AD_USER_PORT_KEY = 0x19 + IFLA_BOND_AD_ACTOR_SYSTEM = 0x1a + IFLA_BOND_TLB_DYNAMIC_LB = 0x1b + IFLA_BOND_PEER_NOTIF_DELAY = 0x1c + IFLA_BOND_AD_LACP_ACTIVE = 0x1d + IFLA_BOND_MISSED_MAX = 0x1e + IFLA_BOND_NS_IP6_TARGET = 0x1f + IFLA_BOND_AD_INFO_UNSPEC = 0x0 + IFLA_BOND_AD_INFO_AGGREGATOR = 0x1 + IFLA_BOND_AD_INFO_NUM_PORTS = 0x2 + IFLA_BOND_AD_INFO_ACTOR_KEY = 0x3 + IFLA_BOND_AD_INFO_PARTNER_KEY = 0x4 + IFLA_BOND_AD_INFO_PARTNER_MAC = 0x5 + IFLA_BOND_SLAVE_UNSPEC = 0x0 + IFLA_BOND_SLAVE_STATE = 0x1 + IFLA_BOND_SLAVE_MII_STATUS = 0x2 + IFLA_BOND_SLAVE_LINK_FAILURE_COUNT = 0x3 + IFLA_BOND_SLAVE_PERM_HWADDR = 0x4 + IFLA_BOND_SLAVE_QUEUE_ID = 0x5 + IFLA_BOND_SLAVE_AD_AGGREGATOR_ID = 0x6 + IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE = 0x7 + IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE = 0x8 + IFLA_BOND_SLAVE_PRIO = 0x9 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_OPERSTATE = 0x10 + IFLA_STATS = 0x7 + IFLA_STATS64 = 0x17 + IFLA_TXQLEN = 0xd + IFLA_GROUP = 0x1b + IFLA_LINKINFO = 0x12 + IFLA_LINKMODE = 0x11 + IFLA_IFALIAS = 0x14 + IFLA_MASTER = 0xa + IFLA_CARRIER = 0x21 + IFLA_CARRIER_CHANGES = 0x23 + IFLA_CARRIER_UP_COUNT = 0x2f + IFLA_CARRIER_DOWN_COUNT = 0x30 + IFLA_PHYS_PORT_ID = 0x22 + IFLA_PHYS_SWITCH_ID = 0x24 + IFLA_PHYS_PORT_NAME = 0x26 + IFLA_INFO_KIND = 0x1 + IFLA_INFO_SLAVE_KIND = 0x4 + IFLA_INFO_DATA = 0x2 + IFLA_INFO_SLAVE_DATA = 0x5 + IFLA_NET_NS_PID = 0x13 + IFLA_NET_NS_FD = 0x1c + IFLA_XDP = 0x2b + IFLA_XDP_FD = 0x1 + IFLA_XDP_ATTACHED = 0x2 + IFLA_XDP_FLAGS = 0x3 + IFLA_XDP_PROG_ID = 0x4 + IFLA_XDP_EXPECTED_FD = 0x8 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_MASK = 0x1f + XDP_FLAGS_REPLACE = 0x10 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + LWTUNNEL_ENCAP_MPLS = 0x1 + MPLS_IPTUNNEL_DST = 0x1 + MPLS_IPTUNNEL_TTL = 0x2 + NDA_UNSPEC = 0x0 + NDA_DST = 0x1 + NDA_LLADDR = 0x2 + NDA_CACHEINFO = 0x3 + NDA_IFINDEX = 0x8 + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_ENCAP = 0x16 + RTA_ENCAP_TYPE = 0x15 + RTA_PREFSRC = 0x7 + RTA_GATEWAY = 0x5 + RTA_OIF = 0x4 + RTA_PRIORITY = 0x6 + RTA_TABLE = 0xf + RTA_MARK = 0x10 + RTA_EXPIRES = 0x17 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_PREF = 0x14 + RTAX_ADVMSS = 0x8 + RTAX_FEATURES = 0xc + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_MTU = 0x2 + NTF_PROXY = 0x8 + RTN_UNICAST = 0x1 + RT_TABLE_MAIN = 0xfe + RTPROT_BOOT = 0x3 + RTPROT_STATIC = 0x4 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_HOST = 0xfe + RT_SCOPE_LINK = 0xfd + RTM_NEWRULE = 0x20 + RTM_GETRULE = 0x22 + RTM_DELRULE = 0x21 + FRA_UNSPEC = 0x0 + FRA_DST = 0x1 + FRA_SRC = 0x2 + FRA_IIFNAME = 0x3 + FRA_GOTO = 0x4 + FRA_UNUSED2 = 0x5 + FRA_PRIORITY = 0x6 + FRA_UNUSED3 = 0x7 + FRA_UNUSED4 = 0x8 + FRA_UNUSED5 = 0x9 + FRA_FWMARK = 0xa + FRA_FLOW = 0xb + FRA_TUN_ID = 0xc + FRA_SUPPRESS_IFGROUP = 0xd + FRA_SUPPRESS_PREFIXLEN = 0xe + FRA_TABLE = 0xf + FRA_FWMASK = 0x10 + FRA_OIFNAME = 0x11 + FRA_PAD = 0x12 + FRA_L3MDEV = 0x13 + FRA_UID_RANGE = 0x14 + FRA_PROTOCOL = 0x15 + FRA_IP_PROTO = 0x16 + FRA_SPORT_RANGE = 0x17 + FRA_DPORT_RANGE = 0x18 )