]>
Commit | Line | Data |
---|---|---|
6054c1eb | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
d04bc300 SH |
2 | /* |
3 | * Get/set/delete fdb table with netlink | |
4 | * | |
0849e60a SH |
5 | * TODO: merge/replace this with ip neighbour |
6 | * | |
d04bc300 SH |
7 | * Authors: Stephen Hemminger <shemminger@vyatta.com> |
8 | */ | |
9 | ||
10 | #include <stdio.h> | |
11 | #include <stdlib.h> | |
12 | #include <unistd.h> | |
5f409678 | 13 | #include <netdb.h> |
d04bc300 SH |
14 | #include <time.h> |
15 | #include <fcntl.h> | |
16 | #include <sys/socket.h> | |
17 | #include <sys/time.h> | |
18 | #include <net/if.h> | |
19 | #include <netinet/in.h> | |
20 | #include <linux/if_bridge.h> | |
21 | #include <linux/if_ether.h> | |
22 | #include <linux/neighbour.h> | |
23 | #include <string.h> | |
dd9cc0ee | 24 | #include <limits.h> |
b239c56e | 25 | #include <stdbool.h> |
d04bc300 | 26 | |
c7c1a1ef | 27 | #include "json_print.h" |
d04bc300 SH |
28 | #include "libnetlink.h" |
29 | #include "br_common.h" | |
0849e60a | 30 | #include "rt_names.h" |
d04bc300 SH |
31 | #include "utils.h" |
32 | ||
7f10090b | 33 | static unsigned int filter_index, filter_vlan, filter_state; |
d04bc300 SH |
34 | |
35 | static void usage(void) | |
36 | { | |
bcddcddd SH |
37 | fprintf(stderr, |
38 | "Usage: bridge fdb { add | append | del | replace } ADDR dev DEV\n" | |
39 | " [ self ] [ master ] [ use ] [ router ]\n" | |
40 | " [ local | static | dynamic ] [ dst IPADDR ] [ vlan VID ]\n" | |
41 | " [ port PORT] [ vni VNI ] [ via DEV ]\n" | |
42 | " bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ] [ state STATE ] ]\n"); | |
d04bc300 SH |
43 | exit(-1); |
44 | } | |
45 | ||
df4b043f | 46 | static const char *state_n2a(unsigned int s) |
d04bc300 SH |
47 | { |
48 | static char buf[32]; | |
49 | ||
0849e60a SH |
50 | if (s & NUD_PERMANENT) |
51 | return "permanent"; | |
d04bc300 SH |
52 | |
53 | if (s & NUD_NOARP) | |
54 | return "static"; | |
55 | ||
56 | if (s & NUD_STALE) | |
57 | return "stale"; | |
0849e60a | 58 | |
d04bc300 SH |
59 | if (s & NUD_REACHABLE) |
60 | return ""; | |
61 | ||
62 | sprintf(buf, "state=%#x", s); | |
63 | return buf; | |
64 | } | |
65 | ||
7f10090b NA |
66 | static int state_a2n(unsigned int *s, const char *arg) |
67 | { | |
68 | if (matches(arg, "permanent") == 0) | |
69 | *s = NUD_PERMANENT; | |
70 | else if (matches(arg, "static") == 0 || matches(arg, "temp") == 0) | |
71 | *s = NUD_NOARP; | |
72 | else if (matches(arg, "stale") == 0) | |
73 | *s = NUD_STALE; | |
74 | else if (matches(arg, "reachable") == 0 || matches(arg, "dynamic") == 0) | |
75 | *s = NUD_REACHABLE; | |
76 | else if (strcmp(arg, "all") == 0) | |
77 | *s = ~0; | |
78 | else if (get_unsigned(s, arg, 0)) | |
79 | return -1; | |
80 | ||
81 | return 0; | |
82 | } | |
83 | ||
c7c1a1ef SH |
84 | static void fdb_print_flags(FILE *fp, unsigned int flags) |
85 | { | |
86 | open_json_array(PRINT_JSON, | |
87 | is_json_context() ? "flags" : ""); | |
88 | ||
89 | if (flags & NTF_SELF) | |
90 | print_string(PRINT_ANY, NULL, "%s ", "self"); | |
91 | ||
92 | if (flags & NTF_ROUTER) | |
93 | print_string(PRINT_ANY, NULL, "%s ", "router"); | |
94 | ||
95 | if (flags & NTF_EXT_LEARNED) | |
96 | print_string(PRINT_ANY, NULL, "%s ", "extern_learn"); | |
97 | ||
98 | if (flags & NTF_OFFLOADED) | |
99 | print_string(PRINT_ANY, NULL, "%s ", "offload"); | |
100 | ||
101 | if (flags & NTF_MASTER) | |
102 | print_string(PRINT_ANY, NULL, "%s ", "master"); | |
103 | ||
104 | close_json_array(PRINT_JSON, NULL); | |
105 | } | |
106 | ||
107 | static void fdb_print_stats(FILE *fp, const struct nda_cacheinfo *ci) | |
b239c56e | 108 | { |
c7c1a1ef SH |
109 | static int hz; |
110 | ||
111 | if (!hz) | |
112 | hz = get_user_hz(); | |
113 | ||
114 | if (is_json_context()) { | |
115 | print_uint(PRINT_JSON, "used", NULL, | |
116 | ci->ndm_used / hz); | |
117 | print_uint(PRINT_JSON, "updated", NULL, | |
118 | ci->ndm_updated / hz); | |
119 | } else { | |
120 | fprintf(fp, "used %d/%d ", ci->ndm_used / hz, | |
121 | ci->ndm_updated / hz); | |
122 | ||
123 | } | |
b239c56e AK |
124 | } |
125 | ||
d04bc300 SH |
126 | int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) |
127 | { | |
0849e60a | 128 | FILE *fp = arg; |
d04bc300 SH |
129 | struct ndmsg *r = NLMSG_DATA(n); |
130 | int len = n->nlmsg_len; | |
df4b043f | 131 | struct rtattr *tb[NDA_MAX+1]; |
ae6eb907 | 132 | __u16 vid = 0; |
0849e60a SH |
133 | |
134 | if (n->nlmsg_type != RTM_NEWNEIGH && n->nlmsg_type != RTM_DELNEIGH) { | |
135 | fprintf(stderr, "Not RTM_NEWNEIGH: %08x %08x %08x\n", | |
136 | n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags); | |
0849e60a SH |
137 | return 0; |
138 | } | |
d04bc300 SH |
139 | |
140 | len -= NLMSG_LENGTH(sizeof(*r)); | |
141 | if (len < 0) { | |
142 | fprintf(stderr, "BUG: wrong nlmsg len %d\n", len); | |
143 | return -1; | |
144 | } | |
145 | ||
146 | if (r->ndm_family != AF_BRIDGE) | |
147 | return 0; | |
148 | ||
149 | if (filter_index && filter_index != r->ndm_ifindex) | |
150 | return 0; | |
151 | ||
7f10090b NA |
152 | if (filter_state && !(r->ndm_state & filter_state)) |
153 | return 0; | |
154 | ||
d04bc300 SH |
155 | parse_rtattr(tb, NDA_MAX, NDA_RTA(r), |
156 | n->nlmsg_len - NLMSG_LENGTH(sizeof(*r))); | |
157 | ||
ae6eb907 NA |
158 | if (tb[NDA_VLAN]) |
159 | vid = rta_getattr_u16(tb[NDA_VLAN]); | |
160 | ||
161 | if (filter_vlan && filter_vlan != vid) | |
162 | return 0; | |
163 | ||
c7c1a1ef SH |
164 | open_json_object(NULL); |
165 | if (n->nlmsg_type == RTM_DELNEIGH) | |
166 | print_bool(PRINT_ANY, "deleted", "Deleted ", true); | |
0849e60a SH |
167 | |
168 | if (tb[NDA_LLADDR]) { | |
c7c1a1ef | 169 | const char *lladdr; |
0849e60a | 170 | SPRINT_BUF(b1); |
c7c1a1ef SH |
171 | |
172 | lladdr = ll_addr_n2a(RTA_DATA(tb[NDA_LLADDR]), | |
173 | RTA_PAYLOAD(tb[NDA_LLADDR]), | |
174 | ll_index_to_type(r->ndm_ifindex), | |
175 | b1, sizeof(b1)); | |
176 | ||
177 | print_color_string(PRINT_ANY, COLOR_MAC, | |
178 | "mac", "%s ", lladdr); | |
d04bc300 | 179 | } |
38df7ac9 | 180 | |
b239c56e | 181 | if (!filter_index && r->ndm_ifindex) { |
c7c1a1ef SH |
182 | if (!is_json_context()) |
183 | fprintf(fp, "dev "); | |
184 | print_color_string(PRINT_ANY, COLOR_IFNAME, | |
185 | "ifname", "%s ", | |
186 | ll_index_to_name(r->ndm_ifindex)); | |
b239c56e | 187 | } |
0849e60a SH |
188 | |
189 | if (tb[NDA_DST]) { | |
9e763fa5 | 190 | int family = AF_INET; |
c7c1a1ef | 191 | const char *dst; |
9e763fa5 MR |
192 | |
193 | if (RTA_PAYLOAD(tb[NDA_DST]) == sizeof(struct in6_addr)) | |
194 | family = AF_INET6; | |
195 | ||
c7c1a1ef SH |
196 | dst = format_host(family, |
197 | RTA_PAYLOAD(tb[NDA_DST]), | |
198 | RTA_DATA(tb[NDA_DST])); | |
b239c56e | 199 | |
c7c1a1ef SH |
200 | print_color_string(PRINT_ANY, |
201 | ifa_family_color(family), | |
202 | "dst", "%s ", dst); | |
b239c56e AK |
203 | } |
204 | ||
c7c1a1ef SH |
205 | if (vid) |
206 | print_uint(PRINT_ANY, | |
207 | "vlan", "vlan %hu ", vid); | |
38df7ac9 | 208 | |
c7c1a1ef SH |
209 | if (tb[NDA_PORT]) |
210 | print_uint(PRINT_ANY, | |
211 | "port", "port %u ", | |
212 | rta_getattr_be16(tb[NDA_PORT])); | |
fd08839c | 213 | |
c7c1a1ef SH |
214 | if (tb[NDA_VNI]) |
215 | print_uint(PRINT_ANY, | |
216 | "vni", "vni %u ", | |
217 | rta_getattr_u32(tb[NDA_VNI])); | |
218 | ||
219 | if (tb[NDA_SRC_VNI]) | |
220 | print_uint(PRINT_ANY, | |
221 | "src_vni", "src_vni %u ", | |
86d0988b | 222 | rta_getattr_u32(tb[NDA_SRC_VNI])); |
86d0988b | 223 | |
5f409678 DS |
224 | if (tb[NDA_IFINDEX]) { |
225 | unsigned int ifindex = rta_getattr_u32(tb[NDA_IFINDEX]); | |
226 | ||
c7c1a1ef SH |
227 | if (tb[NDA_LINK_NETNSID]) |
228 | print_uint(PRINT_ANY, | |
229 | "viaIfIndex", "via ifindex %u ", | |
230 | ifindex); | |
b239c56e | 231 | else |
c7c1a1ef SH |
232 | print_string(PRINT_ANY, |
233 | "viaIf", "via %s ", | |
234 | ll_index_to_name(ifindex)); | |
b239c56e | 235 | } |
5f409678 | 236 | |
c7c1a1ef SH |
237 | if (tb[NDA_LINK_NETNSID]) |
238 | print_uint(PRINT_ANY, | |
239 | "linkNetNsId", "link-netnsid %d ", | |
240 | rta_getattr_u32(tb[NDA_LINK_NETNSID])); | |
d04bc300 | 241 | |
c7c1a1ef SH |
242 | if (show_stats && tb[NDA_CACHEINFO]) |
243 | fdb_print_stats(fp, RTA_DATA(tb[NDA_CACHEINFO])); | |
b239c56e | 244 | |
c7c1a1ef | 245 | fdb_print_flags(fp, r->ndm_flags); |
b239c56e | 246 | |
b239c56e | 247 | |
c7c1a1ef SH |
248 | if (tb[NDA_MASTER]) |
249 | print_string(PRINT_ANY, "master", "%s ", | |
250 | ll_index_to_name(rta_getattr_u32(tb[NDA_MASTER]))); | |
4d45bf3b | 251 | |
c7c1a1ef SH |
252 | print_string(PRINT_ANY, "state", "%s\n", |
253 | state_n2a(r->ndm_state)); | |
254 | close_json_object(); | |
255 | fflush(fp); | |
d04bc300 SH |
256 | return 0; |
257 | } | |
258 | ||
259 | static int fdb_show(int argc, char **argv) | |
260 | { | |
aeb14eb0 | 261 | struct { |
df4b043f | 262 | struct nlmsghdr n; |
aeb14eb0 | 263 | struct ifinfomsg ifm; |
df4b043f | 264 | char buf[256]; |
d17b136f PS |
265 | } req = { |
266 | .n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)), | |
267 | .ifm.ifi_family = PF_BRIDGE, | |
268 | }; | |
aeb14eb0 | 269 | |
d04bc300 | 270 | char *filter_dev = NULL; |
aeb14eb0 JHS |
271 | char *br = NULL; |
272 | int msg_size = sizeof(struct ifinfomsg); | |
273 | ||
d04bc300 | 274 | while (argc > 0) { |
aeb14eb0 | 275 | if ((strcmp(*argv, "brport") == 0) || strcmp(*argv, "dev") == 0) { |
d04bc300 | 276 | NEXT_ARG(); |
d04bc300 | 277 | filter_dev = *argv; |
aeb14eb0 JHS |
278 | } else if (strcmp(*argv, "br") == 0) { |
279 | NEXT_ARG(); | |
280 | br = *argv; | |
ae6eb907 NA |
281 | } else if (strcmp(*argv, "vlan") == 0) { |
282 | NEXT_ARG(); | |
283 | if (filter_vlan) | |
284 | duparg("vlan", *argv); | |
285 | filter_vlan = atoi(*argv); | |
7f10090b NA |
286 | } else if (strcmp(*argv, "state") == 0) { |
287 | unsigned int state; | |
288 | ||
289 | NEXT_ARG(); | |
290 | if (state_a2n(&state, *argv)) | |
291 | invarg("invalid state", *argv); | |
292 | filter_state |= state; | |
aeb14eb0 JHS |
293 | } else { |
294 | if (matches(*argv, "help") == 0) | |
295 | usage(); | |
d04bc300 SH |
296 | } |
297 | argc--; argv++; | |
298 | } | |
299 | ||
aeb14eb0 JHS |
300 | if (br) { |
301 | int br_ifindex = ll_name_to_index(br); | |
df4b043f | 302 | |
aeb14eb0 JHS |
303 | if (br_ifindex == 0) { |
304 | fprintf(stderr, "Cannot find bridge device \"%s\"\n", br); | |
305 | return -1; | |
306 | } | |
307 | addattr32(&req.n, sizeof(req), IFLA_MASTER, br_ifindex); | |
308 | msg_size += RTA_LENGTH(4); | |
309 | } | |
310 | ||
311 | /*we'll keep around filter_dev for older kernels */ | |
d04bc300 | 312 | if (filter_dev) { |
7a14358b | 313 | filter_index = ll_name_to_index(filter_dev); |
fe99adbc SP |
314 | if (!filter_index) |
315 | return nodev(filter_dev); | |
aeb14eb0 | 316 | req.ifm.ifi_index = filter_index; |
d04bc300 SH |
317 | } |
318 | ||
aeb14eb0 | 319 | if (rtnl_dump_request(&rth, RTM_GETNEIGH, &req.ifm, msg_size) < 0) { |
d04bc300 SH |
320 | perror("Cannot send dump request"); |
321 | exit(1); | |
322 | } | |
d04bc300 | 323 | |
c7c1a1ef | 324 | new_json_obj(json); |
0849e60a | 325 | if (rtnl_dump_filter(&rth, print_fdb, stdout) < 0) { |
d04bc300 SH |
326 | fprintf(stderr, "Dump terminated\n"); |
327 | exit(1); | |
328 | } | |
c7c1a1ef SH |
329 | delete_json_obj(); |
330 | fflush(stdout); | |
d04bc300 SH |
331 | |
332 | return 0; | |
333 | } | |
334 | ||
335 | static int fdb_modify(int cmd, int flags, int argc, char **argv) | |
336 | { | |
337 | struct { | |
df4b043f SH |
338 | struct nlmsghdr n; |
339 | struct ndmsg ndm; | |
340 | char buf[256]; | |
d17b136f PS |
341 | } req = { |
342 | .n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)), | |
343 | .n.nlmsg_flags = NLM_F_REQUEST | flags, | |
344 | .n.nlmsg_type = cmd, | |
345 | .ndm.ndm_family = PF_BRIDGE, | |
346 | .ndm.ndm_state = NUD_NOARP, | |
347 | }; | |
d04bc300 SH |
348 | char *addr = NULL; |
349 | char *d = NULL; | |
350 | char abuf[ETH_ALEN]; | |
0849e60a SH |
351 | int dst_ok = 0; |
352 | inet_prefix dst; | |
5f409678 DS |
353 | unsigned long port = 0; |
354 | unsigned long vni = ~0; | |
355 | unsigned int via = 0; | |
356 | char *endptr; | |
fd08839c | 357 | short vid = -1; |
d04bc300 | 358 | |
d04bc300 SH |
359 | while (argc > 0) { |
360 | if (strcmp(*argv, "dev") == 0) { | |
361 | NEXT_ARG(); | |
362 | d = *argv; | |
0849e60a SH |
363 | } else if (strcmp(*argv, "dst") == 0) { |
364 | NEXT_ARG(); | |
365 | if (dst_ok) | |
366 | duparg2("dst", *argv); | |
367 | get_addr(&dst, *argv, preferred_family); | |
368 | dst_ok = 1; | |
5f409678 DS |
369 | } else if (strcmp(*argv, "port") == 0) { |
370 | ||
371 | NEXT_ARG(); | |
372 | port = strtoul(*argv, &endptr, 0); | |
373 | if (endptr && *endptr) { | |
374 | struct servent *pse; | |
375 | ||
376 | pse = getservbyname(*argv, "udp"); | |
377 | if (!pse) | |
378 | invarg("invalid port\n", *argv); | |
379 | port = ntohs(pse->s_port); | |
380 | } else if (port > 0xffff) | |
381 | invarg("invalid port\n", *argv); | |
382 | } else if (strcmp(*argv, "vni") == 0) { | |
383 | NEXT_ARG(); | |
384 | vni = strtoul(*argv, &endptr, 0); | |
385 | if ((endptr && *endptr) || | |
386 | (vni >> 24) || vni == ULONG_MAX) | |
387 | invarg("invalid VNI\n", *argv); | |
388 | } else if (strcmp(*argv, "via") == 0) { | |
389 | NEXT_ARG(); | |
7a14358b | 390 | via = ll_name_to_index(*argv); |
fe99adbc SP |
391 | if (!via) |
392 | exit(nodev(*argv)); | |
dc6a6a25 JF |
393 | } else if (strcmp(*argv, "self") == 0) { |
394 | req.ndm.ndm_flags |= NTF_SELF; | |
0849e60a | 395 | } else if (matches(*argv, "master") == 0) { |
dc6a6a25 | 396 | req.ndm.ndm_flags |= NTF_MASTER; |
5b8a1d4a DS |
397 | } else if (matches(*argv, "router") == 0) { |
398 | req.ndm.ndm_flags |= NTF_ROUTER; | |
e9e9365b | 399 | } else if (matches(*argv, "local") == 0 || |
0849e60a SH |
400 | matches(*argv, "permanent") == 0) { |
401 | req.ndm.ndm_state |= NUD_PERMANENT; | |
a1987cd1 RP |
402 | } else if (matches(*argv, "temp") == 0 || |
403 | matches(*argv, "static") == 0) { | |
0849e60a | 404 | req.ndm.ndm_state |= NUD_REACHABLE; |
c6d0cfb5 RP |
405 | } else if (matches(*argv, "dynamic") == 0) { |
406 | req.ndm.ndm_state |= NUD_REACHABLE; | |
407 | req.ndm.ndm_state &= ~NUD_NOARP; | |
fd08839c VY |
408 | } else if (matches(*argv, "vlan") == 0) { |
409 | if (vid >= 0) | |
410 | duparg2("vlan", *argv); | |
411 | NEXT_ARG(); | |
412 | vid = atoi(*argv); | |
cd8df30b RP |
413 | } else if (matches(*argv, "use") == 0) { |
414 | req.ndm.ndm_flags |= NTF_USE; | |
d04bc300 | 415 | } else { |
bcddcddd | 416 | if (strcmp(*argv, "to") == 0) |
d04bc300 | 417 | NEXT_ARG(); |
bcddcddd | 418 | |
0849e60a SH |
419 | if (matches(*argv, "help") == 0) |
420 | usage(); | |
d04bc300 SH |
421 | if (addr) |
422 | duparg2("to", *argv); | |
423 | addr = *argv; | |
424 | } | |
425 | argc--; argv++; | |
426 | } | |
427 | ||
428 | if (d == NULL || addr == NULL) { | |
429 | fprintf(stderr, "Device and address are required arguments.\n"); | |
42ecedd4 | 430 | return -1; |
d04bc300 SH |
431 | } |
432 | ||
0849e60a SH |
433 | /* Assume self */ |
434 | if (!(req.ndm.ndm_flags&(NTF_SELF|NTF_MASTER))) | |
435 | req.ndm.ndm_flags |= NTF_SELF; | |
436 | ||
437 | /* Assume permanent */ | |
438 | if (!(req.ndm.ndm_state&(NUD_PERMANENT|NUD_REACHABLE))) | |
439 | req.ndm.ndm_state |= NUD_PERMANENT; | |
440 | ||
441 | if (sscanf(addr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", | |
d04bc300 SH |
442 | abuf, abuf+1, abuf+2, |
443 | abuf+3, abuf+4, abuf+5) != 6) { | |
444 | fprintf(stderr, "Invalid mac address %s\n", addr); | |
42ecedd4 | 445 | return -1; |
d04bc300 SH |
446 | } |
447 | ||
448 | addattr_l(&req.n, sizeof(req), NDA_LLADDR, abuf, ETH_ALEN); | |
0849e60a SH |
449 | if (dst_ok) |
450 | addattr_l(&req.n, sizeof(req), NDA_DST, &dst.data, dst.bytelen); | |
d04bc300 | 451 | |
fd08839c | 452 | if (vid >= 0) |
8ae66094 | 453 | addattr16(&req.n, sizeof(req), NDA_VLAN, vid); |
fd08839c | 454 | |
5f409678 DS |
455 | if (port) { |
456 | unsigned short dport; | |
457 | ||
458 | dport = htons((unsigned short)port); | |
459 | addattr16(&req.n, sizeof(req), NDA_PORT, dport); | |
460 | } | |
461 | if (vni != ~0) | |
462 | addattr32(&req.n, sizeof(req), NDA_VNI, vni); | |
463 | if (via) | |
464 | addattr32(&req.n, sizeof(req), NDA_IFINDEX, via); | |
465 | ||
d04bc300 | 466 | req.ndm.ndm_ifindex = ll_name_to_index(d); |
fe99adbc SP |
467 | if (!req.ndm.ndm_ifindex) |
468 | return nodev(d); | |
d04bc300 | 469 | |
86bf43c7 | 470 | if (rtnl_talk(&rth, &req.n, NULL) < 0) |
42ecedd4 | 471 | return -1; |
d04bc300 SH |
472 | |
473 | return 0; | |
474 | } | |
475 | ||
476 | int do_fdb(int argc, char **argv) | |
477 | { | |
478 | ll_init_map(&rth); | |
479 | ||
480 | if (argc > 0) { | |
481 | if (matches(*argv, "add") == 0) | |
482 | return fdb_modify(RTM_NEWNEIGH, NLM_F_CREATE|NLM_F_EXCL, argc-1, argv+1); | |
5f409678 DS |
483 | if (matches(*argv, "append") == 0) |
484 | return fdb_modify(RTM_NEWNEIGH, NLM_F_CREATE|NLM_F_APPEND, argc-1, argv+1); | |
5464049b TR |
485 | if (matches(*argv, "replace") == 0) |
486 | return fdb_modify(RTM_NEWNEIGH, NLM_F_CREATE|NLM_F_REPLACE, argc-1, argv+1); | |
d04bc300 SH |
487 | if (matches(*argv, "delete") == 0) |
488 | return fdb_modify(RTM_DELNEIGH, 0, argc-1, argv+1); | |
489 | if (matches(*argv, "show") == 0 || | |
490 | matches(*argv, "lst") == 0 || | |
491 | matches(*argv, "list") == 0) | |
492 | return fdb_show(argc-1, argv+1); | |
493 | if (matches(*argv, "help") == 0) | |
494 | usage(); | |
495 | } else | |
496 | return fdb_show(0, NULL); | |
497 | ||
083b46bb | 498 | fprintf(stderr, "Command \"%s\" is unknown, try \"bridge fdb help\".\n", *argv); |
d04bc300 SH |
499 | exit(-1); |
500 | } |