summaryrefslogtreecommitdiff
path: root/networking/libiproute/iptunnel.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-11-18 22:56:25 +0000
committerDenis Vlasenko2007-11-18 22:56:25 +0000
commited6a49c657ae204f6ba8ad84315fa04c09297a7c (patch)
tree5f47e19e16582dfcdefb99bc1edea693e86c258d /networking/libiproute/iptunnel.c
parent2a587df80a148e497d10344c79f2b94d3bce6aaf (diff)
downloadbusybox-ed6a49c657ae204f6ba8ad84315fa04c09297a7c.zip
busybox-ed6a49c657ae204f6ba8ad84315fa04c09297a7c.tar.gz
ip: stop propagating argc; optimize ip_parse_common_args
function old new delta find_pair 167 187 +20 static.families - 17 +17 die_must_be_on_off - 11 +11 ... on_off 33 22 -11 do_ipaddr 103 90 -13 do_iptunnel 1001 986 -15 iproute_list_or_flush 1237 1217 -20 static.ip_common_commands 43 22 -21 do_iproute 2217 2193 -24 parse_args 1444 1414 -30 ip_do 47 16 -31 do_iprule 994 963 -31 ip_main 153 113 -40 ipaddr_modify 1357 1305 -52 ipaddr_list_or_flush 2543 2490 -53 ip_parse_common_args 294 159 -135 ------------------------------------------------------------------------------ (add/remove: 4/1 grow/shrink: 4/24 up/down: 85/-563) Total: -478 bytes text data bss dec hex filename 775561 966 9236 785763 bfd63 busybox_old 775073 962 9236 785271 bfb77 busybox_unstripped
Diffstat (limited to 'networking/libiproute/iptunnel.c')
-rw-r--r--networking/libiproute/iptunnel.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index a45e64d..ad909ff 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -126,7 +126,7 @@ static int do_del_ioctl(const char *basedev, struct ip_tunnel_parm *p)
}
/* Dies on error */
-static void parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
+static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p)
{
static const char keywords[] ALIGN1 =
"mode\0""ipip\0""ip/ip\0""gre\0""gre/ip\0""sit\0""ipv6/ip\0"
@@ -157,7 +157,7 @@ static void parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
#endif
p->iph.frag_off = htons(IP_DF);
- while (argc > 0) {
+ while (*argv) {
key = index_in_strings(keywords, *argv);
if (key == ARG_mode) {
NEXT_ARG();
@@ -289,7 +289,6 @@ static void parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
}
}
count++;
- argc--;
argv++;
}
@@ -327,11 +326,11 @@ static void parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
/* Return value becomes exitcode. It's okay to not return at all */
-static int do_add(int cmd, int argc, char **argv)
+static int do_add(int cmd, char **argv)
{
struct ip_tunnel_parm p;
- parse_args(argc, argv, cmd, &p);
+ parse_args(argv, cmd, &p);
if (p.iph.ttl && p.iph.frag_off == 0) {
bb_error_msg_and_die("ttl != 0 and noptmudisc are incompatible");
@@ -350,11 +349,11 @@ static int do_add(int cmd, int argc, char **argv)
}
/* Return value becomes exitcode. It's okay to not return at all */
-static int do_del(int argc, char **argv)
+static int do_del(char **argv)
{
struct ip_tunnel_parm p;
- parse_args(argc, argv, SIOCDELTUNNEL, &p);
+ parse_args(argv, SIOCDELTUNNEL, &p);
switch (p.iph.protocol) {
case IPPROTO_IPIP:
@@ -487,12 +486,12 @@ static void do_tunnels_list(struct ip_tunnel_parm *p)
}
/* Return value becomes exitcode. It's okay to not return at all */
-static int do_show(int argc, char **argv)
+static int do_show(char **argv)
{
int err;
struct ip_tunnel_parm p;
- parse_args(argc, argv, SIOCGETTUNNEL, &p);
+ parse_args(argv, SIOCGETTUNNEL, &p);
switch (p.iph.protocol) {
case IPPROTO_IPIP:
@@ -517,25 +516,24 @@ static int do_show(int argc, char **argv)
}
/* Return value becomes exitcode. It's okay to not return at all */
-int do_iptunnel(int argc, char **argv)
+int do_iptunnel(char **argv)
{
static const char keywords[] ALIGN1 =
"add\0""change\0""delete\0""show\0""list\0""lst\0";
enum { ARG_add = 0, ARG_change, ARG_del, ARG_show, ARG_list, ARG_lst };
int key;
- if (argc) {
+ if (*argv) {
key = index_in_substrings(keywords, *argv);
if (key < 0)
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
- --argc;
- ++argv;
+ argv++;
if (key == ARG_add)
- return do_add(SIOCADDTUNNEL, argc, argv);
+ return do_add(SIOCADDTUNNEL, argv);
if (key == ARG_change)
- return do_add(SIOCCHGTUNNEL, argc, argv);
+ return do_add(SIOCCHGTUNNEL, argv);
if (key == ARG_del)
- return do_del(argc, argv);
+ return do_del(argv);
}
- return do_show(argc, argv);
+ return do_show(argv);
}