aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2011-11-11 17:16:48 -0500
committerDavid S. Miller <davem@davemloft.net>2011-11-13 16:10:10 -0500
commit3d249d4ca7d0ed6629a135ea1ea21c72286c0d80 (patch)
treee89c8b6bbf4f8d0e4a3428304c26305eca76e4b8
parent5d70b88cd41ef0f2ac0caaab4fd492dd686feee6 (diff)
net: introduce ethernet teaming device
This patch introduces new network device called team. It supposes to be very fast, simple, userspace-driven alternative to existing bonding driver. Userspace library called libteam with couple of demo apps is available here: https://github.com/jpirko/libteam Note it's still in its dipers atm. team<->libteam use generic netlink for communication. That and rtnl suppose to be the only way to configure team device, no sysfs etc. Python binding of libteam was recently introduced. Daemon providing arpmon/miimon active-backup functionality will be introduced shortly. All what's necessary is already implemented in kernel team driver. v7->v8: - check ndo_ndo_vlan_rx_[add/kill]_vid functions before calling them. - use dev_kfree_skb_any() instead of dev_kfree_skb() v6->v7: - transmit and receive functions are not checked in hot paths. That also resolves memory leak on transmit when no port is present v5->v6: - changed couple of _rcu calls to non _rcu ones in non-readers v4->v5: - team_change_mtu() uses team->lock while travesing though port list - mac address changes are moved completely to jurisdiction of userspace daemon. This way the daemon can do FOM1, FOM2 and possibly other weird things with mac addresses. Only round-robin mode sets up all ports to bond's address then enslaved. - Extended Kconfig text v3->v4: - remove redundant synchronize_rcu from __team_change_mode() - revert "set and clear of mode_ops happens per pointer, not per byte" - extend comment of function __team_change_mode() v2->v3: - team_change_mtu() uses rcu version of list traversal to unwind - set and clear of mode_ops happens per pointer, not per byte - port hashlist changed to be embedded into team structure - error branch in team_port_enter() does cleanup now - fixed rtln->rtnl v1->v2: - modes are made as modules. Makes team more modular and extendable. - several commenters' nitpicks found on v1 were fixed - several other bugs were fixed. - note I ignored Eric's comment about roundrobin port selector as Eric's way may be easily implemented as another mode (mode "random") in future. Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--Documentation/networking/team.txt2
-rw-r--r--MAINTAINERS7
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/team/Kconfig43
-rw-r--r--drivers/net/team/Makefile7
-rw-r--r--drivers/net/team/team.c1583
-rw-r--r--drivers/net/team/team_mode_activebackup.c137
-rw-r--r--drivers/net/team/team_mode_roundrobin.c107
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/if.h1
-rw-r--r--include/linux/if_team.h242
12 files changed, 2133 insertions, 0 deletions
<
diff --git a/Documentation/networking/team.txt b/Documentation/networking/team.txt
new file mode 100644
index 000000000000..5a013686b9ea
--- /dev/null
+++ b/Documentation/networking/team.txt
@@ -0,0 +1,2 @@
1Team devices are driven from userspace via libteam library which is here:
2 https://github.com/jpirko/libteam
diff --git a/MAINTAINERS b/MAINTAINERS
index 4808256446f2..8d941692c394 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6484,6 +6484,13 @@ W: http://tcp-lp-mod.sourceforge.net/
6484S: Maintained 6484S: Maintained
6485F: net/ipv4/tcp_lp.c 6485F: net/ipv4/tcp_lp.c
6486 6486
6487TEAM DRIVER
6488M: Jiri Pirko <jpirko@redhat.com>
6489L: netdev@vger.kernel.org
6490S: Supported
6491F: drivers/net/team/
6492F: include/linux/if_team.h
6493
6487TEGRA SUPPORT 6494TEGRA SUPPORT
6488M: Colin Cross <ccross@android.com> 6495M: Colin Cross <ccross@android.com>
6489M: Olof Johansson <olof@lixom.net> 6496M: Olof Johansson <olof@lixom.net>
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 583f66cd5bbd..b3020bea39e4 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -125,6 +125,8 @@ config IFB
125 'ifb1' etc. 125 'ifb1' etc.
126 Look at the iproute2 documentation directory for usage etc 126 Look at the iproute2 documentation directory for usage etc
127 127
128source "drivers/net/team/Kconfig"
129
128config MACVLAN 130config MACVLAN
129 tristate "MAC-VLAN support (EXPERIMENTAL)" 131 tristate "MAC-VLAN support (EXPERIMENTAL)"
130 depends on EXPERIMENTAL 132 depends on EXPERIMENTAL
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index fa877cd2b139..4e4ebfe1aa53 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_NET) += Space.o loopback.o
17obj-$(CONFIG_NETCONSOLE) += netconsole.o 17obj-$(CONFIG_NETCONSOLE) += netconsole.o
18obj-$(CONFIG_PHYLIB) += phy/ 18obj-$(CONFIG_PHYLIB) += phy/
19obj-$(CONFIG_RIONET) += rionet.o 19obj-$(CONFIG_RIONET) += rionet.o
20obj-$(CONFIG_NET_TEAM) += team/
20obj-$(CONFIG_TUN) += tun.o 21obj-$(CONFIG_TUN) += tun.o
21obj-$(CONFIG_VETH) += veth.o 22obj-$(CONFIG_VETH) += veth.o
22obj-$(CONFIG_VIRTIO_NET) += virtio_net.o 23obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
diff --git a/drivers/net/team/Kconfig b/drivers/net/team/Kconfig
new file mode 100644
index 000000000000..248a144033ca
--- /dev/null
+++ b/drivers/net/team/Kconfig
@@ -0,0 +1,43 @@
1menuconfig NET_TEAM
2 tristate "Ethernet team driver support (EXPERIMENTAL)"
3 depends on EXPERIMENTAL
4 ---help---
5 This allows one to create virtual interfaces that teams together
6 multiple ethernet devices.
7
8 Team devices can be added using the "ip" command from the
9 iproute2 package:
10
11 "ip link add link [ address MAC ] [ NAME ] type team"
12
13 To compile this driver as a module, choose M here: the module
14 will be called team.
15
16if NET_TEAM
17
18config NET_TEAM_MODE_ROUNDROBIN
19 tristate "Round-robin mode support"
20 depends on NET_TEAM
21 ---help---
22 Basic mode where port used for transmitting packets is selected in
23 round-robin fashion using packet counter.
24
25 All added ports are setup to have bond's mac address.
26
27 To compile this team mode as a module, choose M here: the module
28 will be called team_mode_roundrobin.
29
30config NET_TEAM_MODE_ACTIVEBACKUP
31 tristate "Active-backup mode support"
32 depends on NET_TEAM
33 ---help---
34 Only one port is active at a time and the rest of ports are used
35 for backup.
36
37 Mac addresses of ports are not modified. Userspace is responsible
38 to do so.
39
40 To compile this team mode as a module, choose M here: the module
41 will be called team_mode_activebackup.
42
43endif # NET_TEAM
diff --git a/drivers/net/team/Makefile b/drivers/net/team/Makefile
new file mode 100644
index 000000000000..85f2028a87af
--- /dev/null
+++ b/drivers/net/team/Makefile
@@ -0,0 +1,7 @@
1#
2# Makefile for the network team driver
3#
4
5obj-$(CONFIG_NET_TEAM) += team.o
6obj-$(CONFIG_NET_TEAM_MODE_ROUNDROBIN) += team_mode_roundrobin.o
7obj-$(CONFIG_NET_TEAM_MODE_ACTIVEBACKUP) += team_mode_activebackup.o
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
new file mode 100644
index 000000000000..60672bb09960
--- /dev/null
+++ b/drivers/net/team/team.c
@@ -0,0 +1,1583 @@
1/*
2 * net/drivers/team/team.c - Network team device driver
3 * Copyright (c) 2011 Jiri Pirko <jpirko@redhat.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/slab.h>
16#include <linux/rcupdate.h>
17#include <linux/errno.h>
18#include <linux/ctype.h>
19#include <linux/notifier.h>
20#include <linux/netdevice.h>
21#include <linux/if_arp.h>
22#include <linux/socket.h>
23#include <linux/etherdevice.h>
24#include <linux/rtnetlink.h>
25#include <net/rtnetlink.h>
26#include <net/genetlink.h>
27#include <net/netlink.h>
28#include <linux/if_team.h>
29
30#define DRV_NAME "team"
31
32
33/**********
34 * Helpers
35 **********/
36
37#define team_port_exists(dev) (dev->priv_flags & IFF_TEAM_PORT)
38
39static struct team_port *team_port_get_rcu(const struct net_device *dev)
40{
41 struct team_port *port = rcu_dereference(dev->rx_handler_data);
42
43 return team_port_exists(dev) ? port : NULL;
44}
45
46static struct team_port *team_port_get_rtnl(const struct net_device *dev)
47{
48 struct team_port *port = rtnl_dereference(dev->rx_handler_data);
49
50 return team_port_exists(dev) ? port : NULL;
51}
52
53/*
54 * Since the ability to change mac address for open port device is tested in
55 * team_port_add, this function can be called without control of return value
56 */
57static int __set_port_mac(struct net_device *port_dev,
58 const unsigned char *dev_addr)
59{
60 struct sockaddr addr;
61
62 memcpy(addr.sa_data, dev_addr, ETH_ALEN);
63 addr.sa_family = ARPHRD_ETHER;
64 return dev_set_mac_address(port_dev, &addr);
65}
66
67int team_port_set_orig_mac(struct team_port *port)
68{
69 return __set_port_mac(port->dev, port->orig.dev_addr);
70}
71
72int team_port_set_team_mac(struct team_port *port)
73{
74 return __set_port_mac(port->dev, port->team->dev->dev_addr);
75}
76EXPORT_SYMBOL(team_port_set_team_mac);
77
78
79/*******************
80 * Options handling
81 *******************/
82
83void team_options_register(struct team *team, struct team_option *option,
84 size_t option_count)
85{
86 int i;
87
88 for (i = 0; i < option_count; i++, option++)
89 list_add_tail(&option->list, &team->option_list);
90}