1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 Copyright © 2014 Tom Gundersen <teg@jklm.no>
8 #include "in-addr-util.h"
11 #include "netdev/netdev.h"
14 * Maximum number of targets supported by the kernel for a single
17 #define NETDEV_BOND_ARP_TARGETS_MAX 16
19 typedef enum BondMode
{
20 NETDEV_BOND_MODE_BALANCE_RR
,
21 NETDEV_BOND_MODE_ACTIVE_BACKUP
,
22 NETDEV_BOND_MODE_BALANCE_XOR
,
23 NETDEV_BOND_MODE_BROADCAST
,
24 NETDEV_BOND_MODE_802_3AD
,
25 NETDEV_BOND_MODE_BALANCE_TLB
,
26 NETDEV_BOND_MODE_BALANCE_ALB
,
27 _NETDEV_BOND_MODE_MAX
,
28 _NETDEV_BOND_MODE_INVALID
= -1
31 typedef enum BondXmitHashPolicy
{
32 NETDEV_BOND_XMIT_HASH_POLICY_LAYER2
,
33 NETDEV_BOND_XMIT_HASH_POLICY_LAYER34
,
34 NETDEV_BOND_XMIT_HASH_POLICY_LAYER23
,
35 NETDEV_BOND_XMIT_HASH_POLICY_ENCAP23
,
36 NETDEV_BOND_XMIT_HASH_POLICY_ENCAP34
,
37 _NETDEV_BOND_XMIT_HASH_POLICY_MAX
,
38 _NETDEV_BOND_XMIT_HASH_POLICY_INVALID
= -1
41 typedef enum BondLacpRate
{
42 NETDEV_BOND_LACP_RATE_SLOW
,
43 NETDEV_BOND_LACP_RATE_FAST
,
44 _NETDEV_BOND_LACP_RATE_MAX
,
45 _NETDEV_BOND_LACP_RATE_INVALID
= -1,
48 typedef enum BondAdSelect
{
49 NETDEV_BOND_AD_SELECT_STABLE
,
50 NETDEV_BOND_AD_SELECT_BANDWIDTH
,
51 NETDEV_BOND_AD_SELECT_COUNT
,
52 _NETDEV_BOND_AD_SELECT_MAX
,
53 _NETDEV_BOND_AD_SELECT_INVALID
= -1,
56 typedef enum BondFailOverMac
{
57 NETDEV_BOND_FAIL_OVER_MAC_NONE
,
58 NETDEV_BOND_FAIL_OVER_MAC_ACTIVE
,
59 NETDEV_BOND_FAIL_OVER_MAC_FOLLOW
,
60 _NETDEV_BOND_FAIL_OVER_MAC_MAX
,
61 _NETDEV_BOND_FAIL_OVER_MAC_INVALID
= -1,
64 typedef enum BondArpValidate
{
65 NETDEV_BOND_ARP_VALIDATE_NONE
,
66 NETDEV_BOND_ARP_VALIDATE_ACTIVE
,
67 NETDEV_BOND_ARP_VALIDATE_BACKUP
,
68 NETDEV_BOND_ARP_VALIDATE_ALL
,
69 _NETDEV_BOND_ARP_VALIDATE_MAX
,
70 _NETDEV_BOND_ARP_VALIDATE_INVALID
= -1,
73 typedef enum BondArpAllTargets
{
74 NETDEV_BOND_ARP_ALL_TARGETS_ANY
,
75 NETDEV_BOND_ARP_ALL_TARGETS_ALL
,
76 _NETDEV_BOND_ARP_ALL_TARGETS_MAX
,
77 _NETDEV_BOND_ARP_ALL_TARGETS_INVALID
= -1,
80 typedef enum BondPrimaryReselect
{
81 NETDEV_BOND_PRIMARY_RESELECT_ALWAYS
,
82 NETDEV_BOND_PRIMARY_RESELECT_BETTER
,
83 NETDEV_BOND_PRIMARY_RESELECT_FAILURE
,
84 _NETDEV_BOND_PRIMARY_RESELECT_MAX
,
85 _NETDEV_BOND_PRIMARY_RESELECT_INVALID
= -1,
86 } BondPrimaryReselect
;
88 typedef struct ArpIpTarget
{
89 union in_addr_union ip
;
91 LIST_FIELDS(struct ArpIpTarget
, arp_ip_target
);
98 BondXmitHashPolicy xmit_hash_policy
;
99 BondLacpRate lacp_rate
;
100 BondAdSelect ad_select
;
101 BondFailOverMac fail_over_mac
;
102 BondArpValidate arp_validate
;
103 BondArpAllTargets arp_all_targets
;
104 BondPrimaryReselect primary_reselect
;
106 bool all_slaves_active
;
108 unsigned resend_igmp
;
109 unsigned packets_per_slave
;
110 unsigned num_grat_arp
;
119 int n_arp_ip_targets
;
120 ArpIpTarget
*arp_ip_targets
;
123 DEFINE_NETDEV_CAST(BOND
, Bond
);
124 extern const NetDevVTable bond_vtable
;
126 const char *bond_mode_to_string(BondMode d
) _const_
;
127 BondMode
bond_mode_from_string(const char *d
) _pure_
;
129 const char *bond_xmit_hash_policy_to_string(BondXmitHashPolicy d
) _const_
;
130 BondXmitHashPolicy
bond_xmit_hash_policy_from_string(const char *d
) _pure_
;
132 const char *bond_lacp_rate_to_string(BondLacpRate d
) _const_
;
133 BondLacpRate
bond_lacp_rate_from_string(const char *d
) _pure_
;
135 const char *bond_fail_over_mac_to_string(BondFailOverMac d
) _const_
;
136 BondFailOverMac
bond_fail_over_mac_from_string(const char *d
) _pure_
;
138 const char *bond_ad_select_to_string(BondAdSelect d
) _const_
;
139 BondAdSelect
bond_ad_select_from_string(const char *d
) _pure_
;
141 const char *bond_arp_validate_to_string(BondArpValidate d
) _const_
;
142 BondArpValidate
bond_arp_validate_from_string(const char *d
) _pure_
;
144 const char *bond_arp_all_targets_to_string(BondArpAllTargets d
) _const_
;
145 BondArpAllTargets
bond_arp_all_targets_from_string(const char *d
) _pure_
;
147 const char *bond_primary_reselect_to_string(BondPrimaryReselect d
) _const_
;
148 BondPrimaryReselect
bond_primary_reselect_from_string(const char *d
) _pure_
;
150 int config_parse_bond_mode(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);
151 int config_parse_bond_xmit_hash_policy(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);
152 int config_parse_bond_lacp_rate(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);
153 int config_parse_bond_ad_select(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);
154 int config_parse_bond_fail_over_mac(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);
155 int config_parse_bond_arp_validate(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);
156 int config_parse_bond_arp_all_targets(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);
157 int config_parse_bond_primary_reselect(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);
158 int config_parse_arp_ip_target_address(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);