Index: sbin/ifconfig/iflagg.c =================================================================== --- sbin/ifconfig/iflagg.c +++ sbin/ifconfig/iflagg.c @@ -114,10 +114,13 @@ bzero(&ro, sizeof(ro)); strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname)); - ro.ro_bkt = (int)strtol(val, NULL, 10); + ro.ro_opts = LAGG_OPT_RR_LIMIT; + ro.ro_bkt = (uint32_t)strtoul(val, NULL, 10); + if (ro.ro_bkt == 0) + errx(1, "Invalid round-robin stride: %s", val); if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0) - err(1, "SIOCSLAGG"); + err(1, "SIOCSLAGGOPTS"); } static void Index: sys/net/if_lagg.h =================================================================== --- sys/net/if_lagg.h +++ sys/net/if_lagg.h @@ -63,11 +63,11 @@ #define LAGG_PROTO_DEFAULT LAGG_PROTO_FAILOVER #define LAGG_PROTOS { \ - { "failover", LAGG_PROTO_FAILOVER }, \ + { "failover", LAGG_PROTO_FAILOVER }, \ { "lacp", LAGG_PROTO_LACP }, \ { "loadbalance", LAGG_PROTO_LOADBALANCE }, \ - { "roundrobin", LAGG_PROTO_ROUNDROBIN }, \ - { "broadcast", LAGG_PROTO_BROADCAST }, \ + { "roundrobin", LAGG_PROTO_ROUNDROBIN }, \ + { "broadcast", LAGG_PROTO_BROADCAST }, \ { "none", LAGG_PROTO_NONE }, \ { "default", LAGG_PROTO_DEFAULT } \ } @@ -149,6 +149,7 @@ #define LAGG_OPT_LACP_TXTEST 0x20 /* LACP debug: txtest */ #define LAGG_OPT_LACP_RXTEST 0x40 /* LACP debug: rxtest */ #define LAGG_OPT_LACP_TIMEOUT 0x80 /* LACP timeout */ +#define LAGG_OPT_RR_LIMIT 0x100 /* RR stride */ u_int ro_count; /* number of ports */ u_int ro_active; /* active port count */ u_int ro_flapping; /* number of flapping */ Index: sys/net/if_lagg.c =================================================================== --- sys/net/if_lagg.c +++ sys/net/if_lagg.c @@ -1257,21 +1257,18 @@ /* * The stride option was added without defining a corresponding - * LAGG_OPT flag, so we must handle it before processing any - * remaining options. + * LAGG_OPT flag, so handle a non-zero value before checking + * anything else to preserve compatibility. */ LAGG_XLOCK(sc); - if (ro->ro_bkt != 0) { + if (ro->ro_opts == 0 && ro->ro_bkt != 0) { if (sc->sc_proto != LAGG_PROTO_ROUNDROBIN) { LAGG_XUNLOCK(sc); error = EINVAL; break; } sc->sc_stride = ro->ro_bkt; - } else { - sc->sc_stride = 0; } - if (ro->ro_opts == 0) { LAGG_XUNLOCK(sc); break; @@ -1289,6 +1286,7 @@ case LAGG_OPT_USE_NUMA: case -LAGG_OPT_USE_NUMA: case LAGG_OPT_FLOWIDSHIFT: + case LAGG_OPT_RR_LIMIT: valid = 1; lacp = 0; break; @@ -1314,14 +1312,23 @@ LAGG_XUNLOCK(sc); break; /* Return from SIOCSLAGGOPTS. */ } + /* * Store new options into sc->sc_opts except for - * FLOWIDSHIFT and LACP options. + * FLOWIDSHIFT, RR and LACP options. */ if (lacp == 0) { if (ro->ro_opts == LAGG_OPT_FLOWIDSHIFT) sc->flowid_shift = ro->ro_flowid_shift; - else if (ro->ro_opts > 0) + else if (ro->ro_opts == LAGG_OPT_RR_LIMIT) { + if (sc->sc_proto != LAGG_PROTO_ROUNDROBIN || + ro->ro_bkt == 0) { + error = EINVAL; + LAGG_XUNLOCK(sc); + break; + } + sc->sc_stride = ro->ro_bkt; + } else if (ro->ro_opts > 0) sc->sc_opts |= ro->ro_opts; else sc->sc_opts &= ~ro->ro_opts; @@ -2046,6 +2053,7 @@ lagg_rr_attach(struct lagg_softc *sc) { sc->sc_seq = 0; + sc->sc_stride = 1; } static int @@ -2055,9 +2063,7 @@ uint32_t p; p = atomic_fetchadd_32(&sc->sc_seq, 1); - if (sc->sc_stride > 0) - p /= sc->sc_stride; - + p /= sc->sc_stride; p %= sc->sc_count; lp = CK_SLIST_FIRST(&sc->sc_ports);