]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/netdev/bond.h
tree-wide: beautify remaining copyright statements
[thirdparty/systemd.git] / src / network / netdev / bond.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright © 2014 Tom Gundersen <teg@jklm.no>
6 ***/
7
8 #include "in-addr-util.h"
9 #include "list.h"
10
11 #include "netdev/netdev.h"
12
13 /*
14 * Maximum number of targets supported by the kernel for a single
15 * bond netdev.
16 */
17 #define NETDEV_BOND_ARP_TARGETS_MAX 16
18
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
29 } BondMode;
30
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
39 } BondXmitHashPolicy;
40
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,
46 } BondLacpRate;
47
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,
54 } BondAdSelect;
55
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,
62 } BondFailOverMac;
63
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,
71 } BondArpValidate;
72
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,
78 } BondArpAllTargets;
79
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;
87
88 typedef struct ArpIpTarget {
89 union in_addr_union ip;
90
91 LIST_FIELDS(struct ArpIpTarget, arp_ip_target);
92 } ArpIpTarget;
93
94 typedef struct Bond {
95 NetDev meta;
96
97 BondMode mode;
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;
105
106 bool all_slaves_active;
107
108 unsigned resend_igmp;
109 unsigned packets_per_slave;
110 unsigned num_grat_arp;
111 unsigned min_links;
112
113 usec_t miimon;
114 usec_t updelay;
115 usec_t downdelay;
116 usec_t arp_interval;
117 usec_t lp_interval;
118
119 int n_arp_ip_targets;
120 ArpIpTarget *arp_ip_targets;
121 } Bond;
122
123 DEFINE_NETDEV_CAST(BOND, Bond);
124 extern const NetDevVTable bond_vtable;
125
126 const char *bond_mode_to_string(BondMode d) _const_;
127 BondMode bond_mode_from_string(const char *d) _pure_;
128
129 const char *bond_xmit_hash_policy_to_string(BondXmitHashPolicy d) _const_;
130 BondXmitHashPolicy bond_xmit_hash_policy_from_string(const char *d) _pure_;
131
132 const char *bond_lacp_rate_to_string(BondLacpRate d) _const_;
133 BondLacpRate bond_lacp_rate_from_string(const char *d) _pure_;
134
135 const char *bond_fail_over_mac_to_string(BondFailOverMac d) _const_;
136 BondFailOverMac bond_fail_over_mac_from_string(const char *d) _pure_;
137
138 const char *bond_ad_select_to_string(BondAdSelect d) _const_;
139 BondAdSelect bond_ad_select_from_string(const char *d) _pure_;
140
141 const char *bond_arp_validate_to_string(BondArpValidate d) _const_;
142 BondArpValidate bond_arp_validate_from_string(const char *d) _pure_;
143
144 const char *bond_arp_all_targets_to_string(BondArpAllTargets d) _const_;
145 BondArpAllTargets bond_arp_all_targets_from_string(const char *d) _pure_;
146
147 const char *bond_primary_reselect_to_string(BondPrimaryReselect d) _const_;
148 BondPrimaryReselect bond_primary_reselect_from_string(const char *d) _pure_;
149
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);