[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] ip addr: support change and replace commands
From: Michael Tokarev <mjt () tls ! msk ! ru>
Date: 2015-06-23 16:19:03
Message-ID: 558986F7.7020908 () msgid ! tls ! msk ! ru
[Download RAW message or body]
23.06.2015 18:44, Bernhard Reutner-Fischer wrote:
> On June 23, 2015 3:27:54 PM GMT+02:00, Michael Tokarev <mjt@tls.msk.ru> wrote:
>> Ping?
>>
>> 20.05.2015 16:27, Michael Tokarev wrote:
>>> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
>>> ---
>>> networking/ip.c | 2 +-
>>> networking/libiproute/ipaddress.c | 20 ++++++++++++--------
>>> 2 files changed, 13 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/networking/ip.c b/networking/ip.c
>>> index 98fe621..d35345c 100644
>>> --- 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"
>>> diff --git a/networking/libiproute/ipaddress.c
>> b/networking/libiproute/ipaddress.c
>>> index 4072d06..85f3356 100644
>>> --- a/networking/libiproute/ipaddress.c
>>> +++ b/networking/libiproute/ipaddress.c
>>> @@ -598,7 +598,7 @@ static int default_scope(inet_prefix *lcl)
>>> }
>>>
>>> /* 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 **argv)
>>> 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,20 @@ static int ipaddr_modify(int cmd, char **argv)
>>> 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);
>>> - }
>>> - /* 2 == list, 3 == show, 4 == lst */
>>> - return ipaddr_list_or_flush(argv, cmd == 5);
>>> + if (cmd <= 4)
>>> + return ipaddr_modify(cmd == 4 ? RTM_DELADDR : RTM_NEWADDR,
>
> wrong comma?
Nope, not wrong comma. The first argument is the command, and the second:
>>> + cmd == 0 ? NLM_F_CREATE|NLM_F_EXCL :
>>> + cmd == 1 || cmd == 2 ? NLM_F_REPLACE :
>>> + cmd == 3 ? NLM_F_CREATE|NLM_F_REPLACE :
>>> + 0, argv);
is the flags for the command.
>>> + }
>>> + return ipaddr_list_or_flush(argv, cmd == 8);
>
> bloat-o-meter output, please.
$ make bloatcheck
function old new delta
.rodata 6707 6771 +64
do_ipaddr 90 139 +49
static.commands 32 51 +19
ipaddr_modify 1084 1085 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 133/0) Total: 133 bytes
text data bss dec hex filename
47143 1305 8360 56808 dde8 busybox_old
47255 1305 8360 56920 de58 busybox_unstripped
Thanks,
/mjt
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic