Deleted Added
sdiff udiff text old ( 272386 ) new ( 272446 )
full compact
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 $";
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;
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)
95 errx(1, "Invalid flowid_shift option: %s", val);
96
97 if (ioctl(s, SIOCSLAGG, &ra) != 0)
98 err(1, "SIOCSLAGG");
99}
100
101static void
102setlaggsetopt(const char *val, int d, int s, const struct afswtch *afp)
103{
104 struct lagg_reqall ra;
105
106 bzero(&ra, sizeof(ra));
107 ra.ra_opts = d;
108 switch (ra.ra_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 }
121 strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
122
123 if (ioctl(s, SIOCSLAGG, &ra) != 0)
124 err(1, "SIOCSLAGG");
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_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));
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
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",
245 (ra.ra_opts & LAGG_OPT_USE_FLOWID) ? 1 : 0);
246 printf("\t\tflowid_shift: %d\n", ra.ra_flowid_shift);
247 switch (ra.ra_proto) {
248 case LAGG_PROTO_LACP:
249 printf("\t\tlacp_strict: %d\n",
250 (ra.ra_opts & LAGG_OPT_LACP_STRICT) ? 1 : 0);
251 printf("\t\tlacp_rxtest: %d\n",
252 (ra.ra_opts & LAGG_OPT_LACP_RXTEST) ? 1 : 0);
253 printf("\t\tlacp_txtest: %d\n",
254 (ra.ra_opts & LAGG_OPT_LACP_TXTEST) ? 1 : 0);
255 }
256 printf("\tlagg statistics:\n");
257 printf("\t\tactive ports: %d\n", ra.ra_active);
258 printf("\t\tflapping: %u\n", ra.ra_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 ---