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