]> git.proxmox.com Git - mirror_ovs.git/blame - lib/bond.h
netdev-linux, netdev-bsd: Make access to AF_INET socket thread-safe.
[mirror_ovs.git] / lib / bond.h
CommitLineData
f620b43a 1/*
e0edde6f 2 * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
f620b43a
BP
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef BOND_H
18#define BOND_H 1
19
20#include <stdbool.h>
21#include <stdint.h>
22
23#include "packets.h"
f620b43a
BP
24
25struct flow;
f620b43a
BP
26struct netdev;
27struct ofpbuf;
bdebeece 28enum lacp_status;
f620b43a
BP
29
30/* How flows are balanced among bond slaves. */
31enum bond_mode {
32 BM_TCP, /* Transport Layer Load Balance. */
33 BM_SLB, /* Source Load Balance. */
34 BM_AB /* Active Backup. */
35};
36
37bool bond_mode_from_string(enum bond_mode *, const char *);
38const char *bond_mode_to_string(enum bond_mode);
39
f620b43a
BP
40/* Configuration for a bond as a whole. */
41struct bond_settings {
42 char *name; /* Bond's name, for log messages. */
672d18b2 43 uint32_t basis; /* Flow hashing basis. */
f620b43a
BP
44
45 /* Balancing configuration. */
46 enum bond_mode balance;
bc1b010c
EJ
47 int rebalance_interval; /* Milliseconds between rebalances.
48 Zero to disable rebalancing. */
f620b43a
BP
49
50 /* Link status detection. */
f620b43a
BP
51 int up_delay; /* ms before enabling an up slave. */
52 int down_delay; /* ms before disabling a down slave. */
53
54 /* Legacy compatibility. */
55 bool fake_iface; /* Update fake stats for netdev 'name'? */
f620b43a
BP
56};
57
58/* Program startup. */
59void bond_init(void);
60
61/* Basics. */
62struct bond *bond_create(const struct bond_settings *);
03366a2d
EJ
63void bond_unref(struct bond *);
64struct bond *bond_ref(const struct bond *);
f620b43a 65
59d7b2b6 66bool bond_reconfigure(struct bond *, const struct bond_settings *);
df53d41c 67void bond_slave_register(struct bond *, void *slave_, struct netdev *);
f8ddccd2 68void bond_slave_set_netdev(struct bond *, void *slave_, struct netdev *);
f620b43a
BP
69void bond_slave_unregister(struct bond *, const void *slave);
70
4a1b8f30 71bool bond_run(struct bond *, enum lacp_status);
f620b43a
BP
72void bond_wait(struct bond *);
73
296f6519 74void bond_slave_set_may_enable(struct bond *, void *slave_, bool may_enable);
4d6fb5eb 75
f620b43a
BP
76/* Special MAC learning support for SLB bonding. */
77bool bond_should_send_learning_packets(struct bond *);
ea131871
JG
78struct ofpbuf *bond_compose_learning_packet(struct bond *,
79 const uint8_t eth_src[ETH_ADDR_LEN],
80 uint16_t vlan, void **port_aux);
f620b43a
BP
81
82/* Packet processing. */
83enum bond_verdict {
84 BV_ACCEPT, /* Accept this packet. */
85 BV_DROP, /* Drop this packet. */
86 BV_DROP_IF_MOVED /* Drop if we've learned a different port. */
87};
88enum bond_verdict bond_check_admissibility(struct bond *, const void *slave_,
4a1b8f30 89 const uint8_t dst[ETH_ADDR_LEN]);
bcd2633a 90void *bond_choose_output_slave(struct bond *, const struct flow *,
4a1b8f30 91 struct flow_wildcards *, uint16_t vlan);
f620b43a
BP
92
93/* Rebalancing. */
94void bond_account(struct bond *, const struct flow *, uint16_t vlan,
95 uint64_t n_bytes);
4a1b8f30 96void bond_rebalance(struct bond *);
f620b43a
BP
97
98#endif /* bond.h */