]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/netdev/bond.h
wait-online: use hashmap_free_with_destructor()
[thirdparty/systemd.git] / src / network / netdev / bond.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
fc2f9534
LP
2#pragma once
3
fc2f9534 4#include "in-addr-util.h"
634f0f98 5#include "list.h"
3be1d7e0 6
441e9ae4 7#include "netdev/netdev.h"
3be1d7e0 8
dd906398
DH
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
3be1d7e0
TG
15typedef enum BondMode {
16 NETDEV_BOND_MODE_BALANCE_RR,
17 NETDEV_BOND_MODE_ACTIVE_BACKUP,
18 NETDEV_BOND_MODE_BALANCE_XOR,
19 NETDEV_BOND_MODE_BROADCAST,
20 NETDEV_BOND_MODE_802_3AD,
21 NETDEV_BOND_MODE_BALANCE_TLB,
22 NETDEV_BOND_MODE_BALANCE_ALB,
23 _NETDEV_BOND_MODE_MAX,
24 _NETDEV_BOND_MODE_INVALID = -1
25} BondMode;
26
227cdf2c
SS
27typedef enum BondXmitHashPolicy {
28 NETDEV_BOND_XMIT_HASH_POLICY_LAYER2,
29 NETDEV_BOND_XMIT_HASH_POLICY_LAYER34,
30 NETDEV_BOND_XMIT_HASH_POLICY_LAYER23,
31 NETDEV_BOND_XMIT_HASH_POLICY_ENCAP23,
32 NETDEV_BOND_XMIT_HASH_POLICY_ENCAP34,
33 _NETDEV_BOND_XMIT_HASH_POLICY_MAX,
34 _NETDEV_BOND_XMIT_HASH_POLICY_INVALID = -1
35} BondXmitHashPolicy;
36
fb1021a2
SS
37typedef 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 = -1,
42} BondLacpRate;
43
81bd37a8
SS
44typedef 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 = -1,
50} BondAdSelect;
51
52typedef 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 = -1,
58} BondFailOverMac;
59
60typedef 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 = -1,
67} BondArpValidate;
68
69typedef 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 = -1,
74} BondArpAllTargets;
75
76typedef 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 = -1,
82} BondPrimaryReselect;
83
84typedef struct ArpIpTarget {
85 union in_addr_union ip;
86
87 LIST_FIELDS(struct ArpIpTarget, arp_ip_target);
88} ArpIpTarget;
89
634f0f98 90typedef struct Bond {
aa9f1140
TG
91 NetDev meta;
92
93 BondMode mode;
227cdf2c 94 BondXmitHashPolicy xmit_hash_policy;
fb1021a2 95 BondLacpRate lacp_rate;
81bd37a8
SS
96 BondAdSelect ad_select;
97 BondFailOverMac fail_over_mac;
98 BondArpValidate arp_validate;
99 BondArpAllTargets arp_all_targets;
100 BondPrimaryReselect primary_reselect;
101
102 bool all_slaves_active;
103
104 unsigned resend_igmp;
105 unsigned packets_per_slave;
106 unsigned num_grat_arp;
107 unsigned min_links;
d9c52fa0 108
99f68ef0
TJ
109 uint16_t ad_actor_sys_prio;
110 uint16_t ad_user_port_key;
111 struct ether_addr *ad_actor_system;
112
d9c52fa0
SS
113 usec_t miimon;
114 usec_t updelay;
115 usec_t downdelay;
81bd37a8
SS
116 usec_t arp_interval;
117 usec_t lp_interval;
118
119 int n_arp_ip_targets;
120 ArpIpTarget *arp_ip_targets;
634f0f98 121} Bond;
aa9f1140 122
634f0f98 123DEFINE_NETDEV_CAST(BOND, Bond);
aa9f1140
TG
124extern const NetDevVTable bond_vtable;
125
3be1d7e0
TG
126const char *bond_mode_to_string(BondMode d) _const_;
127BondMode bond_mode_from_string(const char *d) _pure_;
128
227cdf2c
SS
129const char *bond_xmit_hash_policy_to_string(BondXmitHashPolicy d) _const_;
130BondXmitHashPolicy bond_xmit_hash_policy_from_string(const char *d) _pure_;
131
fb1021a2
SS
132const char *bond_lacp_rate_to_string(BondLacpRate d) _const_;
133BondLacpRate bond_lacp_rate_from_string(const char *d) _pure_;
134
81bd37a8
SS
135const char *bond_fail_over_mac_to_string(BondFailOverMac d) _const_;
136BondFailOverMac bond_fail_over_mac_from_string(const char *d) _pure_;
137
138const char *bond_ad_select_to_string(BondAdSelect d) _const_;
139BondAdSelect bond_ad_select_from_string(const char *d) _pure_;
140
141const char *bond_arp_validate_to_string(BondArpValidate d) _const_;
142BondArpValidate bond_arp_validate_from_string(const char *d) _pure_;
143
144const char *bond_arp_all_targets_to_string(BondArpAllTargets d) _const_;
145BondArpAllTargets bond_arp_all_targets_from_string(const char *d) _pure_;
146
147const char *bond_primary_reselect_to_string(BondPrimaryReselect d) _const_;
148BondPrimaryReselect bond_primary_reselect_from_string(const char *d) _pure_;
149
3be1d7e0 150int 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);
227cdf2c 151int 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);
fb1021a2 152int 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);
81bd37a8
SS
153int 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);
154int 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);
155int 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);
156int 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);
157int 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);
158int 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);
99f68ef0
TJ
159int config_parse_ad_actor_sys_prio(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);
160int config_parse_ad_user_port_key(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);
161int config_parse_ad_actor_system(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);