On Tue, Oct 18, 2011 at 3:06 AM, Denys Vlasenko <[email protected]> wrote: > On Saturday 01 October 2011 18:12, Leonid Lisovskiy wrote: >> With all options enabled applet increases size of bb code approx. to >> 36Kb on x86. > > It looks WAY too big. > > There are planty of places to shrink the code. > For example, let's look at dhcp6c_script.c:
Ok, I will try follow your recommendations an prepare new version. > const char reason[] = "REASON=NBI"; > ... > *curr = xstrdup(reason); > > Why reason[] exists? Historical only, but exists in most manuals. For example - http://manpages.ubuntu.com/manpages/hardy/man8/dhcp6c.8.html > dhcp6_script() is called exactly one, this way: > > dhcp6_script(ifp->scriptpath, fill_envp_client6(optinfo, > ifp->ifname)); > > which is also the only callsite of fill_envp_client6. > Therefore, fill_envp_client6 can be made static to dhcp6c_script.c > and called *from within* dhcp6_script() (which, by the way, > is better be renamed to dhcp6_run_script()...) It is a part of future support DHCPv6 relay (almost ready) & server (incomplete), which share code of dhcp6_script(), but has much different environment variables. > Elsewhere, random observations: > > memset(&hints, 0, sizeof(hints)); > hints.ai_family = PF_INET6; > hints.ai_socktype = SOCK_DGRAM; > hints.ai_protocol = IPPROTO_UDP; > error = getaddrinfo(DH6ADDR_ALLAGENT, DH6PORT_UPSTREAM, &hints, &res); > if (error) { > bb_error_msg_and_die("getaddrinfo: %s", gai_strerror(error)); > } > memcpy(&G.sa6_allagent, res->ai_addr, res->ai_addrlen); > freeaddrinfo(res); > > ???! This is a fixed IPv6 address, [ff02::1:2]:547, it can be just a constant > struct, > right? This code come unmodified from wide-dhcpv6, seems to be you are right, I should do this optimization. > argv += optind; > argc -= optind; > if (argc < 1) { > bb_show_usage(); > } > > if (!(opt & OPT_FOREGROUND) && !(opt & OPT_i)) { > bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv); > > BUG: would re-execute (on NOMMU) with wrong argv: argv += optind > is done too early. Sorry, I haven't NOMMU for tests. I should move argv/argc modifications after bb_daemonize_or_rexec(), right? > Need documentation for /etc/dhcp6c.conf format. i.e. self-commented samples/udhcp/dhcp6c.conf isn't enough? > Patch does not compile with uclibc: > > networking/udhcp/lib.a(if6.o): In function `gethwid': > if6.c:(.text.gethwid+0xf): undefined reference to `getifaddrs' > if6.c:(.text.gethwid+0x9a): undefined reference to `freeifaddrs' > networking/udhcp/lib.a(if6.o): In function `if6init': > if6.c:(.text.if6init+0x88): undefined reference to `getifaddrs' > if6.c:(.text.if6init+0x10d): undefined reference to `freeifaddrs' Which uClibc version you are use? Have UCLIBC_SUPPORT_AI_ADDRCONFIG option turned on? Are use of getifaddrs/freeifaddrs prohibited in bb? > networking/udhcp/lib.a(common6.o): In function `duidstr': > common6.c:(.text.duidstr+0x9): undefined reference to > `BUG_dhcp6c_globals_too_big' > collect2: ld returned 1 exit status > make: *** [busybox_unstripped] Error 1 Can I ask you about COMMON_BUFSIZE value on your system? Leonid _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
