Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F12462
if_lagg-rr2.patch
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
araujo
Aug 7 2014, 1:48 AM
2014-08-07 01:48:38 (UTC+0)
Size
4 KB
Referenced Files
None
Subscribers
None
if_lagg-rr2.patch
View Options
Index: share/man/man4/lagg.4
===================================================================
--- share/man/man4/lagg.4 (revision 269364)
+++ share/man/man4/lagg.4 (working copy)
@@ -1,6 +1,7 @@
.\" $OpenBSD: trunk.4,v 1.18 2006/06/09 13:53:34 jmc Exp $
.\"
.\" Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
+.\" Copyright (c) 2014 Marcelo Araujo <araujo@FreeBSD.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
@@ -110,9 +111,12 @@
The hash includes the Ethernet source and destination address, and, if
available, the VLAN tag, and the IP source and destination address.
.It Ic roundrobin
-Distributes outgoing traffic using a round-robin scheduler
-through all active ports and accepts incoming traffic from
-any active port.
+Distributes outgoing traffic using a round-robin scheduler through all active
+ports and accepts incoming traffic from any active port.
+This mode can cause unordered packet arrival at the client. This has a side
+effect of limiting the throughput as reordering packets can be CPU intensive
+on the client.
+Requires a switch which supports IEEE 802.3ad static link aggregation.
.It Ic none
This protocol is intended to do nothing: it disables any traffic without
disabling the
@@ -149,6 +153,14 @@
The default for new interfaces is set via the
.Va net.link.lagg.default_use_flowid
.Xr sysctl 8 .
+.Pp
+Additionally, the
+.Ic roundrobin
+mode can have the number of packets sent per interface fine tuned via
+.Va net.link.lagg.rr_packets
+.Xr sysctl 8 .
+Its default value is 0, where only one packet will be send per interface
+every round.
.Sh EXAMPLES
Create a link aggregation using LACP with two
.Xr bge 4
Index: sys/net/if_lagg.c
===================================================================
--- sys/net/if_lagg.c (revision 269364)
+++ sys/net/if_lagg.c (working copy)
@@ -3,6 +3,7 @@
/*
* Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
* Copyright (c) 2007 Andrew Thompson <thompsa@FreeBSD.org>
+ * Copyright (c) 2014 Marcelo Araujo <araujo@FreeBSD.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -187,7 +188,18 @@
SYSCTL_INT(_net_link_lagg, OID_AUTO, default_flowid_shift, CTLFLAG_RWTUN,
&def_flowid_shift, 0,
"Default setting for flowid shift for load sharing");
+static int lagg_rr_packets = 0; /* Default value for using rr_packets */
+SYSCTL_INT(_net_link_lagg, OID_AUTO, rr_packets, CTLFLAG_RW,
+ &lagg_rr_packets, 0,
+ "How many packets to be send per interface");
+#define RR_PACKETS_COUNTER(sc) \
+ if (sc->sc_rr_packets != lagg_rr_packets) { \
+ atomic_store_rel_int(&sc->sc_rr_packets, lagg_rr_packets); \
+ atomic_store_rel_int(&sc->sc_bkt, lagg_rr_packets); \
+ }
+
+
static int
lagg_modevent(module_t mod, int type, void *data)
{
@@ -1672,6 +1684,7 @@
sc->sc_port_create = NULL;
sc->sc_capabilities = IFCAP_LAGG_FULLDUPLEX;
sc->sc_seq = 0;
+ sc->sc_bkt = lagg_rr_packets;
return (0);
}
@@ -1688,9 +1701,20 @@
struct lagg_port *lp;
uint32_t p;
- p = atomic_fetchadd_32(&sc->sc_seq, 1);
+ RR_PACKETS_COUNTER(sc);
+
+ if (lagg_rr_packets > 1) {
+ atomic_subtract_int(&sc->sc_bkt, 1);
+ if (atomic_cmpset_int(&sc->sc_bkt, 0, lagg_rr_packets))
+ p = atomic_fetchadd_32(&sc->sc_seq, 1);
+ else
+ p = sc->sc_seq;
+ } else
+ p = atomic_fetchadd_32(&sc->sc_seq, 1);
+
p %= sc->sc_count;
lp = SLIST_FIRST(&sc->sc_ports);
+
while (p--)
lp = SLIST_NEXT(lp, lp_entries);
Index: sys/net/if_lagg.h
===================================================================
--- sys/net/if_lagg.h (revision 269364)
+++ sys/net/if_lagg.h (working copy)
@@ -198,6 +198,8 @@
struct ifmedia sc_media; /* media config */
caddr_t sc_psc; /* protocol data */
uint32_t sc_seq; /* sequence counter */
+ uint32_t sc_bkt; /* packet bucket */
+ uint32_t sc_rr_packets; /* reference for sysctl */
uint32_t sc_flags;
counter_u64_t sc_ipackets;
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
12409
Default Alt Text
if_lagg-rr2.patch (4 KB)
Attached To
Mode
D540: Set a better granularity and distribution on roundrobin protocol.
Attached
Detach File
Event Timeline
Log In to Comment