1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #pragma once 3 4 #include <netinet/in.h> 5 #include <linux/if_bonding.h> 6 7 #include "macro.h" 8 9 /* 10 * Maximum number of targets supported by the kernel for a single 11 * bond netdev. 12 */ 13 #define NETDEV_BOND_ARP_TARGETS_MAX 16 14 15 typedef enum BondMode { 16 NETDEV_BOND_MODE_BALANCE_RR = BOND_MODE_ROUNDROBIN, 17 NETDEV_BOND_MODE_ACTIVE_BACKUP = BOND_MODE_ACTIVEBACKUP, 18 NETDEV_BOND_MODE_BALANCE_XOR = BOND_MODE_XOR, 19 NETDEV_BOND_MODE_BROADCAST = BOND_MODE_BROADCAST, 20 NETDEV_BOND_MODE_802_3AD = BOND_MODE_8023AD, 21 NETDEV_BOND_MODE_BALANCE_TLB = BOND_MODE_TLB, 22 NETDEV_BOND_MODE_BALANCE_ALB = BOND_MODE_ALB, 23 _NETDEV_BOND_MODE_MAX, 24 _NETDEV_BOND_MODE_INVALID = -EINVAL, 25 } BondMode; 26 27 typedef enum BondXmitHashPolicy { 28 NETDEV_BOND_XMIT_HASH_POLICY_LAYER2 = BOND_XMIT_POLICY_LAYER2, 29 NETDEV_BOND_XMIT_HASH_POLICY_LAYER34 = BOND_XMIT_POLICY_LAYER34, 30 NETDEV_BOND_XMIT_HASH_POLICY_LAYER23 = BOND_XMIT_POLICY_LAYER23, 31 NETDEV_BOND_XMIT_HASH_POLICY_ENCAP23 = BOND_XMIT_POLICY_ENCAP23, 32 NETDEV_BOND_XMIT_HASH_POLICY_ENCAP34 = BOND_XMIT_POLICY_ENCAP34, 33 _NETDEV_BOND_XMIT_HASH_POLICY_MAX, 34 _NETDEV_BOND_XMIT_HASH_POLICY_INVALID = -EINVAL, 35 } BondXmitHashPolicy; 36 37 typedef enum BondLacpRate { 38 NETDEV_BOND_LACP_RATE_SLOW, 39 NETDEV_BOND_LACP_RATE_FAST, 40 _NETDEV_BOND_LACP_RATE_MAX, 41 _NETDEV_BOND_LACP_RATE_INVALID = -EINVAL, 42 } BondLacpRate; 43 44 typedef enum BondAdSelect { 45 NETDEV_BOND_AD_SELECT_STABLE, 46 NETDEV_BOND_AD_SELECT_BANDWIDTH, 47 NETDEV_BOND_AD_SELECT_COUNT, 48 _NETDEV_BOND_AD_SELECT_MAX, 49 _NETDEV_BOND_AD_SELECT_INVALID = -EINVAL, 50 } BondAdSelect; 51 52 typedef enum BondFailOverMac { 53 NETDEV_BOND_FAIL_OVER_MAC_NONE, 54 NETDEV_BOND_FAIL_OVER_MAC_ACTIVE, 55 NETDEV_BOND_FAIL_OVER_MAC_FOLLOW, 56 _NETDEV_BOND_FAIL_OVER_MAC_MAX, 57 _NETDEV_BOND_FAIL_OVER_MAC_INVALID = -EINVAL, 58 } BondFailOverMac; 59 60 typedef enum BondArpValidate { 61 NETDEV_BOND_ARP_VALIDATE_NONE, 62 NETDEV_BOND_ARP_VALIDATE_ACTIVE, 63 NETDEV_BOND_ARP_VALIDATE_BACKUP, 64 NETDEV_BOND_ARP_VALIDATE_ALL, 65 _NETDEV_BOND_ARP_VALIDATE_MAX, 66 _NETDEV_BOND_ARP_VALIDATE_INVALID = -EINVAL, 67 } BondArpValidate; 68 69 typedef enum BondArpAllTargets { 70 NETDEV_BOND_ARP_ALL_TARGETS_ANY, 71 NETDEV_BOND_ARP_ALL_TARGETS_ALL, 72 _NETDEV_BOND_ARP_ALL_TARGETS_MAX, 73 _NETDEV_BOND_ARP_ALL_TARGETS_INVALID = -EINVAL, 74 } BondArpAllTargets; 75 76 typedef enum BondPrimaryReselect { 77 NETDEV_BOND_PRIMARY_RESELECT_ALWAYS, 78 NETDEV_BOND_PRIMARY_RESELECT_BETTER, 79 NETDEV_BOND_PRIMARY_RESELECT_FAILURE, 80 _NETDEV_BOND_PRIMARY_RESELECT_MAX, 81 _NETDEV_BOND_PRIMARY_RESELECT_INVALID = -EINVAL, 82 } BondPrimaryReselect; 83 84 const char *bond_mode_to_string(BondMode d) _const_; 85 BondMode bond_mode_from_string(const char *d) _pure_; 86 87 const char *bond_xmit_hash_policy_to_string(BondXmitHashPolicy d) _const_; 88 BondXmitHashPolicy bond_xmit_hash_policy_from_string(const char *d) _pure_; 89 90 const char *bond_lacp_rate_to_string(BondLacpRate d) _const_; 91 BondLacpRate bond_lacp_rate_from_string(const char *d) _pure_; 92 93 const char *bond_fail_over_mac_to_string(BondFailOverMac d) _const_; 94 BondFailOverMac bond_fail_over_mac_from_string(const char *d) _pure_; 95 96 const char *bond_ad_select_to_string(BondAdSelect d) _const_; 97 BondAdSelect bond_ad_select_from_string(const char *d) _pure_; 98 99 const char *bond_arp_validate_to_string(BondArpValidate d) _const_; 100 BondArpValidate bond_arp_validate_from_string(const char *d) _pure_; 101 102 const char *bond_arp_all_targets_to_string(BondArpAllTargets d) _const_; 103 BondArpAllTargets bond_arp_all_targets_from_string(const char *d) _pure_; 104 105 const char *bond_primary_reselect_to_string(BondPrimaryReselect d) _const_; 106 BondPrimaryReselect bond_primary_reselect_from_string(const char *d) _pure_; 107