busybox: update to 1.31.0
authorHannu Nyman <hannu.nyman@iki.fi>
Sat, 15 Jun 2019 09:16:55 +0000 (12:16 +0300)
committerHans Dedecker <dedeckeh@gmail.com>
Sat, 15 Jun 2019 17:26:47 +0000 (19:26 +0200)
* Update busybox to version 1.31.0.
    New applets: ts, i2ctransfer
    New (restored) feature: error/info levels in syslog messages.
    Leave new features disabled by default.
* Refresh patches
* Remove patch that was backported from upstream

Config refreshed with commands below, after which the OpenWrt specific
config defaults (ipv6, login session child) were corrected:

  make package/busybox/compile   (to populate the build_dir)

  cd package/utils/busybox/config/
  ../convert_menuconfig.pl ../../../../build_dir/target-mips_24kc_musl/busybox-1.31.0

  cd package/utils/busybox
  ./convert_defaults.pl < ../../../build_dir/target-mips_24kc_musl/busybox-1.31.0/.config > Config-defaults.in

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
15 files changed:
package/utils/busybox/Config-defaults.in
package/utils/busybox/Makefile
package/utils/busybox/config/Config.in
package/utils/busybox/config/coreutils/Config.in
package/utils/busybox/config/miscutils/Config.in
package/utils/busybox/config/networking/Config.in
package/utils/busybox/config/networking/udhcp/Config.in
package/utils/busybox/config/shell/Config.in
package/utils/busybox/config/util-linux/Config.in
package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch
package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch
package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch
package/utils/busybox/patches/240-telnetd_intr.patch
package/utils/busybox/patches/250-date-k-flag.patch
package/utils/busybox/patches/530-ip-use-rtnl_send_check-on-flush-commands.patch [deleted file]

index aa2f70e499056cc611fd59a0ca702bdcd47bde6c..e81747be3c3f541a4099e68e7470d2147917d397 100644 (file)
@@ -79,6 +79,9 @@ config BUSYBOX_DEFAULT_SELINUX
 config BUSYBOX_DEFAULT_FEATURE_CLEAN_UP
        bool
        default n
 config BUSYBOX_DEFAULT_FEATURE_CLEAN_UP
        bool
        default n
+config BUSYBOX_DEFAULT_FEATURE_SYSLOG_INFO
+       bool
+       default n
 config BUSYBOX_DEFAULT_FEATURE_SYSLOG
        bool
        default y
 config BUSYBOX_DEFAULT_FEATURE_SYSLOG
        bool
        default y
@@ -601,9 +604,6 @@ config BUSYBOX_DEFAULT_FALSE
 config BUSYBOX_DEFAULT_FOLD
        bool
        default n
 config BUSYBOX_DEFAULT_FOLD
        bool
        default n
-config BUSYBOX_DEFAULT_FSYNC
-       bool
-       default y
 config BUSYBOX_DEFAULT_HEAD
        bool
        default y
 config BUSYBOX_DEFAULT_HEAD
        bool
        default y
@@ -790,6 +790,9 @@ config BUSYBOX_DEFAULT_SYNC
 config BUSYBOX_DEFAULT_FEATURE_SYNC_FANCY
        bool
        default n
 config BUSYBOX_DEFAULT_FEATURE_SYNC_FANCY
        bool
        default n
+config BUSYBOX_DEFAULT_FSYNC
+       bool
+       default y
 config BUSYBOX_DEFAULT_TAC
        bool
        default n
 config BUSYBOX_DEFAULT_TAC
        bool
        default n
@@ -1618,6 +1621,9 @@ config BUSYBOX_DEFAULT_FEATURE_MDEV_EXEC
 config BUSYBOX_DEFAULT_FEATURE_MDEV_LOAD_FIRMWARE
        bool
        default n
 config BUSYBOX_DEFAULT_FEATURE_MDEV_LOAD_FIRMWARE
        bool
        default n
+config BUSYBOX_DEFAULT_FEATURE_MDEV_DAEMON
+       bool
+       default n
 config BUSYBOX_DEFAULT_MESG
        bool
        default n
 config BUSYBOX_DEFAULT_MESG
        bool
        default n
@@ -2023,6 +2029,9 @@ config BUSYBOX_DEFAULT_I2CDUMP
 config BUSYBOX_DEFAULT_I2CDETECT
        bool
        default n
 config BUSYBOX_DEFAULT_I2CDETECT
        bool
        default n
+config BUSYBOX_DEFAULT_I2CTRANSFER
+       bool
+       default n
 config BUSYBOX_DEFAULT_INOTIFYD
        bool
        default n
 config BUSYBOX_DEFAULT_INOTIFYD
        bool
        default n
@@ -2125,6 +2134,9 @@ config BUSYBOX_DEFAULT_STRINGS
 config BUSYBOX_DEFAULT_TIME
        bool
        default y
 config BUSYBOX_DEFAULT_TIME
        bool
        default y
+config BUSYBOX_DEFAULT_TS
+       bool
+       default n
 config BUSYBOX_DEFAULT_TTYSIZE
        bool
        default n
 config BUSYBOX_DEFAULT_TTYSIZE
        bool
        default n
@@ -2504,6 +2516,9 @@ config BUSYBOX_DEFAULT_TFTP
 config BUSYBOX_DEFAULT_FEATURE_TFTP_PROGRESS_BAR
        bool
        default n
 config BUSYBOX_DEFAULT_FEATURE_TFTP_PROGRESS_BAR
        bool
        default n
+config BUSYBOX_DEFAULT_FEATURE_TFTP_HPA_COMPAT
+       bool
+       default n
 config BUSYBOX_DEFAULT_TFTPD
        bool
        default n
 config BUSYBOX_DEFAULT_TFTPD
        bool
        default n
@@ -3047,6 +3062,9 @@ config BUSYBOX_DEFAULT_FEATURE_SH_MATH
 config BUSYBOX_DEFAULT_FEATURE_SH_MATH_64
        bool
        default y
 config BUSYBOX_DEFAULT_FEATURE_SH_MATH_64
        bool
        default y
+config BUSYBOX_DEFAULT_FEATURE_SH_MATH_BASE
+       bool
+       default n
 config BUSYBOX_DEFAULT_FEATURE_SH_EXTRA_QUIET
        bool
        default n
 config BUSYBOX_DEFAULT_FEATURE_SH_EXTRA_QUIET
        bool
        default n
index 9b80ed1f5ef2fe8e9b000395f0809b8497966e53..1e1712fe71a5290a94f25cb8a059b48ec606d3a1 100644 (file)
@@ -8,14 +8,14 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=busybox
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=busybox
-PKG_VERSION:=1.30.1
-PKG_RELEASE:=5
+PKG_VERSION:=1.31.0
+PKG_RELEASE:=1
 PKG_FLAGS:=essential
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=https://www.busybox.net/downloads \
                http://sources.buildroot.net
 PKG_FLAGS:=essential
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=https://www.busybox.net/downloads \
                http://sources.buildroot.net
-PKG_HASH:=3d1d04a4dbd34048f4794815a5c48ebb9eb53c5277e09ffffc060323b95dfbdc
+PKG_HASH:=0e4925392fd9f3743cc517e031b68b012b24a63b0cf6c1ff03cce7bb3846cc99
 
 PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam
 PKG_BUILD_PARALLEL:=1
 
 PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam
 PKG_BUILD_PARALLEL:=1
index 74493aa47542f004b195c5b9585dbde396de1dc2..8d1394c2e27a111c5c890c0bf9c790d33f71c870 100644 (file)
@@ -11,7 +11,7 @@ config BUSYBOX_CONFIG_HAVE_DOT_CONFIG
 menu "Settings"
 
 config BUSYBOX_CONFIG_DESKTOP
 menu "Settings"
 
 config BUSYBOX_CONFIG_DESKTOP
-       bool "Enable compatibility for full-blown desktop systems"
+       bool "Enable compatibility for full-blown desktop systems (8kb)"
        default BUSYBOX_DEFAULT_DESKTOP
        help
        Enable applet options and features which are not essential.
        default BUSYBOX_DEFAULT_DESKTOP
        help
        Enable applet options and features which are not essential.
@@ -338,6 +338,15 @@ config BUSYBOX_CONFIG_FEATURE_CLEAN_UP
        Don't enable this unless you have a really good reason to clean
        things up manually.
 
        Don't enable this unless you have a really good reason to clean
        things up manually.
 
+config BUSYBOX_CONFIG_FEATURE_SYSLOG_INFO
+       bool "Support LOG_INFO level syslog messages"
+       default BUSYBOX_DEFAULT_FEATURE_SYSLOG_INFO
+       depends on BUSYBOX_CONFIG_FEATURE_SYSLOG
+       help
+       Applets which send their output to syslog use either LOG_INFO or
+       LOG_ERR log levels, but by disabling this option all messages will
+       be logged at the LOG_ERR level, saving just under 200 bytes.
+
 # These are auto-selected by other options
 
 config BUSYBOX_CONFIG_FEATURE_SYSLOG
 # These are auto-selected by other options
 
 config BUSYBOX_CONFIG_FEATURE_SYSLOG
index 76e59a571d8a7d9cdb3769853dc1069e3989fafd..c5cd54d7f64ab907de2d11995136ec5a1b3fb180 100644 (file)
@@ -131,7 +131,7 @@ config BUSYBOX_CONFIG_FEATURE_DATE_COMPAT
        date -s (and other commands like touch -d) use more sensible
        formats (for one, ISO format YYYY-MM-DD hh:mm:ss.ssssss).
 
        date -s (and other commands like touch -d) use more sensible
        formats (for one, ISO format YYYY-MM-DD hh:mm:ss.ssssss).
 
-       With this option off, 'date DATE' is 'date -s DATE' support
+       With this option off, 'date DATE' and 'date -s DATE' support
        the same format. With it on, 'date DATE' additionally supports
        MMDDhhmm[[YY]YY][.ss] format.
 config BUSYBOX_CONFIG_DD
        the same format. With it on, 'date DATE' additionally supports
        MMDDhhmm[[YY]YY][.ss] format.
 config BUSYBOX_CONFIG_DD
@@ -282,11 +282,6 @@ config BUSYBOX_CONFIG_FOLD
        default BUSYBOX_DEFAULT_FOLD
        help
        Wrap text to fit a specific width.
        default BUSYBOX_DEFAULT_FOLD
        help
        Wrap text to fit a specific width.
-config BUSYBOX_CONFIG_FSYNC
-       bool "fsync (3.6 kb)"
-       default BUSYBOX_DEFAULT_FSYNC
-       help
-       fsync is used to flush file-related cached blocks to disk.
 config BUSYBOX_CONFIG_HEAD
        bool "head (3.8 kb)"
        default BUSYBOX_DEFAULT_HEAD
 config BUSYBOX_CONFIG_HEAD
        bool "head (3.8 kb)"
        default BUSYBOX_DEFAULT_HEAD
@@ -667,6 +662,11 @@ config BUSYBOX_CONFIG_FEATURE_SYNC_FANCY
        help
        sync -d FILE... executes fdatasync() on each FILE.
        sync -f FILE... executes syncfs() on each FILE.
        help
        sync -d FILE... executes fdatasync() on each FILE.
        sync -f FILE... executes syncfs() on each FILE.
+config BUSYBOX_CONFIG_FSYNC
+       bool "fsync (3.6 kb)"
+       default BUSYBOX_DEFAULT_FSYNC
+       help
+       fsync is used to flush file-related cached blocks to disk.
 config BUSYBOX_CONFIG_TAC
        bool "tac (3.9 kb)"
        default BUSYBOX_DEFAULT_TAC
 config BUSYBOX_CONFIG_TAC
        bool "tac (3.9 kb)"
        default BUSYBOX_DEFAULT_TAC
index dfd04fbd567132a7918346beb3b6800fdc325dd4..6ce6d2d7e38ad241975353e00f7fbb8c45d4141c 100644 (file)
@@ -470,6 +470,13 @@ config BUSYBOX_CONFIG_I2CDETECT
        help
        Detect I2C chips.
 
        help
        Detect I2C chips.
 
+config BUSYBOX_CONFIG_I2CTRANSFER
+       bool "i2ctransfer (4.0 kb)"
+       default BUSYBOX_DEFAULT_I2CTRANSFER
+       select BUSYBOX_CONFIG_PLATFORM_LINUX
+       help
+       Send user-defined I2C messages in one transfer.
+
 config BUSYBOX_CONFIG_INOTIFYD
        bool "inotifyd (3.6 kb)"
        default BUSYBOX_DEFAULT_INOTIFYD  # doesn't build on Knoppix 5
 config BUSYBOX_CONFIG_INOTIFYD
        bool "inotifyd (3.6 kb)"
        default BUSYBOX_DEFAULT_INOTIFYD  # doesn't build on Knoppix 5
@@ -728,6 +735,9 @@ config BUSYBOX_CONFIG_TIME
        The time command runs the specified program with the given arguments.
        When the command finishes, time writes a message to standard output
        giving timing statistics about this program run.
        The time command runs the specified program with the given arguments.
        When the command finishes, time writes a message to standard output
        giving timing statistics about this program run.
+config BUSYBOX_CONFIG_TS
+       bool "ts (450 bytes)"
+       default BUSYBOX_DEFAULT_TS
 config BUSYBOX_CONFIG_TTYSIZE
        bool "ttysize (432 bytes)"
        default BUSYBOX_DEFAULT_TTYSIZE
 config BUSYBOX_CONFIG_TTYSIZE
        bool "ttysize (432 bytes)"
        default BUSYBOX_DEFAULT_TTYSIZE
index a7d3d5a2e130fa2d19c5f5b02176327a6a84b6d3..1a740d998ef135ef40776e752d0cbafaf5c8b36d 100644 (file)
@@ -972,6 +972,11 @@ config BUSYBOX_CONFIG_FEATURE_TFTP_PROGRESS_BAR
        default BUSYBOX_DEFAULT_FEATURE_TFTP_PROGRESS_BAR
        depends on BUSYBOX_CONFIG_TFTP
 
        default BUSYBOX_DEFAULT_FEATURE_TFTP_PROGRESS_BAR
        depends on BUSYBOX_CONFIG_TFTP
 
+config BUSYBOX_CONFIG_FEATURE_TFTP_HPA_COMPAT
+       bool "tftp-hpa compat (support -c get/put FILE)"
+       default BUSYBOX_DEFAULT_FEATURE_TFTP_HPA_COMPAT
+       depends on BUSYBOX_CONFIG_TFTP
+
 config BUSYBOX_CONFIG_TFTPD
        bool "tftpd (10 kb)"
        default BUSYBOX_DEFAULT_TFTPD
 config BUSYBOX_CONFIG_TFTPD
        bool "tftpd (10 kb)"
        default BUSYBOX_DEFAULT_TFTPD
index 212e4a0bcb501c7d9abbf1711ea9c0278bad51dc..99d5bb9d21222fb870bd02e731dda2e380107a17 100644 (file)
@@ -104,7 +104,7 @@ config BUSYBOX_CONFIG_UDHCPC_DEFAULT_SCRIPT
 # udhcpc6 config is inserted here:
 config BUSYBOX_CONFIG_UDHCPC6
        bool "udhcpc6 (21 kb)"
 # udhcpc6 config is inserted here:
 config BUSYBOX_CONFIG_UDHCPC6
        bool "udhcpc6 (21 kb)"
-       default BUSYBOX_DEFAULT_UDHCPC6  # not yet ready
+       default BUSYBOX_DEFAULT_UDHCPC6
        depends on BUSYBOX_CONFIG_FEATURE_IPV6
        help
        udhcpc6 is a DHCPv6 client
        depends on BUSYBOX_CONFIG_FEATURE_IPV6
        help
        udhcpc6 is a DHCPv6 client
index ddaa333e0487b9bfd79b32c1c0b2e11f57a14732..1ae6eb042e5d6233b2b2134a5deddf41666f8281 100644 (file)
@@ -497,6 +497,11 @@ config BUSYBOX_CONFIG_FEATURE_SH_MATH_64
        slightly larger, but will allow computation with very large numbers.
        This is not in POSIX, so do not rely on this in portable code.
 
        slightly larger, but will allow computation with very large numbers.
        This is not in POSIX, so do not rely on this in portable code.
 
+config BUSYBOX_CONFIG_FEATURE_SH_MATH_BASE
+       bool "Support BASE#nnnn literals"
+       default BUSYBOX_DEFAULT_FEATURE_SH_MATH_BASE
+       depends on BUSYBOX_CONFIG_FEATURE_SH_MATH
+
 config BUSYBOX_CONFIG_FEATURE_SH_EXTRA_QUIET
        bool "Hide message on interactive shell startup"
        default BUSYBOX_DEFAULT_FEATURE_SH_EXTRA_QUIET
 config BUSYBOX_CONFIG_FEATURE_SH_EXTRA_QUIET
        bool "Hide message on interactive shell startup"
        default BUSYBOX_DEFAULT_FEATURE_SH_EXTRA_QUIET
index 20d7818f00fd3b051ccad1e47b9e227a14bb19de..1cb2245e324ff915a20b933d1becad652235ab47 100644 (file)
@@ -473,6 +473,17 @@ config BUSYBOX_CONFIG_FEATURE_MDEV_LOAD_FIRMWARE
        These devices will request userspace look up the files in
        /lib/firmware/ and if it exists, send it to the kernel for
        loading into the hardware.
        These devices will request userspace look up the files in
        /lib/firmware/ and if it exists, send it to the kernel for
        loading into the hardware.
+
+config BUSYBOX_CONFIG_FEATURE_MDEV_DAEMON
+       bool "Support daemon mode"
+       default BUSYBOX_DEFAULT_FEATURE_MDEV_DAEMON
+       depends on BUSYBOX_CONFIG_MDEV
+       help
+       Adds the -d option to run mdev in daemon mode handling hotplug
+       events from the kernel like udev. If the system generates many
+       hotplug events this mode of operation will consume less
+       resources than registering mdev as hotplug helper or using the
+       uevent applet.
 config BUSYBOX_CONFIG_MESG
        bool "mesg (1.4 kb)"
        default BUSYBOX_DEFAULT_MESG
 config BUSYBOX_CONFIG_MESG
        bool "mesg (1.4 kb)"
        default BUSYBOX_DEFAULT_MESG
index 2d61a2d77d6e597970c12bdacded266f75f9967c..4bab25a8d57816ac637be3a112b1ff2c9e789d4d 100644 (file)
@@ -13,6 +13,6 @@
        add_client_options(&packet);
  
 +      if (msgs++ < 3)
        add_client_options(&packet);
  
 +      if (msgs++ < 3)
-       bb_error_msg("sending %s", "discover");
-       return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
+       bb_info_msg("sending %s", "discover");
+       return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY);
  }
  }
index 51b15a73cc31230ee0eaffff97357c40afcf3702..256b049d9e2606fd94849d2bd98b0f564676db76 100644 (file)
@@ -1,6 +1,6 @@
 --- a/networking/udhcp/dhcpc.c
 +++ b/networking/udhcp/dhcpc.c
 --- a/networking/udhcp/dhcpc.c
 +++ b/networking/udhcp/dhcpc.c
-@@ -1417,6 +1417,12 @@ int udhcpc_main(int argc UNUSED_PARAM, c
+@@ -1416,6 +1416,12 @@ int udhcpc_main(int argc UNUSED_PARAM, c
                /* silence "uninitialized!" warning */
                unsigned timestamp_before_wait = timestamp_before_wait;
  
                /* silence "uninitialized!" warning */
                unsigned timestamp_before_wait = timestamp_before_wait;
  
@@ -8,8 +8,8 @@
 +               * member interfaces were added/removed or if the status of the
 +               * bridge changed).
 +               * Workaround: refresh it here before processing the next packet */
 +               * member interfaces were added/removed or if the status of the
 +               * bridge changed).
 +               * Workaround: refresh it here before processing the next packet */
-+              udhcp_read_interface(client_config.interface, &client_config.ifindex, NULL, client_config.client_mac);
++              udhcp_read_interface(client_data.interface, &client_data.ifindex, NULL, client_data.client_mac);
 +
 +
-               //bb_error_msg("sockfd:%d, listen_mode:%d", sockfd, listen_mode);
+               //bb_error_msg("sockfd:%d, listen_mode:%d", client_data.sockfd, client_data.listen_mode);
  
                /* Was opening raw or udp socket here
  
                /* Was opening raw or udp socket here
index 6f5d3cc8bf3b632b2a965592211bc30f4ef5120f..3d3c0cc403ea6371e84d8cddd5525138c756a314 100644 (file)
@@ -1,7 +1,7 @@
 --- a/networking/udhcp/dhcpc.c
 +++ b/networking/udhcp/dhcpc.c
 --- a/networking/udhcp/dhcpc.c
 +++ b/networking/udhcp/dhcpc.c
-@@ -1128,7 +1128,6 @@ static void perform_renew(void)
-               state = RENEW_REQUESTED;
+@@ -1126,7 +1126,6 @@ static void perform_renew(void)
+               client_data.state = RENEW_REQUESTED;
                break;
        case RENEW_REQUESTED: /* impatient are we? fine, square 1 */
 -              udhcp_run_script(NULL, "deconfig");
                break;
        case RENEW_REQUESTED: /* impatient are we? fine, square 1 */
 -              udhcp_run_script(NULL, "deconfig");
index fec2a3a5d030f470ec1bbadc71c9aa74d4cd8f02..773ba44db550e8ae0a3771e4b20f85bc8645f6cd 100644 (file)
@@ -1,6 +1,6 @@
 --- a/networking/telnetd.c
 +++ b/networking/telnetd.c
 --- a/networking/telnetd.c
 +++ b/networking/telnetd.c
-@@ -497,6 +497,7 @@ make_new_session(
+@@ -509,6 +509,7 @@ make_new_session(
  
        /* Restore default signal handling ASAP */
        bb_signals((1 << SIGCHLD) + (1 << SIGPIPE), SIG_DFL);
  
        /* Restore default signal handling ASAP */
        bb_signals((1 << SIGCHLD) + (1 << SIGPIPE), SIG_DFL);
index 3a85312e2f19fc66369b66b0688df66f1e6587cc..5aadbb233c6a3f1124bc5fff839a2e2806505cbe 100644 (file)
@@ -2,7 +2,7 @@
 +++ b/coreutils/date.c
 @@ -123,6 +123,7 @@
  //usage:      IF_FEATURE_DATE_ISOFMT(
 +++ b/coreutils/date.c
 @@ -123,6 +123,7 @@
  //usage:      IF_FEATURE_DATE_ISOFMT(
- //usage:     "\n      -D FMT          Use FMT for -d TIME conversion"
+ //usage:     "\n      -D FMT          Use FMT (strptime format) for -d TIME conversion"
  //usage:      )
 +//usage:     "\n      -k              Set Kernel timezone from localtime and exit"
  //usage:     "\n"
  //usage:      )
 +//usage:     "\n      -k              Set Kernel timezone from localtime and exit"
  //usage:     "\n"
diff --git a/package/utils/busybox/patches/530-ip-use-rtnl_send_check-on-flush-commands.patch b/package/utils/busybox/patches/530-ip-use-rtnl_send_check-on-flush-commands.patch
deleted file mode 100644 (file)
index 0e8ec37..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-From 028c5aa18b5273c029f0278232d922ee1a164de6 Mon Sep 17 00:00:00 2001
-From: Denys Vlasenko <vda.linux@googlemail.com>
-Date: Wed, 22 May 2019 13:54:46 +0200
-Subject: ip: use rtnl_send_check() on flush commands, closes 6962
-
-function                                             old     new   delta
-rtnl_send_check                                        -     160    +160
-xrtnl_wilddump_request                                64      66      +2
-ipneigh_list_or_flush                                714     706      -8
-rtnl_send                                             69       -     -69
-------------------------------------------------------------------------------
-(add/remove: 1/1 grow/shrink: 1/1 up/down: 162/-77)            Total: 85 bytes
-
-Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
----
- networking/libiproute/ipaddress.c  |  6 ++++--
- networking/libiproute/ipneigh.c    |  9 ++++----
- networking/libiproute/iproute.c    |  5 ++++-
- networking/libiproute/libnetlink.c | 43 +++++++++++++++++++++++++++++++-------
- networking/libiproute/libnetlink.h | 19 +++++++++++++++--
- 5 files changed, 65 insertions(+), 17 deletions(-)
-
---- a/networking/libiproute/ipaddress.c
-+++ b/networking/libiproute/ipaddress.c
-@@ -23,6 +23,7 @@
- struct filter_t {
-       char *label;
-+      /* Flush cmd buf. If !NULL, print_addrinfo() constructs flush commands in it */
-       char *flushb;
-       struct rtnl_handle *rth;
-       int scope, scopemask;
-@@ -34,6 +35,8 @@ struct filter_t {
-       smallint showqueue;
-       smallint oneline;
-       smallint up;
-+      /* Misnomer. Does not mean "flushed something" */
-+      /* More like "flush commands were constructed by print_addrinfo()" */
-       smallint flushed;
-       inet_prefix pfx;
- } FIX_ALIASING;
-@@ -201,7 +204,7 @@ static NOINLINE int print_linkinfo(const
- static int flush_update(void)
- {
--      if (rtnl_send(G_filter.rth, G_filter.flushb, G_filter.flushp) < 0) {
-+      if (rtnl_send_check(G_filter.rth, G_filter.flushb, G_filter.flushp) < 0) {
-               bb_perror_msg("can't send flush request");
-               return -1;
-       }
-@@ -507,7 +510,6 @@ int FAST_FUNC ipaddr_list_or_flush(char
-               xrtnl_dump_filter(&rth, store_nlmsg, &ainfo);
-       }
--
-       if (G_filter.family && G_filter.family != AF_PACKET) {
-               struct nlmsg_list **lp;
-               lp = &linfo;
---- a/networking/libiproute/ipneigh.c
-+++ b/networking/libiproute/ipneigh.c
-@@ -32,7 +32,10 @@ struct filter_t {
-       int state;
-       int unused_only;
-       inet_prefix pfx;
-+      /* Misnomer. Does not mean "flushed N something" */
-+      /* More like "no_of_flush_commands_constructed_by_print_neigh()" */
-       int flushed;
-+      /* Flush cmd buf. If !NULL, print_neigh() constructs flush commands in it */
-       char *flushb;
-       int flushp;
-       int flushe;
-@@ -45,7 +48,7 @@ typedef struct filter_t filter_t;
- static int flush_update(void)
- {
--      if (rtnl_send(G_filter.rth, G_filter.flushb, G_filter.flushp) < 0) {
-+      if (rtnl_send_check(G_filter.rth, G_filter.flushb, G_filter.flushp) < 0) {
-               bb_perror_msg("can't send flush request");
-               return -1;
-       }
-@@ -299,9 +302,7 @@ static int FAST_FUNC ipneigh_list_or_flu
-               G_filter.rth = &rth;
-               while (round < MAX_ROUNDS) {
--                      if (xrtnl_wilddump_request(&rth, G_filter.family, RTM_GETNEIGH) < 0) {
--                              bb_perror_msg_and_die("can't send dump request");
--                      }
-+                      xrtnl_wilddump_request(&rth, G_filter.family, RTM_GETNEIGH);
-                       G_filter.flushed = 0;
-                       if (xrtnl_dump_filter(&rth, print_neigh, NULL) < 0) {
-                               bb_perror_msg_and_die("flush terminated");
---- a/networking/libiproute/iproute.c
-+++ b/networking/libiproute/iproute.c
-@@ -26,7 +26,10 @@
- struct filter_t {
-       int tb;
-+      /* Misnomer. Does not mean "flushed something" */
-+      /* More like "flush commands were constructed by print_route()" */
-       smallint flushed;
-+      /* Flush cmd buf. If !NULL, print_route() constructs flush commands in it */
-       char *flushb;
-       int flushp;
-       int flushe;
-@@ -53,7 +56,7 @@ typedef struct filter_t filter_t;
- static int flush_update(void)
- {
--      if (rtnl_send(G_filter.rth, G_filter.flushb, G_filter.flushp) < 0) {
-+      if (rtnl_send_check(G_filter.rth, G_filter.flushb, G_filter.flushp) < 0) {
-               bb_perror_msg("can't send flush request");
-               return -1;
-       }
---- a/networking/libiproute/libnetlink.c
-+++ b/networking/libiproute/libnetlink.c
-@@ -34,7 +34,7 @@ void FAST_FUNC xrtnl_open(struct rtnl_ha
-       rth->seq = time(NULL);
- }
--int FAST_FUNC xrtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
-+void FAST_FUNC xrtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
- {
-       struct {
-               struct nlmsghdr nlh;
-@@ -48,18 +48,45 @@ int FAST_FUNC xrtnl_wilddump_request(str
-       req.nlh.nlmsg_seq = rth->dump = ++rth->seq;
-       req.g.rtgen_family = family;
--      return rtnl_send(rth, (void*)&req, sizeof(req));
-+      rtnl_send(rth, (void*)&req, sizeof(req));
- }
--//TODO: pass rth->fd instead of full rth?
--int FAST_FUNC rtnl_send(struct rtnl_handle *rth, char *buf, int len)
-+/* A version which checks for e.g. EPERM errors.
-+ * Try: setuidgid 1:1 ip addr flush dev eth0
-+ */
-+int FAST_FUNC rtnl_send_check(struct rtnl_handle *rth, const void *buf, int len)
- {
--      struct sockaddr_nl nladdr;
-+      struct nlmsghdr *h;
-+      int status;
-+      char resp[1024];
-+
-+      status = write(rth->fd, buf, len);
-+      if (status < 0)
-+              return status;
-+
-+      /* Check for immediate errors */
-+      status = recv(rth->fd, resp, sizeof(resp), MSG_DONTWAIT|MSG_PEEK);
-+      if (status < 0) {
-+              if (errno == EAGAIN) /* if no error, this happens */
-+                      return 0;
-+              return -1;
-+      }
-+
-+      for (h = (struct nlmsghdr *)resp;
-+          NLMSG_OK(h, status);
-+          h = NLMSG_NEXT(h, status)
-+      ) {
-+              if (h->nlmsg_type == NLMSG_ERROR) {
-+                      struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
-+                      if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr)))
-+                              bb_error_msg("ERROR truncated");
-+                      else
-+                              errno = -err->error;
-+                      return -1;
-+              }
-+      }
--      memset(&nladdr, 0, sizeof(nladdr));
--      nladdr.nl_family = AF_NETLINK;
--
--      return xsendto(rth->fd, buf, len, (struct sockaddr*)&nladdr, sizeof(nladdr));
-+      return 0;
- }
- int FAST_FUNC rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
---- a/networking/libiproute/libnetlink.h
-+++ b/networking/libiproute/libnetlink.h
-@@ -20,7 +20,7 @@ struct rtnl_handle {
- extern void xrtnl_open(struct rtnl_handle *rth) FAST_FUNC;
- #define rtnl_close(rth) (close((rth)->fd))
--extern int xrtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type) FAST_FUNC;
-+extern void xrtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type) FAST_FUNC;
- extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len) FAST_FUNC;
- extern int xrtnl_dump_filter(struct rtnl_handle *rth,
-               int (*filter)(const struct sockaddr_nl*, struct nlmsghdr *n, void*) FAST_FUNC,
-@@ -34,8 +34,23 @@ extern int rtnl_talk(struct rtnl_handle
-               int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
-               void *jarg) FAST_FUNC;
--extern int rtnl_send(struct rtnl_handle *rth, char *buf, int) FAST_FUNC;
-+int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int len) FAST_FUNC;
-+//TODO: pass rth->fd instead of full rth?
-+static ALWAYS_INLINE void rtnl_send(struct rtnl_handle *rth, const void *buf, int len)
-+{
-+      // Used to be:
-+      //struct sockaddr_nl nladdr;
-+      //memset(&nladdr, 0, sizeof(nladdr));
-+      //nladdr.nl_family = AF_NETLINK;
-+      //return xsendto(rth->fd, buf, len, (struct sockaddr*)&nladdr, sizeof(nladdr));
-+      // iproute2-4.2.0 simplified the above to:
-+      //return send(rth->fd, buf, len, 0);
-+
-+      // We are using even shorter:
-+      xwrite(rth->fd, buf, len);
-+      // and convert to void, inline.
-+}
- extern int addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data) FAST_FUNC;
- extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen) FAST_FUNC;