busybox: fix ip applet and netlink behavior
authorSteven Barth <cyrus@openwrt.org>
Wed, 9 Sep 2015 10:38:16 +0000 (10:38 +0000)
committerSteven Barth <cyrus@openwrt.org>
Wed, 9 Sep 2015 10:38:16 +0000 (10:38 +0000)
Signed-off-by: Steven Barth <steven@midlink.org>
SVN-Revision: 46833

package/utils/busybox/Makefile
package/utils/busybox/patches/220-add_lock_util.patch
package/utils/busybox/patches/300-ip-addr-improvements.patch [new file with mode: 0644]
package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch [new file with mode: 0644]

index 83eb82a9288c24fc0aed685840dd16ac4fd22bca..fb247036a37edbadd9aa3bfdaba838dc570e83cc 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=busybox
 PKG_VERSION:=1.23.2
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 PKG_FLAGS:=essential
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
index f42edcb0dee6222cae8a811cb05c5fb5a45ea178..5c7ca26da8b373c59d8a71b5247ef58ae64e3adb 100644 (file)
@@ -1,6 +1,6 @@
 --- a/include/applets.src.h
 +++ b/include/applets.src.h
-@@ -211,6 +211,7 @@ IF_LN(APPLET_NOEXEC(ln, ln, BB_DIR_BIN, 
+@@ -211,6 +211,7 @@ IF_LN(APPLET_NOEXEC(ln, ln, BB_DIR_BIN,
  IF_LOAD_POLICY(APPLET(load_policy, BB_DIR_USR_SBIN, BB_SUID_DROP))
  IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP))
  IF_LOADKMAP(APPLET(loadkmap, BB_DIR_SBIN, BB_SUID_DROP))
diff --git a/package/utils/busybox/patches/300-ip-addr-improvements.patch b/package/utils/busybox/patches/300-ip-addr-improvements.patch
new file mode 100644 (file)
index 0000000..ba1bcd1
--- /dev/null
@@ -0,0 +1,73 @@
+From 6a7cd3d4aba493c0b0d00155b1e09a867db437cf Mon Sep 17 00:00:00 2001
+From: Michael Tokarev <mjt@tls.msk.ru>
+Date: Wed, 20 May 2015 16:27:44 +0300
+Subject: [PATCH] ip addr: support change and replace commands
+
+Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+ networking/ip.c                   |  2 +-
+ networking/libiproute/ipaddress.c | 20 ++++++++++++--------
+ 2 files changed, 13 insertions(+), 9 deletions(-)
+
+--- a/networking/ip.c
++++ b/networking/ip.c
+@@ -33,7 +33,7 @@
+ //usage:       "{ {add|del} IFADDR dev STRING | {show|flush}\n"
+ //usage:       "              [dev STRING] [to PREFIX] }"
+ //usage:#define ipaddr_full_usage "\n\n"
+-//usage:       "ipaddr {add|delete} IFADDR dev STRING\n"
++//usage:       "ipaddr {add|change|replace|delete} IFADDR dev STRING\n"
+ //usage:       "ipaddr {show|flush} [dev STRING] [scope SCOPE-ID]\n"
+ //usage:       "      [to PREFIX] [label PATTERN]\n"
+ //usage:       "      IFADDR := PREFIX | ADDR peer PREFIX\n"
+--- a/networking/libiproute/ipaddress.c
++++ b/networking/libiproute/ipaddress.c
+@@ -598,7 +598,7 @@ static int default_scope(inet_prefix *lc
+ }
+ /* Return value becomes exitcode. It's okay to not return at all */
+-static int ipaddr_modify(int cmd, char **argv)
++static int ipaddr_modify(int cmd, int flags, char **argv)
+ {
+       static const char option[] ALIGN1 =
+               "peer\0""remote\0""broadcast\0""brd\0"
+@@ -622,7 +622,7 @@ static int ipaddr_modify(int cmd, char *
+       memset(&req, 0, sizeof(req));
+       req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
+-      req.n.nlmsg_flags = NLM_F_REQUEST;
++      req.n.nlmsg_flags = NLM_F_REQUEST | flags;
+       req.n.nlmsg_type = cmd;
+       req.ifa.ifa_family = preferred_family;
+@@ -749,16 +749,24 @@ static int ipaddr_modify(int cmd, char *
+ int FAST_FUNC do_ipaddr(char **argv)
+ {
+       static const char commands[] ALIGN1 =
+-              "add\0""delete\0""list\0""show\0""lst\0""flush\0";
++              /* 0    1         2      3          4         5       6       7      8 */
++              "add\0""change\0""chg\0""replace\0""delete\0""list\0""show\0""lst\0""flush\0";
+       int cmd = 2;
+       if (*argv) {
+               cmd = index_in_substrings(commands, *argv);
+               if (cmd < 0)
+                       invarg(*argv, applet_name);
+               argv++;
+-              if (cmd <= 1)
+-                      return ipaddr_modify((cmd == 0) ? RTM_NEWADDR : RTM_DELADDR, argv);
++              if (cmd <= 4) {
++                      return ipaddr_modify(
++                              /*cmd:*/ cmd == 4 ? RTM_DELADDR : RTM_NEWADDR,
++                              /*flags:*/
++                                      cmd == 0 ? NLM_F_CREATE|NLM_F_EXCL : /* add */
++                                      cmd == 1 || cmd == 2 ? NLM_F_REPLACE : /* change */
++                                      cmd == 3 ? NLM_F_CREATE|NLM_F_REPLACE : /* replace */
++                                      0 /* delete */
++                      , argv);
++              }
+       }
+-      /* 2 == list, 3 == show, 4 == lst */
+-      return ipaddr_list_or_flush(argv, cmd == 5);
++      return ipaddr_list_or_flush(argv, cmd == 8);
+ }
diff --git a/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch b/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch
new file mode 100644 (file)
index 0000000..360324b
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/networking/libiproute/iplink.c
++++ b/networking/libiproute/iplink.c
+@@ -470,7 +470,7 @@ static int do_add_or_delete(char **argv,
+       }
+       xrtnl_open(&rth);
+       ll_init_map(&rth);
+-      if (type_str) {
++      if (type_str && rtm == RTM_NEWLINK) {
+               struct rtattr *linkinfo = NLMSG_TAIL(&req.n);
+               addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0);