libiproute: handle table ids larger than 255
[oweals/busybox.git] / networking / libiproute / ipneigh.c
index 6588c12f1a09a0ba648eed0019416f7f4258414e..2a1c20e20b3c3109df4219026d5bda15191c26ec 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include "ip_common.h"  /* #include "libbb.h" is inside */
+#include "common_bufsiz.h"
 #include "rt_names.h"
 #include "utils.h"
 #include <linux/neighbour.h>
@@ -40,7 +41,8 @@ struct filter_t {
 } FIX_ALIASING;
 typedef struct filter_t filter_t;
 
-#define G_filter (*(filter_t*)&bb_common_bufsiz1)
+#define G_filter (*(filter_t*)bb_common_bufsiz1)
+#define INIT_G() do { setup_common_bufsiz(); } while (0)
 
 static int flush_update(void)
 {
@@ -60,7 +62,7 @@ static unsigned nud_state_a2n(char *arg)
                "stale\0"     "incomplete\0"  "delay\0"  "probe\0"
                "failed\0"
                ;
-       static uint8_t nuds[] = {
+       static uint8_t nuds[] ALIGN1 = {
                NUD_PERMANENT,NUD_REACHABLE, NUD_NOARP,NUD_NONE,
                NUD_STALE,    NUD_INCOMPLETE,NUD_DELAY,NUD_PROBE,
                NUD_FAILED
@@ -91,7 +93,6 @@ static int FAST_FUNC print_neigh(const struct sockaddr_nl *who UNUSED_PARAM,
        struct ndmsg *r = NLMSG_DATA(n);
        int len = n->nlmsg_len;
        struct rtattr *tb[NDA_MAX+1];
-       char abuf[256];
 
        if (n->nlmsg_type != RTM_NEWNEIGH && n->nlmsg_type != RTM_DELNEIGH) {
                bb_error_msg_and_die("not RTM_NEWNEIGH: %08x %08x %08x",
@@ -155,8 +156,8 @@ static int FAST_FUNC print_neigh(const struct sockaddr_nl *who UNUSED_PARAM,
                printf("%s ",
                       format_host(r->ndm_family,
                                   RTA_PAYLOAD(tb[NDA_DST]),
-                                  RTA_DATA(tb[NDA_DST]),
-                                  abuf, sizeof(abuf)));
+                                  RTA_DATA(tb[NDA_DST]))
+               );
        }
        if (!G_filter.index && r->ndm_ifindex)
                printf("dev %s ", ll_index_to_name(r->ndm_ifindex));
@@ -339,6 +340,8 @@ int FAST_FUNC do_ipneigh(char **argv)
                /*0-1*/ "show\0"  "flush\0";
        int command_num;
 
+       INIT_G();
+
        if (!*argv)
                return ipneigh_list_or_flush(argv, 0);