diff options
author | Eric Wild <ewild@sysmocom.de> | 2022-03-31 14:53:35 +0200 |
---|---|---|
committer | Eric Wild <ewild@sysmocom.de> | 2022-03-31 15:01:34 +0200 |
commit | ccda03a922f6d502959adbe107cc8591968f2713 (patch) | |
tree | 7545e6ca9069f079bb253adda3f62099b0cf9fb1 | |
parent | f1fab926ed0aa51339d8e168322d0f93624d7764 (diff) |
initial commit of ttcn3 test runner in namespacesewild/namespaces_tests
79 files changed, 3922 insertions, 0 deletions
diff --git a/namespaces/README b/namespaces/README new file mode 100644 index 0000000..5a1d59f --- /dev/null +++ b/namespaces/README @@ -0,0 +1,34 @@ +This script runs ttcn3 tests without a docker setup locally, concurrently, wrapped in a (net)ns. It requires python >= 3.8 + byobu + tmux. +It requires a matching config file, so every part of the cni gets the ip address it wants (according to its own cfg file). +The only modification required to use docker cfg files is to adjust paths for sockets/other cfg files, i.e. top dirs /data/ -> /tmp/. +All configs are copied to a private mounted /tmp dir, where the tests are exectued. Data is stored in a uniquely named directory in cwd after termination. Make sure not to run out of ram due to spawning too many tests! +The usual network setup is one interface in the top anonymous namespace connected to a bridge, and the other end of that if lives in the sub-ns that is used to run a part of the cni and configured with a ip. +The host namespace/network setup is not modified. +Just run the python file within one of the config subdirs after adjusting the configs. + +args: +--run-all-tests +runs all tests (testsuite binary -l output is parsed) +--parallel #num +concurent exection of #num tests (for all tests) + +--test-to-run #name +runs single test #name, i.e. MSC_Tests.TC_lu_imsi_auth_tmsi_encr_13_13 +--gui +spawn setup in byobu+tmux +if this is omitted output ends up in log files +--ws +spawns wireshark after test is done/tmux session is detached +this still happens within the ns, so a generated hosts file is bind mounted that can be used by wireshark to get nice names for all adresses. + + +see example configs in subdirs. + +test config is read from foo.json, gloval config part: +install_prefix : added to path, install (prefix) dir of cni parts not already in path +titandir: titan install dir +workdir: tmp dir used for remounting X related stuff, etc. +testdir: path to this current testsuite, i.e. /foo/bar/osmo-ttcn3-hacks/msc + +interfaces list contains netns interface config + command to run in this ns +test_to_run is derived from interface, but special, because in the non-gui case the whole execution waits for this command to complete diff --git a/namespaces/bsc/.byobu/.screenrc b/namespaces/bsc/.byobu/.screenrc new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/bsc/.byobu/.screenrc diff --git a/namespaces/bsc/.byobu/.tmux.conf b/namespaces/bsc/.byobu/.tmux.conf new file mode 100644 index 0000000..0df777d --- /dev/null +++ b/namespaces/bsc/.byobu/.tmux.conf @@ -0,0 +1,11 @@ +#set -g status-left '#{pane_current_path} ' +#set -g pane-border-format "#{pane_index} #{window_name}" +#set -g allow-rename on +setw -g automatic-rename off +set -g allow-rename off + +set -g window-status-format " #I:#W " +set -g window-status-current-style "fg=$color_light,bold,bg=$color_main" +set -g window-status-current-format "#[fg=$color_dark,bg=$color_main]$separator_powerline_right#[default] #I:#W# #[fg=$color_main,bg=$color_dark]$separator_powerline_right#[default]" + + diff --git a/namespaces/bsc/.byobu/.welcome-displayed b/namespaces/bsc/.byobu/.welcome-displayed new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/bsc/.byobu/.welcome-displayed diff --git a/namespaces/bsc/.byobu/backend b/namespaces/bsc/.byobu/backend new file mode 100644 index 0000000..ac0eb76 --- /dev/null +++ b/namespaces/bsc/.byobu/backend @@ -0,0 +1 @@ +BYOBU_BACKEND=tmux diff --git a/namespaces/bsc/.byobu/color b/namespaces/bsc/.byobu/color new file mode 100644 index 0000000..1ee73ad --- /dev/null +++ b/namespaces/bsc/.byobu/color @@ -0,0 +1,3 @@ +BACKGROUND=k +FOREGROUND=w +MONOCHROME=0
\ No newline at end of file diff --git a/namespaces/bsc/.byobu/color.tmux b/namespaces/bsc/.byobu/color.tmux new file mode 100644 index 0000000..4f55dc7 --- /dev/null +++ b/namespaces/bsc/.byobu/color.tmux @@ -0,0 +1,4 @@ +BYOBU_DARK="\#333333" +BYOBU_LIGHT="\#EEEEEE" +BYOBU_ACCENT="\#75507B" +BYOBU_HIGHLIGHT="\#DD4814" diff --git a/namespaces/bsc/.byobu/datetime.tmux b/namespaces/bsc/.byobu/datetime.tmux new file mode 100644 index 0000000..7c66f48 --- /dev/null +++ b/namespaces/bsc/.byobu/datetime.tmux @@ -0,0 +1,2 @@ +BYOBU_TIME="%H:%M:%S" +BYOBU_DATE= diff --git a/namespaces/bsc/.byobu/keybindings b/namespaces/bsc/.byobu/keybindings new file mode 100644 index 0000000..9d9bbdb --- /dev/null +++ b/namespaces/bsc/.byobu/keybindings @@ -0,0 +1 @@ +source $BYOBU_PREFIX/share/byobu/keybindings/common diff --git a/namespaces/bsc/.byobu/keybindings.tmux b/namespaces/bsc/.byobu/keybindings.tmux new file mode 100644 index 0000000..eb3d92e --- /dev/null +++ b/namespaces/bsc/.byobu/keybindings.tmux @@ -0,0 +1,4 @@ +unbind-key -n C-a +set -g prefix ^A +set -g prefix2 F12 +bind a send-prefix diff --git a/namespaces/bsc/.byobu/profile b/namespaces/bsc/.byobu/profile new file mode 100644 index 0000000..230ac0e --- /dev/null +++ b/namespaces/bsc/.byobu/profile @@ -0,0 +1 @@ +source $BYOBU_PREFIX/share/byobu/profiles/common diff --git a/namespaces/bsc/.byobu/profile.tmux b/namespaces/bsc/.byobu/profile.tmux new file mode 100644 index 0000000..9ccca51 --- /dev/null +++ b/namespaces/bsc/.byobu/profile.tmux @@ -0,0 +1 @@ +source $BYOBU_PREFIX/share/byobu/profiles/tmux diff --git a/namespaces/bsc/.byobu/prompt b/namespaces/bsc/.byobu/prompt new file mode 100644 index 0000000..c0a7eeb --- /dev/null +++ b/namespaces/bsc/.byobu/prompt @@ -0,0 +1 @@ +[ -r /usr/share/byobu/profiles/bashrc ] && . /usr/share/byobu/profiles/bashrc #byobu-prompt# diff --git a/namespaces/bsc/.byobu/status b/namespaces/bsc/.byobu/status new file mode 100644 index 0000000..bad8e2f --- /dev/null +++ b/namespaces/bsc/.byobu/status @@ -0,0 +1,37 @@ +# status - Byobu's default status enabled/disabled settings +# +# Override these in $BYOBU_CONFIG_DIR/status +# where BYOBU_CONFIG_DIR is XDG_CONFIG_HOME if defined, +# and $HOME/.byobu otherwise. +# +# Copyright (C) 2009-2011 Canonical Ltd. +# +# Authors: Dustin Kirkland <kirkland@byobu.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Status beginning with '#' are disabled. + +# Screen has two status lines, with 4 quadrants for status +screen_upper_left="color" +screen_upper_right="color whoami hostname ip_address menu" +screen_lower_left="color logo distro release #arch session" +screen_lower_right="color network #disk_io custom #entropy raid reboot_required updates_available #apport #services #mail users uptime #ec2_cost #rcs_cost #fan_speed #cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap disk #time_utc date time" + +# Tmux has one status line, with 2 halves for status +tmux_left=" logo #distro release #arch session" +# You can have as many tmux right lines below here, and cycle through them using Shift-F5 +tmux_right=" #network #disk_io #custom #entropy raid reboot_required #updates_available #apport #services #mail #users #uptime #ec2_cost #rcs_cost #fan_speed #cpu_temp #battery #wifi_quality #processes load_average #cpu_count #cpu_freq memory #swap #disk whoami #hostname ip_address #time_utc #date time" +#tmux_right="network #disk_io #custom entropy raid reboot_required updates_available #apport #services #mail users uptime #ec2_cost #rcs_cost fan_speed cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap #disk whoami hostname ip_address #time_utc date time" +#tmux_right="network #disk_io custom #entropy raid reboot_required updates_available #apport #services #mail users uptime #ec2_cost #rcs_cost #fan_speed #cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap #disk #whoami #hostname ip_address #time_utc date time" +#tmux_right="#network disk_io #custom entropy #raid #reboot_required #updates_available #apport #services #mail #users #uptime #ec2_cost #rcs_cost fan_speed cpu_temp #battery #wifi_quality #processes #load_average #cpu_count #cpu_freq #memory #swap whoami hostname ip_address #time_utc disk date time" diff --git a/namespaces/bsc/.byobu/statusrc b/namespaces/bsc/.byobu/statusrc new file mode 100644 index 0000000..472e45c --- /dev/null +++ b/namespaces/bsc/.byobu/statusrc @@ -0,0 +1,78 @@ +# statusrc - Byobu's default status configurations +# +# Override these in $BYOBU_CONFIG_DIR/statusrc +# where BYOBU_CONFIG_DIR is XDG_CONFIG_HOME if defined, +# and $HOME/.byobu otherwise. +# +# Copyright (C) 2009-2011 Canonical Ltd. +# +# Authors: Dustin Kirkland <kirkland@byobu.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Configurations that you can override; if you leave these commented out, +# Byobu will try to auto-detect them. + +# This should be auto-detected for most distro, but setting it here will save +# some call to lsb_release and the like. +#BYOBU_DISTRO=Ubuntu + +# Default: depends on the distro (which is either auto-detected, either set +# via $DISTRO) +#LOGO="\o/" + +# Abbreviate the release to N characters +# By default, this is disabled. But if you set RELEASE_ABBREVIATED=1 +# and your lsb_release is "precise", only "p" will be displayed +#RELEASE_ABBREVIATED=1 + +# Default: / +#MONITORED_DISK=/ + +# Minimum disk throughput that triggers the notification (in kB/s) +# Default: 50 +#DISK_IO_THRESHOLD=50 + +# Default: eth0 +#MONITORED_NETWORK=eth0 + +# Unit used for network throughput (either bits per second or bytes per second) +# Default: bits +#NETWORK_UNITS=bytes + +# Minimum network throughput that triggers the notification (in kbit/s) +# Default: 20 +#NETWORK_THRESHOLD=20 + +# You can add an additional source of temperature here +#MONITORED_TEMP=/proc/acpi/thermal_zone/THM0/temperature + +# Default: C +#TEMP=F + +#SERVICES="eucalyptus-nc|NC eucalyptus-cloud|CLC eucalyptus-walrus eucalyptus-cc|CC eucalyptus-sc|SC" + +#FAN=$(find /sys -type f -name fan1_input | head -n1) + +# You can set this to 1 to report your external/public ip address +# Default: 0 +#IP_EXTERNAL=0 + +# The users notification normally counts ssh sessions; set this configuration to '1' +# to instead count number of distinct users logged onto the system +# Default: 0 +#USERS_DISTINCT=0 + +# Set this to zero to hide seconds int the time display +# Default 1 +#TIME_SECONDS=0 diff --git a/namespaces/bsc/.byobu/windows b/namespaces/bsc/.byobu/windows new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/bsc/.byobu/windows diff --git a/namespaces/bsc/.byobu/windows.tmux b/namespaces/bsc/.byobu/windows.tmux new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/bsc/.byobu/windows.tmux diff --git a/namespaces/bsc/BSC_Tests.cfg b/namespaces/bsc/BSC_Tests.cfg new file mode 100644 index 0000000..dba9f39 --- /dev/null +++ b/namespaces/bsc/BSC_Tests.cfg @@ -0,0 +1,85 @@ +[ORDERED_INCLUDE] +"./Common.cfg" +"./BSC_Tests.default" + +[LOGGING] +*.JUnitLogger.testsuite_name := "BSC_Tests" + +[TESTPORT_PARAMETERS] +*.BSCVTY.CTRL_HOSTNAME := "172.18.2.20" +*.STATSVTY.CTRL_HOSTNAME := "172.18.2.20" + +[MODULE_PARAMETERS] +BSC_Tests.mp_bsc_ip := "172.18.2.20"; +BSC_Tests.mp_test_ip := "172.18.2.203"; +#BSC_Tests.mp_enable_osmux_test := true; +BSC_Tests.mp_bssap_cfg := { + { + transport := BSSAP_TRANSPORT_AoIP, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23905, "172.18.2.203", 2905, "172.18.2.200" }, + own_pc := 185, /* 0.23.1 first MSC emulation */ + own_ssn := 254, + peer_pc := 187, /* 0.23.3 osmo-bsc */ + peer_ssn := 254, + sio := '83'O, + rctx := 1 + }, + { + transport := BSSAP_TRANSPORT_AoIP, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23906, "172.18.2.203", 2905, "172.18.2.200" }, + own_pc := 2, /* 0.0.2 second MSC emulation */ + own_ssn := 254, + peer_pc := 187, /* 0.23.3 osmo-bsc */ + peer_ssn := 254, + sio := '83'O, + rctx := 2 + }, + { + transport := BSSAP_TRANSPORT_AoIP, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23907, "172.18.2.203", 2905, "172.18.2.200" }, + own_pc := 3, /* 0.0.3 third MSC emulation */ + own_ssn := 254, + peer_pc := 187, /* 0.23.3 osmo-bsc */ + peer_ssn := 254, + sio := '83'O, + rctx := 3 + } +}; +BSC_Tests.mp_enable_lcs_tests := true; +BSC_Tests.mp_bssap_le_cfg := { + sccp_service_type := "mtp3_itu", + sctp_addr := { 23908, "172.18.2.203", 2905, "172.18.2.211" }, + own_pc := 190, /* 0.23.6 SMLC emulation */ + own_ssn := 252, /* SMLC side SSN */ + peer_pc := 187, /* 0.23.3 osmo-bsc */ + peer_ssn := 250, /* BSC side SSN */ + sio := '83'O, + rctx := 6 +}; +BSC_Tests_CBSP.mp_cgi_bts0 := { '001'H, '01'H, 1, 0 }; +BSC_Tests_CBSP.mp_cgi_bts1 := { '001'H, '01'H, 1, 1 }; +BSC_Tests_CBSP.mp_cgi_bts2 := { '001'H, '01'H, 2, 1 }; +BSC_Tests_CBSP.mp_cgi_bts3 := { '001'H, '01'H, 3, 3 }; +BSC_Tests_CBSP.mp_cbc_ip := "172.18.2.203"; +BSC_Tests_CBSP.mp_cbc_ip6 := "fd02:db8:2::203"; +BSC_Tests_CBSP.mp_bsc_cbsp_ip := "172.18.2.20"; +BSC_Tests_CBSP.mp_bsc_cbsp_ip6 := "fd02:db8:2::20"; + +[MAIN_CONTROLLER] + +[EXECUTE] +#BSC_Tests.control +#BSC_Tests_LCLS.control +#BSC_Tests_CBSP.control +BSC_Tests.TC_assignment_fr_a5_1 +BSC_Tests.TC_assignment_fr_a5_3 +BSC_Tests.TC_assignment_fr_a5_4 +BSC_Tests.TC_assignment_fr_a5_4_fail +BSC_Tests.TC_ciph_mode_a5_0 +BSC_Tests.TC_ciph_mode_a5_1 +BSC_Tests.TC_ciph_mode_a5_3 +BSC_Tests.TC_ciph_mode_a5_4 + diff --git a/namespaces/bsc/BSC_Tests.default b/namespaces/bsc/BSC_Tests.default new file mode 100644 index 0000000..50c5c0a --- /dev/null +++ b/namespaces/bsc/BSC_Tests.default @@ -0,0 +1,33 @@ +[LOGGING] +BSSAP.FileMask := LOG_NOTHING; +"VirtMSC-M3UA".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"VirtMSC-SCCP".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"VirtMSC-MGCP".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"IPA0-RSL-IPA".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"IPA0-CTRL-IPA".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +mtc.FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING | DEBUG_ENCDEC; + +[TESTPORT_PARAMETERS] +*.BSCVTY.CTRL_MODE := "client" +*.BSCVTY.CTRL_HOSTNAME := "127.0.0.1" +*.BSCVTY.CTRL_PORTNUM := "4242" +*.BSCVTY.CTRL_LOGIN_SKIPPED := "yes" +*.BSCVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" +*.BSCVTY.CTRL_READMODE := "buffered" +*.BSCVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.BSCVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" +*.BSCVTY.PROMPT1 := "OsmoBSC> " +*.STATSVTY.CTRL_MODE := "client" +*.STATSVTY.CTRL_HOSTNAME := "127.0.0.1" +*.STATSVTY.CTRL_PORTNUM := "4242" +*.STATSVTY.CTRL_LOGIN_SKIPPED := "yes" +*.STATSVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" +*.STATSVTY.CTRL_READMODE := "buffered" +*.STATSVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.STATSVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" +*.STATSVTY.PROMPT1 := "OsmoBSC> " + +[MODULE_PARAMETERS] +Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoBSC"; + +[EXECUTE] diff --git a/namespaces/bsc/Common.cfg b/namespaces/bsc/Common.cfg new file mode 100644 index 0000000..50abf13 --- /dev/null +++ b/namespaces/bsc/Common.cfg @@ -0,0 +1,19 @@ +# common config file, relevant to all projects + +[DEFINE] +TTCN3_HACKS_PATH := "~/osmo/bscnat/osmo-ttcn3-hacks" +TCPDUMP_START := $TTCN3_HACKS_PATH"/ttcn3-tcpdump-start.sh" +TCPDUMP_STOP := $TTCN3_HACKS_PATH"/ttcn3-tcpdump-stop.sh" + +[LOGGING] +LogFile := "%e-%c-%h-%r.%s" +AppendFile := Yes; +SourceInfoFormat := Single; +LogSourceInfo := Yes; +LoggerPlugins := { JUnitLogger := "libjunitlogger2" } +FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING | DEBUG_ENCDEC; +ConsoleMask := ERROR | WARNING | TESTCASE | USER | VERDICTOP; + +[EXTERNAL_COMMANDS] +BeginTestCase := $TCPDUMP_START +EndTestCase := $TCPDUMP_STOP diff --git a/namespaces/bsc/foo.json b/namespaces/bsc/foo.json new file mode 100644 index 0000000..a894cc2 --- /dev/null +++ b/namespaces/bsc/foo.json @@ -0,0 +1,121 @@ +{ + "global_data": { + "install_prefix": "/home/peta/osmo/bscnat/install", + "titandir": "/home/peta/osmo/titan", + "workdir": "/home/peta/osmo/namespaces/configs/bsc/workdir", + "testdir": "/home/peta/osmo/bscnat/osmo-ttcn3-hacks/bsc" + }, + "interfaces": [ + { + "name": "stp-cn", + "interfaces": [ + { + "ip4": "172.18.2.200/16", + "ip6": "fd02:db8:2::200", + "bridge": "br0" + } + ], + "cmd": "osmo-stp -c ./osmo-stp.cfg" + }, + { + "name": "stp-ran", + "interfaces": [ + { + "ip4": "172.18.2.211/16", + "ip6": "fd02:db8:2::211", + "bridge": "br0" + } + ], + "cmd": "osmo-stp -c ./osmo-stp-ran.cfg" + }, + { + "name": "mgw-nat", + "interfaces": [ + { + "ip4": "172.18.2.114/16", + "ip6": "fd02:db8:2::114", + "bridge": "br0" + } + ], + "cmd": "osmo-mgw -c ./osmo-mgw.cfg" + }, + { + "name": "bscnat", + "interfaces": [ + { + "ip4": "172.18.2.111/16", + "ip6": "fd02:db8:2::111", + "bridge": "br0" + }, + { + "ip4": "172.18.2.112/16", + "ip6": "fd02:db8:2::112", + "bridge": "br0" + }, + { + "ip4": "172.18.2.113/16", + "ip6": "fd02:db8:2::113", + "bridge": "br0" + } + ], + "cmd": "osmo-bsc-nat" + }, + { + "name": "bsc", + "interfaces": [ + { + "ip4": "172.18.2.20/16", + "ip6": "fd02:db8:2::20", + "bridge": "br0" + } + ], + "cmd": "osmo-bsc -c ./osmo-bsc.cfg" + }, + { + "name": "oml0", + "interfaces": [ + { + "ip4": "172.18.2.100/16", + "ip6": null, + "bridge": "br0" + } + ], + "cmd": "./respawn.sh osmo-bts-omldummy 172.18.2.20 1234 1 >>/tmp/osmo-bts-omldummy-0.log 2>&1" + }, + { + "name": "oml1", + "interfaces": [ + { + "ip4": "172.18.2.101/16", + "ip6": null, + "bridge": "br0" + } + ], + "cmd": "./respawn.sh osmo-bts-omldummy 172.18.2.20 1235 1 >>/tmp/osmo-bts-omldummy-1.log 2>&1" + }, + { + "name": "oml2", + "interfaces": [ + { + "ip4": "172.18.2.102/16", + "ip6": null, + "bridge": "br0" + } + ], + "cmd": "./respawn.sh osmo-bts-omldummy 172.18.2.20 1236 1 >>/tmp/osmo-bts-omldummy-2.log 2>&1" + } + ], + "test_to_run": { + "name": "ttcn3", + "interfaces": [ + { + "ip4": "172.18.2.203/16", + "ip6": "fd02:db8:2::203", + "bridge": "br0" + } + ], + "cmd": "ttcn3_start", + "test_binary": "BSC_Tests", + "cfgfile": "BSC_Tests.cfg" + } +}
\ No newline at end of file diff --git a/namespaces/bsc/osmo-bsc-nat.cfg b/namespaces/bsc/osmo-bsc-nat.cfg new file mode 100644 index 0000000..e0e39a1 --- /dev/null +++ b/namespaces/bsc/osmo-bsc-nat.cfg @@ -0,0 +1,69 @@ +# DO NET EDIT THIS FILE DIRECTLY! +# This is generated from templates, and manual edits will be overwritten. + +cs7 instance 0 + point-code 0.23.3 + asp asp-clnt-OsmoBSCNAT-CN 2905 0 m3ua + remote-ip 172.18.2.200 + local-ip 172.18.2.112 +! as bernd m3ua +! asp asp-clnt-OsmoBSCNAT-CN +! routing-key 7 0.23.3 + sccp-address msc + routing-indicator PC + point-code 0.23.1 + subsystem-number 254 + +cs7 instance 1 + point-code 0.23.1 + asp asp-clnt-OsmoBSCNAT-RAN 2905 0 m3ua + remote-ip 172.18.2.211 + local-ip 172.18.2.111 +! sccp-address bsc +! routing-indicator PC +! point-code 0.23.3 +! subsystem-number 254 + +bsc-nat + cs7-instance-cn 0 + cs7-instance-ran 1 + +!mgw 0 +! mgw remote-ip 172.18.2.114 +! mgw remote-port 2427 +! mgw local-ip 172.18.2.113 +! mgw local-port 2427 +! mgw endpoint-domain bscnat + + +log stderr + logging filter all 1 + logging color 1 + logging print level 1 + logging print category 1 + logging print category-hex 0 + logging print file basename last + logging print extended-timestamp 1 + logging level set-all debug + logging level linp notice + +!log file current_log/osmo-bsc-nat.log +! logging filter all 1 +! logging color 1 +! logging print level 1 +! logging print category 1 +! logging print category-hex 0 +! logging print file basename last +! logging print extended-timestamp 1 +! logging level set-all debug + +log gsmtap 172.18.2.203 + logging filter all 1 + logging color 1 + logging print level 1 + logging print category 1 + logging print category-hex 0 + logging print file basename last + logging print extended-timestamp 1 + logging level set-all debug + logging level linp notice diff --git a/namespaces/bsc/osmo-bsc.cfg b/namespaces/bsc/osmo-bsc.cfg new file mode 100644 index 0000000..16c2b55 --- /dev/null +++ b/namespaces/bsc/osmo-bsc.cfg @@ -0,0 +1,438 @@ +! +! OsmoBSC (1.0.1.122-630df) configuration saved from vty +!! +password foo +! +log gsmtap 172.18.2.203 + logging level set-all debug + logging filter all 1 + logging level linp notice +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level rll notice + logging level mm notice + logging level rr notice + logging level rsl notice + logging level nm info + logging level pag notice + logging level meas notice + logging level msc notice + logging level ho notice + logging level ref notice + logging level ctrl notice + logging level filter debug + logging level pcu debug + logging level lglobal notice + logging level llapd notice + logging level linp notice + logging level lmux notice + logging level lmi notice + logging level lmib notice + logging level lsms notice + logging level lctrl notice + logging level lgtp notice + logging level lstats notice + logging level lgsup notice + logging level loap notice + logging level lss7 debug + logging level lsccp notice + logging level lsua notice + logging level lm3ua debug + logging level lmgcp notice +! +stats interval 0 +stats reporter statsd + prefix TTCN3 + level subscriber + remote-ip 172.18.2.203 + remote-port 8125 + flush-period 1 + mtu 1024 + enable +! +line vty + no login + bind 172.18.2.20 +! +e1_input + e1_line 0 driver ipa + e1_line 0 port 0 + no e1_line 0 keepalive +cs7 instance 0 + asp asp-clnt-msc-0 2905 2905 m3ua + local-ip 172.18.2.20 + local-ip fd02:db8:2::20 + remote-ip 172.18.2.211 + remote-ip fd02:db8:2::211 + sccp-address msc2 + point-code 0.0.2 + sccp-address msc3 + point-code 0.0.3 +network + network country code 1 + mobile network code 1 + encryption a5 0 1 3 4 + neci 1 + paging any use tch 0 + handover 1 + handover window rxlev averaging 10 + handover window rxqual averaging 1 + handover window rxlev neighbor averaging 10 + handover power budget interval 6 + handover power budget hysteresis 3 + handover maximum distance 9999 + timer t3113 10 + timer t3212 30 + bts 0 + type sysmobts + band DCS1800 + cell_identity 0 + location_area_code 1 + dtx uplink force + dtx downlink + base_station_id_code 10 + ms max power 15 + cell reselection hysteresis 4 + rxlev access min 0 + radio-link-timeout 32 + channel allocator ascending + rach tx integer 9 + rach max transmission 7 + channel-descrption attach 1 + channel-descrption bs-pa-mfrms 5 + channel-descrption bs-ag-blks-res 1 + early-classmark-sending forbidden + ip.access unit_id 1234 0 + oml ip.access stream_id 255 line 0 + neighbor-list mode manual-si5 + neighbor-list add arfcn 100 + neighbor-list add arfcn 200 + si5 neighbor-list add arfcn 10 + si5 neighbor-list add arfcn 20 + codec-support fr hr efr amr + gprs mode gprs + gprs routing area 0 + gprs network-control-order nc0 + gprs cell bvci 1234 + gprs cell timer blocking-timer 3 + gprs cell timer blocking-retries 3 + gprs cell timer unblocking-retries 3 + gprs cell timer reset-timer 3 + gprs cell timer reset-retries 3 + gprs cell timer suspend-timer 10 + gprs cell timer suspend-retries 3 + gprs cell timer resume-timer 10 + gprs cell timer resume-retries 3 + gprs cell timer capability-update-timer 10 + gprs cell timer capability-update-retries 3 + gprs nsei 1234 + gprs ns timer tns-block 3 + gprs ns timer tns-block-retries 3 + gprs ns timer tns-reset 3 + gprs ns timer tns-reset-retries 3 + gprs ns timer tns-test 30 + gprs ns timer tns-alive 3 + gprs ns timer tns-alive-retries 10 + gprs nsvc 0 nsvci 1234 + gprs nsvc 0 local udp port 23000 + gprs nsvc 0 remote udp port 23000 + gprs nsvc 0 remote ip 192.168.100.239 + gprs nsvc 1 nsvci 0 + gprs nsvc 1 local udp port 0 + gprs nsvc 1 remote udp port 0 + gprs nsvc 1 remote ip 0.0.0.0 + no force-combined-si + si2quater neighbor-list add earfcn 111 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3 + trx 0 + rf_locked 0 + arfcn 871 + nominal power 23 + max_power_red 20 + rsl e1 tei 0 + timeslot 0 + phys_chan_config CCCH+SDCCH4+CBCH + hopping enabled 0 + timeslot 1 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 2 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 3 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 4 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 5 + phys_chan_config TCH/H + hopping enabled 0 + timeslot 6 + phys_chan_config PDCH + hopping enabled 0 + timeslot 7 + phys_chan_config PDCH + hopping enabled 0 + bts 1 + type sysmobts + band DCS1800 + cell_identity 1 + location_area_code 1 + dtx uplink force + dtx downlink + base_station_id_code 11 + ms max power 15 + cell reselection hysteresis 4 + rxlev access min 0 + radio-link-timeout 32 + channel allocator ascending + rach tx integer 9 + rach max transmission 7 + channel-descrption attach 1 + channel-descrption bs-pa-mfrms 5 + channel-descrption bs-ag-blks-res 1 + early-classmark-sending forbidden + ip.access unit_id 1235 0 + oml ip.access stream_id 255 line 0 + neighbor-list mode manual-si5 + neighbor-list add arfcn 100 + neighbor-list add arfcn 200 + si5 neighbor-list add arfcn 10 + si5 neighbor-list add arfcn 20 + codec-support fr hr efr amr + gprs mode gprs + gprs routing area 0 + gprs network-control-order nc0 + gprs cell bvci 1235 + gprs cell timer blocking-timer 3 + gprs cell timer blocking-retries 3 + gprs cell timer unblocking-retries 3 + gprs cell timer reset-timer 3 + gprs cell timer reset-retries 3 + gprs cell timer suspend-timer 10 + gprs cell timer suspend-retries 3 + gprs cell timer resume-timer 10 + gprs cell timer resume-retries 3 + gprs cell timer capability-update-timer 10 + gprs cell timer capability-update-retries 3 + gprs nsei 1235 + gprs ns timer tns-block 3 + gprs ns timer tns-block-retries 3 + gprs ns timer tns-reset 3 + gprs ns timer tns-reset-retries 3 + gprs ns timer tns-test 30 + gprs ns timer tns-alive 3 + gprs ns timer tns-alive-retries 10 + gprs nsvc 0 nsvci 1235 + gprs nsvc 0 local udp port 23000 + gprs nsvc 0 remote udp port 23000 + gprs nsvc 0 remote ip 192.168.100.239 + gprs nsvc 1 nsvci 0 + gprs nsvc 1 local udp port 0 + gprs nsvc 1 remote udp port 0 + gprs nsvc 1 remote ip 0.0.0.0 + no force-combined-si + si2quater neighbor-list add earfcn 111 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3 + trx 0 + rf_locked 0 + arfcn 871 + nominal power 23 + max_power_red 20 + rsl e1 tei 0 + timeslot 0 + phys_chan_config CCCH+SDCCH4+CBCH + hopping enabled 0 + timeslot 1 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 2 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 3 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 4 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 5 + phys_chan_config TCH/H + hopping enabled 0 + timeslot 6 + phys_chan_config PDCH + hopping enabled 0 + timeslot 7 + phys_chan_config PDCH + hopping enabled 0 + bts 2 + type sysmobts + band DCS1800 + cell_identity 1 + location_area_code 2 + dtx uplink force + dtx downlink + base_station_id_code 12 + ms max power 15 + cell reselection hysteresis 4 + rxlev access min 0 + radio-link-timeout 32 + channel allocator ascending + rach tx integer 9 + rach max transmission 7 + channel-descrption attach 1 + channel-descrption bs-pa-mfrms 5 + channel-descrption bs-ag-blks-res 1 + early-classmark-sending forbidden + ip.access unit_id 1236 0 + oml ip.access stream_id 255 line 0 + neighbor-list mode manual-si5 + neighbor-list add arfcn 100 + neighbor-list add arfcn 200 + si5 neighbor-list add arfcn 10 + si5 neighbor-list add arfcn 20 + codec-support fr hr efr amr + gprs mode gprs + gprs routing area 0 + gprs network-control-order nc0 + gprs cell bvci 1236 + gprs cell timer blocking-timer 3 + gprs cell timer blocking-retries 3 + gprs cell timer unblocking-retries 3 + gprs cell timer reset-timer 3 + gprs cell timer reset-retries 3 + gprs cell timer suspend-timer 10 + gprs cell timer suspend-retries 3 + gprs cell timer resume-timer 10 + gprs cell timer resume-retries 3 + gprs cell timer capability-update-timer 10 + gprs cell timer capability-update-retries 3 + gprs nsei 1236 + gprs ns timer tns-block 3 + gprs ns timer tns-block-retries 3 + gprs ns timer tns-reset 3 + gprs ns timer tns-reset-retries 3 + gprs ns timer tns-test 30 + gprs ns timer tns-alive 3 + gprs ns timer tns-alive-retries 10 + gprs nsvc 0 nsvci 1236 + gprs nsvc 0 local udp port 23000 + gprs nsvc 0 remote udp port 23000 + gprs nsvc 0 remote ip 192.168.100.239 + gprs nsvc 1 nsvci 0 + gprs nsvc 1 local udp port 0 + gprs nsvc 1 remote udp port 0 + gprs nsvc 1 remote ip 0.0.0.0 + no force-combined-si + si2quater neighbor-list add earfcn 111 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3 + trx 0 + rf_locked 0 + arfcn 871 + nominal power 23 + max_power_red 20 + rsl e1 tei 0 + timeslot 0 + phys_chan_config CCCH+SDCCH4+CBCH + hopping enabled 0 + timeslot 1 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 2 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 3 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 4 + phys_chan_config TCH/F + hopping enabled 0 + timeslot 5 + phys_chan_config TCH/H + hopping enabled 0 + timeslot 6 + phys_chan_config PDCH + hopping enabled 0 + timeslot 7 + phys_chan_config PDCH + hopping enabled 0 + bts 3 + type sysmobts + band DCS1800 + cell_identity 3 + location_area_code 3 + # re-use bts 2's ARFCN 871 and BSIC 12 (to test handover config) + base_station_id_code 12 + trx 0 + rf_locked 0 + arfcn 871 + nominal power 23 + max_power_red 20 + rsl e1 tei 0 + timeslot 0 + phys_chan_config CCCH+SDCCH4 + timeslot 1 + phys_chan_config TCH/F + timeslot 2 + phys_chan_config TCH/F + timeslot 3 + phys_chan_config TCH/F + timeslot 4 + phys_chan_config TCH/F + timeslot 5 + phys_chan_config TCH/H + timeslot 6 + phys_chan_config PDCH + timeslot 7 + phys_chan_config PDCH +msc 0 + allow-emergency allow + amr-config 12_2k forbidden + amr-config 10_2k forbidden + amr-config 7_95k forbidden + amr-config 7_40k forbidden + amr-config 6_70k forbidden + amr-config 5_90k allowed + amr-config 5_15k forbidden + amr-config 4_75k forbidden + codec-list fr1 fr2 fr3 hr1 hr3 + mgw remote-ip 172.18.2.203 + lcls-mode mgw-loop +msc 1 + msc-addr msc2 + mgw remote-ip 172.18.2.203 +msc 2 + msc-addr msc3 + mgw remote-ip 172.18.2.203 + +network + nri bitlen 10 + # a NULL NRI that is outside the NRI ranges used by the MSCs: + nri null add 0 + # a NULL NRI that is also used by an MSC: + nri null add 1 +msc 0 + nri add 1 255 +msc 1 + nri add 256 511 +msc 2 + nri add 512 767 + # range 768-1024 is not assigned to any MSC on purpose + +bsc + mid-call-timeout 0 + no missing-msc-text +ctrl + bind 172.18.2.20 +cbc + mode disabled + client + remote-ip 172.18.2.203 + remote-port 48049 + server + local-ip 172.18.2.20 + local-port 48050 +smlc + enable diff --git a/namespaces/bsc/osmo-mgw.cfg b/namespaces/bsc/osmo-mgw.cfg new file mode 100644 index 0000000..1d37f3c --- /dev/null +++ b/namespaces/bsc/osmo-mgw.cfg @@ -0,0 +1,46 @@ +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level set-all notice + logging level lmgcp debug +! +stats interval 5 +! +line vty + no login + bind 172.18.2.114 +! +stats interval 0 +stats reporter statsd + prefix TTCN3 + level subscriber + remote-ip 172.18.2.203 + remote-port 8125 + flush-period 1 + mtu 1024 + enable +! +mgcp + bind ip 172.18.2.114 + bind port 2427 + rtp port-range 4002 16000 + rtp bind-ip 172.18.2.114 + rtp bind-ip-v6 ::1 + rtp ip-probing + rtp ip-dscp 46 + no rtp keep-alive + no rtcp-omit + no rtp-patch + sdp audio-payload number 98 + sdp audio-payload name GSM + sdp audio-payload send-ptime + sdp audio-payload send-name + conn-timeout 0 + loop 0 + number endpoints 31 + allow-transcoding + osmux off + diff --git a/namespaces/bsc/osmo-stp-ran.cfg b/namespaces/bsc/osmo-stp-ran.cfg new file mode 100644 index 0000000..05bec80 --- /dev/null +++ b/namespaces/bsc/osmo-stp-ran.cfg @@ -0,0 +1,49 @@ + +! +! OsmoSTP (0.8.1) configuration saved from vty +!! +! +log gsmtap 172.18.2.203 + logging level set-all debug + logging filter all 1 + logging level linp notice +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level set-all debug + logging level linp notice +! +line vty + no login +! +cs7 instance 0 + xua rkm routing-key-allocation dynamic-permitted + asp virt-bsc0-0 0 2905 m3ua + local-ip 172.18.2.211 + remote-ip 172.18.2.111 + as virt-bsc0 m3ua + asp virt-bsc0-0 +! routing-key 3 0.23.1 +! + asp virt-smlc-0 23908 2905 m3ua + local-ip 172.18.2.211 + local-ip fd02:db8:2::211 + remote-ip 172.18.2.203 + remote-ip fd02:db8:2::203 + as virt-smlc m3ua + asp virt-smlc-0 + routing-key 6 0.23.6 + + route-table system + update route 0.23.6 7.255.7 linkset virt-smlc + update route 0.23.1 7.255.7 linkset virt-bsc0 + update route 0.0.2 7.255.7 linkset virt-bsc0 + update route 0.0.3 7.255.7 linkset virt-bsc0 + + listen m3ua 2905 + accept-asp-connections dynamic-permitted + local-ip 172.18.2.211 diff --git a/namespaces/bsc/osmo-stp.cfg b/namespaces/bsc/osmo-stp.cfg new file mode 100644 index 0000000..1df145c --- /dev/null +++ b/namespaces/bsc/osmo-stp.cfg @@ -0,0 +1,97 @@ +! +! OsmoSTP (0.8.1) configuration saved from vty +!! +! +log gsmtap 172.18.2.203 + logging level set-all debug + logging filter all 1 + logging level linp notice +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level lglobal notice + logging level llapd notice + logging level linp notice + logging level lmux notice + logging level lmi notice + logging level lmib notice + logging level lsms notice + logging level lctrl notice + logging level lgtp notice + logging level lstats notice + logging level lgsup notice + logging level loap notice + logging level lss7 debug + logging level lsccp debug + logging level lsua debug + logging level lm3ua debug + logging level lmgcp notice +! +line vty + no login +! +cs7 instance 0 + xua rkm routing-key-allocation dynamic-permitted + asp virt-msc0-0 23905 2905 m3ua + local-ip 172.18.2.200 + local-ip fd02:db8:2::200 + remote-ip 172.18.2.203 + remote-ip fd02:db8:2::203 + as mahlzeit ipa + routing-key 0 0.23.4 + point-code override dpc 0.23.1 + as virt-msc0 m3ua + asp virt-msc0-0 + routing-key 1 0.23.1 + + asp virt-msc1-0 23906 2905 m3ua + local-ip 172.18.2.200 + local-ip fd02:db8:2::200 + remote-ip 172.18.2.203 + remote-ip fd02:db8:2::203 + as virt-msc1 m3ua + asp virt-msc1-0 + routing-key 2 0.0.2 + + asp virt-msc2-0 23907 2905 m3ua + local-ip 172.18.2.200 + local-ip fd02:db8:2::200 + remote-ip 172.18.2.203 + remote-ip fd02:db8:2::203 + as virt-msc2 m3ua + asp virt-msc2-0 + routing-key 3 0.0.3 + + asp virt-smlc-0 23908 2905 m3ua + local-ip 172.18.2.200 + local-ip fd02:db8:2::200 + remote-ip 172.18.2.203 + remote-ip fd02:db8:2::203 + as virt-smlc m3ua + asp virt-smlc-0 + routing-key 6 0.23.6 + + asp virt-bsc0-0 0 2905 m3ua + local-ip 172.18.2.200 + remote-ip 172.18.2.112 + as virt-bsc0 m3ua + asp virt-bsc0-0 +! routing-key 7 0.23.3 + + route-table system + update route 0.23.1 7.255.7 linkset virt-msc0 + update route 0.0.2 7.255.7 linkset virt-msc1 + update route 0.0.3 7.255.7 linkset virt-msc2 + update route 0.23.6 7.255.7 linkset virt-smlc + update route 0.23.3 7.255.7 linkset virt-bsc0 + listen m3ua 2905 + accept-asp-connections dynamic-permitted + local-ip 172.18.2.200 + local-ip fd02:db8:2::200 + listen ipa 5000 + accept-asp-connections dynamic-permitted + local-ip 172.18.2.200 diff --git a/namespaces/bsc/respawn.sh b/namespaces/bsc/respawn.sh new file mode 100755 index 0000000..31a8c06 --- /dev/null +++ b/namespaces/bsc/respawn.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +trap "kill 0" EXIT + +SLEEP_BEFORE_RESPAWN=${SLEEP_BEFORE_RESPAWN:-0} + +i=0 +max_i=500 +while [ $i -lt $max_i ]; do + echo "$i: starting: $*" + $* & + LAST_PID=$! + wait $LAST_PID + echo "$i: stopped pid $LAST_PID with status $?" + if [ $SLEEP_BEFORE_RESPAWN -gt 0 ]; then + echo "sleeping $SLEEP_BEFORE_RESPAWN seconds..." + sleep $SLEEP_BEFORE_RESPAWN + fi + i=$(expr $i + 1) +done +echo "exiting after $max_i runs" diff --git a/namespaces/msc/.byobu/.screenrc b/namespaces/msc/.byobu/.screenrc new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/msc/.byobu/.screenrc diff --git a/namespaces/msc/.byobu/.tmux.conf b/namespaces/msc/.byobu/.tmux.conf new file mode 100644 index 0000000..0df777d --- /dev/null +++ b/namespaces/msc/.byobu/.tmux.conf @@ -0,0 +1,11 @@ +#set -g status-left '#{pane_current_path} ' +#set -g pane-border-format "#{pane_index} #{window_name}" +#set -g allow-rename on +setw -g automatic-rename off +set -g allow-rename off + +set -g window-status-format " #I:#W " +set -g window-status-current-style "fg=$color_light,bold,bg=$color_main" +set -g window-status-current-format "#[fg=$color_dark,bg=$color_main]$separator_powerline_right#[default] #I:#W# #[fg=$color_main,bg=$color_dark]$separator_powerline_right#[default]" + + diff --git a/namespaces/msc/.byobu/.welcome-displayed b/namespaces/msc/.byobu/.welcome-displayed new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/msc/.byobu/.welcome-displayed diff --git a/namespaces/msc/.byobu/backend b/namespaces/msc/.byobu/backend new file mode 100644 index 0000000..ac0eb76 --- /dev/null +++ b/namespaces/msc/.byobu/backend @@ -0,0 +1 @@ +BYOBU_BACKEND=tmux diff --git a/namespaces/msc/.byobu/color b/namespaces/msc/.byobu/color new file mode 100644 index 0000000..1ee73ad --- /dev/null +++ b/namespaces/msc/.byobu/color @@ -0,0 +1,3 @@ +BACKGROUND=k +FOREGROUND=w +MONOCHROME=0
\ No newline at end of file diff --git a/namespaces/msc/.byobu/color.tmux b/namespaces/msc/.byobu/color.tmux new file mode 100644 index 0000000..4f55dc7 --- /dev/null +++ b/namespaces/msc/.byobu/color.tmux @@ -0,0 +1,4 @@ +BYOBU_DARK="\#333333" +BYOBU_LIGHT="\#EEEEEE" +BYOBU_ACCENT="\#75507B" +BYOBU_HIGHLIGHT="\#DD4814" diff --git a/namespaces/msc/.byobu/datetime.tmux b/namespaces/msc/.byobu/datetime.tmux new file mode 100644 index 0000000..7c66f48 --- /dev/null +++ b/namespaces/msc/.byobu/datetime.tmux @@ -0,0 +1,2 @@ +BYOBU_TIME="%H:%M:%S" +BYOBU_DATE= diff --git a/namespaces/msc/.byobu/keybindings b/namespaces/msc/.byobu/keybindings new file mode 100644 index 0000000..9d9bbdb --- /dev/null +++ b/namespaces/msc/.byobu/keybindings @@ -0,0 +1 @@ +source $BYOBU_PREFIX/share/byobu/keybindings/common diff --git a/namespaces/msc/.byobu/keybindings.tmux b/namespaces/msc/.byobu/keybindings.tmux new file mode 100644 index 0000000..eb3d92e --- /dev/null +++ b/namespaces/msc/.byobu/keybindings.tmux @@ -0,0 +1,4 @@ +unbind-key -n C-a +set -g prefix ^A +set -g prefix2 F12 +bind a send-prefix diff --git a/namespaces/msc/.byobu/profile b/namespaces/msc/.byobu/profile new file mode 100644 index 0000000..230ac0e --- /dev/null +++ b/namespaces/msc/.byobu/profile @@ -0,0 +1 @@ +source $BYOBU_PREFIX/share/byobu/profiles/common diff --git a/namespaces/msc/.byobu/profile.tmux b/namespaces/msc/.byobu/profile.tmux new file mode 100644 index 0000000..9ccca51 --- /dev/null +++ b/namespaces/msc/.byobu/profile.tmux @@ -0,0 +1 @@ +source $BYOBU_PREFIX/share/byobu/profiles/tmux diff --git a/namespaces/msc/.byobu/prompt b/namespaces/msc/.byobu/prompt new file mode 100644 index 0000000..c0a7eeb --- /dev/null +++ b/namespaces/msc/.byobu/prompt @@ -0,0 +1 @@ +[ -r /usr/share/byobu/profiles/bashrc ] && . /usr/share/byobu/profiles/bashrc #byobu-prompt# diff --git a/namespaces/msc/.byobu/status b/namespaces/msc/.byobu/status new file mode 100644 index 0000000..bad8e2f --- /dev/null +++ b/namespaces/msc/.byobu/status @@ -0,0 +1,37 @@ +# status - Byobu's default status enabled/disabled settings +# +# Override these in $BYOBU_CONFIG_DIR/status +# where BYOBU_CONFIG_DIR is XDG_CONFIG_HOME if defined, +# and $HOME/.byobu otherwise. +# +# Copyright (C) 2009-2011 Canonical Ltd. +# +# Authors: Dustin Kirkland <kirkland@byobu.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Status beginning with '#' are disabled. + +# Screen has two status lines, with 4 quadrants for status +screen_upper_left="color" +screen_upper_right="color whoami hostname ip_address menu" +screen_lower_left="color logo distro release #arch session" +screen_lower_right="color network #disk_io custom #entropy raid reboot_required updates_available #apport #services #mail users uptime #ec2_cost #rcs_cost #fan_speed #cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap disk #time_utc date time" + +# Tmux has one status line, with 2 halves for status +tmux_left=" logo #distro release #arch session" +# You can have as many tmux right lines below here, and cycle through them using Shift-F5 +tmux_right=" #network #disk_io #custom #entropy raid reboot_required #updates_available #apport #services #mail #users #uptime #ec2_cost #rcs_cost #fan_speed #cpu_temp #battery #wifi_quality #processes load_average #cpu_count #cpu_freq memory #swap #disk whoami #hostname ip_address #time_utc #date time" +#tmux_right="network #disk_io #custom entropy raid reboot_required updates_available #apport #services #mail users uptime #ec2_cost #rcs_cost fan_speed cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap #disk whoami hostname ip_address #time_utc date time" +#tmux_right="network #disk_io custom #entropy raid reboot_required updates_available #apport #services #mail users uptime #ec2_cost #rcs_cost #fan_speed #cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap #disk #whoami #hostname ip_address #time_utc date time" +#tmux_right="#network disk_io #custom entropy #raid #reboot_required #updates_available #apport #services #mail #users #uptime #ec2_cost #rcs_cost fan_speed cpu_temp #battery #wifi_quality #processes #load_average #cpu_count #cpu_freq #memory #swap whoami hostname ip_address #time_utc disk date time" diff --git a/namespaces/msc/.byobu/statusrc b/namespaces/msc/.byobu/statusrc new file mode 100644 index 0000000..472e45c --- /dev/null +++ b/namespaces/msc/.byobu/statusrc @@ -0,0 +1,78 @@ +# statusrc - Byobu's default status configurations +# +# Override these in $BYOBU_CONFIG_DIR/statusrc +# where BYOBU_CONFIG_DIR is XDG_CONFIG_HOME if defined, +# and $HOME/.byobu otherwise. +# +# Copyright (C) 2009-2011 Canonical Ltd. +# +# Authors: Dustin Kirkland <kirkland@byobu.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Configurations that you can override; if you leave these commented out, +# Byobu will try to auto-detect them. + +# This should be auto-detected for most distro, but setting it here will save +# some call to lsb_release and the like. +#BYOBU_DISTRO=Ubuntu + +# Default: depends on the distro (which is either auto-detected, either set +# via $DISTRO) +#LOGO="\o/" + +# Abbreviate the release to N characters +# By default, this is disabled. But if you set RELEASE_ABBREVIATED=1 +# and your lsb_release is "precise", only "p" will be displayed +#RELEASE_ABBREVIATED=1 + +# Default: / +#MONITORED_DISK=/ + +# Minimum disk throughput that triggers the notification (in kB/s) +# Default: 50 +#DISK_IO_THRESHOLD=50 + +# Default: eth0 +#MONITORED_NETWORK=eth0 + +# Unit used for network throughput (either bits per second or bytes per second) +# Default: bits +#NETWORK_UNITS=bytes + +# Minimum network throughput that triggers the notification (in kbit/s) +# Default: 20 +#NETWORK_THRESHOLD=20 + +# You can add an additional source of temperature here +#MONITORED_TEMP=/proc/acpi/thermal_zone/THM0/temperature + +# Default: C +#TEMP=F + +#SERVICES="eucalyptus-nc|NC eucalyptus-cloud|CLC eucalyptus-walrus eucalyptus-cc|CC eucalyptus-sc|SC" + +#FAN=$(find /sys -type f -name fan1_input | head -n1) + +# You can set this to 1 to report your external/public ip address +# Default: 0 +#IP_EXTERNAL=0 + +# The users notification normally counts ssh sessions; set this configuration to '1' +# to instead count number of distinct users logged onto the system +# Default: 0 +#USERS_DISTINCT=0 + +# Set this to zero to hide seconds int the time display +# Default 1 +#TIME_SECONDS=0 diff --git a/namespaces/msc/.byobu/windows b/namespaces/msc/.byobu/windows new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/msc/.byobu/windows diff --git a/namespaces/msc/.byobu/windows.tmux b/namespaces/msc/.byobu/windows.tmux new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/msc/.byobu/windows.tmux diff --git a/namespaces/msc/Common.cfg b/namespaces/msc/Common.cfg new file mode 100644 index 0000000..50abf13 --- /dev/null +++ b/namespaces/msc/Common.cfg @@ -0,0 +1,19 @@ +# common config file, relevant to all projects + +[DEFINE] +TTCN3_HACKS_PATH := "~/osmo/bscnat/osmo-ttcn3-hacks" +TCPDUMP_START := $TTCN3_HACKS_PATH"/ttcn3-tcpdump-start.sh" +TCPDUMP_STOP := $TTCN3_HACKS_PATH"/ttcn3-tcpdump-stop.sh" + +[LOGGING] +LogFile := "%e-%c-%h-%r.%s" +AppendFile := Yes; +SourceInfoFormat := Single; +LogSourceInfo := Yes; +LoggerPlugins := { JUnitLogger := "libjunitlogger2" } +FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING | DEBUG_ENCDEC; +ConsoleMask := ERROR | WARNING | TESTCASE | USER | VERDICTOP; + +[EXTERNAL_COMMANDS] +BeginTestCase := $TCPDUMP_START +EndTestCase := $TCPDUMP_STOP diff --git a/namespaces/msc/MSC_Tests.cfg b/namespaces/msc/MSC_Tests.cfg new file mode 100644 index 0000000..6ad1229 --- /dev/null +++ b/namespaces/msc/MSC_Tests.cfg @@ -0,0 +1,96 @@ +[ORDERED_INCLUDE] +"./Common.cfg" +"./MSC_Tests.default" + +[LOGGING] +SourceInfoFormat:= Single +LogEntityName:= Yes +LogEventTypes:= Yes +*.FileMask :=WARNING|VERDICTOP|TIMEROP|STATISTICS|PORTEVENT|EXECUTOR|ERROR|DEFAULTOP|ACTION|PARALLEL|FUNCTION|USER|TESTCASE|DEBUG; + +[TESTPORT_PARAMETERS] +*.MSCVTY.CTRL_HOSTNAME := "172.18.20.10" + +[MODULE_PARAMETERS] +# connection to STP +MSC_Tests.mp_bssap_cfg := { + { + transport := BSSAP_TRANSPORT_AoIP, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23906, "172.18.20.103", 2905, "172.18.20.200" }, + own_pc := 193, /* 0.24.1 BSC emulation [0] */ + own_ssn := 254, + peer_pc := 185, /* 0.23.1 osmo-msc */ + peer_ssn := 254, + sio := '83'O, + rctx := 0 + }, + { + transport := BSSAP_TRANSPORT_AoIP, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23907, "172.18.20.103", 2905, "172.18.20.200" }, + own_pc := 194, /* 0.24.2 BSC emulation [1] */ + own_ssn := 254, + peer_pc := 185, /* 0.23.1 osmo-msc */ + peer_ssn := 254, + sio := '83'O, + rctx := 1 + }, + { + transport := RANAP_TRANSPORT_IuCS, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23908, "172.18.20.103", 2905, "172.18.20.200" }, + own_pc := 195, /* 0.24.3 BSC emulation [2] */ + own_ssn := 142, + peer_pc := 185, /* 0.23.1 osmo-msc */ + peer_ssn := 142, + sio := '83'O, + rctx := 2 + } +}; + +# remote (IUT) side +MSC_Tests.mp_msc_mncc := "/tmp/unix/mncc"; +MSC_Tests.mp_msc_ip := "172.18.20.10"; +# local (emulation) side) +MSC_Tests.mp_hlr_ip := "172.18.20.103"; +MSC_Tests.mp_mgw_ip := "172.18.20.103"; + +[MAIN_CONTROLLER] + +[EXECUTE] +#MSC_Tests.control +#MSC_Tests_Iu.control + +MSC_Tests.TC_lu_imsi_auth_tmsi_check_imei +MSC_Tests.TC_lu_imsi_auth3g_tmsi_check_imei +MSC_Tests.TC_lu_imsi_noauth_tmsi_check_imei +MSC_Tests.TC_lu_imsi_noauth_notmsi_check_imei +MSC_Tests.TC_lu_imsi_auth_tmsi_check_imei_nack +MSC_Tests.TC_lu_imsi_auth_tmsi_check_imei_err +MSC_Tests.TC_lu_imsi_auth_tmsi_check_imei_early +MSC_Tests.TC_lu_imsi_auth3g_tmsi_check_imei_early +MSC_Tests.TC_lu_imsi_noauth_tmsi_check_imei_early +MSC_Tests.TC_lu_imsi_noauth_notmsi_check_imei_early +MSC_Tests.TC_lu_imsi_auth_tmsi_check_imei_early_nack +MSC_Tests.TC_lu_imsi_auth_tmsi_check_imei_early_err +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug + +#MSC_Tests.TC_lu_auth_2G_fail +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_13_13 +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_1_13 +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_3_13 +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_3_1 +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_3_1_no_cm +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_13_2 +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_013_2 +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_0134_1 +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_0134_34 +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm3 +# +#MSC_Tests.TC_cipher_complete_with_invalid_cipher +#MSC_Tests.TC_cipher_complete_1_without_cipher +#MSC_Tests.TC_cipher_complete_3_without_cipher +#MSC_Tests.TC_cipher_complete_13_without_cipher +#MSC_Tests.TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug diff --git a/namespaces/msc/MSC_Tests.default b/namespaces/msc/MSC_Tests.default new file mode 100644 index 0000000..98bf299 --- /dev/null +++ b/namespaces/msc/MSC_Tests.default @@ -0,0 +1,77 @@ +[LOGGING] +FileMask := LOG_ALL | TTCN_MATCHING; + +BSSAP.FileMask := LOG_NOTHING; +"MSC_Test_0-M3UA".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"MSC_Test_0-SCCP".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"MSC_Test_1-M3UA".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"MSC_Test_1-SCCP".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"MSC_Test-GSUP-IPA".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"MSC_Test-GSUP".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"IPA-CTRL-IPA".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +mtc.FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; + +[TESTPORT_PARAMETERS] +"MSC_Test-MNCC".MNCC.socket_type := "SEQPACKET"; +*.MSCVTY.CTRL_MODE := "client" +*.MSCVTY.CTRL_HOSTNAME := "127.0.0.1" +*.MSCVTY.CTRL_PORTNUM := "4254" +*.MSCVTY.CTRL_LOGIN_SKIPPED := "yes" +*.MSCVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" +*.MSCVTY.CTRL_READMODE := "buffered" +*.MSCVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.MSCVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" +*.MSCVTY.PROMPT1 := "OsmoMSC> " + + +[MODULE_PARAMETERS] +M3UA_Emulation.tsp_logVerbose := true; +MSC_Tests.mp_bssap_cfg := { + { + transport := BSSAP_TRANSPORT_AoIP, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" }, + own_pc := 193, + own_ssn := 254, + peer_pc := 185, + peer_ssn := 254, + sio := '83'O, + rctx := 0 + }, + { + transport := BSSAP_TRANSPORT_AoIP, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" }, + own_pc := 194, + own_ssn := 254, + peer_pc := 185, + peer_ssn := 254, + sio := '83'O, + rctx := 1 + }, + { + transport := RANAP_TRANSPORT_IuCS, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" }, + own_pc := 195, + own_ssn := 142, + peer_pc := 185, + peer_ssn := 142, + sio := '83'O, + rctx := 2 + } +}; + +# remote (IUT) side +MSC_Tests.mp_msc_mncc := "/tmp/mncc.sock"; +MSC_Tests.mp_msc_ip := "127.0.0.1" +# local (emulation) side) +MSC_Tests.mp_hlr_ip := "127.0.0.1" +MSC_Tests.mp_mgw_ip := "127.0.0.1" + + +Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoMSC"; + +[MAIN_CONTROLLER] + +[EXECUTE] diff --git a/namespaces/msc/foo.json b/namespaces/msc/foo.json new file mode 100644 index 0000000..9de898d --- /dev/null +++ b/namespaces/msc/foo.json @@ -0,0 +1,56 @@ +{ + "global_data": { + "install_prefix": "~/osmo/bscnat/install", + "titandir": "~/osmo/titan", + "workdir": "~/osmo/namespaces/configs/msc/workdir", + "testdir": "~/osmo/bscnat/osmo-ttcn3-hacks/msc" + }, + "interfaces": [ + { + "name": "stp", + "interfaces": [ + { + "ip4": "172.18.20.200/16", + "ip6": "fd02:db8:20::200", + "bridge": "br0" + } + ], + "cmd": "osmo-stp -c ./osmo-stp.cfg" + }, + { + "name": "stp-nat", + "interfaces": [ + { + "ip4": "172.18.20.201/16", + "ip6": "fd02:db8:20::201", + "bridge": "br0" + } + ], + "cmd": "osmo-stp -c ./osmo-stp-nat.cfg" + }, + { + "name": "msc", + "interfaces": [ + { + "ip4": "172.18.20.10/16", + "ip6": "fd02:db8:20::10", + "bridge": "br0" + } + ], + "cmd": "osmo-msc -c ./osmo-msc.cfg" + } + ], + "test_to_run": { + "name": "ttcn3", + "interfaces": [ + { + "ip4": "172.18.20.103/16", + "ip6": "fd02:db8:2::203", + "bridge": "br0" + } + ], + "cmd": "ttcn3_start", + "test_binary": "MSC_Tests", + "cfgfile": "MSC_Tests.cfg" + } +}
\ No newline at end of file diff --git a/namespaces/msc/osmo-bsc-nat.cfg b/namespaces/msc/osmo-bsc-nat.cfg new file mode 100644 index 0000000..20c710f --- /dev/null +++ b/namespaces/msc/osmo-bsc-nat.cfg @@ -0,0 +1,57 @@ +# DO NET EDIT THIS FILE DIRECTLY! +# This is generated from templates, and manual edits will be overwritten. + +cs7 instance 0 + point-code 0.23.3 + asp asp-clnt-OsmoBSCNAT-CN 2905 0 m3ua + remote-ip 172.18.20.201 + local-ip 172.18.20.112 + sccp-address msc + routing-indicator PC + point-code 0.23.1 + subsystem-number 254 + +cs7 instance 1 + point-code 0.23.1 + asp asp-clnt-OsmoBSCNAT-RAN 2905 0 m3ua + remote-ip 172.18.20.200 + local-ip 172.18.20.111 + sccp-address bsc + routing-indicator PC + point-code 0.23.3 + subsystem-number 254 + +bsc-nat + cs7-instance-cn 0 + cs7-instance-ran 1 + +log stderr + logging filter all 1 + logging color 1 + logging print level 1 + logging print category 1 + logging print category-hex 0 + logging print file basename last + logging print extended-timestamp 1 + logging level set-all debug + +!log file current_log/osmo-bsc-nat.log +! logging filter all 1 +! logging color 1 +! logging print level 1 +! logging print category 1 +! logging print category-hex 0 +! logging print file basename last +! logging print extended-timestamp 1 +! logging level set-all debug + +log gsmtap 172.18.20.103 + logging filter all 1 + logging color 1 + logging print level 1 + logging print category 1 + logging print category-hex 0 + logging print file basename last + logging print extended-timestamp 1 + logging level set-all debug + diff --git a/namespaces/msc/osmo-msc.cfg b/namespaces/msc/osmo-msc.cfg new file mode 100644 index 0000000..7380634 --- /dev/null +++ b/namespaces/msc/osmo-msc.cfg @@ -0,0 +1,95 @@ +! +! OsmoMSC (1.1.2.66-629c4-dirty) configuration saved from vty +!! +! +log gsmtap 172.18.20.103 + logging level set-all debug + logging filter all 1 +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level rll notice + logging level cc debug + logging level mm debug + logging level rr notice + logging level mncc debug + logging level pag notice + logging level msc notice + logging level mgcp debug + logging level ho notice + logging level db notice + logging level ref notice + logging level ctrl notice + logging level smpp debug + logging level ranap debug + logging level vlr debug + logging level iucs debug + logging level lglobal notice + logging level llapd notice + logging level linp notice + logging level lmux notice + logging level lmi notice + logging level lmib notice + logging level lsms notice + logging level lctrl info + logging level lgtp notice + logging level lstats notice + logging level lgsup notice + logging level loap notice + logging level lss7 debug + logging level lsccp notice + logging level lsua notice + logging level lm3ua debug + logging level lmgcp debug +! +stats interval 5 +! +line vty + no login + bind 0.0.0.0 +ctrl + bind 0.0.0.0 +! +cs7 instance 0 + point-code 0.23.1 + asp asp-clnt-OsmoMSC-A 2905 0 m3ua + local-ip 172.18.20.10 + local-ip fd02:db8:20::10 + remote-ip 172.18.20.200 + remote-ip fd02:db8:20::200 + as as-clnt-OsmoMSC-A m3ua + asp asp-clnt-OsmoMSC-A + routing-key 3 0.23.1 +network + network country code 262 + mobile network code 42 + short name OsmoMSC + long name OsmoMSC + encryption a5 0 + authentication optional + rrlp mode none + mm info 0 + periodic location update 30 +msc + assign-tmsi + cs7-instance-a 0 + cs7-instance-iu 0 + mgw remote-ip 172.18.20.103 + emergency-call route-to-msisdn 112 + mncc external /tmp/unix/mncc +mncc-int + default-codec tch-f fr + default-codec tch-h hr +smpp + local-tcp-port 2775 + policy closed + no smpp-first + esme msc_tester + password osmocom1 +hlr + remote-ip 172.18.20.103 + remote-port 4222 diff --git a/namespaces/msc/osmo-stp-nat.cfg b/namespaces/msc/osmo-stp-nat.cfg new file mode 100644 index 0000000..a8e2642 --- /dev/null +++ b/namespaces/msc/osmo-stp-nat.cfg @@ -0,0 +1,24 @@ +! +! OsmoSTP (0.8.1) configuration saved from vty +!! +! +log gsmtap 172.18.20.103 + logging level set-all debug + logging filter all 1 +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level set-all debug +! +line vty + no login +! +cs7 instance 0 + xua rkm routing-key-allocation dynamic-permitted + listen m3ua 2905 + accept-asp-connections dynamic-permitted + local-ip 172.18.20.201 diff --git a/namespaces/msc/osmo-stp.cfg b/namespaces/msc/osmo-stp.cfg new file mode 100644 index 0000000..34447af --- /dev/null +++ b/namespaces/msc/osmo-stp.cfg @@ -0,0 +1,58 @@ +! +! OsmoSTP (0.8.1) configuration saved from vty +!! +! +log gsmtap 172.18.20.103 + logging level set-all debug + logging filter all 1 +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level set-all debug +! +line vty + no login +! +cs7 instance 0 + xua rkm routing-key-allocation dynamic-permitted + asp virt-bsc0-0 23906 2905 m3ua + local-ip 172.18.20.200 + local-ip fd02:db8:20::200 + remote-ip 172.18.20.103 + remote-ip fd02:db8:20::103 + as virt-bsc0 m3ua + asp virt-bsc0-0 + routing-key 0 0.24.1 +! + asp virt-bsc1-0 23907 2905 m3ua + local-ip 172.18.20.200 + local-ip fd02:db8:20::200 + remote-ip 172.18.20.103 + remote-ip fd02:db8:20::103 + as virt-bsc1 m3ua + asp virt-bsc1-0 + routing-key 1 0.24.2 +! + asp virt-rnc0-0 23908 2905 m3ua + local-ip 172.18.20.200 + local-ip fd02:db8:20::200 + remote-ip 172.18.20.103 + remote-ip fd02:db8:20::103 + as virt-rnc0 m3ua + asp virt-rnc0-0 + routing-key 2 0.24.3 + route-table system + update route 0.24.1 7.255.7 linkset virt-bsc0 + update route 0.24.2 7.255.7 linkset virt-bsc1 + update route 0.24.3 7.255.7 linkset virt-rnc0 + listen m3ua 2905 + accept-asp-connections dynamic-permitted + local-ip 172.18.20.200 + local-ip fd02:db8:20::200 + listen ipa 5000 + accept-asp-connections dynamic-permitted + local-ip 172.18.20.200 diff --git a/namespaces/msc/run-test.py b/namespaces/msc/run-test.py new file mode 100644 index 0000000..13bb132 --- /dev/null +++ b/namespaces/msc/run-test.py @@ -0,0 +1,710 @@ +#!/usr/bin/env python3.8 + +from collections import defaultdict +from datetime import datetime +from functools import partial +from genericpath import exists +from ipaddress import IPv4Interface, IPv6Interface +from json import dump, load +import shutil +import signal +import stat +import subprocess +import os +from dataclasses import dataclass, asdict, field, fields, is_dataclass +import sys +import tempfile +import time +from typing import List, get_args, overload +import argparse + +conf = "bsc" + +parser = argparse.ArgumentParser() +parser.add_argument('--test-to-run', type=str, help='optionally run only one test') +parser.add_argument('--supersecretarg', action='store_true', help=argparse.SUPPRESS) +parser.add_argument('--gui', action='store_true', help='byobu session') +parser.add_argument('--ws', action='store_true', help='run wireshark on br0 after exit') +parser.add_argument('--run-all-tests', action='store_true', help='run all tests except .control') +parser.add_argument('--parallel', type=int, default=4, help='parallel tests to run if all') +args = parser.parse_args() + +if (args.test_to_run is not None) and (not args.supersecretarg): + print(f"###test_to_run has been set (value is {args.test_to_run})") + +if (args.ws is not False) : + print(f"###ws has been set (value is {args.ws})") +# asdict is slower than using __dict__.copy() for the dataclass + + +@dataclass(frozen=True, eq=True) +class if_addr: + """holds all information for a if addr""" + ip4: IPv4Interface = None + ip6: IPv6Interface = None + bridge: str = None + + +@dataclass(frozen=True, eq=True) +class NetNS_info: + """holds all information for a netns""" + name: str = None + interfaces: List[if_addr] = field(default_factory=list) + cmd: str = None + + +@dataclass(frozen=True, eq=True) +class Test_to_run(NetNS_info): + """holds all information for a netns""" + #name: str = None + #interfaces: List[if_addr] = field(default_factory=list) + #cmd: str = None + test_binary: str = None + cfgfile: str = None + + +@dataclass(frozen=True, eq=True) +class glob_data(): + install_prefix: str + titandir: str + workdir: str + testdir: str + + +@dataclass(frozen=True, eq=True) +class Topc: + global_data: glob_data + interfaces: List[NetNS_info] = field(default_factory=list) + test_to_run: Test_to_run = None + + + +if conf == "nat_notest": + global_data = defaultdict(str) + global_data["install_prefix"] = os.path.expanduser("~/osmo/bscnat/install") + global_data["titandir"] = os.path.expanduser("~/osmo/titan") + global_data["workdir"] = os.getcwd()+'/workdir' + global_data["testdir"] = os.path.expanduser("~/osmo/bscnat/osmo-ttcn3-hacks/msc") + networkcfg = [ + NetNS_info("gbernd", + interfaces=[if_addr(ip4='172.0.0.9/16', bridge='br0')], + cmd='nc -l -u -k -p 4729'), # >/dev/null 2> netcat.stderr &'), + NetNS_info("stp-cn", + interfaces=[if_addr(ip4='172.0.0.122/16', bridge='br0')], + cmd='osmo-stp -c ./osmo-stp-cn.cfg'), + NetNS_info("stp-ran", + interfaces=[if_addr(ip4='172.0.0.123/16', bridge='br0')], + cmd='osmo-stp -c ./osmo-stp-ran.cfg'), + NetNS_info("nat", + interfaces=[if_addr(ip4='172.0.0.222/16', bridge='br0'), + if_addr(ip4='172.0.0.223/16', bridge='br0')], + cmd='osmo-bsc-nat -c ./osmo-bsc-nat.cfg'), + NetNS_info("hlr", + interfaces=[if_addr(ip4='172.0.0.5/16', bridge='br0')], + cmd=f"osmo-hlr -c ./osmo-hlr.cfg"), + NetNS_info("msc", + interfaces=[if_addr(ip4='172.0.0.33/16', bridge='br0')], + cmd='osmo-msc -c ./osmo-msc.cfg'), + NetNS_info("bsc-0", + interfaces=[if_addr(ip4='172.0.0.3/16', bridge='br0')], + cmd='osmo-bsc -c ./osmo-bsc-0.cfg'), + # nsc("bsc-1", + # interfaces=[if_addr(ip4='172.0.0.10/16', bridge='br0')], + # cmd='osmo-bsc -c ./osmo-bsc-1.cfg'), + # nsc("mgw4bsc1", + # interfaces=[if_addr(ip4='172.0.0.11/16', bridge='br0')], + # cmd='osmo-mgw -c osmo-mgw-for-bsc-1.cfg'), + # nsc("mgw4msc", + # interfaces=[if_addr(ip4='172.0.0.6/16', bridge='br0')], + # cmd='osmo-mgw -c osmo-mgw-for-msc.cfg'), + # nsc("mgw4bscnat", + # interfaces=[if_addr(ip4='172.0.0.12/16', bridge='br0')], + # cmd='osmo-mgw -c osmo-mgw-for-bsc-nat.cfg'), + ] + + +# automated mapping of bridgedict['brname'] = ["intf0", "intf1", "intfn"...] +bridgedict = defaultdict(list) + + +def dict_to_dc(dclass: dataclass, data: dict): + """ recursively builds dataclass from dict """ + if is_dataclass(dclass): + tmpset = {} + dfd = fields(dclass) + for f in dfd: + val = dict_to_dc(f.type, data[f.name]) + tmpset.update({f.name: val}) + return dclass(**tmpset) + else: + #FIXME fails for IPv4Interface -> ends up as str? + if isinstance(data, list): # list kinda thingy? + l = [] + arg = get_args(dclass)[0] # no mixed types in our list.. + for f in data: + to_append = dict_to_dc(arg, f) + l.append(to_append) + return l + + return data + + +def dc_to_json(arg: dict, fname: str): + with open(fname, "w") as outfile: + dump(arg, outfile, default=lambda o: o.__dict__, indent=4) + + +def json_to_dc(fname: str): + with open(fname, "r") as infile: + data = load(infile) + return dict_to_dc(Topc, data) + + +#dc_to_json(networkcfg, "foo.json") +networkcfg = json_to_dc("foo.json") +#assert loaded == networkcfg + + +# check naming, ns_ + name + num +for idx, entry in enumerate(networkcfg.interfaces): + d = entry.__dict__ + if len(d['name']) > 15-1-2: + print(f"config error! nettwork '{d['name']}' name too long, must be at most 15-1-2 chars!") + os._exit(0) + + +def run_cmds_helper(cmds, vars=None, ignore=False): + if isinstance(cmds, str): + cmds = {cmds} + for line in cmds: + if line == "": + continue + try: + torun = line.format(**vars) + except TypeError: + torun = line + try: + subprocess.check_call(torun, shell=True) + except subprocess.CalledProcessError: + if not ignore: + return + else: + print(f"failed cmd: {torun}") + raise + +# ldd should show full so path for standard clang install if compiled with san, so no env necessary. + + +def prep_env(): + env_vars = { + # 'CC': "clang-12 -fembed-bitcode -fuse-ld=lld -Wno-unused-command-line-argument", + 'ASAN_OPTIONS': 'detect_leaks=1:abort_on_error=1', + # 'ASANPATH': str(os.path.dirname(subprocess.check_output('clang-12 -print-file-name=libclang_rt.asan-x86_64.so', shell=True)), "utf-8"), + 'PYTHONPATH': "{install_prefix}/python:{install_prefix}/lib/python3.8/site-packages:{install_prefix}/lib64/python3.8/site-packages:{install_prefix}/lib/python3.8/dist-packages:{install_prefix}/lib64/python3.8/dist-packages:{install_prefix}/lib/python3/site-packages:{install_prefix}/lib64/python3/site-packages:{install_prefix}/lib/python3/dist-packages:{install_prefix}/lib64/python3/dist-packages", + 'PKG_CONFIG_PATH': "{install_prefix}/lib/pkgconfig:{install_prefix}/lib64/pkgconfig", + 'LIBRARY_PATH': "{install_prefix}/lib:{install_prefix}/lib64/", + 'LD_LIBRARY_PATH': "$ASANPATH:{install_prefix}/lib:{install_prefix}/lib64/:{titandir}/lib:{titandir}/lib/titan:{testdir}", + 'PATH': "{install_prefix}/bin:{titandir}/titan/:{titandir}/bin/", + 'TTCN3_DIR': "{titandir}", + 'TAG': '7b1600f8b13f95baf7ff52935a96a0ec', + 'SLEEP_BEFORE_RESPAWN': "1", + 'HISTFILE': f"{os.getcwd()+os.sep}.history" + # ENVLINE="env TAG=7b1600f8b13f95baf7ff52935a96a0ec ASAN_OPTIONS=$ASAN_OPTIONS PYTHONPATH=$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH LIBRARY_PATH=$LIBRARY_PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH PATH=$PATH" + + } + + # expand ~ paths + confdict = networkcfg.global_data.__dict__.copy() + for k, v in confdict.items(): + confdict[k] = os.path.expanduser(v) + + for k, v in env_vars.items(): + ok = os.environ.get(k) + ok = ':'+ok if ok is not None else "" + val = v or '' + try: + val = v.format(**confdict) + except: + val = v + # print(k+"="+val+ok) + os.environ[k] = val+ok + + +def netns_init(vars): + cmds = [ + # "ip netns add {nsname}", + + # magic path that makes persistent unshared namespaces usable by ip netns + "mkdir -p /run/netns", + "touch /run/netns/{nsname}", + "unshare --mount --uts --ipc --pid --fork --user --map-root-user --mount-proc --net=/run/netns/{nsname} echo created {nsname}...", + # nsenter --net=/var/run/netns/"${nsname}" ip link set lo up + "ip netns exec {nsname} ip link set lo up", + ] + run_cmds_helper(cmds, vars) + + +def netns_add(vars): + cmd = [ + "ip link add {localifname} type veth peer name {remoteifname}", + "ip link set {localifname} up", + "ip link set {remoteifname} netns {nsname}", + + "ip netns exec {nsname} ip link set {remoteifname} up", + "ip netns exec {nsname} ip addr add {ip4} dev {remoteifname}", + "ip netns exec {nsname} ip -6 addr add {ip6} dev {remoteifname} nodad" if vars['ip6'] is not None else "", + ] + run_cmds_helper(cmd, vars) + + +def prep_all_netns(): + + total_if_list = networkcfg.interfaces + [networkcfg.test_to_run] + # print(total_if_list) + + for idx, entry in enumerate(total_if_list): + d = entry.__dict__.copy() + d['nsname'] = "ns_{}".format(d['name']) # str(idx)) + netns_init(d) + + for idx2, ifn in enumerate(d['interfaces']): + d['localifname'] = "veth_{}{}".format(d['name'], str(idx2)) + d['remoteifname'] = "ceth_{}{}".format(d['name'], str(idx2)) + + # lazy + d['ip4'] = ifn.ip4 + d['ip6'] = ifn.ip6 + + if ifn.bridge is not None: + bridgedict[ifn.bridge].append(d['localifname']) + netns_add(d) + + for brname, ifnamelist in bridgedict.items(): + run_cmds_helper(f"ip link add {brname} type bridge") # stp_state 0 ageing_time 0 forward_delay 0") + run_cmds_helper(f"ip link set {brname} up") + for ifname in ifnamelist: + run_cmds_helper(f"ip link set {ifname} master {brname}") + run_cmds_helper(f"ip -all netns") + run_cmds_helper(f"ip link") + + +def prepare_ns_mounts(): + cmds = [ + # 'mount -t proc none /proc', # done by --mount-proc + 'mount -t sysfs none /sys', + + # check cat /proc/1/mountinfo for shared, priv, ... + # in host: + # 28 1 8:5 / / rw,relatime shared:1 - ext4 /dev/sda5 rw,errors=remount-ro + # 24 28 0:22 / /proc rw,nosuid,nodev,noexec,relatime shared:13 - proc proc rw + # in ns: + # 258 244 8:5 / / rw,relatime - ext4 /dev/sda5 rw,errors=remount-ro + # 403 258 0:22 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw + + + # unshare --mount-proc + # [pid 14178] mount("none", "/", NULL, MS_REC|MS_PRIVATE, NULL) = 0 + # mount mount --make-rprivate / + # [pid 14178] mount("none", "/proc", NULL, MS_REC|MS_PRIVATE, NULL) = 0 + # mount -t proc none /proc + # [pid 14178] mount("proc", "/proc", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL) = 0 + # mount -t proc proc /proc + + # xterm tries to chown /dev/pts/$n.. to uid:tty-group-id, which it gets from /etc/group, which fails + # no known fix yet + # mount -t devpts none /dev/pts -o rw,gid=0,newinstance,ptmxmode=0666,mode=0666,max=1024 + # mount --rbind /dev/pts/ptmx /dev/ptmx -o nosuid,noexec + + + # mount -t tmpfs --make-rshared tmpfs /tmp + # mount -t tmpfs tmpfs /home + + # ip tools needs this to work, we don't care about the host run + 'mount -t tmpfs tmpfs /run', + ] + + if os.path.exists("/tmp/.X11-unix"): + cmds2 = [ + # tmp breaks x11, x11 requires workaround by remounting into private dir, then binding back + f"mkdir -p {networkcfg.global_data.workdir}/.X11-unix", + f"mount --rbind /tmp/.X11-unix {networkcfg.global_data.workdir}/.X11-unix", + 'mount -t tmpfs none /tmp', + 'mkdir -p /tmp/.X11-unix', + f"mount --rbind {networkcfg.global_data.workdir}/.X11-unix /tmp/.X11-unix", + f"umount -l {networkcfg.global_data.workdir}/.X11-unix", + ] + else: + cmds2 = ['mount -t tmpfs none /tmp', ] + + run_cmds_helper(cmds+cmds2) + + +def fix_hostname(): + run_cmds_helper("hostname testrun") + + to_check = networkcfg.interfaces + [networkcfg.test_to_run] + addrlist = [] + for _, entry in enumerate(to_check): + d = entry.__dict__.copy() + try: + numifs = len(d['interfaces']) + for idx, val in enumerate(d['interfaces']): + idx = idx if numifs > 1 else '' + addrlist.append(f"{IPv4Interface(val.ip4).ip}\t{d['name']}{idx}") if val.ip4 else "" + addrlist.append(f"{IPv6Interface(val.ip6).ip}\t{d['name']}{idx}6") if val.ip6 else "" + except: + pass + + addrlines = '\n'.join(addrlist) + + my_hosts = f""" +127.0.0.1 localhost +127.1.2.3 testrun + +{addrlines} + +# The following lines are desirable for IPv6 capable hosts +::1 ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters +""" + with open("my_hosts", 'w') as file_: + file_.write(my_hosts) + + run_cmds_helper("mount my_hosts /etc/hosts --bind") + + wshosts = os.path.expanduser('~/.config/wireshark/hosts') + if os.path.exists(wshosts): + print(f"bind mounting {wshosts}..") + run_cmds_helper(f"mount my_hosts {wshosts} --bind") + else: + print(f"{wshosts} does not exist, not bind mounting!") + print(my_hosts) + + + +class silentsession: + def new_wnd(self, netnsidx, name, cmd): + self.new_wnd_nsname(f"ns_{name}", name, cmd) + + def new_wnd_nsname(self, netnsname, name, cmd): + run_cmds_helper(f"ip netns exec {netnsname} sh -c \"{cmd} > {name}.stdout\" C-m") + + def att(self, sessname=None): + pass + + def parse_and_run(self, nwconfig): + for idx, entry in enumerate(nwconfig.interfaces): + d = entry.__dict__.copy() + + d['cmd'] = d['cmd'] + f" >> {d['name']}.log 2>&1" + + # last cmd = not in background, but everything else must be in bg + # if entry == nwconfig.interfaces[-1]: + # pass + # else: + d['cmd'] = d['cmd'] + " &" + + # if "ttcn3_start" in d['cmd']: + # time.sleep(0.5) + self.new_wnd(idx, d['name'], d['cmd']) + if nwconfig.test_to_run: + d = nwconfig.test_to_run.__dict__.copy() + cfgfile = d['cfgfile'] + (f" {args.test_to_run}" if args.test_to_run is not None else "") + ' ' + tbinpath = nwconfig.global_data.testdir+os.path.sep+d['test_binary'] + ' ' + d['cmd'] = d['cmd'] + ' ' + tbinpath + cfgfile + d['cmd'] += f" >> {d['name']}.log 2>&1" + time.sleep(0.5) + self.new_wnd(idx, d['name'], d['cmd']) + + +def get_pids_for_name(name): + try: + rv = subprocess.check_output(["pidof", name]) + except: + return [] + return map(int, rv.split()) + + +class byobusession(silentsession): + def __init__(self): + self.sessname = "ttcn3-bsc2" + run_cmds_helper("tmux list-panes && tmux list-sessions && tmux list-windows") + run_cmds_helper(f"byobu new-session -s {self.sessname} -d -n 'bernd'") + + def new_wnd_nsname(self, netnsname, name, cmd): + idxname = self.sessname # sess+':'+str(idx) if idx != 0 else sess + run_cmds_helper(f"tmux new-window -a -t {idxname} -n '{name}'", ignore=True) + run_cmds_helper(f"tmux send -t '{name}' 'ip netns exec {netnsname} sh -c \"{cmd}\"' C-m") + + def att(self, sessname=None): + sessname = sessname or self.sessname + run_cmds_helper(f"tmux attach -t {sessname}") + + def parse_and_run(self, nwconfig): + for idx, entry in enumerate(nwconfig.interfaces): + d = entry.__dict__.copy() + # print(d['cmd']) +# if "ttcn3_start" in d['cmd']: +# time.sleep(6)#0.2) + self.new_wnd(idx, d['name'], d['cmd']) + if nwconfig.test_to_run: + d = nwconfig.test_to_run.__dict__.copy() + + cfgfile = d['cfgfile'] + (f" {args.test_to_run}" if args.test_to_run is not None else "") + ' ' + tbinpath = nwconfig.global_data.testdir+os.path.sep+d['test_binary'] + ' ' + d['cmd'] = d['cmd'] + ' ' + tbinpath + cfgfile + time.sleep(0.5) + self.new_wnd(idx, d['name'], d['cmd']) + + +def check_debian_userns(): + try: + with open('/proc/sys/kernel/unprivileged_userns_clone') as f: + rv = f.read() + rv = int(rv) if rv.isdigit() else rv + if rv != 0: + print("we're on debian and need 'sudo sysctl -w kernel.unprivileged_userns_clone=0' or a mainline/ubuntu kernel!") + os._exit(0) + except FileNotFoundError: + pass # not debian, we're fine + + +def unshare_myself(): + + # first call from outside + if not args.supersecretarg: + pid = os.fork() + if pid > 0: + print(f"parent {os.getpid()} waiting for child {pid}") + sys.stdout.flush() + os.waitpid(pid, 0) + os._exit(0) + else: # forked self call + print(f"child {os.getpid()} unsharing itself...") + arg = "unshare --mount --uts --ipc --net --pid --fork --user --map-root-user --mount-proc /bin/bash -c".split() + allargs = ' '.join(sys.argv[1:]) + arg += [f'{sys.executable} {__file__} --supersecretarg {allargs}'] + # print(arg) + sys.stdout.flush() + os.execvp("unshare", arg) + print("execvp failed?!") + os._exit(0) + + print(f"we are in our unprivileged namespace! euid:{os.geteuid()} egid:{os.getegid()}") + + if os.geteuid() != 0 or os.getegid() != 0: + print(f"...wat? we are not root, exiting!") + os._exit(0) + + sys.stdout.flush() + # os._exit(0) + + +def create_overlayfs(): + return + + # idea: + # mount --bind -m -n /* mnt/*" + # mount --move ? + + # overlayfs does not work due to + # https://github.com/sosy-lab/benchexec/issues/776 + # https://github.com/torvalds/linux/commit/427215d85e8d1476da1a86b8d67aceb485eb3631 "ovl: prevent private clone if bind mount is not allowed" + + run_cmds_helper("mount --make-rprivate /") + run_cmds_helper("mount --rbind / /") + run_cmds_helper('mount -t proc none /proc') + run_cmds_helper('mount -t sysfs none /sys') + m = "/tmp/mount-point" + run_cmds_helper(f"mkdir -p '{m}'") + run_cmds_helper(f"mount -t tmpfs tmpfs '{m}'") + run_cmds_helper(f"cd '{m}' && mkdir top merge work topdir") + run_cmds_helper(f"cd '{m}' && mount --rbind '{m}'/topdir / || ls topdir") + run_cmds_helper(f"cd '{m}' && mount -t overlay overlay -o lowerdir=/,upperdir={m}/top,workdir={m}/work {m}/merge && mount --rbind /dev ./merge/dev") + + oldpwd = os.getcwd() + os.chroot("merge") + + run_cmds_helper('mount -t proc none /proc') + run_cmds_helper('mount -t sysfs none /sys') + + run_cmds_helper("touch /foobernd") + os.chdir(oldpwd) + os.setgid(0) + os.setuid(0) + + run_cmds_helper("touch foobart; id; ls -al /; ls -al /home/peta/osmo") + run_cmds_helper("touch ~/fooboing") + run_cmds_helper("zsh") + + # run_cmds_helper("id; ls -al .; touch foo") + os._exit(0) + + +def kill_tcpdump(): + pids = get_pids_for_name("tcpdump") + for pid in pids: + try: + os.kill(pid, signal.SIGINT) + except ProcessLookupError: + print(f"already dead: {pid}?") + continue + except OSError: + print(f"fuck: {pid}?") + continue + try: + os.waitpid(pid, os.WSTOPPED) + except ChildProcessError: + pass + + +def exit_cleanup(olddir, test_artifact_storage_location, signum, stack): + + kill_tcpdump() + + def cpy2pass(src, dest): + """does not choke on sockets...""" + try: + shutil.copy2(src, dest) + except: + pass + + print(f"data will end up in {test_artifact_storage_location}") + try: + shutil.copytree('/tmp', test_artifact_storage_location, copy_function=cpy2pass, dirs_exist_ok=True, symlinks=True, ignore_dangling_symlinks=True) + except shutil.Error as e: + pass + + sys.stdout.flush() + sys.stderr.flush() + + +def spawn_num_tests(set_of_tests, how_many, oldenv): + pids_to_wait_For = set() + while how_many: + how_many -= 1 + try: + l = set_of_tests.pop() + except KeyError: + continue + + if l.endswith(".control"): # don't run everything.. duh. + continue + + lcmd = f'{sys.executable} {__file__} --test-to-run {l}' + print(lcmd) + fnull = open(os.devnull, 'w') # pipe will fill up and stall, use nothing instead + process = subprocess.Popen(lcmd, env=oldenv, shell=True, stdout=fnull, stderr=fnull, close_fds=True) + #my_pid, err = process.communicate() + #print(err) + pids_to_wait_For.add(process.pid) + return pids_to_wait_For + +def run_all_tests(): + + oldenv = os.environ.copy() + prep_env() + + cmd = networkcfg.global_data.testdir+os.path.sep+networkcfg.test_to_run.test_binary+" -l" + + #os.environ['LD_LIBRARY_PATH'] = os.environ.get('LD_LIBRARY_PATH')+":"+networkcfg.global_data.testdir # ttcn testdir must be in path + lines = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True) # cmd, shell=True, check=True, capture_output=True, text=True) + total_tests_to_run = set() + total_tests_to_run.update(lines.stdout.split()) + + if "MSC_Tests" in cmd: + # remove all iu tests + filter_to_remove = [] + filterlist = ["TC_iu_"]#, "TC_multi_lu_and_"] + for i in total_tests_to_run: + t = [i for y in filterlist if y in i] + filter_to_remove += t if not None else [] + + #print(f"tests to remove: {filter_to_remove}") + total_tests_to_run.difference_update(filter_to_remove) + + print(f"we have {len(total_tests_to_run)} tests to run, at most {args.parallel} at the same time...") + + num_parallel = args.parallel # 16 = ~ 3GB ram total + pids_to_wait_For = spawn_num_tests(total_tests_to_run, num_parallel, oldenv) + print(pids_to_wait_For) + + print( "%s Waiting for %d processes..." % (datetime.now().strftime('%Y-%m-%d_%H-%M-%S'), len(pids_to_wait_For))) + while pids_to_wait_For: + try: + pid, status = os.wait() + except ChildProcessError: + print("looks like we ran out of children?") + os._exit(0) + if pid in pids_to_wait_For: + pids_to_wait_For.remove(pid) + pids_left = num_parallel-len(pids_to_wait_For) + to_spawn = max(min(pids_left,num_parallel),0) + pids_to_wait_For.update(spawn_num_tests(total_tests_to_run, to_spawn, oldenv)) + print( "%s Waiting for %d processes..." % (datetime.now().strftime('%Y-%m-%d_%H-%M-%S'), len(pids_to_wait_For))) + + os._exit(0) + +if __name__ == "__main__": + + # do not pollute host shell history + os.environ['HISTFILE'] = f"{os.getcwd()+os.sep}.history" + check_debian_userns() + + if args.run_all_tests: + run_all_tests() + + unshare_myself() + + olddir = os.getcwd() + run_cmds_helper(f"export HOME={olddir}") + suffix = f"_{args.test_to_run}" if args.test_to_run is not None else "" + test_artifact_storage_location = tempfile.mkdtemp(dir=olddir, suffix=suffix, prefix=datetime.now().strftime('%Y-%m-%d_%H-%M-%S')) + # if sys.stdout.isatty(): + # pass + # else: + # stdoutname = args.test_to_run or "" + # sys.stdout = open(stdoutname+"_"+os.path.basename(test_artifact_storage_location), 'w') + # #sys.stderr = sys.stdout + + create_overlayfs() + prepare_ns_mounts() + fix_hostname() + prep_env() + prep_all_netns() + + run_cmds_helper("mkdir -p /tmp/unix") + + os.environ['BYOBU_CONFIG_DIR'] = olddir+"/.byobu" + + # put stuff in tmp + run_cmds_helper("mkdir -p /tmp/trash") + run_cmds_helper("cp *cfg *default *sh /tmp/trash") + os.chdir("/tmp/trash") + + for brname, _ in bridgedict.items(): + run_cmds_helper(f"tcpdump -i {brname} -w {brname}.pcapng >> dump.log 2>&1 &") + time.sleep(0.5) + + # salvage stuck tests on exit to ensure we keep the trash and can figure out what failed + signal.signal(signal.SIGINT, partial(exit_cleanup, olddir, test_artifact_storage_location)) + signal.signal(signal.SIGTERM, partial(exit_cleanup, olddir, test_artifact_storage_location)) + + s = byobusession() if args.gui == True else silentsession() + s.parse_and_run(networkcfg) + # s.new_wind(0, "stp", 'osmo-stp -c ./osmo-stp.cfg') + # s.new_wind(1, "bsc", 'osmo-bsc -c ./osmo-bsc.cfg') + s.att() + + if args.ws is True: + print("running ws..") + kill_tcpdump() + subprocess.check_call("wireshark br0.pcapng", shell=True) + + # self kill to clean up either way + os.kill(os.getpid(), signal.SIGINT) + + diff --git a/namespaces/nat-msc/.byobu/.screenrc b/namespaces/nat-msc/.byobu/.screenrc new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/nat-msc/.byobu/.screenrc diff --git a/namespaces/nat-msc/.byobu/.tmux.conf b/namespaces/nat-msc/.byobu/.tmux.conf new file mode 100644 index 0000000..0df777d --- /dev/null +++ b/namespaces/nat-msc/.byobu/.tmux.conf @@ -0,0 +1,11 @@ +#set -g status-left '#{pane_current_path} ' +#set -g pane-border-format "#{pane_index} #{window_name}" +#set -g allow-rename on +setw -g automatic-rename off +set -g allow-rename off + +set -g window-status-format " #I:#W " +set -g window-status-current-style "fg=$color_light,bold,bg=$color_main" +set -g window-status-current-format "#[fg=$color_dark,bg=$color_main]$separator_powerline_right#[default] #I:#W# #[fg=$color_main,bg=$color_dark]$separator_powerline_right#[default]" + + diff --git a/namespaces/nat-msc/.byobu/.welcome-displayed b/namespaces/nat-msc/.byobu/.welcome-displayed new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/nat-msc/.byobu/.welcome-displayed diff --git a/namespaces/nat-msc/.byobu/backend b/namespaces/nat-msc/.byobu/backend new file mode 100644 index 0000000..ac0eb76 --- /dev/null +++ b/namespaces/nat-msc/.byobu/backend @@ -0,0 +1 @@ +BYOBU_BACKEND=tmux diff --git a/namespaces/nat-msc/.byobu/color b/namespaces/nat-msc/.byobu/color new file mode 100644 index 0000000..1ee73ad --- /dev/null +++ b/namespaces/nat-msc/.byobu/color @@ -0,0 +1,3 @@ +BACKGROUND=k +FOREGROUND=w +MONOCHROME=0
\ No newline at end of file diff --git a/namespaces/nat-msc/.byobu/color.tmux b/namespaces/nat-msc/.byobu/color.tmux new file mode 100644 index 0000000..4f55dc7 --- /dev/null +++ b/namespaces/nat-msc/.byobu/color.tmux @@ -0,0 +1,4 @@ +BYOBU_DARK="\#333333" +BYOBU_LIGHT="\#EEEEEE" +BYOBU_ACCENT="\#75507B" +BYOBU_HIGHLIGHT="\#DD4814" diff --git a/namespaces/nat-msc/.byobu/datetime.tmux b/namespaces/nat-msc/.byobu/datetime.tmux new file mode 100644 index 0000000..7c66f48 --- /dev/null +++ b/namespaces/nat-msc/.byobu/datetime.tmux @@ -0,0 +1,2 @@ +BYOBU_TIME="%H:%M:%S" +BYOBU_DATE= diff --git a/namespaces/nat-msc/.byobu/keybindings b/namespaces/nat-msc/.byobu/keybindings new file mode 100644 index 0000000..9d9bbdb --- /dev/null +++ b/namespaces/nat-msc/.byobu/keybindings @@ -0,0 +1 @@ +source $BYOBU_PREFIX/share/byobu/keybindings/common diff --git a/namespaces/nat-msc/.byobu/keybindings.tmux b/namespaces/nat-msc/.byobu/keybindings.tmux new file mode 100644 index 0000000..eb3d92e --- /dev/null +++ b/namespaces/nat-msc/.byobu/keybindings.tmux @@ -0,0 +1,4 @@ +unbind-key -n C-a +set -g prefix ^A +set -g prefix2 F12 +bind a send-prefix diff --git a/namespaces/nat-msc/.byobu/profile b/namespaces/nat-msc/.byobu/profile new file mode 100644 index 0000000..230ac0e --- /dev/null +++ b/namespaces/nat-msc/.byobu/profile @@ -0,0 +1 @@ +source $BYOBU_PREFIX/share/byobu/profiles/common diff --git a/namespaces/nat-msc/.byobu/profile.tmux b/namespaces/nat-msc/.byobu/profile.tmux new file mode 100644 index 0000000..9ccca51 --- /dev/null +++ b/namespaces/nat-msc/.byobu/profile.tmux @@ -0,0 +1 @@ +source $BYOBU_PREFIX/share/byobu/profiles/tmux diff --git a/namespaces/nat-msc/.byobu/prompt b/namespaces/nat-msc/.byobu/prompt new file mode 100644 index 0000000..c0a7eeb --- /dev/null +++ b/namespaces/nat-msc/.byobu/prompt @@ -0,0 +1 @@ +[ -r /usr/share/byobu/profiles/bashrc ] && . /usr/share/byobu/profiles/bashrc #byobu-prompt# diff --git a/namespaces/nat-msc/.byobu/status b/namespaces/nat-msc/.byobu/status new file mode 100644 index 0000000..bad8e2f --- /dev/null +++ b/namespaces/nat-msc/.byobu/status @@ -0,0 +1,37 @@ +# status - Byobu's default status enabled/disabled settings +# +# Override these in $BYOBU_CONFIG_DIR/status +# where BYOBU_CONFIG_DIR is XDG_CONFIG_HOME if defined, +# and $HOME/.byobu otherwise. +# +# Copyright (C) 2009-2011 Canonical Ltd. +# +# Authors: Dustin Kirkland <kirkland@byobu.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Status beginning with '#' are disabled. + +# Screen has two status lines, with 4 quadrants for status +screen_upper_left="color" +screen_upper_right="color whoami hostname ip_address menu" +screen_lower_left="color logo distro release #arch session" +screen_lower_right="color network #disk_io custom #entropy raid reboot_required updates_available #apport #services #mail users uptime #ec2_cost #rcs_cost #fan_speed #cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap disk #time_utc date time" + +# Tmux has one status line, with 2 halves for status +tmux_left=" logo #distro release #arch session" +# You can have as many tmux right lines below here, and cycle through them using Shift-F5 +tmux_right=" #network #disk_io #custom #entropy raid reboot_required #updates_available #apport #services #mail #users #uptime #ec2_cost #rcs_cost #fan_speed #cpu_temp #battery #wifi_quality #processes load_average #cpu_count #cpu_freq memory #swap #disk whoami #hostname ip_address #time_utc #date time" +#tmux_right="network #disk_io #custom entropy raid reboot_required updates_available #apport #services #mail users uptime #ec2_cost #rcs_cost fan_speed cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap #disk whoami hostname ip_address #time_utc date time" +#tmux_right="network #disk_io custom #entropy raid reboot_required updates_available #apport #services #mail users uptime #ec2_cost #rcs_cost #fan_speed #cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap #disk #whoami #hostname ip_address #time_utc date time" +#tmux_right="#network disk_io #custom entropy #raid #reboot_required #updates_available #apport #services #mail #users #uptime #ec2_cost #rcs_cost fan_speed cpu_temp #battery #wifi_quality #processes #load_average #cpu_count #cpu_freq #memory #swap whoami hostname ip_address #time_utc disk date time" diff --git a/namespaces/nat-msc/.byobu/statusrc b/namespaces/nat-msc/.byobu/statusrc new file mode 100644 index 0000000..472e45c --- /dev/null +++ b/namespaces/nat-msc/.byobu/statusrc @@ -0,0 +1,78 @@ +# statusrc - Byobu's default status configurations +# +# Override these in $BYOBU_CONFIG_DIR/statusrc +# where BYOBU_CONFIG_DIR is XDG_CONFIG_HOME if defined, +# and $HOME/.byobu otherwise. +# +# Copyright (C) 2009-2011 Canonical Ltd. +# +# Authors: Dustin Kirkland <kirkland@byobu.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Configurations that you can override; if you leave these commented out, +# Byobu will try to auto-detect them. + +# This should be auto-detected for most distro, but setting it here will save +# some call to lsb_release and the like. +#BYOBU_DISTRO=Ubuntu + +# Default: depends on the distro (which is either auto-detected, either set +# via $DISTRO) +#LOGO="\o/" + +# Abbreviate the release to N characters +# By default, this is disabled. But if you set RELEASE_ABBREVIATED=1 +# and your lsb_release is "precise", only "p" will be displayed +#RELEASE_ABBREVIATED=1 + +# Default: / +#MONITORED_DISK=/ + +# Minimum disk throughput that triggers the notification (in kB/s) +# Default: 50 +#DISK_IO_THRESHOLD=50 + +# Default: eth0 +#MONITORED_NETWORK=eth0 + +# Unit used for network throughput (either bits per second or bytes per second) +# Default: bits +#NETWORK_UNITS=bytes + +# Minimum network throughput that triggers the notification (in kbit/s) +# Default: 20 +#NETWORK_THRESHOLD=20 + +# You can add an additional source of temperature here +#MONITORED_TEMP=/proc/acpi/thermal_zone/THM0/temperature + +# Default: C +#TEMP=F + +#SERVICES="eucalyptus-nc|NC eucalyptus-cloud|CLC eucalyptus-walrus eucalyptus-cc|CC eucalyptus-sc|SC" + +#FAN=$(find /sys -type f -name fan1_input | head -n1) + +# You can set this to 1 to report your external/public ip address +# Default: 0 +#IP_EXTERNAL=0 + +# The users notification normally counts ssh sessions; set this configuration to '1' +# to instead count number of distinct users logged onto the system +# Default: 0 +#USERS_DISTINCT=0 + +# Set this to zero to hide seconds int the time display +# Default 1 +#TIME_SECONDS=0 diff --git a/namespaces/nat-msc/.byobu/windows b/namespaces/nat-msc/.byobu/windows new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/nat-msc/.byobu/windows diff --git a/namespaces/nat-msc/.byobu/windows.tmux b/namespaces/nat-msc/.byobu/windows.tmux new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/namespaces/nat-msc/.byobu/windows.tmux diff --git a/namespaces/nat-msc/Common.cfg b/namespaces/nat-msc/Common.cfg new file mode 100644 index 0000000..50abf13 --- /dev/null +++ b/namespaces/nat-msc/Common.cfg @@ -0,0 +1,19 @@ +# common config file, relevant to all projects + +[DEFINE] +TTCN3_HACKS_PATH := "~/osmo/bscnat/osmo-ttcn3-hacks" +TCPDUMP_START := $TTCN3_HACKS_PATH"/ttcn3-tcpdump-start.sh" +TCPDUMP_STOP := $TTCN3_HACKS_PATH"/ttcn3-tcpdump-stop.sh" + +[LOGGING] +LogFile := "%e-%c-%h-%r.%s" +AppendFile := Yes; +SourceInfoFormat := Single; +LogSourceInfo := Yes; +LoggerPlugins := { JUnitLogger := "libjunitlogger2" } +FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING | DEBUG_ENCDEC; +ConsoleMask := ERROR | WARNING | TESTCASE | USER | VERDICTOP; + +[EXTERNAL_COMMANDS] +BeginTestCase := $TCPDUMP_START +EndTestCase := $TCPDUMP_STOP diff --git a/namespaces/nat-msc/MSC_Tests.cfg b/namespaces/nat-msc/MSC_Tests.cfg new file mode 100644 index 0000000..b1dd53e --- /dev/null +++ b/namespaces/nat-msc/MSC_Tests.cfg @@ -0,0 +1,83 @@ +[ORDERED_INCLUDE] +"./Common.cfg" +"./MSC_Tests.default" + +[LOGGING] +SourceInfoFormat:= Single +LogEntityName:= Yes +LogEventTypes:= Yes +*.FileMask :=WARNING|VERDICTOP|TIMEROP|STATISTICS|PORTEVENT|EXECUTOR|ERROR|DEFAULTOP|ACTION|PARALLEL|FUNCTION|USER|TESTCASE|DEBUG; + +[TESTPORT_PARAMETERS] +*.MSCVTY.CTRL_HOSTNAME := "172.18.20.10" + +[MODULE_PARAMETERS] +MSC_Tests.bssap_reset_retries := 3 +# connection to STP +MSC_Tests.mp_bssap_cfg := { + { + transport := BSSAP_TRANSPORT_AoIP, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23906, "172.18.20.103", 2905, "172.18.20.200" }, + own_pc := 193, /* 0.24.1 BSC emulation [0] */ + own_ssn := 254, + peer_pc := 185, /* 0.23.1 osmo-msc */ + peer_ssn := 254, + sio := '83'O, + rctx := 0 + }, + { + transport := BSSAP_TRANSPORT_AoIP, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23907, "172.18.20.103", 2905, "172.18.20.200" }, + own_pc := 194, /* 0.24.2 BSC emulation [1] */ + own_ssn := 254, + peer_pc := 185, /* 0.23.1 osmo-msc */ + peer_ssn := 254, + sio := '83'O, + rctx := 1 + }, + { + transport := RANAP_TRANSPORT_IuCS, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23908, "172.18.20.103", 2905, "172.18.20.200" }, + own_pc := 195, /* 0.24.3 BSC emulation [2] */ + own_ssn := 142, + peer_pc := 185, /* 0.23.1 osmo-msc */ + peer_ssn := 142, + sio := '83'O, + rctx := 2 + } +}; + +# remote (IUT) side +MSC_Tests.mp_msc_mncc := "/tmp/unix/mncc"; +MSC_Tests.mp_msc_ip := "172.18.20.10"; +# local (emulation) side) +MSC_Tests.mp_hlr_ip := "172.18.20.103"; +MSC_Tests.mp_mgw_ip := "172.18.20.103"; + +[MAIN_CONTROLLER] + +[EXECUTE] +#MSC_Tests.control +#MSC_Tests_Iu.control + +MSC_Tests.TC_lu_auth_2G_fail +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_13_13 +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_1_13 +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_3_13 +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_3_1 +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_3_1_no_cm +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_13_2 +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_013_2 +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_0134_1 +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_0134_34 +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm3 + +MSC_Tests.TC_cipher_complete_with_invalid_cipher +MSC_Tests.TC_cipher_complete_1_without_cipher +MSC_Tests.TC_cipher_complete_3_without_cipher +MSC_Tests.TC_cipher_complete_13_without_cipher +MSC_Tests.TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug diff --git a/namespaces/nat-msc/MSC_Tests.default b/namespaces/nat-msc/MSC_Tests.default new file mode 100644 index 0000000..98bf299 --- /dev/null +++ b/namespaces/nat-msc/MSC_Tests.default @@ -0,0 +1,77 @@ +[LOGGING] +FileMask := LOG_ALL | TTCN_MATCHING; + +BSSAP.FileMask := LOG_NOTHING; +"MSC_Test_0-M3UA".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"MSC_Test_0-SCCP".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"MSC_Test_1-M3UA".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"MSC_Test_1-SCCP".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"MSC_Test-GSUP-IPA".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"MSC_Test-GSUP".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +"IPA-CTRL-IPA".FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; +mtc.FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; + +[TESTPORT_PARAMETERS] +"MSC_Test-MNCC".MNCC.socket_type := "SEQPACKET"; +*.MSCVTY.CTRL_MODE := "client" +*.MSCVTY.CTRL_HOSTNAME := "127.0.0.1" +*.MSCVTY.CTRL_PORTNUM := "4254" +*.MSCVTY.CTRL_LOGIN_SKIPPED := "yes" +*.MSCVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" +*.MSCVTY.CTRL_READMODE := "buffered" +*.MSCVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.MSCVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" +*.MSCVTY.PROMPT1 := "OsmoMSC> " + + +[MODULE_PARAMETERS] +M3UA_Emulation.tsp_logVerbose := true; +MSC_Tests.mp_bssap_cfg := { + { + transport := BSSAP_TRANSPORT_AoIP, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" }, + own_pc := 193, + own_ssn := 254, + peer_pc := 185, + peer_ssn := 254, + sio := '83'O, + rctx := 0 + }, + { + transport := BSSAP_TRANSPORT_AoIP, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" }, + own_pc := 194, + own_ssn := 254, + peer_pc := 185, + peer_ssn := 254, + sio := '83'O, + rctx := 1 + }, + { + transport := RANAP_TRANSPORT_IuCS, + sccp_service_type := "mtp3_itu", + sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" }, + own_pc := 195, + own_ssn := 142, + peer_pc := 185, + peer_ssn := 142, + sio := '83'O, + rctx := 2 + } +}; + +# remote (IUT) side +MSC_Tests.mp_msc_mncc := "/tmp/mncc.sock"; +MSC_Tests.mp_msc_ip := "127.0.0.1" +# local (emulation) side) +MSC_Tests.mp_hlr_ip := "127.0.0.1" +MSC_Tests.mp_mgw_ip := "127.0.0.1" + + +Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoMSC"; + +[MAIN_CONTROLLER] + +[EXECUTE] diff --git a/namespaces/nat-msc/foo.json b/namespaces/nat-msc/foo.json new file mode 100644 index 0000000..f48267c --- /dev/null +++ b/namespaces/nat-msc/foo.json @@ -0,0 +1,88 @@ +{ + "global_data": { + "install_prefix": "/home/peta/osmo/bscnat/install", + "titandir": "/home/peta/osmo/titan", + "workdir": "/home/peta/osmo/namespaces/configs/msc/workdir", + "testdir": "/home/peta/osmo/bscnat/osmo-ttcn3-hacks/msc" + }, + "interfaces": [ + { + "name": "stp", + "interfaces": [ + { + "ip4": "172.18.20.200/16", + "ip6": "fd02:db8:20::200", + "bridge": "br0" + } + ], + "cmd": "osmo-stp -c ./osmo-stp.cfg" + }, + { + "name": "stp-nat", + "interfaces": [ + { + "ip4": "172.18.20.201/16", + "ip6": "fd02:db8:20::201", + "bridge": "br0" + } + ], + "cmd": "osmo-stp -c ./osmo-stp-nat.cfg" + }, + { + "name": "mgw-nat", + "interfaces": [ + { + "ip4": "172.18.2.114/16", + "ip6": "fd02:db8:2::114", + "bridge": "br0" + } + ], + "cmd": "osmo-mgw -c ./osmo-mgw.cfg" + }, + { + "name": "bscnat", + "interfaces": [ + { + "ip4": "172.18.20.111/16", + "ip6": "fd02:db8:2::111", + "bridge": "br0" + }, + { + "ip4": "172.18.20.112/16", + "ip6": "fd02:db8:2::112", + "bridge": "br0" + }, + { + "ip4": "172.18.2.113/16", + "ip6": "fd02:db8:2::113", + "bridge": "br0" + } + ], + "cmd": "osmo-bsc-nat" + }, + { + "name": "msc", + "interfaces": [ + { + "ip4": "172.18.20.10/16", + "ip6": "fd02:db8:20::10", + "bridge": "br0" + } + ], + "cmd": "osmo-msc -c ./osmo-msc.cfg" + } + ], + "test_to_run": { + "name": "ttcn3", + "interfaces": [ + { + "ip4": "172.18.20.103/16", + "ip6": "fd02:db8:2::203", + "bridge": "br0" + } + ], + "cmd": "ttcn3_start", + "test_binary": "MSC_Tests", + "cfgfile": "MSC_Tests.cfg" + } +}
\ No newline at end of file diff --git a/namespaces/nat-msc/osmo-bsc-nat.cfg b/namespaces/nat-msc/osmo-bsc-nat.cfg new file mode 100644 index 0000000..a8e47a1 --- /dev/null +++ b/namespaces/nat-msc/osmo-bsc-nat.cfg @@ -0,0 +1,65 @@ +# DO NET EDIT THIS FILE DIRECTLY! +# This is generated from templates, and manual edits will be overwritten. + +cs7 instance 0 + point-code 0.23.3 + asp asp-clnt-OsmoBSCNAT-CN 2905 0 m3ua + remote-ip 172.18.20.201 + local-ip 172.18.20.112 + sccp-address msc + routing-indicator PC + point-code 0.23.1 + subsystem-number 254 + +cs7 instance 1 + point-code 0.23.1 + asp asp-clnt-OsmoBSCNAT-RAN 2905 0 m3ua + remote-ip 172.18.20.200 + local-ip 172.18.20.111 + sccp-address bsc + routing-indicator PC + point-code 0.23.3 + subsystem-number 254 + +bsc-nat + cs7-instance-cn 0 + cs7-instance-ran 1 + +!mgw 0 +! mgw remote-ip 172.18.2.114 +! mgw remote-port 2427 +! mgw local-ip 172.18.2.113 +! mgw local-port 2427 +! mgw endpoint-domain bscnat + +log stderr + logging filter all 1 + logging color 1 + logging print level 1 + logging print category 1 + logging print category-hex 0 + logging print file basename last + logging print extended-timestamp 1 + logging level set-all debug + logging level linp notice + +!log file current_log/osmo-bsc-nat.log +! logging filter all 1 +! logging color 1 +! logging print level 1 +! logging print category 1 +! logging print category-hex 0 +! logging print file basename last +! logging print extended-timestamp 1 +! logging level set-all debug + +log gsmtap 172.18.20.103 + logging filter all 1 + logging color 1 + logging print level 1 + logging print category 1 + logging print category-hex 0 + logging print file basename last + logging print extended-timestamp 1 + logging level set-all debug + logging level linp notice diff --git a/namespaces/nat-msc/osmo-mgw.cfg b/namespaces/nat-msc/osmo-mgw.cfg new file mode 100644 index 0000000..1d37f3c --- /dev/null +++ b/namespaces/nat-msc/osmo-mgw.cfg @@ -0,0 +1,46 @@ +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level set-all notice + logging level lmgcp debug +! +stats interval 5 +! +line vty + no login + bind 172.18.2.114 +! +stats interval 0 +stats reporter statsd + prefix TTCN3 + level subscriber + remote-ip 172.18.2.203 + remote-port 8125 + flush-period 1 + mtu 1024 + enable +! +mgcp + bind ip 172.18.2.114 + bind port 2427 + rtp port-range 4002 16000 + rtp bind-ip 172.18.2.114 + rtp bind-ip-v6 ::1 + rtp ip-probing + rtp ip-dscp 46 + no rtp keep-alive + no rtcp-omit + no rtp-patch + sdp audio-payload number 98 + sdp audio-payload name GSM + sdp audio-payload send-ptime + sdp audio-payload send-name + conn-timeout 0 + loop 0 + number endpoints 31 + allow-transcoding + osmux off + diff --git a/namespaces/nat-msc/osmo-msc.cfg b/namespaces/nat-msc/osmo-msc.cfg new file mode 100644 index 0000000..b9392e7 --- /dev/null +++ b/namespaces/nat-msc/osmo-msc.cfg @@ -0,0 +1,95 @@ +! +! OsmoMSC (1.1.2.66-629c4-dirty) configuration saved from vty +!! +! +log gsmtap 172.18.20.103 + logging level set-all debug + logging filter all 1 +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level rll notice + logging level cc debug + logging level mm debug + logging level rr notice + logging level mncc debug + logging level pag notice + logging level msc notice + logging level mgcp debug + logging level ho notice + logging level db notice + logging level ref notice + logging level ctrl notice + logging level smpp debug + logging level ranap debug + logging level vlr debug + logging level iucs debug + logging level lglobal notice + logging level llapd notice + logging level linp notice + logging level lmux notice + logging level lmi notice + logging level lmib notice + logging level lsms notice + logging level lctrl info + logging level lgtp notice + logging level lstats notice + logging level lgsup notice + logging level loap notice + logging level lss7 debug + logging level lsccp notice + logging level lsua notice + logging level lm3ua debug + logging level lmgcp debug +! +stats interval 5 +! +line vty + no login + bind 0.0.0.0 +ctrl + bind 0.0.0.0 +! +cs7 instance 0 + point-code 0.23.1 + asp asp-clnt-OsmoMSC-A 2905 0 m3ua + local-ip 172.18.20.10 + local-ip fd02:db8:20::10 + remote-ip 172.18.20.201 + remote-ip fd02:db8:20::201 + as as-clnt-OsmoMSC-A m3ua + asp asp-clnt-OsmoMSC-A + routing-key 3 0.23.1 +network + network country code 262 + mobile network code 42 + short name OsmoMSC + long name OsmoMSC + encryption a5 0 + authentication optional + rrlp mode none + mm info 0 + periodic location update 30 +msc + assign-tmsi + cs7-instance-a 0 + cs7-instance-iu 0 + mgw remote-ip 172.18.20.103 + emergency-call route-to-msisdn 112 + mncc external /tmp/unix/mncc +mncc-int + default-codec tch-f fr + default-codec tch-h hr +smpp + local-tcp-port 2775 + policy closed + no smpp-first + esme msc_tester + password osmocom1 +hlr + remote-ip 172.18.20.103 + remote-port 4222 diff --git a/namespaces/nat-msc/osmo-stp-nat.cfg b/namespaces/nat-msc/osmo-stp-nat.cfg new file mode 100644 index 0000000..a8e2642 --- /dev/null +++ b/namespaces/nat-msc/osmo-stp-nat.cfg @@ -0,0 +1,24 @@ +! +! OsmoSTP (0.8.1) configuration saved from vty +!! +! +log gsmtap 172.18.20.103 + logging level set-all debug + logging filter all 1 +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level set-all debug +! +line vty + no login +! +cs7 instance 0 + xua rkm routing-key-allocation dynamic-permitted + listen m3ua 2905 + accept-asp-connections dynamic-permitted + local-ip 172.18.20.201 diff --git a/namespaces/nat-msc/osmo-stp.cfg b/namespaces/nat-msc/osmo-stp.cfg new file mode 100644 index 0000000..7e489ab --- /dev/null +++ b/namespaces/nat-msc/osmo-stp.cfg @@ -0,0 +1,67 @@ +! +! OsmoSTP (0.8.1) configuration saved from vty +!! +! +log gsmtap 172.18.20.103 + logging level set-all debug + logging filter all 1 +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging timestamp 1 + logging print extended-timestamp 1 + logging level set-all debug +! +line vty + no login +! +cs7 instance 0 + xua rkm routing-key-allocation dynamic-permitted + asp virt-bsc0-0 23906 2905 m3ua + local-ip 172.18.20.200 + local-ip fd02:db8:20::200 + remote-ip 172.18.20.103 + remote-ip fd02:db8:20::103 + as virt-bsc0 m3ua + asp virt-bsc0-0 + routing-key 0 0.24.1 +! + asp virt-bsc1-0 23907 2905 m3ua + local-ip 172.18.20.200 + local-ip fd02:db8:20::200 + remote-ip 172.18.20.103 + remote-ip fd02:db8:20::103 + as virt-bsc1 m3ua + asp virt-bsc1-0 + routing-key 1 0.24.2 +! + asp virt-rnc0-0 23908 2905 m3ua + local-ip 172.18.20.200 + local-ip fd02:db8:20::200 + remote-ip 172.18.20.103 + remote-ip fd02:db8:20::103 + as virt-rnc0 m3ua + asp virt-rnc0-0 + routing-key 2 0.24.3 +! + asp virt-msc0-0 0 2905 m3ua + local-ip 172.18.20.200 + remote-ip 172.18.20.111 + as virt-msc0 m3ua + asp virt-msc0-0 +! routing-key 3 0.23.1 + + route-table system + update route 0.24.1 7.255.7 linkset virt-bsc0 + update route 0.24.2 7.255.7 linkset virt-bsc1 + update route 0.24.3 7.255.7 linkset virt-rnc0 + update route 0.23.1 7.255.7 linkset virt-msc0 + listen m3ua 2905 + accept-asp-connections dynamic-permitted + local-ip 172.18.20.200 + local-ip fd02:db8:20::200 + listen ipa 5000 + accept-asp-connections dynamic-permitted + local-ip 172.18.20.200 diff --git a/namespaces/run-test.py b/namespaces/run-test.py new file mode 100644 index 0000000..d2d02db --- /dev/null +++ b/namespaces/run-test.py @@ -0,0 +1,707 @@ +#!/usr/bin/env python3.8 + +import argparse +import os +import shutil +import signal +import subprocess +import sys +import tempfile +import time +from collections import defaultdict +from dataclasses import asdict, dataclass, field, fields, is_dataclass +from datetime import datetime +from functools import partial +from ipaddress import IPv4Interface, IPv6Interface +from json import dump, load +from pathlib import Path +from typing import List, get_args + +conf = "bsc" + +parser = argparse.ArgumentParser() +parser.add_argument('--test-to-run', type=str, help='optionally run only one test') +parser.add_argument('--supersecretarg', action='store_true', help=argparse.SUPPRESS) +parser.add_argument('--gui', action='store_true', help='byobu session') +parser.add_argument('--ws', action='store_true', help='run wireshark on br0 after exit') +parser.add_argument('--run-all-tests', action='store_true', help='run all tests except .control') +parser.add_argument('--parallel', type=int, default=4, help='parallel tests to run if all') +args = parser.parse_args() + +if (args.test_to_run is not None) and (not args.supersecretarg): + print(f"###test_to_run has been set (value is {args.test_to_run})") + +if (args.ws is not False): + print(f"###ws has been set (value is {args.ws})") +# asdict is slower than using __dict__.copy() for the dataclass + + +@dataclass(frozen=True, eq=True) +class if_addr: + """holds all information for a if addr""" + ip4: IPv4Interface = None + ip6: IPv6Interface = None + bridge: str = None + + +@dataclass(frozen=True, eq=True) +class NetNS_info: + """holds all information for a netns""" + name: str = None + interfaces: List[if_addr] = field(default_factory=list) + cmd: str = None + + +@dataclass(frozen=True, eq=True) +class Test_to_run(NetNS_info): + """holds all information for a netns""" + #name: str = None + #interfaces: List[if_addr] = field(default_factory=list) + #cmd: str = None + test_binary: str = None + cfgfile: str = None + + +@dataclass(frozen=True, eq=True) +class glob_data(): + install_prefix: str + titandir: str + workdir: str + testdir: str + + +@dataclass(frozen=True, eq=True) +class Topc: + global_data: glob_data + interfaces: List[NetNS_info] = field(default_factory=list) + test_to_run: Test_to_run = None + + +if conf == "nat_notest": + global_data = defaultdict(str) + global_data["install_prefix"] = os.path.expanduser("~/osmo/bscnat/install") + global_data["titandir"] = os.path.expanduser("~/osmo/titan") + global_data["workdir"] = os.getcwd()+'/workdir' + global_data["testdir"] = os.path.expanduser("~/osmo/bscnat/osmo-ttcn3-hacks/msc") + networkcfg = [ + NetNS_info("gbernd", + interfaces=[if_addr(ip4='172.0.0.9/16', bridge='br0')], + cmd='nc -l -u -k -p 4729'), # >/dev/null 2> netcat.stderr &'), + NetNS_info("stp-cn", + interfaces=[if_addr(ip4='172.0.0.122/16', bridge='br0')], + cmd='osmo-stp -c ./osmo-stp-cn.cfg'), + NetNS_info("stp-ran", + interfaces=[if_addr(ip4='172.0.0.123/16', bridge='br0')], + cmd='osmo-stp -c ./osmo-stp-ran.cfg'), + NetNS_info("nat", + interfaces=[if_addr(ip4='172.0.0.222/16', bridge='br0'), + if_addr(ip4='172.0.0.223/16', bridge='br0')], + cmd='osmo-bsc-nat -c ./osmo-bsc-nat.cfg'), + NetNS_info("hlr", + interfaces=[if_addr(ip4='172.0.0.5/16', bridge='br0')], + cmd=f"osmo-hlr -c ./osmo-hlr.cfg"), + NetNS_info("msc", + interfaces=[if_addr(ip4='172.0.0.33/16', bridge='br0')], + cmd='osmo-msc -c ./osmo-msc.cfg'), + NetNS_info("bsc-0", + interfaces=[if_addr(ip4='172.0.0.3/16', bridge='br0')], + cmd='osmo-bsc -c ./osmo-bsc-0.cfg'), + # nsc("bsc-1", + # interfaces=[if_addr(ip4='172.0.0.10/16', bridge='br0')], + # cmd='osmo-bsc -c ./osmo-bsc-1.cfg'), + # nsc("mgw4bsc1", + # interfaces=[if_addr(ip4='172.0.0.11/16', bridge='br0')], + # cmd='osmo-mgw -c osmo-mgw-for-bsc-1.cfg'), + # nsc("mgw4msc", + # interfaces=[if_addr(ip4='172.0.0.6/16', bridge='br0')], + # cmd='osmo-mgw -c osmo-mgw-for-msc.cfg'), + # nsc("mgw4bscnat", + # interfaces=[if_addr(ip4='172.0.0.12/16', bridge='br0')], + # cmd='osmo-mgw -c osmo-mgw-for-bsc-nat.cfg'), + ] + + +# automated mapping of bridgedict['brname'] = ["intf0", "intf1", "intfn"...] +bridgedict = defaultdict(list) + + +def dict_to_dc(dclass: dataclass, data: dict): + """ recursively builds dataclass from dict """ + if is_dataclass(dclass): + tmpset = {} + dfd = fields(dclass) + for f in dfd: + val = dict_to_dc(f.type, data[f.name]) + tmpset.update({f.name: val}) + return dclass(**tmpset) + else: + # FIXME fails for IPv4Interface -> ends up as str? + if isinstance(data, list): # list kinda thingy? + l = [] + arg = get_args(dclass)[0] # no mixed types in our list.. + for f in data: + to_append = dict_to_dc(arg, f) + l.append(to_append) + return l + + return data + + +def dc_to_json(arg: dict, fname: str): + with open(fname, "w") as outfile: + dump(arg, outfile, default=lambda o: o.__dict__, indent=4) + + +def json_to_dc(fname: str): + with open(fname, "r") as infile: + data = load(infile) + return dict_to_dc(Topc, data) + + +#dc_to_json(networkcfg, "foo.json") +networkcfg = json_to_dc("foo.json") +#assert loaded == networkcfg + + +# check naming, ns_ + name + num +for idx, entry in enumerate(networkcfg.interfaces): + d = entry.__dict__ + if len(d['name']) > 15-1-2: + print(f"config error! nettwork '{d['name']}' name too long, must be at most 15-1-2 chars!") + os._exit(0) + + +def run_cmds_helper(cmds, vars=None, ignore=False): + if isinstance(cmds, str): + cmds = {cmds} + for line in cmds: + if line == "": + continue + try: + torun = line.format(**vars) + except TypeError: + torun = line + try: + subprocess.check_call(torun, shell=True) + except subprocess.CalledProcessError: + if not ignore: + return + else: + print(f"failed cmd: {torun}") + raise + +# ldd should show full so path for standard clang install if compiled with san, so no env necessary. + + +def prep_env(): + env_vars = { + # 'CC': "clang-12 -fembed-bitcode -fuse-ld=lld -Wno-unused-command-line-argument", + 'ASAN_OPTIONS': 'detect_leaks=1:abort_on_error=1', + # 'ASANPATH': str(os.path.dirname(subprocess.check_output('clang-12 -print-file-name=libclang_rt.asan-x86_64.so', shell=True)), "utf-8"), + 'PYTHONPATH': "{install_prefix}/python:{install_prefix}/lib/python3.8/site-packages:{install_prefix}/lib64/python3.8/site-packages:{install_prefix}/lib/python3.8/dist-packages:{install_prefix}/lib64/python3.8/dist-packages:{install_prefix}/lib/python3/site-packages:{install_prefix}/lib64/python3/site-packages:{install_prefix}/lib/python3/dist-packages:{install_prefix}/lib64/python3/dist-packages", + 'PKG_CONFIG_PATH': "{install_prefix}/lib/pkgconfig:{install_prefix}/lib64/pkgconfig", + 'LIBRARY_PATH': "{install_prefix}/lib:{install_prefix}/lib64/", + 'LD_LIBRARY_PATH': "$ASANPATH:{install_prefix}/lib:{install_prefix}/lib64/:{titandir}/lib:{titandir}/lib/titan:{testdir}", + 'PATH': "{install_prefix}/bin:{titandir}/titan/:{titandir}/bin/", + 'TTCN3_DIR': "{titandir}", + 'TAG': '7b1600f8b13f95baf7ff52935a96a0ec', + 'SLEEP_BEFORE_RESPAWN': "1", + 'HISTFILE': f"{os.getcwd()+os.sep}.history" + # ENVLINE="env TAG=7b1600f8b13f95baf7ff52935a96a0ec ASAN_OPTIONS=$ASAN_OPTIONS PYTHONPATH=$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH LIBRARY_PATH=$LIBRARY_PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH PATH=$PATH" + + } + + # expand ~ paths + confdict = networkcfg.global_data.__dict__.copy() + for k, v in confdict.items(): + confdict[k] = os.path.expanduser(v) + + for k, v in env_vars.items(): + ok = os.environ.get(k) + ok = ':'+ok if ok is not None else "" + val = v or '' + try: + val = v.format(**confdict) + except: + val = v + # print(k+"="+val+ok) + os.environ[k] = val+ok + + +def netns_init(vars): + cmds = [ + # "ip netns add {nsname}", + + # magic path that makes persistent unshared namespaces usable by ip netns + "mkdir -p /run/netns", + "touch /run/netns/{nsname}", + "unshare --mount --uts --ipc --pid --fork --user --map-root-user --mount-proc --net=/run/netns/{nsname} echo created {nsname}...", + # nsenter --net=/var/run/netns/"${nsname}" ip link set lo up + "ip netns exec {nsname} ip link set lo up", + ] + run_cmds_helper(cmds, vars) + + +def netns_add(vars): + cmd = [ + "ip link add {localifname} type veth peer name {remoteifname}", + "ip link set {localifname} up", + "ip link set {remoteifname} netns {nsname}", + + "ip netns exec {nsname} ip link set {remoteifname} up", + "ip netns exec {nsname} ip addr add {ip4} dev {remoteifname}", + "ip netns exec {nsname} ip -6 addr add {ip6} dev {remoteifname} nodad" if vars['ip6'] is not None else "", + ] + run_cmds_helper(cmd, vars) + + +def prep_all_netns(): + + total_if_list = networkcfg.interfaces + [networkcfg.test_to_run] + # print(total_if_list) + + for idx, entry in enumerate(total_if_list): + d = entry.__dict__.copy() + d['nsname'] = "ns_{}".format(d['name']) # str(idx)) + netns_init(d) + + for idx2, ifn in enumerate(d['interfaces']): + d['localifname'] = "veth_{}{}".format(d['name'], str(idx2)) + d['remoteifname'] = "ceth_{}{}".format(d['name'], str(idx2)) + + # lazy + d['ip4'] = ifn.ip4 + d['ip6'] = ifn.ip6 + + if ifn.bridge is not None: + bridgedict[ifn.bridge].append(d['localifname']) + netns_add(d) + + for brname, ifnamelist in bridgedict.items(): + run_cmds_helper(f"ip link add {brname} type bridge") # stp_state 0 ageing_time 0 forward_delay 0") + run_cmds_helper(f"ip link set {brname} up") + for ifname in ifnamelist: + run_cmds_helper(f"ip link set {ifname} master {brname}") + run_cmds_helper(f"ip -all netns") + run_cmds_helper(f"ip link") + + +def prepare_ns_mounts(): + cmds = [ + # 'mount -t proc none /proc', # done by --mount-proc + 'mount -t sysfs none /sys', + + # check cat /proc/1/mountinfo for shared, priv, ... + # in host: + # 28 1 8:5 / / rw,relatime shared:1 - ext4 /dev/sda5 rw,errors=remount-ro + # 24 28 0:22 / /proc rw,nosuid,nodev,noexec,relatime shared:13 - proc proc rw + # in ns: + # 258 244 8:5 / / rw,relatime - ext4 /dev/sda5 rw,errors=remount-ro + # 403 258 0:22 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw + + + # unshare --mount-proc + # [pid 14178] mount("none", "/", NULL, MS_REC|MS_PRIVATE, NULL) = 0 + # mount mount --make-rprivate / + # [pid 14178] mount("none", "/proc", NULL, MS_REC|MS_PRIVATE, NULL) = 0 + # mount -t proc none /proc + # [pid 14178] mount("proc", "/proc", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL) = 0 + # mount -t proc proc /proc + + # xterm tries to chown /dev/pts/$n.. to uid:tty-group-id, which it gets from /etc/group, which fails + # no known fix yet + # mount -t devpts none /dev/pts -o rw,gid=0,newinstance,ptmxmode=0666,mode=0666,max=1024 + # mount --rbind /dev/pts/ptmx /dev/ptmx -o nosuid,noexec + + + # mount -t tmpfs --make-rshared tmpfs /tmp + # mount -t tmpfs tmpfs /home + + # ip tools needs this to work, we don't care about the host run + 'mount -t tmpfs tmpfs /run', + ] + + if os.path.exists("/tmp/.X11-unix"): + cmds2 = [ + # tmp breaks x11, x11 requires workaround by remounting into private dir, then binding back + f"mkdir -p {networkcfg.global_data.workdir}/.X11-unix", + f"mount --rbind /tmp/.X11-unix {networkcfg.global_data.workdir}/.X11-unix", + 'mount -t tmpfs none /tmp', + 'mkdir -p /tmp/.X11-unix', + f"mount --rbind {networkcfg.global_data.workdir}/.X11-unix /tmp/.X11-unix", + f"umount -l {networkcfg.global_data.workdir}/.X11-unix", + ] + else: + cmds2 = ['mount -t tmpfs none /tmp', ] + + run_cmds_helper(cmds+cmds2) + + +def fix_hostname(): + run_cmds_helper("hostname testrun") + + to_check = networkcfg.interfaces + [networkcfg.test_to_run] + addrlist = [] + for _, entry in enumerate(to_check): + d = entry.__dict__.copy() + try: + numifs = len(d['interfaces']) + for idx, val in enumerate(d['interfaces']): + idx = idx if numifs > 1 else '' + addrlist.append(f"{IPv4Interface(val.ip4).ip}\t{d['name']}{idx}") if val.ip4 else "" + addrlist.append(f"{IPv6Interface(val.ip6).ip}\t{d['name']}{idx}6") if val.ip6 else "" + except: + pass + + addrlines = '\n'.join(addrlist) + + my_hosts = f""" +127.0.0.1 localhost +127.1.2.3 testrun + +{addrlines} + +# The following lines are desirable for IPv6 capable hosts +::1 ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters +""" + with open("my_hosts", 'w') as file_: + file_.write(my_hosts) + + run_cmds_helper("mount my_hosts /etc/hosts --bind") + + wshosts = os.path.expanduser('~/.config/wireshark/hosts') + if not os.path.exists(wshosts): + print(f"{wshosts} does not exist, touching..") + Path(os.path.basename(wshosts)).mkdir(parents=True, exist_ok=True) + Path(wshosts).touch() + print(f"bind mounting {wshosts}..") + run_cmds_helper(f"mount my_hosts {wshosts} --bind") + print(my_hosts) + + +class silentsession: + def new_wnd(self, netnsidx, name, cmd): + self.new_wnd_nsname(f"ns_{name}", name, cmd) + + def new_wnd_nsname(self, netnsname, name, cmd): + run_cmds_helper(f"ip netns exec {netnsname} sh -c \"{cmd} > {name}.stdout\" C-m") + + def att(self, sessname=None): + pass + + def parse_and_run(self, nwconfig): + for idx, entry in enumerate(nwconfig.interfaces): + d = entry.__dict__.copy() + + d['cmd'] += f" >> {d['name']}.log 2>&1" + + # last cmd = not in background, but everything else must be in bg + # if entry == nwconfig.interfaces[-1]: + # pass + # else: + d['cmd'] += " &" + + # if "ttcn3_start" in d['cmd']: + # time.sleep(0.5) + self.new_wnd(idx, d['name'], d['cmd']) + if nwconfig.test_to_run: + d = nwconfig.test_to_run.__dict__.copy() + cfgfile = d['cfgfile'] + (f" {args.test_to_run}" if args.test_to_run is not None else "") + ' ' + tbinpath = nwconfig.global_data.testdir+os.path.sep+d['test_binary'] + ' ' + d['cmd'] += ' ' + tbinpath + cfgfile + d['cmd'] += f" >> {d['name']}.log 2>&1" + # time.sleep(0.5) + self.new_wnd(idx, d['name'], d['cmd']) + + +def get_pids_for_name(name): + try: + rv = subprocess.check_output(["pidof", name]) + except: + return [] + return map(int, rv.split()) + + +class byobusession(silentsession): + def __init__(self): + self.sessname = "ttcn3-bsc2" + run_cmds_helper("tmux list-panes && tmux list-sessions && tmux list-windows") + run_cmds_helper(f"byobu new-session -s {self.sessname} -d -n 'bernd'") + + def new_wnd_nsname(self, netnsname, name, cmd): + idxname = self.sessname # sess+':'+str(idx) if idx != 0 else sess + run_cmds_helper(f"tmux new-window -a -t {idxname} -n '{name}'", ignore=True) + run_cmds_helper(f"tmux send -t '{name}' 'ip netns exec {netnsname} sh -c \"{cmd}\"' C-m") + + def att(self, sessname=None): + sessname = sessname or self.sessname + run_cmds_helper(f"tmux attach -t {sessname}") + + def parse_and_run(self, nwconfig): + for idx, entry in enumerate(nwconfig.interfaces): + d = entry.__dict__.copy() + # print(d['cmd']) +# if "ttcn3_start" in d['cmd']: +# time.sleep(6)#0.2) + self.new_wnd(idx, d['name'], d['cmd']) + if nwconfig.test_to_run: + d = nwconfig.test_to_run.__dict__.copy() + + cfgfile = d['cfgfile'] + (f" {args.test_to_run}" if args.test_to_run is not None else "") + ' ' + tbinpath = nwconfig.global_data.testdir+os.path.sep+d['test_binary'] + ' ' + d['cmd'] += ' ' + tbinpath + cfgfile + # time.sleep(0.5) + self.new_wnd(idx, d['name'], d['cmd']) + + +def check_debian_userns(): + try: + with open('/proc/sys/kernel/unprivileged_userns_clone') as f: + rv = f.read() + rv = int(rv) if rv.isdigit() else rv + if rv != 0: + print("we're on debian and need 'sudo sysctl -w kernel.unprivileged_userns_clone=0' or a mainline/ubuntu kernel!") + os._exit(0) + except FileNotFoundError: + pass # not debian, we're fine + + +def unshare_myself(): + + # first call from outside + if not args.supersecretarg: + pid = os.fork() + if pid > 0: + print(f"parent {os.getpid()} waiting for child {pid}") + sys.stdout.flush() + os.waitpid(pid, 0) + os._exit(0) + else: # forked self call + print(f"child {os.getpid()} unsharing itself...") + arg = "unshare --mount --uts --ipc --net --pid --fork --user --map-root-user --mount-proc /bin/bash -c".split() + allargs = ' '.join(sys.argv[1:]) + arg += [f'{sys.executable} {__file__} --supersecretarg {allargs}'] + # print(arg) + sys.stdout.flush() + os.execvp("unshare", arg) + print("execvp failed?!") + os._exit(0) + + print(f"we are in our unprivileged namespace! euid:{os.geteuid()} egid:{os.getegid()}") + + if os.geteuid() != 0 or os.getegid() != 0: + print(f"...wat? we are not root, exiting!") + os._exit(0) + + sys.stdout.flush() + # os._exit(0) + + +def create_overlayfs(): + return + + # idea: + # mount --bind -m -n /* mnt/*" + # mount --move ? + + # overlayfs does not work due to + # https://github.com/sosy-lab/benchexec/issues/776 + # https://github.com/torvalds/linux/commit/427215d85e8d1476da1a86b8d67aceb485eb3631 "ovl: prevent private clone if bind mount is not allowed" + + run_cmds_helper("mount --make-rprivate /") + run_cmds_helper("mount --rbind / /") + run_cmds_helper('mount -t proc none /proc') + run_cmds_helper('mount -t sysfs none /sys') + m = "/tmp/mount-point" + run_cmds_helper(f"mkdir -p '{m}'") + run_cmds_helper(f"mount -t tmpfs tmpfs '{m}'") + run_cmds_helper(f"cd '{m}' && mkdir top merge work topdir") + run_cmds_helper(f"cd '{m}' && mount --rbind '{m}'/topdir / || ls topdir") + run_cmds_helper(f"cd '{m}' && mount -t overlay overlay -o lowerdir=/,upperdir={m}/top,workdir={m}/work {m}/merge && mount --rbind /dev ./merge/dev") + + oldpwd = os.getcwd() + os.chroot("merge") + + run_cmds_helper('mount -t proc none /proc') + run_cmds_helper('mount -t sysfs none /sys') + + run_cmds_helper("touch /foobernd") + os.chdir(oldpwd) + os.setgid(0) + os.setuid(0) + + run_cmds_helper("touch foobart; id; ls -al /; ls -al /home/peta/osmo") + run_cmds_helper("touch ~/fooboing") + run_cmds_helper("zsh") + + # run_cmds_helper("id; ls -al .; touch foo") + os._exit(0) + + +def kill_tcpdump(): + pids = get_pids_for_name("tcpdump") + for pid in pids: + try: + os.kill(pid, signal.SIGINT) + except ProcessLookupError: + print(f"already dead: {pid}?") + continue + except OSError: + print(f"fuck: {pid}?") + continue + try: + os.waitpid(pid, os.WSTOPPED) + except ChildProcessError: + pass + + +def exit_cleanup(olddir, test_artifact_storage_location, signum, stack): + + kill_tcpdump() + + def cpy2pass(src, dest): + """does not choke on sockets...""" + try: + shutil.copy2(src, dest) + except: + pass + + print(f"data will end up in {test_artifact_storage_location}") + try: + shutil.copytree('/tmp', test_artifact_storage_location, copy_function=cpy2pass, dirs_exist_ok=True, symlinks=True, ignore_dangling_symlinks=True) + except shutil.Error as e: + pass + + sys.stdout.flush() + sys.stderr.flush() + + +def spawn_num_tests(set_of_tests, how_many, oldenv): + pids_to_wait_For = set() + while how_many: + how_many -= 1 + try: + l = set_of_tests.pop() + except KeyError: + continue + + if l.endswith(".control"): # don't run everything.. duh. + continue + + lcmd = f'{sys.executable} {__file__} --test-to-run {l}' + print(lcmd) + fnull = open(os.devnull, 'w') # pipe will fill up and stall, use nothing instead + process = subprocess.Popen(lcmd, env=oldenv, shell=True, stdout=fnull, stderr=fnull, close_fds=True) + #my_pid, err = process.communicate() + # print(err) + pids_to_wait_For.add(process.pid) + return pids_to_wait_For + + +def run_all_tests(): + + oldenv = os.environ.copy() + prep_env() + + cmd = networkcfg.global_data.testdir+os.path.sep+networkcfg.test_to_run.test_binary+" -l" + + # os.environ['LD_LIBRARY_PATH'] = os.environ.get('LD_LIBRARY_PATH')+":"+networkcfg.global_data.testdir # ttcn testdir must be in path + lines = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True) # cmd, shell=True, check=True, capture_output=True, text=True) + total_tests_to_run = set() + total_tests_to_run.update(lines.stdout.split()) + +# if "MSC_Tests" in cmd: +# # remove all iu tests +# filter_to_remove = [] +# filterlist = ["TC_iu_"]#, "TC_multi_lu_and_"] +# for i in total_tests_to_run: +# t = [i for y in filterlist if y in i] +# filter_to_remove += t if not None else [] +# +# #print(f"tests to remove: {filter_to_remove}") +# total_tests_to_run.difference_update(filter_to_remove) + + print(f"we have {len(total_tests_to_run)} tests to run, at most {args.parallel} at the same time...") + + num_parallel = args.parallel # 16 = ~ 3GB ram total + pids_to_wait_For = spawn_num_tests(total_tests_to_run, num_parallel, oldenv) + print(pids_to_wait_For) + + print("%s Waiting for %d processes..." % (datetime.now().strftime('%Y-%m-%d_%H-%M-%S'), len(pids_to_wait_For))) + while pids_to_wait_For: + try: + pid, status = os.wait() + except ChildProcessError: + print("looks like we ran out of children?") + os._exit(0) + if pid in pids_to_wait_For: + pids_to_wait_For.remove(pid) + pids_left = num_parallel-len(pids_to_wait_For) + to_spawn = max(min(pids_left, num_parallel), 0) + pids_to_wait_For.update(spawn_num_tests(total_tests_to_run, to_spawn, oldenv)) + print("%s currently waiting for %d processes...%d tests left" % (datetime.now().strftime('%Y-%m-%d_%H-%M-%S'), len(pids_to_wait_For), len(total_tests_to_run))) + + os._exit(0) + + +if __name__ == "__main__": + + olddir = os.getcwd() + + # do not pollute host shell history + os.environ['HISTFILE'] = f"{os.getcwd()+os.sep}.history" + check_debian_userns() + + if args.run_all_tests: + run_all_tests() + + unshare_myself() + # if we are here, we're in our ns + os.environ['BYOBU_CONFIG_DIR'] = olddir+"/.byobu" + + run_cmds_helper(f"export HOME={olddir}") + suffix = f"_{args.test_to_run}" if args.test_to_run is not None else "" + test_artifact_storage_location = tempfile.mkdtemp(dir=olddir, suffix=suffix, prefix=datetime.now().strftime('%Y-%m-%d_%H-%M-%S')) + # if sys.stdout.isatty(): + # pass + # else: + # stdoutname = args.test_to_run or "" + # sys.stdout = open(stdoutname+"_"+os.path.basename(test_artifact_storage_location), 'w') + # #sys.stderr = sys.stdout + + create_overlayfs() + prepare_ns_mounts() + fix_hostname() + prep_env() + prep_all_netns() + + run_cmds_helper("mkdir -p /tmp/unix /tmp/trash") + # put stuff in tmp + run_cmds_helper("cp *cfg *default *sh /tmp/trash") + os.chdir("/tmp/trash") + + for brname, _ in bridgedict.items(): + run_cmds_helper(f"tcpdump -i {brname} -w {brname}.pcapng >> dump.log 2>&1 &") + time.sleep(0.5) + + # salvage stuck tests on exit to ensure we keep the trash and can figure out what failed + signal.signal(signal.SIGINT, partial(exit_cleanup, olddir, test_artifact_storage_location)) + signal.signal(signal.SIGTERM, partial(exit_cleanup, olddir, test_artifact_storage_location)) + + s = byobusession() if args.gui == True else silentsession() + s.parse_and_run(networkcfg) + # s.new_wind(0, "stp", 'osmo-stp -c ./osmo-stp.cfg') + # s.new_wind(1, "bsc", 'osmo-bsc -c ./osmo-bsc.cfg') + s.att() + + if args.ws is True: + print("running ws..") + kill_tcpdump() + subprocess.check_call("wireshark br0.pcapng", shell=True) + + # self kill to clean up either way + os.kill(os.getpid(), signal.SIGINT) diff --git a/namespaces/stats.sh b/namespaces/stats.sh new file mode 100755 index 0000000..9e89788 --- /dev/null +++ b/namespaces/stats.sh @@ -0,0 +1,15 @@ +#!/bin/bash +s=`grep -A1 failures */*/*xml*log | grep "failures='0'" | wc -l` +f=`grep -A1 failures */*/*xml*log | grep "failures='1'" | wc -l` +echo $s fail=0=success +echo $f fail=1=FAIL + +#sort part after reason: +grep "Final verdict" */*/*log | sort -k10 | while read -r line ; do + if $(echo $line | cut -c 29- | sort | grep -q "fail rea") ; then + #dirn=$(dirname echo $line | grep -o ".*log") + echo $line + #echo $(grep Unimplemented $dirn/\*) + fi +done + |