4 This file is part of systemd.
6 Copyright 2014 Tom Gundersen <teg@jklm.no>
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include "in-addr-util.h"
25 #include "netdev/netdev.h"
28 * Maximum number of targets supported by the kernel for a single
31 #define NETDEV_BOND_ARP_TARGETS_MAX 16
33 typedef enum BondMode
{
34 NETDEV_BOND_MODE_BALANCE_RR
,
35 NETDEV_BOND_MODE_ACTIVE_BACKUP
,
36 NETDEV_BOND_MODE_BALANCE_XOR
,
37 NETDEV_BOND_MODE_BROADCAST
,
38 NETDEV_BOND_MODE_802_3AD
,
39 NETDEV_BOND_MODE_BALANCE_TLB
,
40 NETDEV_BOND_MODE_BALANCE_ALB
,
41 _NETDEV_BOND_MODE_MAX
,
42 _NETDEV_BOND_MODE_INVALID
= -1
45 typedef enum BondXmitHashPolicy
{
46 NETDEV_BOND_XMIT_HASH_POLICY_LAYER2
,
47 NETDEV_BOND_XMIT_HASH_POLICY_LAYER34
,
48 NETDEV_BOND_XMIT_HASH_POLICY_LAYER23
,
49 NETDEV_BOND_XMIT_HASH_POLICY_ENCAP23
,
50 NETDEV_BOND_XMIT_HASH_POLICY_ENCAP34
,
51 _NETDEV_BOND_XMIT_HASH_POLICY_MAX
,
52 _NETDEV_BOND_XMIT_HASH_POLICY_INVALID
= -1
55 typedef enum BondLacpRate
{
56 NETDEV_BOND_LACP_RATE_SLOW
,
57 NETDEV_BOND_LACP_RATE_FAST
,
58 _NETDEV_BOND_LACP_RATE_MAX
,
59 _NETDEV_BOND_LACP_RATE_INVALID
= -1,
62 typedef enum BondAdSelect
{
63 NETDEV_BOND_AD_SELECT_STABLE
,
64 NETDEV_BOND_AD_SELECT_BANDWIDTH
,
65 NETDEV_BOND_AD_SELECT_COUNT
,
66 _NETDEV_BOND_AD_SELECT_MAX
,
67 _NETDEV_BOND_AD_SELECT_INVALID
= -1,
70 typedef enum BondFailOverMac
{
71 NETDEV_BOND_FAIL_OVER_MAC_NONE
,
72 NETDEV_BOND_FAIL_OVER_MAC_ACTIVE
,
73 NETDEV_BOND_FAIL_OVER_MAC_FOLLOW
,
74 _NETDEV_BOND_FAIL_OVER_MAC_MAX
,
75 _NETDEV_BOND_FAIL_OVER_MAC_INVALID
= -1,
78 typedef enum BondArpValidate
{
79 NETDEV_BOND_ARP_VALIDATE_NONE
,
80 NETDEV_BOND_ARP_VALIDATE_ACTIVE
,
81 NETDEV_BOND_ARP_VALIDATE_BACKUP
,
82 NETDEV_BOND_ARP_VALIDATE_ALL
,
83 _NETDEV_BOND_ARP_VALIDATE_MAX
,
84 _NETDEV_BOND_ARP_VALIDATE_INVALID
= -1,
87 typedef enum BondArpAllTargets
{
88 NETDEV_BOND_ARP_ALL_TARGETS_ANY
,
89 NETDEV_BOND_ARP_ALL_TARGETS_ALL
,
90 _NETDEV_BOND_ARP_ALL_TARGETS_MAX
,
91 _NETDEV_BOND_ARP_ALL_TARGETS_INVALID
= -1,
94 typedef enum BondPrimaryReselect
{
95 NETDEV_BOND_PRIMARY_RESELECT_ALWAYS
,
96 NETDEV_BOND_PRIMARY_RESELECT_BETTER
,
97 NETDEV_BOND_PRIMARY_RESELECT_FAILURE
,
98 _NETDEV_BOND_PRIMARY_RESELECT_MAX
,
99 _NETDEV_BOND_PRIMARY_RESELECT_INVALID
= -1,
100 } BondPrimaryReselect
;
102 typedef struct ArpIpTarget
{
103 union in_addr_union ip
;
105 LIST_FIELDS(struct ArpIpTarget
, arp_ip_target
);
108 typedef struct Bond
{
112 BondXmitHashPolicy xmit_hash_policy
;
113 BondLacpRate lacp_rate
;
114 BondAdSelect ad_select
;
115 BondFailOverMac fail_over_mac
;
116 BondArpValidate arp_validate
;
117 BondArpAllTargets arp_all_targets
;
118 BondPrimaryReselect primary_reselect
;
120 bool all_slaves_active
;
122 unsigned resend_igmp
;
123 unsigned packets_per_slave
;
124 unsigned num_grat_arp
;
133 int n_arp_ip_targets
;
134 ArpIpTarget
*arp_ip_targets
;
137 DEFINE_NETDEV_CAST(BOND
, Bond
);
138 extern const NetDevVTable bond_vtable
;
140 const char *bond_mode_to_string(BondMode d
) _const_
;
141 BondMode
bond_mode_from_string(const char *d
) _pure_
;
143 const char *bond_xmit_hash_policy_to_string(BondXmitHashPolicy d
) _const_
;
144 BondXmitHashPolicy
bond_xmit_hash_policy_from_string(const char *d
) _pure_
;
146 const char *bond_lacp_rate_to_string(BondLacpRate d
) _const_
;
147 BondLacpRate
bond_lacp_rate_from_string(const char *d
) _pure_
;
149 const char *bond_fail_over_mac_to_string(BondFailOverMac d
) _const_
;
150 BondFailOverMac
bond_fail_over_mac_from_string(const char *d
) _pure_
;
152 const char *bond_ad_select_to_string(BondAdSelect d
) _const_
;
153 BondAdSelect
bond_ad_select_from_string(const char *d
) _pure_
;
155 const char *bond_arp_validate_to_string(BondArpValidate d
) _const_
;
156 BondArpValidate
bond_arp_validate_from_string(const char *d
) _pure_
;
158 const char *bond_arp_all_targets_to_string(BondArpAllTargets d
) _const_
;
159 BondArpAllTargets
bond_arp_all_targets_from_string(const char *d
) _pure_
;
161 const char *bond_primary_reselect_to_string(BondPrimaryReselect d
) _const_
;
162 BondPrimaryReselect
bond_primary_reselect_from_string(const char *d
) _pure_
;
164 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
);
165 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
);
166 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
);
167 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
);
168 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
);
169 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
);
170 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
);
171 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
);
172 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
);