Deleted Added
sdiff udiff text old ( 292402 ) new ( 294615 )
full compact
1/* $OpenBSD: if_trunk.c,v 1.30 2007/01/31 06:20:19 reyk Exp $ */
2
3/*
4 * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
5 * Copyright (c) 2007 Andrew Thompson <thompsa@FreeBSD.org>
6 * Copyright (c) 2014 Marcelo Araujo
7 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21#include <sys/cdefs.h>
22__FBSDID("$FreeBSD: head/sys/net/if_lagg.c 292402 2015-12-17 14:41:30Z smh $");
23
24#include "opt_inet.h"
25#include "opt_inet6.h"
26
27#include <sys/param.h>
28#include <sys/kernel.h>
29#include <sys/malloc.h>
30#include <sys/mbuf.h>

--- 1255 unchanged lines hidden (view full) ---

1286 ro->ro_opts |= LAGG_OPT_LACP_TIMEOUT;
1287
1288 ro->ro_active = sc->sc_active;
1289 } else {
1290 ro->ro_active = 0;
1291 SLIST_FOREACH(lp, &sc->sc_ports, lp_entries)
1292 ro->ro_active += LAGG_PORTACTIVE(lp);
1293 }
1294 ro->ro_flapping = sc->sc_flapping;
1295 ro->ro_flowid_shift = sc->flowid_shift;
1296 break;
1297 case SIOCSLAGGOPTS:
1298 error = priv_check(td, PRIV_NET_LAGG);
1299 if (error)
1300 break;
1301 if (ro->ro_opts == 0)
1302 break;
1303 /*
1304 * Set options. LACP options are stored in sc->sc_psc,
1305 * not in sc_opts.

--- 18 unchanged lines hidden (view full) ---

1324 valid = lacp = 1;
1325 break;
1326 default:
1327 valid = lacp = 0;
1328 break;
1329 }
1330
1331 LAGG_WLOCK(sc);
1332 if (valid == 0 ||
1333 (lacp == 1 && sc->sc_proto != LAGG_PROTO_LACP)) {
1334 /* Invalid combination of options specified. */
1335 error = EINVAL;
1336 LAGG_WUNLOCK(sc);
1337 break; /* Return from SIOCSLAGGOPTS. */
1338 }
1339 /*

--- 534 unchanged lines hidden (view full) ---

1874/*
1875 * Simple round robin aggregation
1876 */
1877static void
1878lagg_rr_attach(struct lagg_softc *sc)
1879{
1880 sc->sc_capabilities = IFCAP_LAGG_FULLDUPLEX;
1881 sc->sc_seq = 0;
1882}
1883
1884static int
1885lagg_rr_start(struct lagg_softc *sc, struct mbuf *m)
1886{
1887 struct lagg_port *lp;
1888 uint32_t p;
1889
1890 p = atomic_fetchadd_32(&sc->sc_seq, 1);
1891 p %= sc->sc_count;
1892 lp = SLIST_FIRST(&sc->sc_ports);
1893 while (p--)
1894 lp = SLIST_NEXT(lp, lp_entries);
1895
1896 /*
1897 * Check the port's link state. This will return the next active
1898 * port if the link is down or the port is NULL.
1899 */
1900 if ((lp = lagg_link_active(sc, lp)) == NULL) {

--- 319 unchanged lines hidden ---