Deleted Added
full compact
iflagg.c (272386) iflagg.c (272446)
1/*-
2 */
3
4#ifndef lint
5static const char rcsid[] =
1/*-
2 */
3
4#ifndef lint
5static const char rcsid[] =
6 "$FreeBSD: head/sbin/ifconfig/iflagg.c 272386 2014-10-01 21:37:32Z hrs $";
6 "$FreeBSD: head/sbin/ifconfig/iflagg.c 272446 2014-10-02 20:01:13Z hrs $";
7#endif /* not lint */
8
9#include <sys/param.h>
10#include <sys/ioctl.h>
11#include <sys/socket.h>
12#include <sys/sockio.h>
13
14#include <stdlib.h>

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

80 strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
81 if (ioctl(s, SIOCSLAGG, &ra) != 0)
82 err(1, "SIOCSLAGG");
83}
84
85static void
86setlaggflowidshift(const char *val, int d, int s, const struct afswtch *afp)
87{
7#endif /* not lint */
8
9#include <sys/param.h>
10#include <sys/ioctl.h>
11#include <sys/socket.h>
12#include <sys/sockio.h>
13
14#include <stdlib.h>

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

80 strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
81 if (ioctl(s, SIOCSLAGG, &ra) != 0)
82 err(1, "SIOCSLAGG");
83}
84
85static void
86setlaggflowidshift(const char *val, int d, int s, const struct afswtch *afp)
87{
88 struct lagg_reqall ra;
88 struct lagg_reqopts ro;
89
89
90 bzero(&ra, sizeof(ra));
91 ra.ra_opts = LAGG_OPT_FLOWIDSHIFT;
92 strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
93 ra.ra_flowid_shift = (int)strtol(val, NULL, 10);
94 if (ra.ra_flowid_shift & ~LAGG_OPT_FLOWIDSHIFT_MASK)
90 bzero(&ro, sizeof(ro));
91 ro.ro_opts = LAGG_OPT_FLOWIDSHIFT;
92 strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname));
93 ro.ro_flowid_shift = (int)strtol(val, NULL, 10);
94 if (ro.ro_flowid_shift & ~LAGG_OPT_FLOWIDSHIFT_MASK)
95 errx(1, "Invalid flowid_shift option: %s", val);
96
95 errx(1, "Invalid flowid_shift option: %s", val);
96
97 if (ioctl(s, SIOCSLAGG, &ra) != 0)
98 err(1, "SIOCSLAGG");
97 if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0)
98 err(1, "SIOCSLAGGOPTS");
99}
100
101static void
102setlaggsetopt(const char *val, int d, int s, const struct afswtch *afp)
103{
99}
100
101static void
102setlaggsetopt(const char *val, int d, int s, const struct afswtch *afp)
103{
104 struct lagg_reqall ra;
104 struct lagg_reqopts ro;
105
105
106 bzero(&ra, sizeof(ra));
107 ra.ra_opts = d;
108 switch (ra.ra_opts) {
106 bzero(&ro, sizeof(ro));
107 ro.ro_opts = d;
108 switch (ro.ro_opts) {
109 case LAGG_OPT_USE_FLOWID:
110 case -LAGG_OPT_USE_FLOWID:
111 case LAGG_OPT_LACP_STRICT:
112 case -LAGG_OPT_LACP_STRICT:
113 case LAGG_OPT_LACP_TXTEST:
114 case -LAGG_OPT_LACP_TXTEST:
115 case LAGG_OPT_LACP_RXTEST:
116 case -LAGG_OPT_LACP_RXTEST:
117 break;
118 default:
119 err(1, "Invalid lagg option");
120 }
109 case LAGG_OPT_USE_FLOWID:
110 case -LAGG_OPT_USE_FLOWID:
111 case LAGG_OPT_LACP_STRICT:
112 case -LAGG_OPT_LACP_STRICT:
113 case LAGG_OPT_LACP_TXTEST:
114 case -LAGG_OPT_LACP_TXTEST:
115 case LAGG_OPT_LACP_RXTEST:
116 case -LAGG_OPT_LACP_RXTEST:
117 break;
118 default:
119 err(1, "Invalid lagg option");
120 }
121 strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
121 strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname));
122
122
123 if (ioctl(s, SIOCSLAGG, &ra) != 0)
124 err(1, "SIOCSLAGG");
123 if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0)
124 err(1, "SIOCSLAGGOPTS");
125}
126
127static void
128setlagghash(const char *val, int d, int s, const struct afswtch *afp)
129{
130 struct lagg_reqflags rf;
131 char *str, *tmp, *tok;
132

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

181}
182
183static void
184lagg_status(int s)
185{
186 struct lagg_protos lpr[] = LAGG_PROTOS;
187 struct lagg_reqport rp, rpbuf[LAGG_MAX_PORTS];
188 struct lagg_reqall ra;
125}
126
127static void
128setlagghash(const char *val, int d, int s, const struct afswtch *afp)
129{
130 struct lagg_reqflags rf;
131 char *str, *tmp, *tok;
132

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

181}
182
183static void
184lagg_status(int s)
185{
186 struct lagg_protos lpr[] = LAGG_PROTOS;
187 struct lagg_reqport rp, rpbuf[LAGG_MAX_PORTS];
188 struct lagg_reqall ra;
189 struct lagg_reqopts ro;
189 struct lagg_reqflags rf;
190 struct lacp_opreq *lp;
191 const char *proto = "<unknown>";
192 int i, isport = 0;
193
194 bzero(&rp, sizeof(rp));
195 bzero(&ra, sizeof(ra));
190 struct lagg_reqflags rf;
191 struct lacp_opreq *lp;
192 const char *proto = "<unknown>";
193 int i, isport = 0;
194
195 bzero(&rp, sizeof(rp));
196 bzero(&ra, sizeof(ra));
197 bzero(&ro, sizeof(ro));
196
197 strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
198 strlcpy(rp.rp_portname, name, sizeof(rp.rp_portname));
199
200 if (ioctl(s, SIOCGLAGGPORT, &rp) == 0)
201 isport = 1;
202
203 strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
204 ra.ra_size = sizeof(rpbuf);
205 ra.ra_port = rpbuf;
206
198
199 strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
200 strlcpy(rp.rp_portname, name, sizeof(rp.rp_portname));
201
202 if (ioctl(s, SIOCGLAGGPORT, &rp) == 0)
203 isport = 1;
204
205 strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
206 ra.ra_size = sizeof(rpbuf);
207 ra.ra_port = rpbuf;
208
209 strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname));
210 ioctl(s, SIOCGLAGGOPTS, &ro);
211
207 strlcpy(rf.rf_ifname, name, sizeof(rf.rf_ifname));
208 if (ioctl(s, SIOCGLAGGFLAGS, &rf) != 0)
209 rf.rf_flags = 0;
210
211 if (ioctl(s, SIOCGLAGG, &ra) == 0) {
212 lp = (struct lacp_opreq *)&ra.ra_lacpreq;
213
214 for (i = 0; i < nitems(lpr); i++) {

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

237 }
238 }
239 if (isport)
240 printf(" laggdev %s", rp.rp_ifname);
241 putchar('\n');
242 if (verbose) {
243 printf("\tlagg options:\n");
244 printf("\t\tuse_flowid: %d\n",
212 strlcpy(rf.rf_ifname, name, sizeof(rf.rf_ifname));
213 if (ioctl(s, SIOCGLAGGFLAGS, &rf) != 0)
214 rf.rf_flags = 0;
215
216 if (ioctl(s, SIOCGLAGG, &ra) == 0) {
217 lp = (struct lacp_opreq *)&ra.ra_lacpreq;
218
219 for (i = 0; i < nitems(lpr); i++) {

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

242 }
243 }
244 if (isport)
245 printf(" laggdev %s", rp.rp_ifname);
246 putchar('\n');
247 if (verbose) {
248 printf("\tlagg options:\n");
249 printf("\t\tuse_flowid: %d\n",
245 (ra.ra_opts & LAGG_OPT_USE_FLOWID) ? 1 : 0);
246 printf("\t\tflowid_shift: %d\n", ra.ra_flowid_shift);
250 (ro.ro_opts & LAGG_OPT_USE_FLOWID) ? 1 : 0);
251 printf("\t\tflowid_shift: %d\n", ro.ro_flowid_shift);
247 switch (ra.ra_proto) {
248 case LAGG_PROTO_LACP:
249 printf("\t\tlacp_strict: %d\n",
252 switch (ra.ra_proto) {
253 case LAGG_PROTO_LACP:
254 printf("\t\tlacp_strict: %d\n",
250 (ra.ra_opts & LAGG_OPT_LACP_STRICT) ? 1 : 0);
255 (ro.ro_opts & LAGG_OPT_LACP_STRICT) ? 1 : 0);
251 printf("\t\tlacp_rxtest: %d\n",
256 printf("\t\tlacp_rxtest: %d\n",
252 (ra.ra_opts & LAGG_OPT_LACP_RXTEST) ? 1 : 0);
257 (ro.ro_opts & LAGG_OPT_LACP_RXTEST) ? 1 : 0);
253 printf("\t\tlacp_txtest: %d\n",
258 printf("\t\tlacp_txtest: %d\n",
254 (ra.ra_opts & LAGG_OPT_LACP_TXTEST) ? 1 : 0);
259 (ro.ro_opts & LAGG_OPT_LACP_TXTEST) ? 1 : 0);
255 }
256 printf("\tlagg statistics:\n");
260 }
261 printf("\tlagg statistics:\n");
257 printf("\t\tactive ports: %d\n", ra.ra_active);
258 printf("\t\tflapping: %u\n", ra.ra_flapping);
262 printf("\t\tactive ports: %d\n", ro.ro_active);
263 printf("\t\tflapping: %u\n", ro.ro_flapping);
259 if (ra.ra_proto == LAGG_PROTO_LACP) {
260 printf("\tlag id: %s\n",
261 lacp_format_peer(lp, "\n\t\t "));
262 }
263 }
264
265 for (i = 0; i < ra.ra_ports; i++) {
266 lp = (struct lacp_opreq *)&rpbuf[i].rp_lacpreq;

--- 50 unchanged lines hidden ---
264 if (ra.ra_proto == LAGG_PROTO_LACP) {
265 printf("\tlag id: %s\n",
266 lacp_format_peer(lp, "\n\t\t "));
267 }
268 }
269
270 for (i = 0; i < ra.ra_ports; i++) {
271 lp = (struct lacp_opreq *)&rpbuf[i].rp_lacpreq;

--- 50 unchanged lines hidden ---