aboutsummaryrefslogtreecommitdiff
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorHiroki Sato <hrs@FreeBSD.org>2014-10-02 20:01:13 +0000
committerHiroki Sato <hrs@FreeBSD.org>2014-10-02 20:01:13 +0000
commit9732189ca9738cb356e550d291e5bce78fc6a7ec (patch)
tree8d305540de855e3d9297a747b3d32f393253d873 /sbin/ifconfig
parenta85f6c30437e1e248729023716b64aac1b4cd259 (diff)
downloadsrc-9732189ca9738cb356e550d291e5bce78fc6a7ec.tar.gz
src-9732189ca9738cb356e550d291e5bce78fc6a7ec.zip
Separate option handling from SIOC[SG]LAGG to SIOC[SG]LAGGOPTS for
backward compatibility with old ifconfig(8).
Notes
Notes: svn path=/head/; revision=272446
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/iflagg.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/sbin/ifconfig/iflagg.c b/sbin/ifconfig/iflagg.c
index edb6121634b1..9c478b3dfc5f 100644
--- a/sbin/ifconfig/iflagg.c
+++ b/sbin/ifconfig/iflagg.c
@@ -85,27 +85,27 @@ setlaggproto(const char *val, int d, int s, const struct afswtch *afp)
static void
setlaggflowidshift(const char *val, int d, int s, const struct afswtch *afp)
{
- struct lagg_reqall ra;
+ struct lagg_reqopts ro;
- bzero(&ra, sizeof(ra));
- ra.ra_opts = LAGG_OPT_FLOWIDSHIFT;
- strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
- ra.ra_flowid_shift = (int)strtol(val, NULL, 10);
- if (ra.ra_flowid_shift & ~LAGG_OPT_FLOWIDSHIFT_MASK)
+ bzero(&ro, sizeof(ro));
+ ro.ro_opts = LAGG_OPT_FLOWIDSHIFT;
+ strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname));
+ ro.ro_flowid_shift = (int)strtol(val, NULL, 10);
+ if (ro.ro_flowid_shift & ~LAGG_OPT_FLOWIDSHIFT_MASK)
errx(1, "Invalid flowid_shift option: %s", val);
- if (ioctl(s, SIOCSLAGG, &ra) != 0)
- err(1, "SIOCSLAGG");
+ if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0)
+ err(1, "SIOCSLAGGOPTS");
}
static void
setlaggsetopt(const char *val, int d, int s, const struct afswtch *afp)
{
- struct lagg_reqall ra;
+ struct lagg_reqopts ro;
- bzero(&ra, sizeof(ra));
- ra.ra_opts = d;
- switch (ra.ra_opts) {
+ bzero(&ro, sizeof(ro));
+ ro.ro_opts = d;
+ switch (ro.ro_opts) {
case LAGG_OPT_USE_FLOWID:
case -LAGG_OPT_USE_FLOWID:
case LAGG_OPT_LACP_STRICT:
@@ -118,10 +118,10 @@ setlaggsetopt(const char *val, int d, int s, const struct afswtch *afp)
default:
err(1, "Invalid lagg option");
}
- strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
+ strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname));
- if (ioctl(s, SIOCSLAGG, &ra) != 0)
- err(1, "SIOCSLAGG");
+ if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0)
+ err(1, "SIOCSLAGGOPTS");
}
static void
@@ -186,6 +186,7 @@ lagg_status(int s)
struct lagg_protos lpr[] = LAGG_PROTOS;
struct lagg_reqport rp, rpbuf[LAGG_MAX_PORTS];
struct lagg_reqall ra;
+ struct lagg_reqopts ro;
struct lagg_reqflags rf;
struct lacp_opreq *lp;
const char *proto = "<unknown>";
@@ -193,6 +194,7 @@ lagg_status(int s)
bzero(&rp, sizeof(rp));
bzero(&ra, sizeof(ra));
+ bzero(&ro, sizeof(ro));
strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
strlcpy(rp.rp_portname, name, sizeof(rp.rp_portname));
@@ -204,6 +206,9 @@ lagg_status(int s)
ra.ra_size = sizeof(rpbuf);
ra.ra_port = rpbuf;
+ strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname));
+ ioctl(s, SIOCGLAGGOPTS, &ro);
+
strlcpy(rf.rf_ifname, name, sizeof(rf.rf_ifname));
if (ioctl(s, SIOCGLAGGFLAGS, &rf) != 0)
rf.rf_flags = 0;
@@ -242,20 +247,20 @@ lagg_status(int s)
if (verbose) {
printf("\tlagg options:\n");
printf("\t\tuse_flowid: %d\n",
- (ra.ra_opts & LAGG_OPT_USE_FLOWID) ? 1 : 0);
- printf("\t\tflowid_shift: %d\n", ra.ra_flowid_shift);
+ (ro.ro_opts & LAGG_OPT_USE_FLOWID) ? 1 : 0);
+ printf("\t\tflowid_shift: %d\n", ro.ro_flowid_shift);
switch (ra.ra_proto) {
case LAGG_PROTO_LACP:
printf("\t\tlacp_strict: %d\n",
- (ra.ra_opts & LAGG_OPT_LACP_STRICT) ? 1 : 0);
+ (ro.ro_opts & LAGG_OPT_LACP_STRICT) ? 1 : 0);
printf("\t\tlacp_rxtest: %d\n",
- (ra.ra_opts & LAGG_OPT_LACP_RXTEST) ? 1 : 0);
+ (ro.ro_opts & LAGG_OPT_LACP_RXTEST) ? 1 : 0);
printf("\t\tlacp_txtest: %d\n",
- (ra.ra_opts & LAGG_OPT_LACP_TXTEST) ? 1 : 0);
+ (ro.ro_opts & LAGG_OPT_LACP_TXTEST) ? 1 : 0);
}
printf("\tlagg statistics:\n");
- printf("\t\tactive ports: %d\n", ra.ra_active);
- printf("\t\tflapping: %u\n", ra.ra_flapping);
+ printf("\t\tactive ports: %d\n", ro.ro_active);
+ printf("\t\tflapping: %u\n", ro.ro_flapping);
if (ra.ra_proto == LAGG_PROTO_LACP) {
printf("\tlag id: %s\n",
lacp_format_peer(lp, "\n\t\t "));