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