Changeset View
Changeset View
Standalone View
Standalone View
head/sbin/ifconfig/iflagg.c
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | setlaggflowidshift(const char *val, int d, int s, const struct afswtch *afp) | ||||
if (ro.ro_flowid_shift & ~LAGG_OPT_FLOWIDSHIFT_MASK) | if (ro.ro_flowid_shift & ~LAGG_OPT_FLOWIDSHIFT_MASK) | ||||
errx(1, "Invalid flowid_shift option: %s", val); | errx(1, "Invalid flowid_shift option: %s", val); | ||||
if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0) | if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0) | ||||
err(1, "SIOCSLAGGOPTS"); | err(1, "SIOCSLAGGOPTS"); | ||||
} | } | ||||
static void | static void | ||||
setlaggrr_limit(const char *val, int d, int s, const struct afswtch *afp) | |||||
{ | |||||
struct lagg_reqopts ro; | |||||
bzero(&ro, sizeof(ro)); | |||||
strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname)); | |||||
ro.ro_bkt = (int)strtol(val, NULL, 10); | |||||
if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0) | |||||
err(1, "SIOCSLAGG"); | |||||
} | |||||
static void | |||||
setlaggsetopt(const char *val, int d, int s, const struct afswtch *afp) | setlaggsetopt(const char *val, int d, int s, const struct afswtch *afp) | ||||
{ | { | ||||
struct lagg_reqopts ro; | struct lagg_reqopts ro; | ||||
bzero(&ro, sizeof(ro)); | bzero(&ro, sizeof(ro)); | ||||
ro.ro_opts = d; | ro.ro_opts = d; | ||||
switch (ro.ro_opts) { | switch (ro.ro_opts) { | ||||
case LAGG_OPT_USE_FLOWID: | case LAGG_OPT_USE_FLOWID: | ||||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | if (ioctl(s, SIOCGLAGG, &ra) == 0) { | ||||
if (isport) | if (isport) | ||||
printf(" laggdev %s", rp.rp_ifname); | printf(" laggdev %s", rp.rp_ifname); | ||||
putchar('\n'); | putchar('\n'); | ||||
if (verbose) { | if (verbose) { | ||||
printf("\tlagg options:\n"); | printf("\tlagg options:\n"); | ||||
printb("\t\tflags", ro.ro_opts, LAGG_OPT_BITS); | printb("\t\tflags", ro.ro_opts, LAGG_OPT_BITS); | ||||
putchar('\n'); | putchar('\n'); | ||||
printf("\t\tflowid_shift: %d\n", ro.ro_flowid_shift); | printf("\t\tflowid_shift: %d\n", ro.ro_flowid_shift); | ||||
if (ra.ra_proto == LAGG_PROTO_ROUNDROBIN) | |||||
printf("\t\trr_limit: %d\n", ro.ro_bkt); | |||||
printf("\tlagg statistics:\n"); | printf("\tlagg statistics:\n"); | ||||
printf("\t\tactive ports: %d\n", ro.ro_active); | printf("\t\tactive ports: %d\n", ro.ro_active); | ||||
printf("\t\tflapping: %u\n", ro.ro_flapping); | printf("\t\tflapping: %u\n", ro.ro_flapping); | ||||
if (ra.ra_proto == LAGG_PROTO_LACP) { | if (ra.ra_proto == LAGG_PROTO_LACP) { | ||||
printf("\tlag id: %s\n", | printf("\tlag id: %s\n", | ||||
lacp_format_peer(lp, "\n\t\t ")); | lacp_format_peer(lp, "\n\t\t ")); | ||||
} | } | ||||
} | } | ||||
Show All 30 Lines | static struct cmd lagg_cmds[] = { | ||||
DEF_CMD("-lacp_strict", -LAGG_OPT_LACP_STRICT, setlaggsetopt), | DEF_CMD("-lacp_strict", -LAGG_OPT_LACP_STRICT, setlaggsetopt), | ||||
DEF_CMD("lacp_txtest", LAGG_OPT_LACP_TXTEST, setlaggsetopt), | DEF_CMD("lacp_txtest", LAGG_OPT_LACP_TXTEST, setlaggsetopt), | ||||
DEF_CMD("-lacp_txtest", -LAGG_OPT_LACP_TXTEST, setlaggsetopt), | DEF_CMD("-lacp_txtest", -LAGG_OPT_LACP_TXTEST, setlaggsetopt), | ||||
DEF_CMD("lacp_rxtest", LAGG_OPT_LACP_RXTEST, setlaggsetopt), | DEF_CMD("lacp_rxtest", LAGG_OPT_LACP_RXTEST, setlaggsetopt), | ||||
DEF_CMD("-lacp_rxtest", -LAGG_OPT_LACP_RXTEST, setlaggsetopt), | DEF_CMD("-lacp_rxtest", -LAGG_OPT_LACP_RXTEST, setlaggsetopt), | ||||
DEF_CMD("lacp_fast_timeout", LAGG_OPT_LACP_TIMEOUT, setlaggsetopt), | DEF_CMD("lacp_fast_timeout", LAGG_OPT_LACP_TIMEOUT, setlaggsetopt), | ||||
DEF_CMD("-lacp_fast_timeout", -LAGG_OPT_LACP_TIMEOUT, setlaggsetopt), | DEF_CMD("-lacp_fast_timeout", -LAGG_OPT_LACP_TIMEOUT, setlaggsetopt), | ||||
DEF_CMD_ARG("flowid_shift", setlaggflowidshift), | DEF_CMD_ARG("flowid_shift", setlaggflowidshift), | ||||
DEF_CMD_ARG("rr_limit", setlaggrr_limit), | |||||
}; | }; | ||||
static struct afswtch af_lagg = { | static struct afswtch af_lagg = { | ||||
.af_name = "af_lagg", | .af_name = "af_lagg", | ||||
.af_af = AF_UNSPEC, | .af_af = AF_UNSPEC, | ||||
.af_other_status = lagg_status, | .af_other_status = lagg_status, | ||||
}; | }; | ||||
static __constructor void | static __constructor void | ||||
lagg_ctor(void) | lagg_ctor(void) | ||||
{ | { | ||||
int i; | int i; | ||||
for (i = 0; i < nitems(lagg_cmds); i++) | for (i = 0; i < nitems(lagg_cmds); i++) | ||||
cmd_register(&lagg_cmds[i]); | cmd_register(&lagg_cmds[i]); | ||||
af_register(&af_lagg); | af_register(&af_lagg); | ||||
} | } |