]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/netdev/bond.h
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / network / netdev / bond.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
fc2f9534
LP
2#pragma once
3
3be1d7e0
TG
4/***
5 This file is part of systemd.
6
7 Copyright 2014 Tom Gundersen <teg@jklm.no>
3be1d7e0
TG
8***/
9
fc2f9534 10#include "in-addr-util.h"
634f0f98 11#include "list.h"
3be1d7e0 12
441e9ae4 13#include "netdev/netdev.h"
3be1d7e0 14
dd906398
DH
15/*
16 * Maximum number of targets supported by the kernel for a single
17 * bond netdev.
18 */
19#define NETDEV_BOND_ARP_TARGETS_MAX 16
20
3be1d7e0
TG
21typedef enum BondMode {
22 NETDEV_BOND_MODE_BALANCE_RR,
23 NETDEV_BOND_MODE_ACTIVE_BACKUP,
24 NETDEV_BOND_MODE_BALANCE_XOR,
25 NETDEV_BOND_MODE_BROADCAST,
26 NETDEV_BOND_MODE_802_3AD,
27 NETDEV_BOND_MODE_BALANCE_TLB,
28 NETDEV_BOND_MODE_BALANCE_ALB,
29 _NETDEV_BOND_MODE_MAX,
30 _NETDEV_BOND_MODE_INVALID = -1
31} BondMode;
32
227cdf2c
SS
33typedef enum BondXmitHashPolicy {
34 NETDEV_BOND_XMIT_HASH_POLICY_LAYER2,
35 NETDEV_BOND_XMIT_HASH_POLICY_LAYER34,
36 NETDEV_BOND_XMIT_HASH_POLICY_LAYER23,
37 NETDEV_BOND_XMIT_HASH_POLICY_ENCAP23,
38 NETDEV_BOND_XMIT_HASH_POLICY_ENCAP34,
39 _NETDEV_BOND_XMIT_HASH_POLICY_MAX,
40 _NETDEV_BOND_XMIT_HASH_POLICY_INVALID = -1
41} BondXmitHashPolicy;
42
fb1021a2
SS
43typedef enum BondLacpRate {
44 NETDEV_BOND_LACP_RATE_SLOW,
45 NETDEV_BOND_LACP_RATE_FAST,
46 _NETDEV_BOND_LACP_RATE_MAX,
47 _NETDEV_BOND_LACP_RATE_INVALID = -1,
48} BondLacpRate;
49
81bd37a8
SS
50typedef enum BondAdSelect {
51 NETDEV_BOND_AD_SELECT_STABLE,
52 NETDEV_BOND_AD_SELECT_BANDWIDTH,
53 NETDEV_BOND_AD_SELECT_COUNT,
54 _NETDEV_BOND_AD_SELECT_MAX,
55 _NETDEV_BOND_AD_SELECT_INVALID = -1,
56} BondAdSelect;
57
58typedef enum BondFailOverMac {
59 NETDEV_BOND_FAIL_OVER_MAC_NONE,
60 NETDEV_BOND_FAIL_OVER_MAC_ACTIVE,
61 NETDEV_BOND_FAIL_OVER_MAC_FOLLOW,
62 _NETDEV_BOND_FAIL_OVER_MAC_MAX,
63 _NETDEV_BOND_FAIL_OVER_MAC_INVALID = -1,
64} BondFailOverMac;
65
66typedef enum BondArpValidate {
67 NETDEV_BOND_ARP_VALIDATE_NONE,
68 NETDEV_BOND_ARP_VALIDATE_ACTIVE,
69 NETDEV_BOND_ARP_VALIDATE_BACKUP,
70 NETDEV_BOND_ARP_VALIDATE_ALL,
71 _NETDEV_BOND_ARP_VALIDATE_MAX,
72 _NETDEV_BOND_ARP_VALIDATE_INVALID = -1,
73} BondArpValidate;
74
75typedef enum BondArpAllTargets {
76 NETDEV_BOND_ARP_ALL_TARGETS_ANY,
77 NETDEV_BOND_ARP_ALL_TARGETS_ALL,
78 _NETDEV_BOND_ARP_ALL_TARGETS_MAX,
79 _NETDEV_BOND_ARP_ALL_TARGETS_INVALID = -1,
80} BondArpAllTargets;
81
82typedef enum BondPrimaryReselect {
83 NETDEV_BOND_PRIMARY_RESELECT_ALWAYS,
84 NETDEV_BOND_PRIMARY_RESELECT_BETTER,
85 NETDEV_BOND_PRIMARY_RESELECT_FAILURE,
86 _NETDEV_BOND_PRIMARY_RESELECT_MAX,
87 _NETDEV_BOND_PRIMARY_RESELECT_INVALID = -1,
88} BondPrimaryReselect;
89
90typedef struct ArpIpTarget {
91 union in_addr_union ip;
92
93 LIST_FIELDS(struct ArpIpTarget, arp_ip_target);
94} ArpIpTarget;
95
634f0f98 96typedef struct Bond {
aa9f1140
TG
97 NetDev meta;
98
99 BondMode mode;
227cdf2c 100 BondXmitHashPolicy xmit_hash_policy;
fb1021a2 101 BondLacpRate lacp_rate;
81bd37a8
SS
102 BondAdSelect ad_select;
103 BondFailOverMac fail_over_mac;
104 BondArpValidate arp_validate;
105 BondArpAllTargets arp_all_targets;
106 BondPrimaryReselect primary_reselect;
107
108 bool all_slaves_active;
109
110 unsigned resend_igmp;
111 unsigned packets_per_slave;
112 unsigned num_grat_arp;
113 unsigned min_links;
d9c52fa0
SS
114
115 usec_t miimon;
116 usec_t updelay;
117 usec_t downdelay;
81bd37a8
SS
118 usec_t arp_interval;
119 usec_t lp_interval;
120
121 int n_arp_ip_targets;
122 ArpIpTarget *arp_ip_targets;
634f0f98 123} Bond;
aa9f1140 124
634f0f98 125DEFINE_NETDEV_CAST(BOND, Bond);
aa9f1140
TG
126extern const NetDevVTable bond_vtable;
127
3be1d7e0
TG
128const char *bond_mode_to_string(BondMode d) _const_;
129BondMode bond_mode_from_string(const char *d) _pure_;
130
227cdf2c
SS
131const char *bond_xmit_hash_policy_to_string(BondXmitHashPolicy d) _const_;
132BondXmitHashPolicy bond_xmit_hash_policy_from_string(const char *d) _pure_;
133
fb1021a2
SS
134const char *bond_lacp_rate_to_string(BondLacpRate d) _const_;
135BondLacpRate bond_lacp_rate_from_string(const char *d) _pure_;
136
81bd37a8
SS
137const char *bond_fail_over_mac_to_string(BondFailOverMac d) _const_;
138BondFailOverMac bond_fail_over_mac_from_string(const char *d) _pure_;
139
140const char *bond_ad_select_to_string(BondAdSelect d) _const_;
141BondAdSelect bond_ad_select_from_string(const char *d) _pure_;
142
143const char *bond_arp_validate_to_string(BondArpValidate d) _const_;
144BondArpValidate bond_arp_validate_from_string(const char *d) _pure_;
145
146const char *bond_arp_all_targets_to_string(BondArpAllTargets d) _const_;
147BondArpAllTargets bond_arp_all_targets_from_string(const char *d) _pure_;
148
149const char *bond_primary_reselect_to_string(BondPrimaryReselect d) _const_;
150BondPrimaryReselect bond_primary_reselect_from_string(const char *d) _pure_;
151
3be1d7e0 152int 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 153int 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 154int 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
155int 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);
156int 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);
157int 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);
158int 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);
159int 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);
160int 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);