aboutsummaryrefslogtreecommitdiffstats
path: root/package/utils/busybox/patches
diff options
context:
space:
mode:
Diffstat (limited to 'package/utils/busybox/patches')
-rw-r--r--package/utils/busybox/patches/002-libbb-send_to_from-do-not-require-that-to-should-hav.patch37
-rw-r--r--package/utils/busybox/patches/102-trylink_mktemp_fix.patch20
-rw-r--r--package/utils/busybox/patches/120-remove_uclibc_rpc_check.patch2
-rw-r--r--package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch4
-rw-r--r--package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch2
-rw-r--r--package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch2
-rw-r--r--package/utils/busybox/patches/240-telnetd_intr.patch2
-rw-r--r--package/utils/busybox/patches/250-date-k-flag.patch12
-rw-r--r--package/utils/busybox/patches/302-netlink-alignment.patch100
-rw-r--r--package/utils/busybox/patches/303-ip-route-fix-high-table-ids.patch486
10 files changed, 12 insertions, 655 deletions
diff --git a/package/utils/busybox/patches/002-libbb-send_to_from-do-not-require-that-to-should-hav.patch b/package/utils/busybox/patches/002-libbb-send_to_from-do-not-require-that-to-should-hav.patch
deleted file mode 100644
index f33c3b22e1..0000000000
--- a/package/utils/busybox/patches/002-libbb-send_to_from-do-not-require-that-to-should-hav.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From 7cef4817d6d6d61a1166ed7dfc13537b95c65970 Mon Sep 17 00:00:00 2001
-From: Denys Vlasenko <vda.linux@googlemail.com>
-Date: Thu, 15 Sep 2016 13:20:51 +0200
-Subject: [PATCH] libbb:/send_to_from: do not require that "to" should have the
- same AF. Closes 9146
-
-Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
----
- libbb/udp_io.c | 10 ++++++++--
- 1 file changed, 8 insertions(+), 2 deletions(-)
-
---- a/libbb/udp_io.c
-+++ b/libbb/udp_io.c
-@@ -70,7 +70,13 @@ send_to_from(int fd, void *buf, size_t l
- msg.msg_flags = flags;
-
- cmsgptr = CMSG_FIRSTHDR(&msg);
-- if (to->sa_family == AF_INET && from->sa_family == AF_INET) {
-+ /*
-+ * Users report that to->sa_family can be AF_INET6 too,
-+ * if "to" was acquired by recv_from_to(). IOW: recv_from_to()
-+ * was seen showing IPv6 "from" even when the destination
-+ * of received packet (our local address) was IPv4.
-+ */
-+ if (/* to->sa_family == AF_INET && */ from->sa_family == AF_INET) {
- struct in_pktinfo *pktptr;
- cmsgptr->cmsg_level = IPPROTO_IP;
- cmsgptr->cmsg_type = IP_PKTINFO;
-@@ -86,7 +92,7 @@ send_to_from(int fd, void *buf, size_t l
- pktptr->ipi_spec_dst = ((struct sockaddr_in*)from)->sin_addr;
- }
- # if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO)
-- else if (to->sa_family == AF_INET6 && from->sa_family == AF_INET6) {
-+ else if (/* to->sa_family == AF_INET6 && */ from->sa_family == AF_INET6) {
- struct in6_pktinfo *pktptr;
- cmsgptr->cmsg_level = IPPROTO_IPV6;
- cmsgptr->cmsg_type = IPV6_PKTINFO;
diff --git a/package/utils/busybox/patches/102-trylink_mktemp_fix.patch b/package/utils/busybox/patches/102-trylink_mktemp_fix.patch
deleted file mode 100644
index ed1dcbb66f..0000000000
--- a/package/utils/busybox/patches/102-trylink_mktemp_fix.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/scripts/trylink
-+++ b/scripts/trylink
-@@ -46,7 +46,7 @@ try() {
- }
-
- check_cc() {
-- local tempname="$(mktemp)"
-+ local tempname="$(mktemp /tmp/tmp.XXXXXXXXXX)"
- local r
- echo "int main(int argc,char**argv){return argv?argc:0;}" >"$tempname".c
- # Can use "-o /dev/null", but older gcc tend to *unlink it* on failure! :(
-@@ -61,7 +61,7 @@ check_cc() {
- }
-
- check_libc_is_glibc() {
-- local tempname="$(mktemp)"
-+ local tempname="$(mktemp /tmp/tmp.XXXXXXXXXX)"
- local r
- echo "\
- #include <stdlib.h>
diff --git a/package/utils/busybox/patches/120-remove_uclibc_rpc_check.patch b/package/utils/busybox/patches/120-remove_uclibc_rpc_check.patch
index 4825bc8a67..682a68eebd 100644
--- a/package/utils/busybox/patches/120-remove_uclibc_rpc_check.patch
+++ b/package/utils/busybox/patches/120-remove_uclibc_rpc_check.patch
@@ -1,6 +1,6 @@
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
-@@ -237,9 +237,6 @@
+@@ -245,9 +245,6 @@
#if ENABLE_FEATURE_MOUNT_NFS
/* This is just a warning of a common mistake. Possibly this should be a
* uclibc faq entry rather than in busybox... */
diff --git a/package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch b/package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch
index 0fdaed502a..8ef8f2211b 100644
--- a/package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch
+++ b/package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch
@@ -1,6 +1,6 @@
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
-@@ -697,6 +697,7 @@ static int bcast_or_ucast(struct dhcp_pa
+@@ -704,6 +704,7 @@ static int bcast_or_ucast(struct dhcp_pa
static NOINLINE int send_discover(uint32_t xid, uint32_t requested)
{
struct dhcp_packet packet;
@@ -8,7 +8,7 @@
/* Fill in: op, htype, hlen, cookie, chaddr fields,
* random xid field (we override it below),
-@@ -714,6 +715,7 @@ static NOINLINE int send_discover(uint32
+@@ -721,6 +722,7 @@ static NOINLINE int send_discover(uint32
*/
add_client_options(&packet);
diff --git a/package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch b/package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch
index 4a9ae9813e..f5e3a075ae 100644
--- a/package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch
+++ b/package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch
@@ -1,6 +1,6 @@
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
-@@ -1422,6 +1422,12 @@ int udhcpc_main(int argc UNUSED_PARAM, c
+@@ -1439,6 +1439,12 @@ int udhcpc_main(int argc UNUSED_PARAM, c
/* silence "uninitialized!" warning */
unsigned timestamp_before_wait = timestamp_before_wait;
diff --git a/package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch b/package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch
index 1e44552c13..3df8d930b1 100644
--- a/package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch
+++ b/package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch
@@ -1,6 +1,6 @@
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
-@@ -1103,7 +1103,6 @@ static void perform_renew(void)
+@@ -1110,7 +1110,6 @@ static void perform_renew(void)
state = RENEW_REQUESTED;
break;
case RENEW_REQUESTED: /* impatient are we? fine, square 1 */
diff --git a/package/utils/busybox/patches/240-telnetd_intr.patch b/package/utils/busybox/patches/240-telnetd_intr.patch
index d52ea3fcc1..fec2a3a5d0 100644
--- a/package/utils/busybox/patches/240-telnetd_intr.patch
+++ b/package/utils/busybox/patches/240-telnetd_intr.patch
@@ -1,6 +1,6 @@
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
-@@ -333,6 +333,7 @@ make_new_session(
+@@ -497,6 +497,7 @@ make_new_session(
/* Restore default signal handling ASAP */
bb_signals((1 << SIGCHLD) + (1 << SIGPIPE), SIG_DFL);
diff --git a/package/utils/busybox/patches/250-date-k-flag.patch b/package/utils/busybox/patches/250-date-k-flag.patch
index b2681a17f9..476440f62a 100644
--- a/package/utils/busybox/patches/250-date-k-flag.patch
+++ b/package/utils/busybox/patches/250-date-k-flag.patch
@@ -1,6 +1,6 @@
--- a/coreutils/date.c
+++ b/coreutils/date.c
-@@ -123,6 +123,7 @@
+@@ -122,6 +122,7 @@
//usage: IF_FEATURE_DATE_ISOFMT(
//usage: "\n -D FMT Use FMT for -d TIME conversion"
//usage: )
@@ -8,7 +8,7 @@
//usage: "\n"
//usage: "\nRecognized TIME formats:"
//usage: "\n hh:mm[:ss]"
-@@ -139,9 +140,8 @@
+@@ -138,9 +139,8 @@
#include "libbb.h"
#include "common_bufsiz.h"
@@ -20,7 +20,7 @@
enum {
OPT_RFC2822 = (1 << 0), /* R */
-@@ -149,8 +149,9 @@ enum {
+@@ -148,8 +148,9 @@ enum {
OPT_UTC = (1 << 2), /* u */
OPT_DATE = (1 << 3), /* d */
OPT_REFERENCE = (1 << 4), /* r */
@@ -32,7 +32,7 @@
};
static void maybe_set_utc(int opt)
-@@ -168,12 +169,15 @@ static const char date_longopts[] ALIGN1
+@@ -167,12 +168,15 @@ static const char date_longopts[] ALIGN1
/* "universal\0" No_argument "u" */
"date\0" Required_argument "d"
"reference\0" Required_argument "r"
@@ -48,7 +48,7 @@
struct timespec ts;
struct tm tm_time;
char buf_fmt_dt2str[64];
-@@ -188,7 +192,7 @@ int date_main(int argc UNUSED_PARAM, cha
+@@ -187,7 +191,7 @@ int date_main(int argc UNUSED_PARAM, cha
opt_complementary = "d--s:s--d"
IF_FEATURE_DATE_ISOFMT(":R--I:I--R");
IF_LONG_OPTS(applet_long_options = date_longopts;)
@@ -57,7 +57,7 @@
IF_FEATURE_DATE_ISOFMT("I::D:"),
&date_str, &date_str, &filename
IF_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt));
-@@ -245,6 +249,31 @@ int date_main(int argc UNUSED_PARAM, cha
+@@ -244,6 +248,31 @@ int date_main(int argc UNUSED_PARAM, cha
if (*argv)
bb_show_usage();
diff --git a/package/utils/busybox/patches/302-netlink-alignment.patch b/package/utils/busybox/patches/302-netlink-alignment.patch
deleted file mode 100644
index 4cd25b1872..0000000000
--- a/package/utils/busybox/patches/302-netlink-alignment.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-From a843f09a4d4428cf11ca02307e60058251b05743 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Fri, 16 Sep 2016 21:52:03 +0200
-Subject: [PATCH] libnetlink: fix alignment of netlink messages
-
-An padding to align a message should not only be added between
-different attributes of a netlink message, but also at the end of the
-message to pad it to the correct size.
-
-Without this patch the following command does not work and returns an
-error code:
-ip link add type nlmon
-
-Without this ip from busybox sends this:
-sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=45, type=0x10 /* NLMSG_??? */, flags=NLM_F_REQUEST|NLM_F_ACK|0x600, seq=1474057401, pid=0}, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon"}, iov_len=45}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 45
-return value: 2
-
-The normal ip utile from iproute2 sends this:
-sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=48, type=0x10 /* NLMSG_??? */, flags=NLM_F_REQUEST|NLM_F_ACK|0x600, seq=1473716938, pid=0}, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon\0\0\0"}, iov_len=48}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 48
-return value: 0
-
-With this patch ip from busybox sends this:
-sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base={{len=48, type=0x10 /* NLMSG_??? */, flags=NLM_F_REQUEST|NLM_F_ACK|0x600, seq=1473716908, pid=0}, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon\0\0\0"}, iov_len=48}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 48
-return value: 0
-
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
----
- networking/libiproute/libnetlink.c | 16 ++++++++--------
- 1 file changed, 8 insertions(+), 8 deletions(-)
-
---- a/networking/libiproute/libnetlink.c
-+++ b/networking/libiproute/libnetlink.c
-@@ -338,14 +338,14 @@ int FAST_FUNC addattr32(struct nlmsghdr
- int len = RTA_LENGTH(4);
- struct rtattr *rta;
-
-- if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen) {
-+ if ((int)(NLMSG_ALIGN(n->nlmsg_len + len)) > maxlen) {
- return -1;
- }
- rta = (struct rtattr*)(((char*)n) + NLMSG_ALIGN(n->nlmsg_len));
- rta->rta_type = type;
- rta->rta_len = len;
- move_to_unaligned32(RTA_DATA(rta), data);
-- n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len;
-+ n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len + len);
- return 0;
- }
-
-@@ -354,14 +354,14 @@ int FAST_FUNC addattr_l(struct nlmsghdr
- int len = RTA_LENGTH(alen);
- struct rtattr *rta;
-
-- if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen) {
-+ if ((int)(NLMSG_ALIGN(n->nlmsg_len + len)) > maxlen) {
- return -1;
- }
- rta = (struct rtattr*)(((char*)n) + NLMSG_ALIGN(n->nlmsg_len));
- rta->rta_type = type;
- rta->rta_len = len;
- memcpy(RTA_DATA(rta), data, alen);
-- n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len;
-+ n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len + len);
- return 0;
- }
-
-@@ -370,14 +370,14 @@ int FAST_FUNC rta_addattr32(struct rtatt
- int len = RTA_LENGTH(4);
- struct rtattr *subrta;
-
-- if (RTA_ALIGN(rta->rta_len) + len > maxlen) {
-+ if (RTA_ALIGN(rta->rta_len + len) > maxlen) {
- return -1;
- }
- subrta = (struct rtattr*)(((char*)rta) + RTA_ALIGN(rta->rta_len));
- subrta->rta_type = type;
- subrta->rta_len = len;
- move_to_unaligned32(RTA_DATA(subrta), data);
-- rta->rta_len = NLMSG_ALIGN(rta->rta_len) + len;
-+ rta->rta_len = NLMSG_ALIGN(rta->rta_len + len);
- return 0;
- }
-
-@@ -386,14 +386,14 @@ int FAST_FUNC rta_addattr_l(struct rtatt
- struct rtattr *subrta;
- int len = RTA_LENGTH(alen);
-
-- if (RTA_ALIGN(rta->rta_len) + len > maxlen) {
-+ if (RTA_ALIGN(rta->rta_len + len) > maxlen) {
- return -1;
- }
- subrta = (struct rtattr*)(((char*)rta) + RTA_ALIGN(rta->rta_len));
- subrta->rta_type = type;
- subrta->rta_len = len;
- memcpy(RTA_DATA(subrta), data, alen);
-- rta->rta_len = NLMSG_ALIGN(rta->rta_len) + len;
-+ rta->rta_len = NLMSG_ALIGN(rta->rta_len + len);
- return 0;
- }
-
diff --git a/package/utils/busybox/patches/303-ip-route-fix-high-table-ids.patch b/package/utils/busybox/patches/303-ip-route-fix-high-table-ids.patch
deleted file mode 100644
index d7a38f632e..0000000000
--- a/package/utils/busybox/patches/303-ip-route-fix-high-table-ids.patch
+++ /dev/null
@@ -1,486 +0,0 @@
-From 485fcc89b99eae9cc7501eaff344b104e52ab7bf Mon Sep 17 00:00:00 2001
-From: Jo-Philipp Wich <jo@mein.io>
-Date: Mon, 26 Sep 2016 17:48:22 +0200
-Subject: [PATCH] iproute: properly support high routing table IDs
-
-The Linux kernel uses two distinct fields to denote the routing table ID in
-use by network routes; the 8 bit `rtm_table` member of `struct rtmsg` and the
-32 bit `RTA_TABLE` netlink attribute.
-
-If a routing table ID is larger than 255, the `RT_TABLE` attribute must be used
-and the `rtm_table` field has to be set to the special `RT_TABLE_UNSPEC` value.
-
-This commit ...
- - switches the *_n2a() and *_a2n() functions of rt_names.c to use dynamically
- sized, name-sorted arrays instead of fixed arrays limited to 1024 slots in
- order to support IDs up to 65535
- - adds proper handling of high table IDs to iprule.c and iproute.c when
- adding, removing and dumping ip rules and network routes
-
-After this change, the Busybox ip applet fully supports IP rules with high ID
-numbers, using the same logic as the full iproute2.
-
-Signed-off-by: Jo-Philipp Wich <jo@mein.io>
----
- networking/libiproute/iproute.c | 75 ++++++++------
- networking/libiproute/iprule.c | 4 +-
- networking/libiproute/rt_names.c | 204 +++++++++++++++++++++++----------------
- 3 files changed, 169 insertions(+), 114 deletions(-)
-
---- a/networking/libiproute/iproute.c
-+++ b/networking/libiproute/iproute.c
-@@ -66,6 +66,7 @@ static int FAST_FUNC print_route(const s
- inet_prefix dst;
- inet_prefix src;
- int host_len = -1;
-+ uint32_t rtable;
-
- if (n->nlmsg_type != RTM_NEWROUTE && n->nlmsg_type != RTM_DELROUTE) {
- fprintf(stderr, "Not a route: %08x %08x %08x\n",
-@@ -83,34 +84,6 @@ static int FAST_FUNC print_route(const s
- else if (r->rtm_family == AF_INET)
- host_len = 32;
-
-- if (r->rtm_family == AF_INET6) {
-- if (G_filter.tb) {
-- if (G_filter.tb < 0) {
-- if (!(r->rtm_flags & RTM_F_CLONED)) {
-- return 0;
-- }
-- } else {
-- if (r->rtm_flags & RTM_F_CLONED) {
-- return 0;
-- }
-- if (G_filter.tb == RT_TABLE_LOCAL) {
-- if (r->rtm_type != RTN_LOCAL) {
-- return 0;
-- }
-- } else if (G_filter.tb == RT_TABLE_MAIN) {
-- if (r->rtm_type == RTN_LOCAL) {
-- return 0;
-- }
-- } else {
-- return 0;
-- }
-- }
-- }
-- } else {
-- if (G_filter.tb > 0 && G_filter.tb != r->rtm_table) {
-- return 0;
-- }
-- }
- if (G_filter.rdst.family
- && (r->rtm_family != G_filter.rdst.family || G_filter.rdst.bitlen > r->rtm_dst_len)
- ) {
-@@ -141,6 +114,37 @@ static int FAST_FUNC print_route(const s
- memset(&dst, 0, sizeof(dst));
- parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len);
-
-+ rtable = tb[RTA_TABLE] ? *(uint32_t*)RTA_DATA(tb[RTA_TABLE]) : r->rtm_table;
-+
-+ if (G_filter.tb) {
-+ if (r->rtm_family == AF_INET6) {
-+ if (G_filter.tb < 0) {
-+ if (!(r->rtm_flags & RTM_F_CLONED)) {
-+ return 0;
-+ }
-+ } else {
-+ if (r->rtm_flags & RTM_F_CLONED) {
-+ return 0;
-+ }
-+ if (G_filter.tb == RT_TABLE_LOCAL) {
-+ if (r->rtm_type != RTN_LOCAL) {
-+ return 0;
-+ }
-+ } else if (G_filter.tb == RT_TABLE_MAIN) {
-+ if (r->rtm_type == RTN_LOCAL) {
-+ return 0;
-+ }
-+ } else if (G_filter.tb != rtable) {
-+ return 0;
-+ }
-+ }
-+ } else {
-+ if (G_filter.tb != rtable) {
-+ return 0;
-+ }
-+ }
-+ }
-+
- if (tb[RTA_SRC]) {
- src.bitlen = r->rtm_src_len;
- src.bytelen = (r->rtm_family == AF_INET6 ? 16 : 4);
-@@ -349,7 +353,9 @@ IF_FEATURE_IP_RULE(ARG_table,)
- smalluint ok = 0;
- smalluint scope_ok = 0;
- int arg;
--
-+#if ENABLE_FEATURE_IP_RULE
-+ uint32_t rtable = 0;
-+#endif
- memset(&req, 0, sizeof(req));
-
- req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
-@@ -419,7 +425,7 @@ IF_FEATURE_IP_RULE(ARG_table,)
- NEXT_ARG();
- if (rtnl_rttable_a2n(&tid, *argv))
- invarg_1_to_2(*argv, "table");
-- req.r.rtm_table = tid;
-+ rtable = tid;
- #endif
- } else if (arg == ARG_dev || arg == ARG_oif) {
- NEXT_ARG();
-@@ -475,6 +481,15 @@ IF_FEATURE_IP_RULE(ARG_table,)
- }
- }
-
-+#if ENABLE_FEATURE_IP_RULE
-+ if (rtable >= 256) {
-+ addattr32(&req.n, sizeof(req), RTA_TABLE, rtable);
-+ req.r.rtm_table = RT_TABLE_UNSPEC;
-+ } else if (rtable > 0) {
-+ req.r.rtm_table = rtable;
-+ }
-+#endif
-+
- if (mxrta->rta_len > RTA_LENGTH(0)) {
- if (mxlock) {
- rta_addattr32(mxrta, sizeof(mxbuf), RTAX_LOCK, mxlock);
---- a/networking/libiproute/iprule.c
-+++ b/networking/libiproute/iprule.c
-@@ -114,7 +114,9 @@ static int FAST_FUNC print_rule(const st
- printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF]));
- }
-
-- if (r->rtm_table)
-+ if (tb[RTA_TABLE])
-+ printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE])));
-+ else if (r->rtm_table)
- printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table));
-
- if (tb[RTA_FLOW]) {
---- a/networking/libiproute/rt_names.c
-+++ b/networking/libiproute/rt_names.c
-@@ -11,21 +11,26 @@
- #include "rt_names.h"
-
- #define CONFDIR CONFIG_FEATURE_IP_ROUTE_DIR
-+#define RT_TABLE_MAX 65535
-+
-+struct rtnl_tab_entry {
-+ unsigned int id;
-+ const char *name;
-+};
-
- typedef struct rtnl_tab_t {
-- const char *cached_str;
-- unsigned cached_result;
-- /* upstream version switched to a hash table and removed
-- * id < 256 limit. For now bbox bumps this array size from 256
-- * to 1024. If you plan to change this to a hash table,
-- * consider merging several hash tables we have (for example,
-- * awk has resizable one!
-- */
--#define RT_TABLE_MAX 1023
-- const char *tab[RT_TABLE_MAX+1];
-+ struct rtnl_tab_entry *tab;
-+ size_t length;
- } rtnl_tab_t;
-
--static void rtnl_tab_initialize(const char *file, const char **tab)
-+static int tabcmp(const void *p1, const void *p2)
-+{
-+ const struct rtnl_tab_entry *e1 = p1;
-+ const struct rtnl_tab_entry *e2 = p2;
-+ return strcmp(e1->name, e2->name);
-+}
-+
-+static void rtnl_tab_initialize(const char *file, rtnl_tab_t *tab)
- {
- char *token[2];
- char fullname[sizeof(CONFDIR"/rt_dsfield") + 8];
-@@ -40,34 +45,42 @@ static void rtnl_tab_initialize(const ch
- file, parser->lineno);
- break;
- }
-- tab[id] = xstrdup(token[1]);
-+
-+ tab->tab = xrealloc(tab->tab, (tab->length + 1) * sizeof(*tab->tab));
-+ tab->tab[tab->length].id = id;
-+ tab->tab[tab->length].name = xstrdup(token[1]);
-+ tab->length++;
- }
- config_close(parser);
-+ qsort(tab->tab, tab->length, sizeof(*tab->tab), tabcmp);
- }
-
- static int rtnl_a2n(rtnl_tab_t *tab, uint32_t *id, const char *arg, int base)
- {
-- unsigned i;
--
-- if (tab->cached_str && strcmp(tab->cached_str, arg) == 0) {
-- *id = tab->cached_result;
-- return 0;
-- }
-+ int delta;
-+ ssize_t l = 0;
-+ ssize_t r = tab->length - 1;
-+ ssize_t m;
-+ uint32_t i;
-+
-+ while (l <= r) {
-+ m = l + (r - l) / 2;
-+ delta = strcmp(tab->tab[m].name, arg);
-
-- for (i = 0; i <= RT_TABLE_MAX; i++) {
-- if (tab->tab[i]
-- && strcmp(tab->tab[i], arg) == 0
-- ) {
-- tab->cached_str = tab->tab[i];
-- tab->cached_result = i;
-- *id = i;
-+ if (delta == 0) {
-+ *id = tab->tab[m].id;
- return 0;
-+ } else if (delta < 0) {
-+ l = m + 1;
-+ } else {
-+ r = m - 1;
- }
- }
-
- i = bb_strtou(arg, NULL, base);
- if (i > RT_TABLE_MAX)
- return -1;
-+
- *id = i;
- return 0;
- }
-@@ -77,40 +90,39 @@ static rtnl_tab_t *rtnl_rtprot_tab;
-
- static void rtnl_rtprot_initialize(void)
- {
-- static const char *const init_tab[] = {
-- "none",
-- "redirect",
-- "kernel",
-- "boot",
-- "static",
-- NULL,
-- NULL,
-- NULL,
-- "gated",
-- "ra",
-- "mrt",
-- "zebra",
-- "bird",
-+ static const struct rtnl_tab_entry init_tab[] = {
-+ { 0, "none" },
-+ { 1, "redirect" },
-+ { 2, "kernel" },
-+ { 3, "boot" },
-+ { 4, "static" },
-+ { 8, "gated" },
-+ { 9, "ra" },
-+ { 10, "mrt" },
-+ { 11, "zebra" },
-+ { 12, "bird" }
- };
-
- if (rtnl_rtprot_tab)
- return;
- rtnl_rtprot_tab = xzalloc(sizeof(*rtnl_rtprot_tab));
-+ rtnl_rtprot_tab->tab = xzalloc(sizeof(init_tab));
-+ rtnl_rtprot_tab->length = sizeof(init_tab) / sizeof(init_tab[0]);
- memcpy(rtnl_rtprot_tab->tab, init_tab, sizeof(init_tab));
-- rtnl_tab_initialize("protos", rtnl_rtprot_tab->tab);
-+ rtnl_tab_initialize("protos", rtnl_rtprot_tab);
- }
-
- #if 0 /* UNUSED */
- const char* FAST_FUNC rtnl_rtprot_n2a(int id)
- {
-- if (id < 0 || id > RT_TABLE_MAX) {
-- return itoa(id);
-- }
-+ size_t i;
-
- rtnl_rtprot_initialize();
-
-- if (rtnl_rtprot_tab->tab[id])
-- return rtnl_rtprot_tab->tab[id];
-+ for (i = 0; i < rtnl_rtprot_tab->length; i++)
-+ if (rtnl_rtprot_tab->tab[i].id == id)
-+ return rtnl_rtprot_tab->tab[i].name;
-+
- return itoa(id);
- }
- #endif
-@@ -126,27 +138,33 @@ static rtnl_tab_t *rtnl_rtscope_tab;
-
- static void rtnl_rtscope_initialize(void)
- {
-+ static const struct rtnl_tab_entry init_tab[] = {
-+ { 0, "global" },
-+ { 200, "site" },
-+ { 253, "link" },
-+ { 254, "host" },
-+ { 255, "nowhere" }
-+ };
-+
- if (rtnl_rtscope_tab)
- return;
- rtnl_rtscope_tab = xzalloc(sizeof(*rtnl_rtscope_tab));
-- rtnl_rtscope_tab->tab[0] = "global";
-- rtnl_rtscope_tab->tab[255] = "nowhere";
-- rtnl_rtscope_tab->tab[254] = "host";
-- rtnl_rtscope_tab->tab[253] = "link";
-- rtnl_rtscope_tab->tab[200] = "site";
-- rtnl_tab_initialize("scopes", rtnl_rtscope_tab->tab);
-+ rtnl_rtscope_tab->tab = xzalloc(sizeof(init_tab));
-+ rtnl_rtscope_tab->length = sizeof(init_tab) / sizeof(init_tab[0]);
-+ memcpy(rtnl_rtscope_tab->tab, init_tab, sizeof(init_tab));
-+ rtnl_tab_initialize("scopes", rtnl_rtscope_tab);
- }
-
- const char* FAST_FUNC rtnl_rtscope_n2a(int id)
- {
-- if (id < 0 || id > RT_TABLE_MAX) {
-- return itoa(id);
-- }
-+ size_t i;
-
- rtnl_rtscope_initialize();
-
-- if (rtnl_rtscope_tab->tab[id])
-- return rtnl_rtscope_tab->tab[id];
-+ for (i = 0; i < rtnl_rtscope_tab->length; i++)
-+ if (rtnl_rtscope_tab->tab[i].id == id)
-+ return rtnl_rtscope_tab->tab[i].name;
-+
- return itoa(id);
- }
-
-@@ -161,10 +179,17 @@ static rtnl_tab_t *rtnl_rtrealm_tab;
-
- static void rtnl_rtrealm_initialize(void)
- {
-- if (rtnl_rtrealm_tab) return;
-+ static const struct rtnl_tab_entry init_tab[] = {
-+ { 0, "unknown" }
-+ };
-+
-+ if (rtnl_rtrealm_tab)
-+ return;
- rtnl_rtrealm_tab = xzalloc(sizeof(*rtnl_rtrealm_tab));
-- rtnl_rtrealm_tab->tab[0] = "unknown";
-- rtnl_tab_initialize("realms", rtnl_rtrealm_tab->tab);
-+ rtnl_rtrealm_tab->tab = xzalloc(sizeof(init_tab));
-+ rtnl_rtrealm_tab->length = sizeof(init_tab) / sizeof(init_tab[0]);
-+ memcpy(rtnl_rtrealm_tab->tab, init_tab, sizeof(init_tab));
-+ rtnl_tab_initialize("realms", rtnl_rtrealm_tab);
- }
-
- int FAST_FUNC rtnl_rtrealm_a2n(uint32_t *id, char *arg)
-@@ -176,14 +201,14 @@ int FAST_FUNC rtnl_rtrealm_a2n(uint32_t
- #if ENABLE_FEATURE_IP_RULE
- const char* FAST_FUNC rtnl_rtrealm_n2a(int id)
- {
-- if (id < 0 || id > RT_TABLE_MAX) {
-- return itoa(id);
-- }
-+ size_t i;
-
- rtnl_rtrealm_initialize();
-
-- if (rtnl_rtrealm_tab->tab[id])
-- return rtnl_rtrealm_tab->tab[id];
-+ for (i = 0; i < rtnl_rtrealm_tab->length; i++)
-+ if (rtnl_rtrealm_tab->tab[i].id == id)
-+ return rtnl_rtrealm_tab->tab[i].name;
-+
- return itoa(id);
- }
- #endif
-@@ -193,22 +218,29 @@ static rtnl_tab_t *rtnl_rtdsfield_tab;
-
- static void rtnl_rtdsfield_initialize(void)
- {
-- if (rtnl_rtdsfield_tab) return;
-+ static const struct rtnl_tab_entry init_tab[] = {
-+ { 0, "0" }
-+ };
-+
-+ if (rtnl_rtdsfield_tab)
-+ return;
- rtnl_rtdsfield_tab = xzalloc(sizeof(*rtnl_rtdsfield_tab));
-- rtnl_rtdsfield_tab->tab[0] = "0";
-- rtnl_tab_initialize("dsfield", rtnl_rtdsfield_tab->tab);
-+ rtnl_rtdsfield_tab->tab = xzalloc(sizeof(init_tab));
-+ rtnl_rtdsfield_tab->length = sizeof(init_tab) / sizeof(init_tab[0]);
-+ memcpy(rtnl_rtdsfield_tab->tab, init_tab, sizeof(init_tab));
-+ rtnl_tab_initialize("dsfield", rtnl_rtdsfield_tab);
- }
-
- const char* FAST_FUNC rtnl_dsfield_n2a(int id)
- {
-- if (id < 0 || id > RT_TABLE_MAX) {
-- return itoa(id);
-- }
-+ size_t i;
-
- rtnl_rtdsfield_initialize();
-
-- if (rtnl_rtdsfield_tab->tab[id])
-- return rtnl_rtdsfield_tab->tab[id];
-+ for (i = 0; i < rtnl_rtdsfield_tab->length; i++)
-+ if (rtnl_rtdsfield_tab->tab[i].id == id)
-+ return rtnl_rtdsfield_tab->tab[i].name;
-+
- return itoa(id);
- }
-
-@@ -224,27 +256,33 @@ static rtnl_tab_t *rtnl_rttable_tab;
-
- static void rtnl_rttable_initialize(void)
- {
-+ static const struct rtnl_tab_entry tab_init[] = {
-+ { 0, "unspec" },
-+ { 253, "default" },
-+ { 254, "main" },
-+ { 255, "local" }
-+ };
-+
- if (rtnl_rttable_tab)
- return;
-
- rtnl_rttable_tab = xzalloc(sizeof(*rtnl_rttable_tab));
-- rtnl_rttable_tab->tab[0] = "unspec";
-- rtnl_rttable_tab->tab[255] = "local";
-- rtnl_rttable_tab->tab[254] = "main";
-- rtnl_rttable_tab->tab[253] = "default";
-- rtnl_tab_initialize("tables", rtnl_rttable_tab->tab);
-+ rtnl_rttable_tab->tab = xzalloc(sizeof(tab_init));
-+ rtnl_rttable_tab->length = sizeof(tab_init) / sizeof(tab_init[0]);
-+ memcpy(rtnl_rttable_tab->tab, tab_init, sizeof(tab_init));
-+ rtnl_tab_initialize("tables", rtnl_rttable_tab);
- }
-
- const char* FAST_FUNC rtnl_rttable_n2a(int id)
- {
-- if (id < 0 || id > RT_TABLE_MAX) {
-- return itoa(id);
-- }
-+ size_t i;
-
- rtnl_rttable_initialize();
-
-- if (rtnl_rttable_tab->tab[id])
-- return rtnl_rttable_tab->tab[id];
-+ for (i = 0; i < rtnl_rttable_tab->length; i++)
-+ if (rtnl_rttable_tab->tab[i].id == id)
-+ return rtnl_rttable_tab->tab[i].name;
-+
- return itoa(id);
- }
-