]> git.proxmox.com Git - mirror_iproute2.git/blob - bridge/vlan.c
9f4a7a2be55c4d81700993a8415fac46d221aa20
[mirror_iproute2.git] / bridge / vlan.c
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <fcntl.h>
6 #include <sys/socket.h>
7 #include <net/if.h>
8 #include <netinet/in.h>
9 #include <linux/if_bridge.h>
10 #include <linux/if_ether.h>
11 #include <string.h>
12
13 #include "json_print.h"
14 #include "libnetlink.h"
15 #include "br_common.h"
16 #include "utils.h"
17
18 static unsigned int filter_index, filter_vlan;
19 static int show_vlan_tunnel_info = 0;
20
21 static void usage(void)
22 {
23 fprintf(stderr,
24 "Usage: bridge vlan { add | del } vid VLAN_ID dev DEV [ tunnel_info id TUNNEL_ID ]\n"
25 " [ pvid ] [ untagged ]\n"
26 " [ self ] [ master ]\n"
27 " bridge vlan { show } [ dev DEV ] [ vid VLAN_ID ]\n"
28 " bridge vlan { tunnelshow } [ dev DEV ] [ vid VLAN_ID ]\n");
29 exit(-1);
30 }
31
32 static int parse_tunnel_info(int *argcp, char ***argvp, __u32 *tun_id_start,
33 __u32 *tun_id_end)
34 {
35 char **argv = *argvp;
36 int argc = *argcp;
37 char *t;
38
39 NEXT_ARG();
40 if (!matches(*argv, "id")) {
41 NEXT_ARG();
42 t = strchr(*argv, '-');
43 if (t) {
44 *t = '\0';
45 if (get_u32(tun_id_start, *argv, 0) ||
46 *tun_id_start >= 1u << 24)
47 invarg("invalid tun id", *argv);
48 if (get_u32(tun_id_end, t + 1, 0) ||
49 *tun_id_end >= 1u << 24)
50 invarg("invalid tun id", *argv);
51
52 } else {
53 if (get_u32(tun_id_start, *argv, 0) ||
54 *tun_id_start >= 1u << 24)
55 invarg("invalid tun id", *argv);
56 }
57 } else {
58 invarg("tunnel id expected", *argv);
59 }
60
61 *argcp = argc;
62 *argvp = argv;
63
64 return 0;
65 }
66
67 static int add_tunnel_info(struct nlmsghdr *n, int reqsize,
68 __u16 vid, __u32 tun_id, __u16 flags)
69 {
70 struct rtattr *tinfo;
71
72 tinfo = addattr_nest(n, reqsize, IFLA_BRIDGE_VLAN_TUNNEL_INFO);
73 addattr32(n, reqsize, IFLA_BRIDGE_VLAN_TUNNEL_ID, tun_id);
74 addattr32(n, reqsize, IFLA_BRIDGE_VLAN_TUNNEL_VID, vid);
75 addattr32(n, reqsize, IFLA_BRIDGE_VLAN_TUNNEL_FLAGS, flags);
76
77 addattr_nest_end(n, tinfo);
78
79 return 0;
80 }
81
82 static int add_tunnel_info_range(struct nlmsghdr *n, int reqsize,
83 __u16 vid_start, int16_t vid_end,
84 __u32 tun_id_start, __u32 tun_id_end)
85 {
86 if (vid_end != -1 && (vid_end - vid_start) > 0) {
87 add_tunnel_info(n, reqsize, vid_start, tun_id_start,
88 BRIDGE_VLAN_INFO_RANGE_BEGIN);
89
90 add_tunnel_info(n, reqsize, vid_end, tun_id_end,
91 BRIDGE_VLAN_INFO_RANGE_END);
92 } else {
93 add_tunnel_info(n, reqsize, vid_start, tun_id_start, 0);
94 }
95
96 return 0;
97 }
98
99 static int add_vlan_info_range(struct nlmsghdr *n, int reqsize, __u16 vid_start,
100 int16_t vid_end, __u16 flags)
101 {
102 struct bridge_vlan_info vinfo = {};
103
104 vinfo.flags = flags;
105 vinfo.vid = vid_start;
106 if (vid_end != -1) {
107 /* send vlan range start */
108 addattr_l(n, reqsize, IFLA_BRIDGE_VLAN_INFO, &vinfo,
109 sizeof(vinfo));
110 vinfo.flags &= ~BRIDGE_VLAN_INFO_RANGE_BEGIN;
111
112 /* Now send the vlan range end */
113 vinfo.flags |= BRIDGE_VLAN_INFO_RANGE_END;
114 vinfo.vid = vid_end;
115 addattr_l(n, reqsize, IFLA_BRIDGE_VLAN_INFO, &vinfo,
116 sizeof(vinfo));
117 } else {
118 addattr_l(n, reqsize, IFLA_BRIDGE_VLAN_INFO, &vinfo,
119 sizeof(vinfo));
120 }
121
122 return 0;
123 }
124
125 static int vlan_modify(int cmd, int argc, char **argv)
126 {
127 struct {
128 struct nlmsghdr n;
129 struct ifinfomsg ifm;
130 char buf[1024];
131 } req = {
132 .n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)),
133 .n.nlmsg_flags = NLM_F_REQUEST,
134 .n.nlmsg_type = cmd,
135 .ifm.ifi_family = PF_BRIDGE,
136 };
137 char *d = NULL;
138 short vid = -1;
139 short vid_end = -1;
140 struct rtattr *afspec;
141 struct bridge_vlan_info vinfo = {};
142 bool tunnel_info_set = false;
143 unsigned short flags = 0;
144 __u32 tun_id_start = 0;
145 __u32 tun_id_end = 0;
146
147 while (argc > 0) {
148 if (strcmp(*argv, "dev") == 0) {
149 NEXT_ARG();
150 d = *argv;
151 } else if (strcmp(*argv, "vid") == 0) {
152 char *p;
153
154 NEXT_ARG();
155 p = strchr(*argv, '-');
156 if (p) {
157 *p = '\0';
158 p++;
159 vid = atoi(*argv);
160 vid_end = atoi(p);
161 vinfo.flags |= BRIDGE_VLAN_INFO_RANGE_BEGIN;
162 } else {
163 vid = atoi(*argv);
164 }
165 } else if (strcmp(*argv, "self") == 0) {
166 flags |= BRIDGE_FLAGS_SELF;
167 } else if (strcmp(*argv, "master") == 0) {
168 flags |= BRIDGE_FLAGS_MASTER;
169 } else if (strcmp(*argv, "pvid") == 0) {
170 vinfo.flags |= BRIDGE_VLAN_INFO_PVID;
171 } else if (strcmp(*argv, "untagged") == 0) {
172 vinfo.flags |= BRIDGE_VLAN_INFO_UNTAGGED;
173 } else if (strcmp(*argv, "tunnel_info") == 0) {
174 if (parse_tunnel_info(&argc, &argv,
175 &tun_id_start,
176 &tun_id_end))
177 return -1;
178 tunnel_info_set = true;
179 } else {
180 if (matches(*argv, "help") == 0)
181 NEXT_ARG();
182 }
183 argc--; argv++;
184 }
185
186 if (d == NULL || vid == -1) {
187 fprintf(stderr, "Device and VLAN ID are required arguments.\n");
188 return -1;
189 }
190
191 req.ifm.ifi_index = ll_name_to_index(d);
192 if (req.ifm.ifi_index == 0) {
193 fprintf(stderr, "Cannot find bridge device \"%s\"\n", d);
194 return -1;
195 }
196
197 if (vid >= 4096) {
198 fprintf(stderr, "Invalid VLAN ID \"%hu\"\n", vid);
199 return -1;
200 }
201
202 if (vinfo.flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) {
203 if (vid_end == -1 || vid_end >= 4096 || vid >= vid_end) {
204 fprintf(stderr, "Invalid VLAN range \"%hu-%hu\"\n",
205 vid, vid_end);
206 return -1;
207 }
208 if (vinfo.flags & BRIDGE_VLAN_INFO_PVID) {
209 fprintf(stderr,
210 "pvid cannot be configured for a vlan range\n");
211 return -1;
212 }
213 }
214
215 afspec = addattr_nest(&req.n, sizeof(req), IFLA_AF_SPEC);
216
217 if (flags)
218 addattr16(&req.n, sizeof(req), IFLA_BRIDGE_FLAGS, flags);
219
220 if (tunnel_info_set)
221 add_tunnel_info_range(&req.n, sizeof(req), vid, vid_end,
222 tun_id_start, tun_id_end);
223 else
224 add_vlan_info_range(&req.n, sizeof(req), vid, vid_end,
225 vinfo.flags);
226
227 addattr_nest_end(&req.n, afspec);
228
229 if (rtnl_talk(&rth, &req.n, NULL) < 0)
230 return -1;
231
232 return 0;
233 }
234
235 /* In order to use this function for both filtering and non-filtering cases
236 * we need to make it a tristate:
237 * return -1 - if filtering we've gone over so don't continue
238 * return 0 - skip entry and continue (applies to range start or to entries
239 * which are less than filter_vlan)
240 * return 1 - print the entry and continue
241 */
242 static int filter_vlan_check(__u16 vid, __u16 flags)
243 {
244 /* if we're filtering we should stop on the first greater entry */
245 if (filter_vlan && vid > filter_vlan &&
246 !(flags & BRIDGE_VLAN_INFO_RANGE_END))
247 return -1;
248 if ((flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) ||
249 vid < filter_vlan)
250 return 0;
251
252 return 1;
253 }
254
255 static void print_vlan_port(FILE *fp, int ifi_index)
256 {
257 print_string(PRINT_ANY, NULL, "%s",
258 ll_index_to_name(ifi_index));
259 }
260
261 static void print_range(const char *name, __u16 start, __u16 id)
262 {
263 char end[64];
264
265 snprintf(end, sizeof(end), "%sEnd", name);
266
267 print_hu(PRINT_ANY, name, "\t %hu", start);
268 if (start != id)
269 print_hu(PRINT_ANY, end, "-%hu", id);
270
271 }
272
273 static void print_vlan_tunnel_info(FILE *fp, struct rtattr *tb, int ifindex)
274 {
275 struct rtattr *i, *list = tb;
276 int rem = RTA_PAYLOAD(list);
277 __u16 last_vid_start = 0;
278 __u32 last_tunid_start = 0;
279
280 if (!filter_vlan)
281 print_vlan_port(fp, ifindex);
282
283 open_json_array(PRINT_JSON, "tunnel");
284 for (i = RTA_DATA(list); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
285 struct rtattr *ttb[IFLA_BRIDGE_VLAN_TUNNEL_MAX+1];
286 __u32 tunnel_id = 0;
287 __u16 tunnel_vid = 0;
288 __u16 tunnel_flags = 0;
289 int vcheck_ret;
290
291 if (i->rta_type != IFLA_BRIDGE_VLAN_TUNNEL_INFO)
292 continue;
293
294 parse_rtattr(ttb, IFLA_BRIDGE_VLAN_TUNNEL_MAX,
295 RTA_DATA(i), RTA_PAYLOAD(i));
296
297 if (ttb[IFLA_BRIDGE_VLAN_TUNNEL_VID])
298 tunnel_vid =
299 rta_getattr_u32(ttb[IFLA_BRIDGE_VLAN_TUNNEL_VID]);
300 else
301 continue;
302
303 if (ttb[IFLA_BRIDGE_VLAN_TUNNEL_ID])
304 tunnel_id =
305 rta_getattr_u32(ttb[IFLA_BRIDGE_VLAN_TUNNEL_ID]);
306
307 if (ttb[IFLA_BRIDGE_VLAN_TUNNEL_FLAGS])
308 tunnel_flags =
309 rta_getattr_u32(ttb[IFLA_BRIDGE_VLAN_TUNNEL_FLAGS]);
310
311 if (!(tunnel_flags & BRIDGE_VLAN_INFO_RANGE_END)) {
312 last_vid_start = tunnel_vid;
313 last_tunid_start = tunnel_id;
314 }
315
316 vcheck_ret = filter_vlan_check(tunnel_vid, tunnel_flags);
317 if (vcheck_ret == -1)
318 break;
319 else if (vcheck_ret == 0)
320 continue;
321
322 if (tunnel_flags & BRIDGE_VLAN_INFO_RANGE_BEGIN)
323 continue;
324
325 if (filter_vlan)
326 print_vlan_port(fp, ifindex);
327
328 open_json_object(NULL);
329 print_range("vlan", last_vid_start, tunnel_vid);
330 print_range("tunid", last_tunid_start, tunnel_id);
331 close_json_object();
332
333 if (!is_json_context())
334 fprintf(fp, "\n");
335
336 }
337 close_json_array(PRINT_JSON, NULL);
338 }
339
340 static int print_vlan_tunnel(const struct sockaddr_nl *who,
341 struct nlmsghdr *n,
342 void *arg)
343 {
344 struct ifinfomsg *ifm = NLMSG_DATA(n);
345 struct rtattr *tb[IFLA_MAX+1];
346 int len = n->nlmsg_len;
347 FILE *fp = arg;
348
349 if (n->nlmsg_type != RTM_NEWLINK) {
350 fprintf(stderr, "Not RTM_NEWLINK: %08x %08x %08x\n",
351 n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
352 return 0;
353 }
354
355 len -= NLMSG_LENGTH(sizeof(*ifm));
356 if (len < 0) {
357 fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
358 return -1;
359 }
360
361 if (ifm->ifi_family != AF_BRIDGE)
362 return 0;
363
364 if (filter_index && filter_index != ifm->ifi_index)
365 return 0;
366
367 parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifm), len);
368
369 /* if AF_SPEC isn't there, vlan table is not preset for this port */
370 if (!tb[IFLA_AF_SPEC]) {
371 if (!filter_vlan && !is_json_context()) {
372 color_fprintf(fp, COLOR_IFNAME, "%s",
373 ll_index_to_name(ifm->ifi_index));
374 fprintf(fp, "\tNone\n");
375 }
376 return 0;
377 }
378
379 print_vlan_tunnel_info(fp, tb[IFLA_AF_SPEC], ifm->ifi_index);
380
381 fflush(fp);
382 return 0;
383 }
384
385 static int print_vlan(const struct sockaddr_nl *who,
386 struct nlmsghdr *n,
387 void *arg)
388 {
389 FILE *fp = arg;
390 struct ifinfomsg *ifm = NLMSG_DATA(n);
391 int len = n->nlmsg_len;
392 struct rtattr *tb[IFLA_MAX+1];
393
394 if (n->nlmsg_type != RTM_NEWLINK) {
395 fprintf(stderr, "Not RTM_NEWLINK: %08x %08x %08x\n",
396 n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
397 return 0;
398 }
399
400 len -= NLMSG_LENGTH(sizeof(*ifm));
401 if (len < 0) {
402 fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
403 return -1;
404 }
405
406 if (ifm->ifi_family != AF_BRIDGE)
407 return 0;
408
409 if (filter_index && filter_index != ifm->ifi_index)
410 return 0;
411
412 parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifm), len);
413
414 /* if AF_SPEC isn't there, vlan table is not preset for this port */
415 if (!tb[IFLA_AF_SPEC]) {
416 if (!filter_vlan && !is_json_context()) {
417 color_fprintf(fp, COLOR_IFNAME, "%s",
418 ll_index_to_name(ifm->ifi_index));
419 fprintf(fp, "\tNone\n");
420 }
421 return 0;
422 }
423
424 print_vlan_port(fp, ifm->ifi_index);
425 print_vlan_info(fp, tb[IFLA_AF_SPEC]);
426
427 fflush(fp);
428 return 0;
429 }
430
431 static void print_vlan_flags(__u16 flags)
432 {
433 if (flags & BRIDGE_VLAN_INFO_PVID)
434 print_null(PRINT_ANY, "pvid", " %s", "PVID");
435
436 if (flags & BRIDGE_VLAN_INFO_UNTAGGED)
437 print_null(PRINT_ANY, "untagged", " %s", "untagged");
438 }
439
440 static void print_one_vlan_stats(const struct bridge_vlan_xstats *vstats)
441 {
442 open_json_object(NULL);
443 print_hu(PRINT_ANY, "vid", " %hu", vstats->vid);
444
445 print_vlan_flags(vstats->flags);
446
447 print_lluint(PRINT_ANY, "rx_bytes",
448 "\n RX: %llu bytes",
449 vstats->rx_bytes);
450 print_lluint(PRINT_ANY, "rx_packets", " %llu packets\n",
451 vstats->rx_packets);
452 print_lluint(PRINT_ANY, "tx_bytes",
453 " TX: %llu bytes",
454 vstats->tx_bytes);
455 print_lluint(PRINT_ANY, "tx_packets", " %llu packets",
456 vstats->tx_packets);
457 close_json_object();
458 }
459
460 static void print_vlan_stats_attr(struct rtattr *attr, int ifindex)
461 {
462 struct rtattr *brtb[LINK_XSTATS_TYPE_MAX+1];
463 struct rtattr *i, *list;
464 int rem;
465
466 parse_rtattr(brtb, LINK_XSTATS_TYPE_MAX, RTA_DATA(attr),
467 RTA_PAYLOAD(attr));
468 if (!brtb[LINK_XSTATS_TYPE_BRIDGE])
469 return;
470
471 list = brtb[LINK_XSTATS_TYPE_BRIDGE];
472 rem = RTA_PAYLOAD(list);
473
474 open_json_object(NULL);
475
476 print_color_string(PRINT_ANY, COLOR_IFNAME,
477 "dev", "%-16s",
478 ll_index_to_name(ifindex));
479
480 open_json_array(PRINT_JSON, "xstats");
481 for (i = RTA_DATA(list); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
482 const struct bridge_vlan_xstats *vstats = RTA_DATA(i);
483
484 if (i->rta_type != BRIDGE_XSTATS_VLAN)
485 continue;
486
487 if (filter_vlan && filter_vlan != vstats->vid)
488 continue;
489
490 /* skip pure port entries, they'll be dumped via the slave stats call */
491 if ((vstats->flags & BRIDGE_VLAN_INFO_MASTER) &&
492 !(vstats->flags & BRIDGE_VLAN_INFO_BRENTRY))
493 continue;
494
495 print_one_vlan_stats(vstats);
496 }
497 close_json_array(PRINT_ANY, "\n");
498 close_json_object();
499
500 }
501
502 static int print_vlan_stats(const struct sockaddr_nl *who,
503 struct nlmsghdr *n,
504 void *arg)
505 {
506 struct if_stats_msg *ifsm = NLMSG_DATA(n);
507 struct rtattr *tb[IFLA_STATS_MAX+1];
508 int len = n->nlmsg_len;
509 FILE *fp = arg;
510
511 len -= NLMSG_LENGTH(sizeof(*ifsm));
512 if (len < 0) {
513 fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
514 return -1;
515 }
516
517 if (filter_index && filter_index != ifsm->ifindex)
518 return 0;
519
520 parse_rtattr(tb, IFLA_STATS_MAX, IFLA_STATS_RTA(ifsm), len);
521
522 /* We have to check if any of the two attrs are usable */
523 if (tb[IFLA_STATS_LINK_XSTATS])
524 print_vlan_stats_attr(tb[IFLA_STATS_LINK_XSTATS],
525 ifsm->ifindex);
526
527 if (tb[IFLA_STATS_LINK_XSTATS_SLAVE])
528 print_vlan_stats_attr(tb[IFLA_STATS_LINK_XSTATS_SLAVE],
529 ifsm->ifindex);
530
531 fflush(fp);
532 return 0;
533 }
534
535 static int vlan_show(int argc, char **argv)
536 {
537 char *filter_dev = NULL;
538 int ret = 0;
539
540 while (argc > 0) {
541 if (strcmp(*argv, "dev") == 0) {
542 NEXT_ARG();
543 if (filter_dev)
544 duparg("dev", *argv);
545 filter_dev = *argv;
546 } else if (strcmp(*argv, "vid") == 0) {
547 NEXT_ARG();
548 if (filter_vlan)
549 duparg("vid", *argv);
550 filter_vlan = atoi(*argv);
551 }
552 argc--; argv++;
553 }
554
555 if (filter_dev) {
556 filter_index = ll_name_to_index(filter_dev);
557 if (filter_index == 0) {
558 fprintf(stderr, "Cannot find device \"%s\"\n",
559 filter_dev);
560 return -1;
561 }
562 }
563
564 new_json_obj(json);
565
566 if (!show_stats) {
567 if (rtnl_wilddump_req_filter(&rth, PF_BRIDGE, RTM_GETLINK,
568 (compress_vlans ?
569 RTEXT_FILTER_BRVLAN_COMPRESSED :
570 RTEXT_FILTER_BRVLAN)) < 0) {
571 perror("Cannont send dump request");
572 exit(1);
573 }
574
575 if (!is_json_context()) {
576 if (show_vlan_tunnel_info)
577 printf("port\tvlan ids\ttunnel id\n");
578 else
579 printf("port\tvlan ids\n");
580 }
581
582 if (show_vlan_tunnel_info)
583 ret = rtnl_dump_filter(&rth, print_vlan_tunnel,
584 stdout);
585 else
586 ret = rtnl_dump_filter(&rth, print_vlan, stdout);
587 if (ret < 0) {
588 fprintf(stderr, "Dump ternminated\n");
589 exit(1);
590 }
591 } else {
592 __u32 filt_mask;
593
594 filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS);
595 if (rtnl_wilddump_stats_req_filter(&rth, AF_UNSPEC,
596 RTM_GETSTATS,
597 filt_mask) < 0) {
598 perror("Cannont send dump request");
599 exit(1);
600 }
601
602 if (!is_json_context())
603 printf("%-16s vlan id\n", "port");
604
605 if (rtnl_dump_filter(&rth, print_vlan_stats, stdout) < 0) {
606 fprintf(stderr, "Dump terminated\n");
607 exit(1);
608 }
609
610 filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS_SLAVE);
611 if (rtnl_wilddump_stats_req_filter(&rth, AF_UNSPEC,
612 RTM_GETSTATS,
613 filt_mask) < 0) {
614 perror("Cannont send slave dump request");
615 exit(1);
616 }
617
618 if (rtnl_dump_filter(&rth, print_vlan_stats, stdout) < 0) {
619 fprintf(stderr, "Dump terminated\n");
620 exit(1);
621 }
622 }
623
624 delete_json_obj();
625 fflush(stdout);
626 return 0;
627 }
628
629 void print_vlan_info(FILE *fp, struct rtattr *tb)
630 {
631 struct rtattr *i, *list = tb;
632 int rem = RTA_PAYLOAD(list);
633 __u16 last_vid_start = 0;
634
635 if (!is_json_context())
636 fprintf(fp, "%s", _SL_);
637
638 open_json_array(PRINT_JSON, "vlan");
639
640 for (i = RTA_DATA(list); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
641 struct bridge_vlan_info *vinfo;
642 int vcheck_ret;
643
644 if (i->rta_type != IFLA_BRIDGE_VLAN_INFO)
645 continue;
646
647 vinfo = RTA_DATA(i);
648
649 if (!(vinfo->flags & BRIDGE_VLAN_INFO_RANGE_END))
650 last_vid_start = vinfo->vid;
651 vcheck_ret = filter_vlan_check(vinfo->vid, vinfo->flags);
652 if (vcheck_ret == -1)
653 break;
654 else if (vcheck_ret == 0)
655 continue;
656
657 open_json_object(NULL);
658 print_range("vlan", last_vid_start, vinfo->vid);
659
660 print_vlan_flags(vinfo->flags);
661 close_json_object();
662 }
663
664 close_json_array(PRINT_ANY, "\n");
665 }
666
667 int do_vlan(int argc, char **argv)
668 {
669 ll_init_map(&rth);
670
671 if (argc > 0) {
672 if (matches(*argv, "add") == 0)
673 return vlan_modify(RTM_SETLINK, argc-1, argv+1);
674 if (matches(*argv, "delete") == 0)
675 return vlan_modify(RTM_DELLINK, argc-1, argv+1);
676 if (matches(*argv, "show") == 0 ||
677 matches(*argv, "lst") == 0 ||
678 matches(*argv, "list") == 0)
679 return vlan_show(argc-1, argv+1);
680 if (matches(*argv, "tunnelshow") == 0) {
681 show_vlan_tunnel_info = 1;
682 return vlan_show(argc-1, argv+1);
683 }
684 if (matches(*argv, "help") == 0)
685 usage();
686 } else {
687 return vlan_show(0, NULL);
688 }
689
690 fprintf(stderr, "Command \"%s\" is unknown, try \"bridge vlan help\".\n", *argv);
691 exit(-1);
692 }