iperf: fix build on !MMU platforms
PATCH 1/2 iperf: fix build on !MMU platforms
Build tested on sh2a and blackfin architectures.
--- package/iperf/iperf-add-pthread.patch | 25 +++++++++++++++ package/iperf/iperf-man-installation.patch | 15 +++++++++ package/iperf/iperf-no-mmu.patch | 48 ++++++++++++++++++++++++++++ package/iperf/iperf.mk | 2 +- 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 package/iperf/iperf-add-pthread.patch create mode 100644 package/iperf/iperf-man-installation.patch create mode 100644 package/iperf/iperf-no-mmu.patch
package/iperf/iperf-add-pthread.patch new file +25 -0
@@ -0,0 +1,25 @@ +Fix pthread link problem + +Some toolchains support linking against pthread by passing +-pthread. For such toolchains, iperf was working because + at PTHREAD_CFLAGS@ was used. + +However, some other toolchains (ex: Renesas 2010.09) requires passing +-lpthread to link against the pthread library. And this was breaking +in iperf because @PTHREAD_LIBS@ wasn't used. We fix this here. + +Signed-off-by: Thomas Petazzoni <[email protected]> + +Index: b/src/Makefile.am +=================================================================== +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -12,7 +12,7 @@ + AM_CXXFLAGS = -Wall + AM_CFLAGS = -Wall + +-iperf_LDFLAGS = @CFLAGS@ @PTHREAD_CFLAGS@ @WEB100_CFLAGS@ @DEFS@ ++iperf_LDFLAGS = @CFLAGS@ @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ @WEB100_CFLAGS@ @DEFS@ + + iperf_SOURCES = \ + Client.cpp \
package/iperf/iperf-man-installation.patch new file +15 -0
@@ -0,0 +1,15 @@ +Fix man installation + +Using man_MANS and dist_man_MANS is redundant, and makes the Makefile +try to install twice the iperf.1 manpage, which fails. + +Signed-off-by: Thomas Petazzoni <[email protected]> + +Index: b/man/Makefile.am +=================================================================== +--- a/man/Makefile.am ++++ b/man/Makefile.am +@@ -1,2 +1 @@ +-man_MANS = iperf.1 +-dist_man_MANS = $(man_MANS) ++dist_man_MANS = iperf.1
package/iperf/iperf-no-mmu.patch new file +48 -0
48 lines not on this page · raw message
package/iperf/iperf.mk +1 -1
@@ -6,7 +6,7 @@ IPERF_VERSION = 2.0.5 IPERF_SOURCE = iperf-$(IPERF_VERSION).tar.gz IPERF_SITE = http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/iperf - +IPERF_AUTORECONF = YES IPERF_CONF_ENV = \ ac_cv_func_malloc_0_nonnull=yes \ ac_cv_type_bool=yes \
Signature · 1 line
1.7.9.5
PATCH 2/2 dropbear: fix on !MMU platforms
Build tested for sh2a and blackfin.
--- package/dropbear/dropbear-better-fork-test.patch | 232 ++++++++++++++++++++++ package/dropbear/dropbear-no-mmu.patch | 21 ++ package/dropbear/dropbear.mk | 1 + 3 files changed, 254 insertions(+) create mode 100644 package/dropbear/dropbear-better-fork-test.patch create mode 100644 package/dropbear/dropbear-no-mmu.patch
package/dropbear/dropbear-better-fork-test.patch new file +232 -0
@@ -0,0 +1,232 @@ +Upstream patch, will be part of the next Dropbear release. + +# HG changeset patch +# User Mike Frysinger <[email protected]> +# Date 1333864252 14400 +# Node ID 0ad95abf8d3c78d16203fa6e3609fccfdb1effba +# Parent 4d9511f98462cf1fdcc9f657534669fd4dc571bd +check for fork() and not __uClinux__ + +diff -r 4d9511f98462 -r 0ad95abf8d3c configure.in +--- a/configure.in Sun Apr 08 02:06:54 2012 -0400 ++++ b/configure.in Sun Apr 08 01:50:52 2012 -0400 +@@ -616,7 +616,7 @@ + AC_FUNC_MEMCMP + AC_FUNC_SELECT_ARGTYPES + AC_TYPE_SIGNAL +-AC_CHECK_FUNCS([dup2 getspnam getusershell memset putenv select socket strdup clearenv strlcpy strlcat daemon basename _getpty getaddrinfo freeaddrinfo getnameinfo]) ++AC_CHECK_FUNCS([dup2 getspnam getusershell memset putenv select socket strdup clearenv strlcpy strlcat daemon basename _getpty getaddrinfo freeaddrinfo getnameinfo fork]) + + AC_SEARCH_LIBS(basename, gen, AC_DEFINE(HAVE_BASENAME)) + +diff -r 4d9511f98462 -r 0ad95abf8d3c dbutil.c +--- a/dbutil.c Sun Apr 08 02:06:54 2012 -0400 ++++ b/dbutil.c Sun Apr 08 01:50:52 2012 -0400 +@@ -443,7 +443,7 @@ + return DROPBEAR_FAILURE; + } + +-#ifdef __uClinux__ ++#ifndef HAVE_FORK + pid = vfork(); + #else + pid = fork(); +diff -r 4d9511f98462 -r 0ad95abf8d3c scp.c +--- a/scp.c Sun Apr 08 02:06:54 2012 -0400 ++++ b/scp.c Sun Apr 08 01:50:52 2012 -0400 +@@ -130,22 +130,22 @@ + fprintf(stderr, " %s", a->list[i]); + fprintf(stderr, "\n"); + } +-#ifdef __uClinux__ ++#ifndef HAVE_FORK + pid = vfork(); + #else + pid = fork(); +-#endif /* __uClinux__ */ ++#endif + if (pid == -1) + fatal("do_local_cmd: fork: %s", strerror(errno)); + + if (pid == 0) { + execvp(a->list[0], a->list); + perror(a->list[0]); +-#ifdef __uClinux__ ++#ifndef HAVE_FORK + _exit(1); + #else + exit(1); +-#endif /* __uClinux__ */ ++#endif + } + + do_cmd_pid = pid; +@@ -171,6 +171,16 @@ + * assigns the input and output file descriptors on success. + */ + ++static void ++arg_setup(char *host, char *remuser, char *cmd) ++{ ++ replacearg(&args, 0, "%s", ssh_program); ++ if (remuser != NULL) ++ addargs(&args, "-l%s", remuser); ++ addargs(&args, "%s", host); ++ addargs(&args, "%s", cmd); ++} ++ + int + do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc) + { +@@ -198,22 +208,18 @@ + close(reserved[0]); + close(reserved[1]); + +- /* uClinux needs to build the args here before vforking, +- otherwise we do it later on. */ +-#ifdef __uClinux__ +- replacearg(&args, 0, "%s", ssh_program); +- if (remuser != NULL) +- addargs(&args, "-l%s", remuser); +- addargs(&args, "%s", host); +- addargs(&args, "%s", cmd); +-#endif /* __uClinux__ */ ++ /* uClinux needs to build the args here before vforking, ++ otherwise we do it later on. */ ++#ifndef HAVE_FORK ++ arg_setup(host, remuser, cmd); ++#endif + + /* Fork a child to execute the command on the remote host using ssh. */ +-#ifdef __uClinux__ ++#ifndef HAVE_FORK + do_cmd_pid = vfork(); + #else + do_cmd_pid = fork(); +-#endif /* __uClinux__ */ ++#endif + + if (do_cmd_pid == 0) { + /* Child. */ +@@ -224,27 +230,22 @@ + close(pin[0]); + close(pout[1]); + +-#ifndef __uClinux__ +- replacearg(&args, 0, "%s", ssh_program); +- if (remuser != NULL) +- addargs(&args, "-l%s", remuser); +- addargs(&args, "%s", host); +- addargs(&args, "%s", cmd); +-#endif /* __uClinux__ */ ++#ifndef HAVE_FORK ++ arg_setup(host, remuser, cmd); ++#endif + + execvp(ssh_program, args.list); + perror(ssh_program); +-#ifndef __uClinux__ ++#ifndef HAVE_FORK ++ _exit(1); ++#else + exit(1); +-#else +- _exit(1); +-#endif /* __uClinux__ */ ++#endif + } else if (do_cmd_pid == -1) { + fatal("fork: %s", strerror(errno)); + } + +- +-#ifdef __uClinux__ ++#ifndef HAVE_FORK + /* clean up command */ + /* pop cmd */ + xfree(args.list[args.num-1]); +@@ -260,7 +261,7 @@ + args.list[args.num-1]=NULL; + args.num--; + } +-#endif /* __uClinux__ */ ++#endif + + /* Parent. Close the other side, and return the local side. */ + close(pin[0]); +diff -r 4d9511f98462 -r 0ad95abf8d3c session.h +--- a/session.h Sun Apr 08 02:06:54 2012 -0400 ++++ b/session.h Sun Apr 08 01:50:52 2012 -0400 +@@ -218,7 +218,7 @@ + /* The resolved remote address, used for lastlog etc */ + char *remotehost; + +-#ifdef __uClinux__ ++#ifndef HAVE_FORK + pid_t server_pid; + #endif + +diff -r 4d9511f98462 -r 0ad95abf8d3c svr-chansession.c +--- a/svr-chansession.c Sun Apr 08 02:06:54 2012 -0400 ++++ b/svr-chansession.c Sun Apr 08 01:50:52 2012 -0400 +@@ -658,7 +658,7 @@ + + /* uClinux will vfork(), so there'll be a race as + connection_string is freed below. */ +-#ifndef __uClinux__ ++#ifdef HAVE_FORK + chansess->connection_string = make_connection_string(); + #endif + +@@ -670,7 +670,7 @@ + ret = ptycommand(channel, chansess); + } + +-#ifndef __uClinux__ ++#ifdef HAVE_FORK + m_free(chansess->connection_string); + #endif + +@@ -745,7 +745,7 @@ + return DROPBEAR_FAILURE; + } + +-#ifdef __uClinux__ ++#ifndef HAVE_FORK + pid = vfork(); + #else + pid = fork(); +@@ -863,9 +863,9 @@ + struct ChanSess *chansess = user_data; + char *usershell = NULL; + +- /* with uClinux we'll have vfork()ed, so don't want to overwrite the +- * hostkey. can't think of a workaround to clear it */ +-#ifndef __uClinux__ ++ /* with uClinux we'll have vfork()ed, so don't want to overwrite the ++ * hostkey. can't think of a workaround to clear it */ ++#ifdef HAVE_FORK + /* wipe the hostkey */ + sign_key_free(svr_opts.hostkey); + svr_opts.hostkey = NULL; +diff -r 4d9511f98462 -r 0ad95abf8d3c svr-session.c +--- a/svr-session.c Sun Apr 08 02:06:54 2012 -0400 ++++ b/svr-session.c Sun Apr 08 01:50:52 2012 -0400 +@@ -84,7 +84,7 @@ + + /* Initialise server specific parts of the session */ + svr_ses.childpipe = childpipe; +-#ifdef __uClinux__ ++#ifndef HAVE_FORK + svr_ses.server_pid = getpid(); + #endif + svr_authinitialise(); +@@ -157,7 +157,7 @@ + + _dropbear_log(LOG_INFO, fmtbuf, param); + +-#ifdef __uClinux__ ++#ifndef HAVE_FORK + /* only the main server process should cleanup - we don't want + * forked children doing that */ + if (svr_ses.server_pid == getpid()) +
package/dropbear/dropbear-no-mmu.patch new file +21 -0
@@ -0,0 +1,21 @@ +Fix fork() usage + +Signed-off-by: Thomas Petazzoni <[email protected]> + +Index: b/svr-main.c +=================================================================== +--- a/svr-main.c ++++ b/svr-main.c +@@ -262,8 +262,12 @@ + #ifdef DEBUG_NOFORK + fork_ret = 0; + #else ++#ifndef HAVE_FORK ++ fork_ret = vfork(); ++#else + fork_ret = fork(); + #endif ++#endif + if (fork_ret < 0) { + dropbear_log(LOG_WARNING, "Error forking: %s", strerror(errno)); + goto out;
package/dropbear/dropbear.mk +1 -0
@@ -9,6 +9,7 @@ DROPBEAR_SITE = http://matt.ucc.asn.au/dropbear/releases DROPBEAR_TARGET_BINS = dbclient dropbearkey dropbearconvert scp ssh DROPBEAR_MAKE = $(MAKE) MULTI=1 SCPPROGRESS=1 \ PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" +DROPBEAR_AUTORECONF = YES ifeq ($(BR2_PREFER_STATIC_LIB),y) DROPBEAR_MAKE += STATIC=1
Signature · 1 line
1.7.9.5
PATCH 1/2 iperf: fix build on !MMU platforms
In reply to Thomas PetazzoniQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
Thomas> Build tested on sh2a and blackfin architectures.
Thanks. Have you sent these patches upstream?
Thomas> ++++ b/src/Listener.cpp
Thomas> +@@ -679,7 +679,11 @@
Thomas> + pid_t pid;
Thomas> +
Thomas> + /* Create a child process & if successful, exit from the parent process */
Thomas> ++#ifndef HAVE_FORK
Thomas> ++ if ( (pid = vfork()) == -1 ) {
Thomas> ++#else
Thomas> + if ( (pid = fork()) == -1 ) {
Thomas> ++#endif
Thomas> + fprintf( stderr, "error in first child create\n");
Thomas> + exit(0);
I believe you aren't allowed to call exit() after vfork (but should use _exit() instead).
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/2 iperf: fix build on !MMU platforms
Quoted 19 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni<[email protected]> writes:
Thomas> Build tested on sh2a and blackfin architectures.
Thanks. Have you sent these patches upstream?
Thomas> ++++ b/src/Listener.cpp Thomas> +@@ -679,7 +679,11 @@ Thomas> + pid_t pid; Thomas> + Thomas> + /* Create a child process& if successful, exit from the parent process */ Thomas> ++#ifndef HAVE_FORK Thomas> ++ if ( (pid = vfork()) == -1 ) { Thomas> ++#else Thomas> + if ( (pid = fork()) == -1 ) { Thomas> ++#endif Thomas> + fprintf( stderr, "error in first child create\n"); Thomas> + exit(0);
Quoted 4 lines
I believe you aren't allowed to call
exit()after vfork (but should use_exit()instead).
This particular exit is OK, because it is in the error case.
It's the one below that is not OK. Or rather, nothing is OK, because the child process after a vfork is not supposed to do anything except exec() or _exit() - it certainly shouldn't return from the function. In fact, on Linux the parent process is suspended until the child either _exit()s or exec()s, so it doesn't daemonize at all.
I'm not sure how you can daemonize in a posixly-correct way on a NOMMU
target. But since we're running on Linux, we can just use daemon(), right? Both glibc and uclibc define it AFAIK.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286540 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F