]> git.proxmox.com Git - mirror_frr.git/blob - pimd/mtracebis_netlink.c
lib: enforce vrf_name_to_id by returning default_vrf when name is null
[mirror_frr.git] / pimd / mtracebis_netlink.c
1 /*
2 * libnetlink.c RTnetlink service routines.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10 *
11 */
12
13 #ifdef HAVE_CONFIG_H
14 #include "config.h"
15 #endif
16
17 #ifdef __linux__
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <unistd.h>
22 #include <syslog.h>
23 #include <fcntl.h>
24 #include <net/if_arp.h>
25 #include <sys/socket.h>
26 #include <netinet/in.h>
27 #include <string.h>
28 #include <errno.h>
29 #include <time.h>
30 #include <sys/uio.h>
31 #include <assert.h>
32
33 #include "mtracebis_netlink.h"
34
35 int rcvbuf = 1024 * 1024;
36
37 void rtnl_close(struct rtnl_handle *rth)
38 {
39 if (rth->fd >= 0) {
40 close(rth->fd);
41 rth->fd = -1;
42 }
43 }
44
45 int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,
46 int protocol)
47 {
48 socklen_t addr_len;
49 int sndbuf = 32768;
50
51 memset(rth, 0, sizeof(*rth));
52
53 rth->fd = socket(AF_NETLINK, SOCK_RAW, protocol);
54 if (rth->fd < 0) {
55 perror("Cannot open netlink socket");
56 return -1;
57 }
58
59 if (setsockopt(rth->fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf))
60 < 0) {
61 perror("SO_SNDBUF");
62 return -1;
63 }
64
65 if (setsockopt(rth->fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf))
66 < 0) {
67 perror("SO_RCVBUF");
68 return -1;
69 }
70
71 memset(&rth->local, 0, sizeof(rth->local));
72 rth->local.nl_family = AF_NETLINK;
73 rth->local.nl_groups = subscriptions;
74
75 if (bind(rth->fd, (struct sockaddr *)&rth->local, sizeof(rth->local))
76 < 0) {
77 perror("Cannot bind netlink socket");
78 return -1;
79 }
80 addr_len = sizeof(rth->local);
81 if (getsockname(rth->fd, (struct sockaddr *)&rth->local, &addr_len)
82 < 0) {
83 perror("Cannot getsockname");
84 return -1;
85 }
86 if (addr_len != sizeof(rth->local)) {
87 fprintf(stderr, "Wrong address length %d\n", addr_len);
88 return -1;
89 }
90 if (rth->local.nl_family != AF_NETLINK) {
91 fprintf(stderr, "Wrong address family %d\n",
92 rth->local.nl_family);
93 return -1;
94 }
95 rth->seq = time(NULL);
96 return 0;
97 }
98
99 int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions)
100 {
101 return rtnl_open_byproto(rth, subscriptions, NETLINK_ROUTE);
102 }
103
104 int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
105 {
106 struct {
107 struct nlmsghdr nlh;
108 struct rtgenmsg g;
109 } req;
110
111 memset(&req, 0, sizeof(req));
112 req.nlh.nlmsg_len = sizeof(req);
113 req.nlh.nlmsg_type = type;
114 req.nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
115 req.nlh.nlmsg_pid = 0;
116 req.nlh.nlmsg_seq = rth->dump = ++rth->seq;
117 req.g.rtgen_family = family;
118
119 return send(rth->fd, (void *)&req, sizeof(req), 0);
120 }
121
122 int rtnl_send(struct rtnl_handle *rth, const char *buf, int len)
123 {
124 return send(rth->fd, buf, len, 0);
125 }
126
127 int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int len)
128 {
129 struct nlmsghdr *h;
130 int status;
131 char resp[1024];
132
133 status = send(rth->fd, buf, len, 0);
134 if (status < 0)
135 return status;
136
137 /* Check for immediate errors */
138 status = recv(rth->fd, resp, sizeof(resp), MSG_DONTWAIT | MSG_PEEK);
139 if (status < 0) {
140 if (errno == EAGAIN)
141 return 0;
142 return -1;
143 }
144
145 for (h = (struct nlmsghdr *)resp; NLMSG_OK(h, (uint32_t)status);
146 h = NLMSG_NEXT(h, status)) {
147 if (h->nlmsg_type == NLMSG_ERROR) {
148 struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(h);
149 if (h->nlmsg_len
150 < NLMSG_LENGTH(sizeof(struct nlmsgerr)))
151 fprintf(stderr, "ERROR truncated\n");
152 else
153 errno = -err->error;
154 return -1;
155 }
156 }
157
158 return 0;
159 }
160
161 int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
162 {
163 struct nlmsghdr nlh;
164 struct sockaddr_nl nladdr;
165 struct iovec iov[2] = {{.iov_base = &nlh, .iov_len = sizeof(nlh)},
166 {.iov_base = req, .iov_len = len}};
167 struct msghdr msg = {
168 .msg_name = &nladdr,
169 .msg_namelen = sizeof(nladdr),
170 .msg_iov = iov,
171 .msg_iovlen = 2,
172 };
173
174 memset(&nladdr, 0, sizeof(nladdr));
175 nladdr.nl_family = AF_NETLINK;
176
177 nlh.nlmsg_len = NLMSG_LENGTH(len);
178 nlh.nlmsg_type = type;
179 nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
180 nlh.nlmsg_pid = 0;
181 nlh.nlmsg_seq = rth->dump = ++rth->seq;
182
183 return sendmsg(rth->fd, &msg, 0);
184 }
185
186 int rtnl_dump_filter_l(struct rtnl_handle *rth,
187 const struct rtnl_dump_filter_arg *arg)
188 {
189 struct sockaddr_nl nladdr;
190 struct iovec iov;
191 struct msghdr msg = {
192 .msg_name = &nladdr,
193 .msg_namelen = sizeof(nladdr),
194 .msg_iov = &iov,
195 .msg_iovlen = 1,
196 };
197 char buf[16384];
198
199 iov.iov_base = buf;
200 while (1) {
201 int status;
202 const struct rtnl_dump_filter_arg *a;
203 int found_done = 0;
204 int msglen = 0;
205
206 iov.iov_len = sizeof(buf);
207 status = recvmsg(rth->fd, &msg, 0);
208
209 if (status < 0) {
210 if (errno == EINTR || errno == EAGAIN)
211 continue;
212 fprintf(stderr, "netlink receive error %s (%d)\n",
213 strerror(errno), errno);
214 return -1;
215 }
216
217 if (status == 0) {
218 fprintf(stderr, "EOF on netlink\n");
219 return -1;
220 }
221
222 for (a = arg; a->filter; a++) {
223 struct nlmsghdr *h = (struct nlmsghdr *)buf;
224 msglen = status;
225
226 while (NLMSG_OK(h, (uint32_t)msglen)) {
227 int err;
228
229 if (nladdr.nl_pid != 0
230 || h->nlmsg_pid != rth->local.nl_pid
231 || h->nlmsg_seq != rth->dump) {
232 if (a->junk) {
233 err = a->junk(&nladdr, h,
234 a->arg2);
235 if (err < 0)
236 return err;
237 }
238 goto skip_it;
239 }
240
241 if (h->nlmsg_type == NLMSG_DONE) {
242 found_done = 1;
243 break; /* process next filter */
244 }
245 if (h->nlmsg_type == NLMSG_ERROR) {
246 struct nlmsgerr *merr =
247 (struct nlmsgerr *)NLMSG_DATA(
248 h);
249 if (h->nlmsg_len
250 < NLMSG_LENGTH(sizeof(
251 struct nlmsgerr))) {
252 fprintf(stderr,
253 "ERROR truncated\n");
254 } else {
255 errno = -merr->error;
256 perror("RTNETLINK answers");
257 }
258 return -1;
259 }
260 err = a->filter(&nladdr, h, a->arg1);
261 if (err < 0)
262 return err;
263
264 skip_it:
265 h = NLMSG_NEXT(h, msglen);
266 }
267 }
268
269 if (found_done)
270 return 0;
271
272 if (msg.msg_flags & MSG_TRUNC) {
273 fprintf(stderr, "Message truncated\n");
274 continue;
275 }
276 if (msglen) {
277 fprintf(stderr, "!!!Remnant of size %d\n", msglen);
278 exit(1);
279 }
280 }
281 }
282
283 int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter, void *arg1,
284 rtnl_filter_t junk, void *arg2)
285 {
286 const struct rtnl_dump_filter_arg a[2] = {
287 {.filter = filter, .arg1 = arg1, .junk = junk, .arg2 = arg2},
288 {.filter = NULL, .arg1 = NULL, .junk = NULL, .arg2 = NULL}};
289
290 return rtnl_dump_filter_l(rth, a);
291 }
292
293 int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
294 unsigned groups, struct nlmsghdr *answer, rtnl_filter_t junk,
295 void *jarg)
296 {
297 int status;
298 unsigned seq;
299 struct nlmsghdr *h;
300 struct sockaddr_nl nladdr;
301 struct iovec iov = {.iov_base = (void *)n, .iov_len = n->nlmsg_len};
302 struct msghdr msg = {
303 .msg_name = &nladdr,
304 .msg_namelen = sizeof(nladdr),
305 .msg_iov = &iov,
306 .msg_iovlen = 1,
307 };
308 char buf[16384];
309
310 memset(&nladdr, 0, sizeof(nladdr));
311 nladdr.nl_family = AF_NETLINK;
312 nladdr.nl_pid = peer;
313 nladdr.nl_groups = groups;
314
315 n->nlmsg_seq = seq = ++rtnl->seq;
316
317 if (answer == NULL)
318 n->nlmsg_flags |= NLM_F_ACK;
319
320 status = sendmsg(rtnl->fd, &msg, 0);
321
322 if (status < 0) {
323 perror("Cannot talk to rtnetlink");
324 return -1;
325 }
326
327 memset(buf, 0, sizeof(buf));
328
329 iov.iov_base = buf;
330
331 while (1) {
332 iov.iov_len = sizeof(buf);
333 status = recvmsg(rtnl->fd, &msg, 0);
334
335 if (status < 0) {
336 if (errno == EINTR || errno == EAGAIN)
337 continue;
338 fprintf(stderr, "netlink receive error %s (%d)\n",
339 strerror(errno), errno);
340 return -1;
341 }
342 if (status == 0) {
343 fprintf(stderr, "EOF on netlink\n");
344 return -1;
345 }
346 if (msg.msg_namelen != sizeof(nladdr)) {
347 fprintf(stderr, "sender address length == %d\n",
348 msg.msg_namelen);
349 exit(1);
350 }
351 for (h = (struct nlmsghdr *)buf; status >= (int)sizeof(*h);) {
352 int err;
353 int len = h->nlmsg_len;
354 int l = len - sizeof(*h);
355
356 if (l < 0 || len > status) {
357 if (msg.msg_flags & MSG_TRUNC) {
358 fprintf(stderr, "Truncated message\n");
359 return -1;
360 }
361 fprintf(stderr,
362 "!!!malformed message: len=%d\n", len);
363 exit(1);
364 }
365
366 if ((int)nladdr.nl_pid != peer
367 || h->nlmsg_pid != rtnl->local.nl_pid
368 || h->nlmsg_seq != seq) {
369 if (junk) {
370 err = junk(&nladdr, h, jarg);
371 if (err < 0)
372 return err;
373 }
374 /* Don't forget to skip that message. */
375 status -= NLMSG_ALIGN(len);
376 h = (struct nlmsghdr *)((char *)h
377 + NLMSG_ALIGN(len));
378 continue;
379 }
380
381 if (h->nlmsg_type == NLMSG_ERROR) {
382 struct nlmsgerr *merr =
383 (struct nlmsgerr *)NLMSG_DATA(h);
384 if (l < (int)sizeof(struct nlmsgerr)) {
385 fprintf(stderr, "ERROR truncated\n");
386 } else {
387 errno = -merr->error;
388 if (errno == 0) {
389 if (answer)
390 memcpy(answer, h,
391 h->nlmsg_len);
392 return 0;
393 }
394 perror("RTNETLINK answers");
395 }
396 return -1;
397 }
398 if (answer) {
399 memcpy(answer, h, h->nlmsg_len);
400 return 0;
401 }
402
403 fprintf(stderr, "Unexpected reply!!!\n");
404
405 status -= NLMSG_ALIGN(len);
406 h = (struct nlmsghdr *)((char *)h + NLMSG_ALIGN(len));
407 }
408 if (msg.msg_flags & MSG_TRUNC) {
409 fprintf(stderr, "Message truncated\n");
410 continue;
411 }
412 if (status) {
413 fprintf(stderr, "!!!Remnant of size %d\n", status);
414 exit(1);
415 }
416 }
417 }
418
419 int rtnl_listen(struct rtnl_handle *rtnl, rtnl_filter_t handler, void *jarg)
420 {
421 int status;
422 struct nlmsghdr *h;
423 struct sockaddr_nl nladdr;
424 struct iovec iov;
425 struct msghdr msg = {
426 .msg_name = &nladdr,
427 .msg_namelen = sizeof(nladdr),
428 .msg_iov = &iov,
429 .msg_iovlen = 1,
430 };
431 char buf[8192];
432
433 memset(&nladdr, 0, sizeof(nladdr));
434 nladdr.nl_family = AF_NETLINK;
435 nladdr.nl_pid = 0;
436 nladdr.nl_groups = 0;
437
438 iov.iov_base = buf;
439 while (1) {
440 iov.iov_len = sizeof(buf);
441 status = recvmsg(rtnl->fd, &msg, 0);
442
443 if (status < 0) {
444 if (errno == EINTR || errno == EAGAIN)
445 continue;
446 fprintf(stderr, "netlink receive error %s (%d)\n",
447 strerror(errno), errno);
448 if (errno == ENOBUFS)
449 continue;
450 return -1;
451 }
452 if (status == 0) {
453 fprintf(stderr, "EOF on netlink\n");
454 return -1;
455 }
456 if (msg.msg_namelen != sizeof(nladdr)) {
457 fprintf(stderr, "Sender address length == %d\n",
458 msg.msg_namelen);
459 exit(1);
460 }
461 for (h = (struct nlmsghdr *)buf; status >= (int)sizeof(*h);) {
462 int err;
463 int len = h->nlmsg_len;
464 int l = len - sizeof(*h);
465
466 if (l < 0 || len > status) {
467 if (msg.msg_flags & MSG_TRUNC) {
468 fprintf(stderr, "Truncated message\n");
469 return -1;
470 }
471 fprintf(stderr,
472 "!!!malformed message: len=%d\n", len);
473 exit(1);
474 }
475
476 err = handler(&nladdr, h, jarg);
477 if (err < 0)
478 return err;
479
480 status -= NLMSG_ALIGN(len);
481 h = (struct nlmsghdr *)((char *)h + NLMSG_ALIGN(len));
482 }
483 if (msg.msg_flags & MSG_TRUNC) {
484 fprintf(stderr, "Message truncated\n");
485 continue;
486 }
487 if (status) {
488 fprintf(stderr, "!!!Remnant of size %d\n", status);
489 exit(1);
490 }
491 }
492 }
493
494 int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler, void *jarg)
495 {
496 struct sockaddr_nl nladdr;
497 char buf[8192];
498 struct nlmsghdr *h = (void *)buf;
499
500 memset(&nladdr, 0, sizeof(nladdr));
501 nladdr.nl_family = AF_NETLINK;
502 nladdr.nl_pid = 0;
503 nladdr.nl_groups = 0;
504
505 while (1) {
506 int err;
507 size_t l, rl, arl;
508
509 rl = sizeof(*h);
510 arl = fread(&buf, 1, rl, rtnl);
511
512 if (arl != rl) {
513 if (arl == 0)
514 return 0;
515
516 if (ferror(rtnl))
517 fprintf(stderr, "%s: header read failed\n",
518 __func__);
519 else
520 fprintf(stderr, "%s: truncated header\n",
521 __func__);
522 return -1;
523 }
524
525 l = h->nlmsg_len > rl ? h->nlmsg_len - rl : 0;
526
527 if (l == 0 || (l + (size_t)NLMSG_HDRLEN) > sizeof(buf)) {
528 fprintf(stderr, "%s: malformed message: len=%zu @%lu\n",
529 __func__, (size_t)h->nlmsg_len, ftell(rtnl));
530 return -1;
531 }
532
533 rl = NLMSG_ALIGN(l);
534 arl = fread(NLMSG_DATA(h), 1, rl, rtnl);
535
536 if (arl != rl) {
537 if (ferror(rtnl))
538 fprintf(stderr, "%s: msg read failed\n",
539 __func__);
540 else
541 fprintf(stderr, "%s: truncated message\n",
542 __func__);
543 return -1;
544 }
545
546 err = handler(&nladdr, h, jarg);
547 if (err < 0)
548 return err;
549 }
550 }
551
552 int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data)
553 {
554 int len = RTA_LENGTH(4);
555 struct rtattr *rta;
556 if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen) {
557 fprintf(stderr,
558 "addattr32: Error! max allowed bound %d exceeded\n",
559 maxlen);
560 return -1;
561 }
562 rta = NLMSG_TAIL(n);
563 rta->rta_type = type;
564 rta->rta_len = len;
565 memcpy(RTA_DATA(rta), &data, 4);
566 n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len;
567 return 0;
568 }
569
570 int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
571 int alen)
572 {
573 int len = RTA_LENGTH(alen);
574 struct rtattr *rta;
575
576 if ((int)(NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len)) > maxlen) {
577 fprintf(stderr,
578 "addattr_l ERROR: message exceeded bound of %d\n",
579 maxlen);
580 return -1;
581 }
582 rta = NLMSG_TAIL(n);
583 rta->rta_type = type;
584 rta->rta_len = len;
585
586 if (data)
587 memcpy(RTA_DATA(rta), data, alen);
588 else
589 assert(alen == 0);
590
591 n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len);
592 return 0;
593 }
594
595 int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len)
596 {
597 if ((int)(NLMSG_ALIGN(n->nlmsg_len) + NLMSG_ALIGN(len)) > maxlen) {
598 fprintf(stderr,
599 "addraw_l ERROR: message exceeded bound of %d\n",
600 maxlen);
601 return -1;
602 }
603
604 memcpy(NLMSG_TAIL(n), data, len);
605 memset((uint8_t *)NLMSG_TAIL(n) + len, 0, NLMSG_ALIGN(len) - len);
606 n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + NLMSG_ALIGN(len);
607 return 0;
608 }
609
610 struct rtattr *addattr_nest(struct nlmsghdr *n, int maxlen, int type)
611 {
612 struct rtattr *nest = NLMSG_TAIL(n);
613
614 addattr_l(n, maxlen, type, NULL, 0);
615 return nest;
616 }
617
618 int addattr_nest_end(struct nlmsghdr *n, struct rtattr *nest)
619 {
620 nest->rta_len = (uint8_t *)NLMSG_TAIL(n) - (uint8_t *)nest;
621 return n->nlmsg_len;
622 }
623
624 struct rtattr *addattr_nest_compat(struct nlmsghdr *n, int maxlen, int type,
625 const void *data, int len)
626 {
627 struct rtattr *start = NLMSG_TAIL(n);
628
629 addattr_l(n, maxlen, type, data, len);
630 addattr_nest(n, maxlen, type);
631 return start;
632 }
633
634 int addattr_nest_compat_end(struct nlmsghdr *n, struct rtattr *start)
635 {
636 struct rtattr *nest = start + NLMSG_ALIGN(start->rta_len);
637
638 start->rta_len = (uint8_t *)NLMSG_TAIL(n) - (uint8_t *)start;
639 addattr_nest_end(n, nest);
640 return n->nlmsg_len;
641 }
642
643 int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data)
644 {
645 int len = RTA_LENGTH(4);
646 struct rtattr *subrta;
647
648 if ((int)(RTA_ALIGN(rta->rta_len) + len) > maxlen) {
649 fprintf(stderr,
650 "rta_addattr32: Error! max allowed bound %d exceeded\n",
651 maxlen);
652 return -1;
653 }
654 subrta = (struct rtattr *)(((char *)rta) + RTA_ALIGN(rta->rta_len));
655 subrta->rta_type = type;
656 subrta->rta_len = len;
657 memcpy(RTA_DATA(subrta), &data, 4);
658 rta->rta_len = NLMSG_ALIGN(rta->rta_len) + len;
659 return 0;
660 }
661
662 int rta_addattr_l(struct rtattr *rta, int maxlen, int type, const void *data,
663 int alen)
664 {
665 struct rtattr *subrta;
666 int len = RTA_LENGTH(alen);
667
668 if ((int)(RTA_ALIGN(rta->rta_len) + RTA_ALIGN(len)) > maxlen) {
669 fprintf(stderr,
670 "rta_addattr_l: Error! max allowed bound %d exceeded\n",
671 maxlen);
672 return -1;
673 }
674 subrta = (struct rtattr *)(((char *)rta) + RTA_ALIGN(rta->rta_len));
675 subrta->rta_type = type;
676 subrta->rta_len = len;
677 memcpy(RTA_DATA(subrta), data, alen);
678 rta->rta_len = NLMSG_ALIGN(rta->rta_len) + RTA_ALIGN(len);
679 return 0;
680 }
681
682 int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
683 {
684 memset(tb, 0, sizeof(struct rtattr *) * (max + 1));
685 while (RTA_OK(rta, len)) {
686 if ((rta->rta_type <= max) && (!tb[rta->rta_type]))
687 tb[rta->rta_type] = rta;
688 rta = RTA_NEXT(rta, len);
689 }
690 if (len)
691 fprintf(stderr, "!!!Deficit %d, rta_len=%d\n", len,
692 rta->rta_len);
693 return 0;
694 }
695
696 int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta,
697 int len)
698 {
699 int i = 0;
700
701 memset(tb, 0, sizeof(struct rtattr *) * max);
702 while (RTA_OK(rta, len)) {
703 if (rta->rta_type <= max && i < max)
704 tb[i++] = rta;
705 rta = RTA_NEXT(rta, len);
706 }
707 if (len)
708 fprintf(stderr, "!!!Deficit %d, rta_len=%d\n", len,
709 rta->rta_len);
710 return i;
711 }
712
713 int __parse_rtattr_nested_compat(struct rtattr *tb[], int max,
714 struct rtattr *rta, int len)
715 {
716 if ((int)RTA_PAYLOAD(rta) < len)
717 return -1;
718 if (RTA_PAYLOAD(rta) >= RTA_ALIGN(len) + sizeof(struct rtattr)) {
719 rta = (struct rtattr *)(uint8_t *)RTA_DATA(rta)
720 + RTA_ALIGN(len);
721 return parse_rtattr_nested(tb, max, rta);
722 }
723 memset(tb, 0, sizeof(struct rtattr *) * (max + 1));
724 return 0;
725 }
726
727 #endif /* __linux__ */