Remove Noux networking support

Noux networking is not well tested and not in practical use. It also
uses a number of deprecated libraries.

Ref #2535
Fix #2955
This commit is contained in:
Ehmry - 2018-08-30 14:56:02 +02:00 committed by Norman Feske
parent 0603481aaa
commit 1370fa7631
39 changed files with 20 additions and 1407 deletions

View File

@ -3,7 +3,7 @@ build {
app/sequence
drivers/timer
lib/libc_noux
noux/minimal
noux
noux-pkg/coreutils
server/vfs
lib/vfs/audit

View File

@ -10,7 +10,7 @@
if {[have_spec linux]} { puts "Run script does not support Linux"; exit 0 }
set build_components {
core init noux/minimal lib/libc_noux app/cli_monitor test/bomb test/signal
core init noux lib/libc_noux app/cli_monitor test/bomb test/signal
test/resource_yield drivers/timer drivers/uart server/terminal_mux
server/terminal_log noux-pkg/vim
}

View File

@ -1 +0,0 @@
3ca6fd9c7fde4057f10d597d6e9fb62371f09217

View File

@ -1,7 +0,0 @@
LICENSE := BSD
VERSION := 8.2.0
DOWNLOADS := etc.svn
URL(etc) := http://svn.freebsd.org/base/release/$(VERSION)/etc
REV(etc) := HEAD
DIR(etc) := src/noux-pkg/etc

View File

@ -1 +0,0 @@
246c70837772a85dbadb01537242adb020bcffed

View File

@ -1,8 +0,0 @@
LICENSE := GPLv2
VERSION := 2.8.8rel.2
DOWNLOADS := lynx.archive
URL(lynx) := ftp://ftp.invisible-island.net/lynx/tarballs/lynx$(VERSION).tar.gz
SHA(lynx) := 234c9dc77d4c4594ad6216d7df4d49eae3019a3880e602f39721b35b97fbc408
SIG(lynx) := ${URL(lynx)}.asc
DIR(lynx) := src/noux-pkg/lynx

View File

@ -1 +0,0 @@
466a032cb884bc2e28f6c3b9f40cf1ed22bd2c07

View File

@ -1,8 +0,0 @@
LICENSE := GPLv2
VERSION := 0.7.1
DOWNLOADS := netcat.archive
URL(netcat) := http://downloads.sourceforge.net/sourceforge/netcat/netcat-$(VERSION).tar.bz2
SHA(netcat) := b55af0bbdf5acc02d1eb6ab18da2acd77a400bafd074489003f3df09676332bb
DIR(netcat) := src/noux-pkg/netcat

View File

@ -1 +0,0 @@
52fee484002bd753d6bc6674b8b4d99aa498801e

View File

@ -1,13 +0,0 @@
LICENSE := BSD
VERSION := 7.1p1
DOWNLOADS := openssh.archive
URL(openssh) := http://artfiles.org/openbsd/OpenSSH/portable/openssh-$(VERSION).tar.gz
SHA(openssh) := fc0a6d2d1d063d5c66dffd952493d0cda256cad204f681de0f84ef85b2ad8428
SIG(openssh) := ${URL(openssh)}.asc
KEY(openssh) := 3981992A1523ABA079DBFC66CE8ECB0386FF9C48
DIR(openssh) := src/noux-pkg/openssh
PATCHES := $(addprefix ${DIR(openssh)}/,\
$(notdir $(wildcard $(REP_DIR)/${DIR(openssh)}/*.patch)))
PATCH_OPT := -N -p1

View File

@ -5,7 +5,7 @@ if {[have_spec linux]} {
set build_components {
core init drivers/timer drivers/uart
noux/minimal lib/libc_noux
noux lib/libc_noux
server/ram_fs test/libc_noux
}

View File

@ -1,4 +1,4 @@
build { core init drivers/timer noux/minimal server/log_terminal
build { core init drivers/timer noux server/log_terminal
lib/libc_noux noux-pkg/coreutils }
create_boot_directory

View File

@ -1,5 +1,5 @@
build {
core init drivers/timer server/log_terminal noux/minimal lib/libc_noux
core init drivers/timer server/log_terminal noux lib/libc_noux
test/noux_fork
}

View File

@ -1,249 +0,0 @@
set use_usb_driver [expr [have_spec omap4] || [have_spec arndale] || [have_spec rpi]]
set use_nic_driver [expr !$use_usb_driver && ![have_spec linux] && ![have_spec odroid_xu]]
if {[expr !$use_usb_driver && !$use_nic_driver] ||
[expr [have_include "power_on/qemu"] && [have_spec zynq]] ||
[expr [have_spec imx53] && [have_spec trustzone]]} {
puts "\n Run script is not supported on this platform. \n"; exit 0 }
set bridge_mac "02:02:02:02:02:00"
# autopilot: configure disjoint mac-address ranges for x86_32, x86_64, and others
if {[get_cmd_switch --autopilot]} {
if {[have_spec x86_32]} { set bridge_mac "02:02:02:02:32:00" }
if {[have_spec x86_64]} { set bridge_mac "02:02:02:02:64:00" }
}
set build_components {
core init
drivers/timer
server/tcp_terminal
server/nic_bridge
noux/net lib/libc_noux
noux-pkg/netcat
}
proc gpio_drv { } { if {[have_spec rpi] && [have_spec hw]} { return hw_gpio_drv }
if {[have_spec rpi] && [have_spec foc]} { return foc_gpio_drv }
return gpio_drv }
lappend_if $use_usb_driver build_components drivers/usb
lappend_if $use_nic_driver build_components drivers/nic
lappend_if [have_spec gpio] build_components drivers/gpio
lappend_if [have_include "power_on/qemu"] build_components drivers/uart
source ${genode_dir}/repos/base/run/platform_drv.inc
append_platform_drv_build_components
build $build_components
#
# The '<build-dir>/bin/etc/' directory is expected to contain the
# files 'services', 'protocols', and 'hosts'.
# Download these files from the FreeBSD source tree is possible.
#
exec mkdir -p bin/etc
set freebsd_url "http://svn.freebsd.org/base/release/8.2.0/etc"
foreach etc_file { services protocols hosts } {
if {![file exists bin/etc/$etc_file]} {
catch { exec wget -c -P bin/etc $freebsd_url/$etc_file } } }
exec tar rfv bin/netcat.tar -h -C bin/ etc
create_boot_directory
append config {
<config verbose="yes">
<parent-provides>
<service name="ROM"/>
<service name="LOG"/>
<service name="RM"/>
<service name="CPU"/>
<service name="PD"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
<default caps="100"/>
<start name="timer">
<resource name="RAM" quantum="1M"/>
<provides><service name="Timer"/></provides>
</start>}
append_if [have_include "power_on/qemu"] config {
<start name="uart_drv">
<resource name="RAM" quantum="1M"/>
<provides>
<service name="Terminal"/>
<service name="Uart"/>
</provides>
<config>
<policy label_prefix="noux_net" uart="1"/>
</config>
</start>}
if {![have_include "power_on/qemu"]} {
append config {
<start name="tcp_terminal" caps="200">
<resource name="RAM" quantum="5M"/>
<provides> <service name="Terminal"/> </provides>
<route>
<service name="Nic"> <child name="nic_bridge"/> </service>
<any-service> <parent/> <any-child/> </any-service>
</route>
<config>
<policy label_prefix="noux_net" port="8888"/>
</config>
</start>
<start name="nic_bridge" caps="200">
<resource name="RAM" quantum="6M"/>
<provides><service name="Nic"/></provides>
<config mac="} $bridge_mac {"/>
<route>}
append_if $use_nic_driver config {
<service name="Nic"> <child name="nic_drv"/></service>}
append_if $use_usb_driver config {
<service name="Nic"> <child name="usb_drv"/></service>}
append config {
<any-service> <parent/> </any-service>
</route>
</start>}
}
append_if $use_nic_driver config {
<start name="nic_drv" caps="130">
<resource name="RAM" quantum="20M"/>
<provides> <service name="Nic"/> </provides>
} [nic_drv_config] {
</start>}
append_if [have_spec gpio] config "
<start name=\"[gpio_drv]\" caps=\"140\">
<resource name=\"RAM\" quantum=\"4M\"/>
<provides><service name=\"Gpio\"/></provides>
<config/>
</start>"
append_if $use_usb_driver config {
<start name="usb_drv" caps="120">
<resource name="RAM" quantum="14M"/>
<provides>
<service name="Nic"/>
<service name="Input"/>
</provides>
<config uhci="no" ehci="yes" xhci="no">
<nic mac="02:00:00:00:01:01"/>
</config>
</start>}
append_platform_drv_config
append config {
<start name="noux_net" caps="500">
<resource name="RAM" quantum="1G"/>
<config>
<fstab> <tar name="netcat.tar" at="/"/> </fstab>
<start name="/bin/netcat">
<arg value="-l"/>
<arg value="-p 5555"/>
</start>
</config>}
append_if [expr ![have_include "power_on/qemu"]] config {
<route>
<service name="Nic"> <child name="nic_bridge"/> </service>
<any-service> <parent/> <any-child/> </any-service>
</route>}
append config {
</start>
</config>
}
install_config $config
#
# Boot modules
#
# generic modules
set boot_modules {
core init timer tcp_terminal nic_bridge
ld.lib.so noux_net libc.lib.so vfs.lib.so libm.lib.so libc_pipe.lib.so pthread.lib.so
libc_noux.lib.so lwip_legacy.lib.so netcat.tar posix.lib.so
}
# platform-specific modules
lappend_if $use_nic_driver boot_modules nic_drv
lappend_if $use_usb_driver boot_modules usb_drv
lappend_if [have_include "power_on/qemu"] boot_modules uart_drv
lappend_if [have_spec gpio] boot_modules [gpio_drv]
append_platform_drv_boot_modules
build_boot_image $boot_modules
set noux_output_file "noux_output.log"
set serial_ip_addr "localhost"
set noux_ip_addr "localhost"
if {[have_include "power_on/qemu"]} {
#
# Redirect the output of Noux via the virtual serial port 1 into a file to be
# dumped after the successful completion of the test.
append qemu_args " -nographic"
append qemu_args " -serial mon:stdio"
append qemu_args " -serial file:$noux_output_file"
append_if [have_spec x86] qemu_args " -net nic,model=e1000 "
append_if [have_spec lan9118] qemu_args " -net nic,model=lan9118 "
append qemu_args " -net user -redir tcp:5555::5555 "
run_genode_until {.*got IP address.*\n} 60
set serial_id [output_spawn_id]
} else {
# wait until we got both IP addresses in the output afterwards
run_genode_until {.*got IP address.*\n.*got IP address.*\n} 60
set serial_id [output_spawn_id]
regexp {\[init -> noux_net\] got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $output noux_ip_addr
regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $noux_ip_addr noux_ip_addr
regexp {\[init -> tcp_terminal\] got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $output serial_ip_addr
regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $serial_ip_addr serial_ip_addr
# connect to Genode target and reading log output via network connection
spawn socat -u tcp:$serial_ip_addr:8888 OPEN:$noux_output_file,creat,append
}
sleep 4
puts "--- serial '$serial_ip_addr' noux '$noux_ip_addr'"
#
# This usage of netcat needs the OpenBSD nc command and will not
# work with GNU netcat because it will not close the connection
# automatically after sending the string.
#
exec echo -e "Hello Genode" | netcat $noux_ip_addr 5555 &
run_genode_until {exited with exit value 1} 20 $serial_id
sleep 4
set output [exec cat $noux_output_file]
puts "\noutput:\n$output\n"
exec rm $noux_output_file
exec rm -r bin/etc
if {![regexp {Hello Genode} $output dummy]} {
puts stderr "Error: output not as expected"
exit 1
}

View File

@ -1,6 +1,6 @@
set build_components {
core init drivers/timer drivers/uart
noux/minimal
noux
test/noux_signals
}

View File

@ -30,7 +30,7 @@ set use_usb_input [expr ![have_spec ps2] && ![have_spec sdl] && [have_spec usb]]
create_boot_directory
set build_components {
core init drivers/timer noux/minimal lib/libc_noux
core init drivers/timer noux lib/libc_noux
server/log_terminal server/ram_fs
test/libports/ncurses
}

View File

@ -3,7 +3,7 @@ build {
app/sequence
drivers/timer
lib/libc_noux
noux/minimal
noux
noux-pkg/coreutils
}

View File

@ -106,7 +106,7 @@ set build_components {
server/ram_fs server/report_rom
server/tcp_terminal drivers/nic
lib/libc_noux
noux/minimal
noux
}
#

View File

@ -1,8 +0,0 @@
TARGET = lighttpd_noux
include $(REP_DIR)/src/app/lighttpd/target.inc
# search path for 'plugin-static.h'
INC_DIR += $(REP_DIR)/src/app/lighttpd
LIBS += libc_noux

View File

@ -1,42 +0,0 @@
CONFIGURE_ARGS = --with-ssl \
--with-zlib \
--disable-nls \
--disable-ipv6 \
--disable-rpath-hack \
--with-cfg-file=/etc/lynx.cfg \
--with-lss-file=/etc/lynx.lss
#
# Rather than dealing with autoconf force usage of <openssl/xxx.h>
# by defining it explicitly
#
CFLAGS += -DUSE_OPENSSL_INCL
#
# Needed for <sys/types.h>
#
CFLAGS += -D__BSD_VISIBLE
LIBS += ncurses zlib libssl libcrypto
#
# Make the zlib linking test succeed
#
Makefile: dummy_libs
LDFLAGS += -L$(PWD)
dummy_libs: libcrypto.a libssl.a libz.a
libcrypto.a:
$(VERBOSE)$(AR) -rc $@
libssl.a:
$(VERBOSE)$(AR) -rc $@
libz.a:
$(VERBOSE)$(AR) -rc $@
INSTALL_TARGET = install
include $(call select_from_repositories,mk/noux.mk)

View File

@ -1,3 +0,0 @@
TARGET = netcat
include $(call select_from_repositories,mk/noux.mk)

View File

@ -1,28 +0,0 @@
#
# This is no actual noux-pkg but a collection of files
# which are essential for noux/net.
#
BUILD_BIN_DIR = ../../bin
TARGET_DIR = $(BUILD_BIN_DIR)/noux-etc/etc
ETC_CONTRIB_DIR := $(call select_from_ports,etc)/src/noux-pkg/etc
ETC_FILES = hosts \
nsswitch.conf \
protocols \
services
TARGET = noux-etc.build
copy-contrib-files:
$(VERBOSE)mkdir -p $(TARGET_DIR)
$(VERBOSE)for i in $(ETC_FILES); do \
cp $(ETC_CONTRIB_DIR)/$$i $(TARGET_DIR) ; \
done
generate-files: copy-contrib-files
$(BUILD_BIN_DIR)/$(TARGET): generate-files
$(TARGET): $(BUILD_BIN_DIR)/$(TARGET)

View File

@ -1,75 +0,0 @@
Although we use FreeBSD libc we actually do not have __progname. As
interim fix we just remove the check from configure.
diff --git a/configure b/configure
index 0d7a5b9..3218724 100755
--- a/src/noux-pkg/openssh/configure
+++ b/src/noux-pkg/openssh/configure
@@ -30485,67 +30485,6 @@ _ACEOF
fi
-{ echo "$as_me:$LINENO: checking if libc defines __progname" >&5
-echo $ECHO_N "checking if libc defines __progname... $ECHO_C" >&6; }
-if test "${ac_cv_libc_defines___progname+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
- extern char *__progname; printf("%s", __progname);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext &&
- $as_test_x conftest$ac_exeext; then
- ac_cv_libc_defines___progname="yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_libc_defines___progname="no"
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_libc_defines___progname" >&5
-echo "${ECHO_T}$ac_cv_libc_defines___progname" >&6; }
-if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE___PROGNAME 1
-_ACEOF
-
-fi
{ echo "$as_me:$LINENO: checking whether $CC implements __FUNCTION__" >&5
echo $ECHO_N "checking whether $CC implements __FUNCTION__... $ECHO_C" >&6; }

View File

@ -1,22 +0,0 @@
set*uid() is not implemented but it does not matter anyway because there
is only one user per noux instance.
diff --git a/sshconnect.h b/sshconnect.h
index 0ea6e99..18f7d36 100644
--- a/src/noux-pkg/openssh/sshconnect.h
+++ b/src/noux-pkg/openssh/sshconnect.h
@@ -55,6 +55,7 @@ void ssh_userauth2(const char *, const char *, char *, Sensitive *);
void ssh_put_password(char *);
int ssh_local_cmd(const char *);
+#if 0
/*
* Macros to raise/lower permissions.
*/
@@ -73,3 +74,6 @@ int ssh_local_cmd(const char *);
strerror(errno)); \
errno = save_errno; \
} while (0)
+#endif
+#define PRIV_START
+#define PRIV_END

View File

@ -1,67 +0,0 @@
TARGET = openssh
#
# This prefix 'magic' is needed because OpenSSH uses $exec_prefix
# while compiling (e.g. -DSSH_PATH) and in the end the $prefix and
# $exec_prefix path differ.
#
CONFIGURE_ARGS += --disable-ip6 \
--with-md5-passwords \
--without-zlib-version-check \
--with-ssl-engine \
--without-stackprotect \
--disable-finger \
--disable-gopher \
--disable-news \
--disable-ftp \
--disable-rpath-hack \
--disable-utmpx \
--disable-strip \
--exec-prefix= \
--bindir=/bin \
--sbindir=/bin \
--libexecdir=/bin
INSTALL_TARGET = install
LIBS += libcrypto libssl zlib
built.tag: Makefile Makefile_patch
Makefile_patch: Makefile
@#
@# Our $(LDFLAGS) contain options which are usable by gcc(1)
@# only. So instead of using ld(1) to link the binary, we have
@# to use gcc(1).
@#
$(VERBOSE)sed -i 's|^LD=.*|LD=$(CC)|' Makefile
@#
@# We do not want to generate host-keys because we are crosscompiling
@# and we can not run Genode binaries on the build system.
@#
$(VERBOSE)sed -i 's|^install:.*||' Makefile
$(VERBOSE)sed -i 's|^install-nokeys:|install:|' Makefile
@#
@# The path of ssh(1) is hardcoded to $(bindir)/ssh which in our
@# case is insufficient.
@#
$(VERBOSE)sed -i 's|^SSH_PROGRAM=.*|SSH_PROGRAM=/bin/ssh|' Makefile
#
# Make the zlib linking test succeed
#
Makefile: dummy_libs
LDFLAGS += -L$(PWD)
dummy_libs: libz.a libcrypto.a libssl.a
libcrypto.a:
$(VERBOSE)$(AR) -rc $@
libssl.a:
$(VERBOSE)$(AR) -rc $@
libz.a:
$(VERBOSE)$(AR) -rc $@
include $(call select_from_repositories,mk/noux.mk)

View File

@ -285,11 +285,6 @@ class Noux::Child : public Rpc_object<Session>,
io->unregister_wake_up_notifier(&notifier);
}
/**
* Method for handling noux network related system calls
*/
bool _syscall_net(Syscall sc);
void _destruct()
{
_ep.dissolve(this);

View File

@ -1,21 +0,0 @@
/**
* \brief Noux initialization
* \author Sebastian Sumpf
* \date 2017-02-24
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef __NOUX_CONSTRUCT_H_
#define __NOUX_CONSTRUCT_H_
namespace Genode { class Env; }
void noux_construct(Genode::Env &env);
#endif /* __NOUX_CONSTRUCT_H_ */

View File

@ -18,7 +18,6 @@
/* Noux includes */
#include <child.h>
#include <construct.h>
#include <noux_session/sysio.h>
#include <vfs_io_channel.h>
#include <terminal_io_channel.h>
@ -38,8 +37,6 @@ namespace Noux {
void init_process_exited(int exit) { init_child = 0; exit_value = exit; }
}
extern void init_network();
Noux::Io_receptor_registry * Noux::io_receptor_registry()
{
@ -271,8 +268,6 @@ struct Noux::Main
User_info _user_info { _config.xml() };
bool _network_initialized = (init_network(), true);
Signal_handler<Main> _destruct_handler {
_env.ep(), *this, &Main::_handle_destruct };
@ -355,7 +350,7 @@ struct Noux::Main
};
void noux_construct(Genode::Env &env)
void Component::construct(Genode::Env &env)
{
static Noux::Main main(env);
}

View File

@ -1,20 +0,0 @@
/**
* \brief Noux initialization
* \author Sebastian Sumpf
* \date 2017-02-24
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#include <base/component.h>
#include <construct.h>
void Component::construct(Genode::Env &env)
{
noux_construct(env);
}

View File

@ -1,19 +0,0 @@
/*
* \brief Dummy stubs for network-related Noux functions
* \author Norman Feske
* \date 2012-05-24
*/
/*
* Copyright (C) 2011-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* local includes */
#include <child.h>
void init_network() { }
bool Noux::Child::_syscall_net(Noux::Session::Syscall sc) { return false; }

View File

@ -1,11 +0,0 @@
TARGET = noux
LIBS = base alarm vfs
SRC_CC = main.cc syscall.cc dummy_net.cc construct.cc
INC_DIR += $(PRG_DIR)
INC_DIR += $(PRG_DIR)/../
vpath main.cc $(PRG_DIR)/..
vpath syscall.cc $(PRG_DIR)/..
vpath dummy_net.cc $(PRG_DIR)
CC_CXX_WARN_STRICT =

View File

@ -1,4 +0,0 @@
This directory contains the implementation of network related stuff for noux.
Currently network support is provided by using the libc and lwip directly
(only for initialization of the actual network subsystem).

View File

@ -1,20 +0,0 @@
/**
* \brief Noux initialization
* \author Sebastian Sumpf
* \date 2017-02-24
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#include <libc/component.h>
#include <construct.h>
void Libc::Component::construct(Libc::Env &env)
{
noux_construct(env);
}

View File

@ -1,243 +0,0 @@
/*
* \brief Unix emulation environment for Genode
* \author Josef Soentgen
* \date 2012-04-13
*/
/*
* Copyright (C) 2011-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* Genode includes */
#include <dataspace/client.h>
#include <base/lock.h>
#include <lwip_legacy/genode.h>
/* Noux includes */
#include <child.h>
#include <socket_io_channel.h>
#include <shared_pointer.h>
#include <io_receptor_registry.h>
/* Libc includes */
#include <sys/select.h>
#include <sys/time.h>
#include <netdb.h>
using namespace Noux;
void (*libc_select_notify)();
/* helper macro for casting the backend */
#define GET_SOCKET_IO_CHANNEL_BACKEND(backend, name) \
Socket_io_channel_backend *name = \
dynamic_cast<Socket_io_channel_backend*>(backend)
/**
* This callback function is called from lwip via the libc_select_notify
* function pointer if an event occurs.
*/
static void select_notify()
{
static Genode::Lock mutex;
/*
* The function could be called multiple times while actually
* still running.
*/
Genode::Lock::Guard guard(mutex);
for (Io_receptor *r = io_receptor_registry()->first();
r != 0; r = r->next()) {
r->check_and_wakeup();
}
}
/**
* Initialise the network subsystem by directly using lwip
*/
void init_network()
{
log("--- noux: initialize network ---");
if (!libc_select_notify)
libc_select_notify = select_notify;
}
/*********************************
** Noux net syscall dispatcher **
*********************************/
bool Noux::Child::_syscall_net(Noux::Session::Syscall sc)
{
switch (sc) {
/**
* Keep compiler from complaining
*/
case SYSCALL_WRITE:
case SYSCALL_READ:
case SYSCALL_STAT:
case SYSCALL_LSTAT:
case SYSCALL_FSTAT:
case SYSCALL_FCNTL:
case SYSCALL_OPEN:
case SYSCALL_CLOSE:
case SYSCALL_IOCTL:
case SYSCALL_LSEEK:
case SYSCALL_DIRENT:
case SYSCALL_EXECVE:
case SYSCALL_SELECT:
case SYSCALL_FORK:
case SYSCALL_GETPID:
case SYSCALL_WAIT4:
case SYSCALL_PIPE:
case SYSCALL_DUP2:
case SYSCALL_INVALID:
case SYSCALL_UNLINK:
case SYSCALL_RENAME:
case SYSCALL_MKDIR:
case SYSCALL_FTRUNCATE:
case SYSCALL_READLINK:
case SYSCALL_SYMLINK:
case SYSCALL_USERINFO:
case SYSCALL_GETTIMEOFDAY:
case SYSCALL_CLOCK_GETTIME:
case SYSCALL_UTIMES:
case SYSCALL_SYNC:
case SYSCALL_KILL:
case SYSCALL_GETDTABLESIZE:
break;
case SYSCALL_SOCKET:
{
Socket_io_channel *socket_io_channel = new (_heap) Socket_io_channel();
GET_SOCKET_IO_CHANNEL_BACKEND(socket_io_channel->backend(), backend);
if (!backend->socket(_sysio)) {
delete socket_io_channel;
return false;
}
Shared_pointer<Io_channel> io_channel(socket_io_channel, _heap);
_sysio.socket_out.fd = add_io_channel(io_channel);
return true;
}
case SYSCALL_GETSOCKOPT:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.getsockopt_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
return backend->getsockopt(_sysio);
}
case SYSCALL_SETSOCKOPT:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.setsockopt_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
return backend->setsockopt(_sysio);
}
case SYSCALL_ACCEPT:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.accept_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
int socket = backend->accept(_sysio);
if (socket == -1)
return false;
Socket_io_channel *socket_io_channel = new (_heap) Socket_io_channel(socket);
Shared_pointer<Io_channel> io_channel(socket_io_channel, _heap);
_sysio.accept_out.fd = add_io_channel(io_channel);
return true;
}
case SYSCALL_BIND:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.bind_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
return (backend->bind(_sysio) == -1) ? false : true;
}
case SYSCALL_LISTEN:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.listen_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
return (backend->listen(_sysio) == -1) ? false : true;
}
case SYSCALL_SEND:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.send_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
return (backend->send(_sysio) == -1) ? false : true;
}
case SYSCALL_SENDTO:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.sendto_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
return (backend->sendto(_sysio) == -1) ? false : true;
}
case SYSCALL_RECV:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.recv_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
return (backend->recv(_sysio) == -1) ? false : true;
}
case SYSCALL_RECVFROM:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.recvfrom_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
return (backend->recvfrom(_sysio) == -1) ? false : true;
}
case SYSCALL_GETPEERNAME:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.getpeername_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
return (backend->getpeername(_sysio) == -1) ? false : true;
}
case SYSCALL_SHUTDOWN:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.shutdown_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
return (backend->shutdown(_sysio) == -1) ? false : true;
}
case SYSCALL_CONNECT:
{
Shared_pointer<Io_channel> io = _lookup_channel(_sysio.connect_in.fd);
GET_SOCKET_IO_CHANNEL_BACKEND(io->backend(), backend);
return (backend->connect(_sysio) == -1) ? false : true;
}
}
return false;
}

View File

@ -1,501 +0,0 @@
/*
* \brief I/O channel for sockets
* \author Josef Söntgen
* \date 2012-04-12
*/
/*
* Copyright (C) 2011-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _NOUX__SOCKET_IO_CHANNEL_H_
#define _NOUX__SOCKET_IO_CHANNEL_H_
/* Genode includes */
#include <base/log.h>
/* Noux includes */
#include <io_channel.h>
#include <noux_session/sysio.h>
/* Libc includes */
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netdb.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <errno.h>
namespace Noux {
class Socket_io_channel_backend;
class Socket_io_channel;
}
class Noux::Socket_io_channel_backend : public Io_channel_backend
{
private:
int _socket;
public:
Socket_io_channel_backend()
:
_socket(-1)
{ }
Socket_io_channel_backend(int s)
:
_socket(s)
{ }
~Socket_io_channel_backend()
{
if (_socket != -1) {
::shutdown(_socket, SHUT_RDWR);
::close(_socket);
}
}
int type() const { return 1; }
int socket() const { return _socket; }
/**
* Io_channel interface implementation (only needed methods)
*/
bool write(Sysio &sysio, ::size_t &count)
{
ssize_t result = ::write(_socket, sysio.write_in.chunk,
sysio.write_in.count);
if (result > -1) {
sysio.write_out.count = result;
count = result;
return true;
}
switch (errno) {
/* case EAGAIN: sysio.error.read = Sysio::READ_ERR_AGAIN; break; */
case EWOULDBLOCK: sysio.error.read = Vfs::File_io_service::READ_ERR_WOULD_BLOCK; break;
case EINVAL: sysio.error.read = Vfs::File_io_service::READ_ERR_INVALID; break;
case EIO: sysio.error.read = Vfs::File_io_service::READ_ERR_IO; break;
default:
log(__func__, ": unhandled errno: ", (int)errno);
break;
}
return false;
}
bool read(Sysio &sysio)
{
::size_t const max_count = Genode::min(sysio.read_in.count, sizeof(sysio.read_out.chunk));
ssize_t result = ::read(_socket, sysio.read_out.chunk, max_count);
if (result > -1) {
sysio.read_out.count = result;
return true;
}
switch (errno) {
/* case EAGAIN: sysio.error.read = Sysio::READ_ERR_AGAIN; break; */
case EWOULDBLOCK: sysio.error.read = Vfs::File_io_service::READ_ERR_WOULD_BLOCK; break;
case EINVAL: sysio.error.read = Vfs::File_io_service::READ_ERR_INVALID; break;
case EIO: sysio.error.read = Vfs::File_io_service::READ_ERR_IO; break;
default:
log(__func__, ": unhandled errno: ", (int)errno);
break;
}
return false;
}
bool fcntl(Sysio &sysio)
{
int cmd = -1;
switch (sysio.fcntl_in.cmd) {
case Sysio::FCNTL_CMD_GET_FILE_STATUS_FLAGS: cmd = F_GETFL; break;
case Sysio::FCNTL_CMD_SET_FILE_STATUS_FLAGS: cmd = F_SETFL; break;
default:
log("invalid fcntl command: ", (int)sysio.fcntl_in.cmd);
sysio.error.fcntl = Sysio::FCNTL_ERR_CMD_INVALID;
return false;
}
int result = ::fcntl(_socket, cmd, sysio.fcntl_in.long_arg);
sysio.fcntl_out.result = result;
return true;
}
bool dirent(Sysio &sysio) { return false; }
bool ioctl(Sysio &sysio)
{
int request;
switch (sysio.ioctl_in.request) {
case Vfs::File_io_service::IOCTL_OP_FIONBIO: request = FIONBIO; break;
default:
log(__func__, ": invalid ioctl request: ", (int)sysio.ioctl_in.request);
return false;
}
int result = ::ioctl(_socket, request, NULL);
return result ? false : true;
}
bool check_unblock(bool rd, bool wr, bool ex) const
{
fd_set readfds;
fd_set writefds;
fd_set exceptfds;
int ready;
/**
* The timeout will be overriden in libc's select() function
* but we still need a valid pointer because libc's select()
* will block forever otherwise.
*/
struct timeval timeout = { 0, 0 };
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
FD_SET(_socket, &readfds);
FD_SET(_socket, &writefds);
FD_SET(_socket, &exceptfds);
ready = ::select(_socket + 1, &readfds, &writefds, &exceptfds, &timeout);
if (ready > 0) {
if (rd) {
if (FD_ISSET(_socket, &readfds))
return true;
}
if (wr) {
if (FD_ISSET(_socket, &writefds))
return true;
}
if (ex) {
if (FD_ISSET(_socket, &exceptfds))
return true;
}
}
/**
* HACK: Since lwip won't mark fds as writable, even if they
* are, if asked multiple times we return true in this
* case. Hopefully that won't break any time soon.
*/
if (wr)
return true;
return false;
}
/**
* Socket methods
*/
int accept(Sysio &sysio)
{
int result;
if (sysio.accept_in.addrlen == 0) {
result = ::accept(_socket, NULL, NULL);
}
else {
result = ::accept(_socket, (sockaddr *)&sysio.accept_in.addr,
&sysio.accept_in.addrlen);
}
if (result == -1) {
switch (errno) {
/* case EAGAIN: sysio.error.accept = Sysio::ACCEPT_ERR_AGAIN; break; */
case ENOMEM: sysio.error.accept = Sysio::ACCEPT_ERR_NO_MEMORY; break;
case EINVAL: sysio.error.accept = Sysio::ACCEPT_ERR_INVALID; break;
case EOPNOTSUPP: sysio.error.accept = Sysio::ACCEPT_ERR_NOT_SUPPORTED; break;
case EWOULDBLOCK: sysio.error.accept = Sysio::ACCEPT_ERR_WOULD_BLOCK; break;
default:
log(__func__, ": unhandled errno: ", (int)errno);
break;
}
}
return result;
}
int bind(Sysio &sysio)
{
int result = ::bind(_socket, (const struct sockaddr *)&sysio.bind_in.addr,
sysio.bind_in.addrlen);
if (result == -1) {
switch (errno) {
case EACCES: sysio.error.bind = Sysio::BIND_ERR_ACCESS; break;
case EADDRINUSE: sysio.error.bind = Sysio::BIND_ERR_ADDR_IN_USE; break;
case EINVAL: sysio.error.bind = Sysio::BIND_ERR_INVALID; break;
case ENOMEM: sysio.error.bind = Sysio::BIND_ERR_NO_MEMORY; break;
default:
log(__func__, ": unhandled errno: ", (int)errno);
break;
}
}
return result;
}
int connect(Sysio &sysio)
{
int result = ::connect(_socket, (struct sockaddr *)&sysio.connect_in.addr,
sysio.connect_in.addrlen);
if (result == -1) {
switch (errno) {
case EAGAIN: sysio.error.connect = Sysio::CONNECT_ERR_AGAIN; break;
case EALREADY: sysio.error.connect = Sysio::CONNECT_ERR_ALREADY; break;
case EADDRINUSE: sysio.error.connect = Sysio::CONNECT_ERR_ADDR_IN_USE; break;
case EINPROGRESS: sysio.error.connect = Sysio::CONNECT_ERR_IN_PROGRESS; break;
case EISCONN: sysio.error.connect = Sysio::CONNECT_ERR_IS_CONNECTED; break;
case ECONNRESET: sysio.error.connect = Sysio::CONNECT_ERR_RESET; break;
case ECONNABORTED: sysio.error.connect = Sysio::CONNECT_ERR_ABORTED; break;
case EHOSTUNREACH: sysio.error.connect = Sysio::CONNECT_ERR_NO_ROUTE; break;
default:
log(__func__, ": unhandled errno: ", (int)errno);
break;
}
}
return result;
}
int getpeername(Sysio &sysio)
{
return ::getpeername(_socket, (struct sockaddr *)&sysio.getpeername_in.addr,
(socklen_t *)&sysio.getpeername_in.addrlen);
}
bool getsockopt(Sysio &sysio)
{
int result = ::getsockopt(_socket, sysio.getsockopt_in.level,
sysio.getsockopt_in.optname,
sysio.getsockopt_in.optval,
&sysio.getsockopt_in.optlen);
return (result == -1) ? false : true;
}
int listen(Sysio &sysio)
{
int result = ::listen(_socket, sysio.listen_in.backlog);
if (result == -1) {
switch (errno) {
case EADDRINUSE: sysio.error.listen = Sysio::LISTEN_ERR_ADDR_IN_USE; break;
case EOPNOTSUPP: sysio.error.listen = Sysio::LISTEN_ERR_NOT_SUPPORTED; break;
default:
log(__func__, ": unhandled errno: ", (int)errno);
break;
}
}
return result;
}
ssize_t recv(Sysio &sysio)
{
ssize_t result = ::recv(_socket, sysio.recv_in.buf, sysio.recv_in.len, sysio.recv_in.flags);
if (result == -1) {
switch (errno) {
/*case EAGAIN: sysio.error.recv = Sysio::RECV_ERR_AGAIN; break; */
case EWOULDBLOCK: sysio.error.recv = Sysio::RECV_ERR_WOULD_BLOCK; break;
case EINVAL: sysio.error.recv = Sysio::RECV_ERR_INVALID; break;
case ENOTCONN: sysio.error.recv = Sysio::RECV_ERR_NOT_CONNECTED; break;
default:
log(__func__, ": unhandled errno: ", (int)errno);
break;
}
}
sysio.recv_out.len = result;
return result;
}
ssize_t recvfrom(Sysio &sysio)
{
ssize_t result = ::recvfrom(_socket, sysio.recv_in.buf, sysio.recv_in.len,
sysio.recv_in.flags, (struct sockaddr *)&sysio.recvfrom_in.src_addr,
&sysio.recvfrom_in.addrlen);
if (result == -1) {
switch (errno) {
/*case EAGAIN: sysio.error.recv = Sysio::RECV_ERR_AGAIN; break; */
case EWOULDBLOCK: sysio.error.recv = Sysio::RECV_ERR_WOULD_BLOCK; break;
case EINVAL: sysio.error.recv = Sysio::RECV_ERR_INVALID; break;
case ENOTCONN: sysio.error.recv = Sysio::RECV_ERR_NOT_CONNECTED; break;
default:
log(__func__, " unhandled errno: ", (int)errno);
break;
}
}
sysio.recvfrom_out.len = result;
return result;
}
bool setsockopt(Sysio &sysio)
{
/*
* Filter options out because lwip only supports several socket
* options. Therefore for now we silently return 0 and notify
* the user via debug message.
*/
switch (sysio.setsockopt_in.optname) {
case SO_DEBUG:
case SO_LINGER:
warning("SOL_SOCKET option '", sysio.setsockopt_in.optname, "' "
"is currently not supported, however we report success");
return true;
}
int result = ::setsockopt(_socket, sysio.setsockopt_in.level,
sysio.setsockopt_in.optname,
sysio.setsockopt_in.optval,
sysio.setsockopt_in.optlen);
return (result == -1) ? false : true;
}
ssize_t send(Sysio &sysio)
{
ssize_t result = ::send(_socket, sysio.send_in.buf, sysio.send_in.len,
sysio.send_in.flags);
if (result == -1) {
switch (errno) {
/*case EAGAIN: sysio.error.send = Sysio::SEND_ERR_AGAIN; break; */
case EWOULDBLOCK: sysio.error.send = Sysio::SEND_ERR_WOULD_BLOCK; break;
case ECONNRESET: sysio.error.send = Sysio::SEND_ERR_CONNECTION_RESET; break;
case EINVAL: sysio.error.send = Sysio::SEND_ERR_INVALID; break;
case EISCONN: sysio.error.send = Sysio::SEND_ERR_IS_CONNECTED; break;
case ENOMEM: sysio.error.send = Sysio::SEND_ERR_NO_MEMORY; break;
default:
log(__func__, ": unhandled errno: ", (int)errno);
break;
}
}
sysio.send_out.len = result;
return result;
}
ssize_t sendto(Sysio &sysio)
{
ssize_t result = ::sendto(_socket, sysio.sendto_in.buf, sysio.sendto_in.len,
sysio.sendto_in.flags,
(const struct sockaddr *) &sysio.sendto_in.dest_addr,
sysio.sendto_in.addrlen);
if (result == -1) {
switch (errno) {
/*case EAGAIN: sysio.error.send = Sysio::SEND_ERR_AGAIN; break; */
case EWOULDBLOCK: sysio.error.send = Sysio::SEND_ERR_WOULD_BLOCK; break;
case ECONNRESET: sysio.error.send = Sysio::SEND_ERR_CONNECTION_RESET; break;
case EINVAL: sysio.error.send = Sysio::SEND_ERR_INVALID; break;
case EISCONN: sysio.error.send = Sysio::SEND_ERR_IS_CONNECTED; break;
case ENOMEM: sysio.error.send = Sysio::SEND_ERR_NO_MEMORY; break;
default:
log(__func__, ": unhandled errno: ", (int)errno);
break;
}
}
sysio.sendto_out.len = result;
return result;
}
int shutdown(Sysio &sysio)
{
int result = ::shutdown(_socket, sysio.shutdown_in.how);
if (result == -1) {
switch (errno) {
case ENOTCONN: sysio.error.shutdown = Sysio::SHUTDOWN_ERR_NOT_CONNECTED; break;
default:
log(__func__, ": unhandled errno: ", (int)errno);
break;
}
}
return result;
}
bool socket(Sysio &sysio)
{
_socket = ::socket(sysio.socket_in.domain,
sysio.socket_in.type,
sysio.socket_in.protocol);
return (_socket == -1) ? false : true;
}
};
class Noux::Socket_io_channel : public Io_channel
{
private:
Socket_io_channel_backend _backend;
public:
Socket_io_channel() { }
Socket_io_channel(int s) : _backend(s) { }
~Socket_io_channel() { }
/*
* Io_channel interface (only needed methods)
*/
Io_channel_backend *backend() { return &_backend; }
bool write(Sysio &sysio, ::size_t &count)
{
return _backend.write(sysio, count);
}
bool read(Sysio &sysio) { return _backend.read(sysio); }
bool fcntl(Sysio &sysio) { return _backend.fcntl(sysio); }
bool ioctl(Sysio &sysio) { return _backend.ioctl(sysio); }
bool check_unblock(bool rd, bool wr, bool ex) const
{
return _backend.check_unblock(rd, wr, ex);
}
};
#endif /* _NOUX__SOCKET_IO_CHANNEL_H_ */

View File

@ -1,12 +0,0 @@
TARGET = noux_net
LIBS += alarm libc libc_lwip_nic_dhcp vfs
SRC_CC = main.cc syscall.cc net.cc construct.cc
INC_DIR += $(PRG_DIR)
INC_DIR += $(PRG_DIR)/../
vpath main.cc $(PRG_DIR)/..
vpath syscall.cc $(PRG_DIR)/..
vpath net.cc $(PRG_DIR)
CC_CXX_WARN_STRICT =

View File

@ -969,7 +969,8 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc)
case SYSCALL_SHUTDOWN:
case SYSCALL_CONNECT:
result = _syscall_net(sc);
/* network support was removed */
result = false;
break;
case SYSCALL_INVALID: break;

View File

@ -0,0 +1,8 @@
TARGET = noux
LIBS = base alarm vfs
SRC_CC = main.cc syscall.cc
INC_DIR += $(PRG_DIR)
vpath %.cc $(PRG_DIR)
CC_CXX_WARN_STRICT =

View File

@ -60,7 +60,6 @@ nic_router
nic_router_flood
nic_router_uplinks
noux
noux_net_netcat
noux_tool_chain_auto
nvme
part_blk