Skip to contentSkip to conversation

net: introduce ethernet teaming device

PATCH Superseded Jiri Pirko 2 participants 5 messages Oct 26, 2011 – Nov 10, 2011

Subsystems (5)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH v6 1/1 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 basis for libteam was recently introduced (some need still need to be done on it though). Daemon providing arpmon/miimon active-backup functionality will be introduced shortly. All what's necessary is already implemented in kernel team driver.

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.

---
 Documentation/networking/team.txt         |    2 +
 MAINTAINERS                               |    7 +
 drivers/net/Kconfig                       |    2 +
 drivers/net/Makefile                      |    1 +
 drivers/net/team/Kconfig                  |   43 +
 drivers/net/team/Makefile                 |    7 +
 drivers/net/team/team.c                   | 1555 +++++++++++++++++++++++++++++
 drivers/net/team/team_mode_activebackup.c |  137 +++
 drivers/net/team/team_mode_roundrobin.c   |  107 ++
 include/linux/Kbuild                      |    1 +
 include/linux/if.h                        |    1 +
 include/linux/if_team.h                   |  242 +++++
 12 files changed, 2105 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/networking/team.txt
 create mode 100644 drivers/net/team/Kconfig
 create mode 100644 drivers/net/team/Makefile
 create mode 100644 drivers/net/team/team.c
 create mode 100644 drivers/net/team/team_mode_activebackup.c
 create mode 100644 drivers/net/team/team_mode_roundrobin.c
 create mode 100644 include/linux/if_team.h
Documentation/networking/team.txt new file +2 -0
new file mode 100644
index 0000000..5a01368
@@ -0,0 +1,2 @@
+Team devices are driven from userspace via libteam library which is here:
+	https://github.com/jpirko/libteam
MAINTAINERS +7 -0
index bb4a83a..a20c84e 100644
@@ -6372,6 +6372,13 @@ W:	http://tcp-lp-mod.sourceforge.net/
 S:	Maintained
 F:	net/ipv4/tcp_lp.c
 
+TEAM DRIVER
+M:	Jiri Pirko <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/net/team/
+F:	include/linux/if_team.h
+
 TEGRA SUPPORT
 M:	Colin Cross <[email protected]>
 M:	Olof Johansson <[email protected]>
drivers/net/Kconfig +2 -0
index 583f66c..b3020be 100644
@@ -125,6 +125,8 @@ config IFB
 	  'ifb1' etc.
 	  Look at the iproute2 documentation directory for usage etc
 
+source "drivers/net/team/Kconfig"
+
 config MACVLAN
 	tristate "MAC-VLAN support (EXPERIMENTAL)"
 	depends on EXPERIMENTAL
drivers/net/Makefile +1 -0
index fa877cd..4e4ebfe 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_NET) += Space.o loopback.o
 obj-$(CONFIG_NETCONSOLE) += netconsole.o
 obj-$(CONFIG_PHYLIB) += phy/
 obj-$(CONFIG_RIONET) += rionet.o
+obj-$(CONFIG_NET_TEAM) += team/
 obj-$(CONFIG_TUN) += tun.o
 obj-$(CONFIG_VETH) += veth.o
 obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
drivers/net/team/Kconfig new file +43 -0

43 lines not on this page · raw message

drivers/net/team/Makefile new file +7 -0
new file mode 100644
index 0000000..85f2028
@@ -0,0 +1,7 @@
+#
+# Makefile for the network team driver
+#
+
+obj-$(CONFIG_NET_TEAM) += team.o
+obj-$(CONFIG_NET_TEAM_MODE_ROUNDROBIN) += team_mode_roundrobin.o
+obj-$(CONFIG_NET_TEAM_MODE_ACTIVEBACKUP) += team_mode_activebackup.o
drivers/net/team/team.c new file +1555 -0

1,555 lines not on this page · raw message

drivers/net/team/team_mode_activebackup.c new file +137 -0

137 lines not on this page · raw message

drivers/net/team/team_mode_roundrobin.c new file +107 -0

107 lines not on this page · raw message

include/linux/Kbuild +1 -0
index 619b565..0b091b3 100644
@@ -185,6 +185,7 @@ header-y += if_pppol2tp.h
 header-y += if_pppox.h
 header-y += if_slip.h
 header-y += if_strip.h
+header-y += if_team.h
 header-y += if_tr.h
 header-y += if_tun.h
 header-y += if_tunnel.h
include/linux/if.h +1 -0
index db20bd4..06b6ef6 100644
@@ -79,6 +79,7 @@
 #define IFF_TX_SKB_SHARING	0x10000	/* The interface supports sharing
 					 * skbs on transmit */
 #define IFF_UNICAST_FLT	0x20000		/* Supports unicast filtering	*/
+#define IFF_TEAM_PORT	0x40000		/* device used as team port */
 
 #define IF_GET_IFACE	0x0001		/* for querying only */
 #define IF_GET_PROTO	0x0002
include/linux/if_team.h new file +242 -0

242 lines not on this page · raw message

Signature · 1 line
1.7.6
#1 lore raw

PATCH 1/1 libteam: fix function names to include 'bond'

---

I found those while trying to test V6 patch using latest libteam (commit 5e9790816606a6dd4e7f6f32c0bb0c45e5d13b31) and libnl-3.2.2 (last stable).
thanks,
fbl

 lib/libteam.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
lib/libteam.c +2 -2
index feb13b6..e7ae6b0 100644
@@ -1331,7 +1331,7 @@ int team_port_add(struct team_handle *th, uint32_t port_ifindex)
 {
 	int err;
 
-	err = rtnl_link_enslave_ifindex(th->nl_cli.sock, th->ifindex,
+	err = rtnl_link_bond_enslave_ifindex(th->nl_cli.sock, th->ifindex,
 					port_ifindex);
 	return -nl2syserr(err);
 }
@@ -1350,6 +1350,6 @@ int team_port_remove(struct team_handle *th, uint32_t port_ifindex)
 {
 	int err;
 
-	err = rtnl_link_release_ifindex(th->nl_cli.sock, port_ifindex);
+	err = rtnl_link_bond_release_ifindex(th->nl_cli.sock, port_ifindex);
 	return -nl2syserr(err);
 }
Signature · 1 line
1.7.6
author
#2 lore raw

Re: [PATCH] libteam: fix function names to include 'bond'

Hi Flavio.

Thomas included these 2 functions in latest libnl upstream. Bond versions wouldn't work because of "bond" type check.

Jirka

Quoted 36 lines · Wed, Nov 09, 2011 at 07:20:46PM CET, [email protected] wrote:

---

I found those while trying to test V6 patch using latest libteam (commit 5e9790816606a6dd4e7f6f32c0bb0c45e5d13b31) and libnl-3.2.2 (last stable).
thanks,
fbl

lib/libteam.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
lib/libteam.c +2 -2
index feb13b6..e7ae6b0 100644
@@ -1331,7 +1331,7 @@ int team_port_add(struct team_handle *th, uint32_t port_ifindex)
 {
 	int err;
 
-	err = rtnl_link_enslave_ifindex(th->nl_cli.sock, th->ifindex,
+	err = rtnl_link_bond_enslave_ifindex(th->nl_cli.sock, th->ifindex,
 					port_ifindex);
 	return -nl2syserr(err);
 }
@@ -1350,6 +1350,6 @@ int team_port_remove(struct team_handle *th, uint32_t port_ifindex)
 {
 	int err;
 
-	err = rtnl_link_release_ifindex(th->nl_cli.sock, port_ifindex);
+	err = rtnl_link_bond_release_ifindex(th->nl_cli.sock, port_ifindex);
 	return -nl2syserr(err);
 }
Signature · 1 line
1.7.6
#3 lore raw

Re: [PATCH] libteam: fix function names to include 'bond'

Quoted 6 lines · On Wed, 9 Nov 2011 23:04:25 +0100 Jiri Pirko <[email protected]> wrote:

Hi Flavio.

Thomas included these 2 functions in latest libnl upstream. Bond versions wouldn't work because of "bond" type check.

Yeah, my first option would be using git repo, but the one mentioned in the page seems to be off and I am not finding another one. Do you have the repo url handy?

Anyway, I've tried here with my patch applied and it didn't work. Every packet transmitted increased TX dropped in ifconfig team0 output. The tcpdump attached to the slave doesn't show anything, the packets appear only when attached to team0.

When I ping the team0 host from another host, both slave and team0 RX dropped increases at the same rate. tcpdump attached to the slave shows the packet coming.

Well, maybe this is an effect of having used the wrong libnl version, though the team_monitor seems to be working just fine. (patch applied on top of net-next of today, commit e56c57d,
followed the exact same steps as in HOWTO.BASICS)

I am planning to upgrade the system to the new fedora and try again after that. If I have time, I will follow up with fresh results.

thanks,
fbl

Quoted 45 lines

Jirka

Quoted 42 lines · Wed, Nov 09, 2011 at 07:20:46PM CET, [email protected] wrote:

---

I found those while trying to test V6 patch using latest libteam (commit 5e9790816606a6dd4e7f6f32c0bb0c45e5d13b31) and libnl-3.2.2 (last stable).
thanks,
fbl

lib/libteam.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
lib/libteam.c +1 -1
index feb13b6..e7ae6b0 100644
@@ -1331,7 +1331,7 @@ int team_port_add(struct team_handle *th,
 uint32_t port_ifindex)
 {
 	int err;
 
-	err = rtnl_link_enslave_ifindex(th->nl_cli.sock,
 th->ifindex,
+	err = rtnl_link_bond_enslave_ifindex(th->nl_cli.sock,
 th->ifindex,
					port_ifindex);
	return -nl2syserr(err);
}
lib/libteam.c +1 -1
@@ -1350,6 +1350,6 @@ int team_port_remove(struct team_handle *th,
 uint32_t port_ifindex)
 {
 	int err;
 
-	err = rtnl_link_release_ifindex(th->nl_cli.sock,
 port_ifindex);
+	err = rtnl_link_bond_release_ifindex(th->nl_cli.sock,
port_ifindex);
	return -nl2syserr(err);
}
Signature · 1 line
1.7.6
author
#4 lore raw

Re: [PATCH] libteam: fix function names to include 'bond'

Quoted 6 lines · Thu, Nov 10, 2011 at 12:23:08AM CET, [email protected] wrote:
Quoted 3 lines · On Wed, 9 Nov 2011 23:04:25 +0100 Jiri Pirko <[email protected]> wrote:

Hi Flavio.

Quoted 7 lines
Quoted 3 lines

Thomas included these 2 functions in latest libnl upstream. Bond versions wouldn't work because of "bond" type check.

Yeah, my first option would be using git repo, but the one mentioned in the page seems to be off and I am not finding another one. Do you have the repo url handy?

git://git.infradead.org/users/tgr/libnl.git

Quoted 6 lines

Anyway, I've tried here with my patch applied and it didn't work. Every packet transmitted increased TX dropped in ifconfig team0 output. The tcpdump attached to the slave doesn't show anything, the packets appear only when attached to team0.

Quoted 8 lines

When I ping the team0 host from another host, both slave and team0 RX dropped increases at the same rate. tcpdump attached to the slave shows the packet coming.

Well, maybe this is an effect of having used the wrong libnl version, though the team_monitor seems to be working just fine. (patch applied on top of net-next of today, commit e56c57d, followed the exact same steps as in HOWTO.BASICS)

Oh. I changed activebackup mode behaviour in V4 or V5 of kernel patch. Now it's needed to adjust mac address of ports by hand. I'll refresh HOWTO.BASICS shortly.

Quoted 54 lines

I am planning to upgrade the system to the new fedora and try again after that. If I have time, I will follow up with fresh results.

thanks,
fbl

Quoted 45 lines

Jirka

Quoted 42 lines · Wed, Nov 09, 2011 at 07:20:46PM CET, [email protected] wrote:

---

I found those while trying to test V6 patch using latest libteam (commit 5e9790816606a6dd4e7f6f32c0bb0c45e5d13b31) and libnl-3.2.2 (last stable).
thanks,
fbl

lib/libteam.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
lib/libteam.c +1 -1
index feb13b6..e7ae6b0 100644
@@ -1331,7 +1331,7 @@ int team_port_add(struct team_handle *th,
 uint32_t port_ifindex)
 {
 	int err;
 
-	err = rtnl_link_enslave_ifindex(th->nl_cli.sock,
 th->ifindex,
+	err = rtnl_link_bond_enslave_ifindex(th->nl_cli.sock,
 th->ifindex,
					port_ifindex);
	return -nl2syserr(err);
}
lib/libteam.c +1 -1
@@ -1350,6 +1350,6 @@ int team_port_remove(struct team_handle *th,
 uint32_t port_ifindex)
 {
 	int err;
 
-	err = rtnl_link_release_ifindex(th->nl_cli.sock,
 port_ifindex);
+	err = rtnl_link_bond_release_ifindex(th->nl_cli.sock,
port_ifindex);
	return -nl2syserr(err);
}
Signature · 1 line
1.7.6