diff --git a/configuration.c b/configuration.c index 3f6449ff..8a246a51 100644 --- a/configuration.c +++ b/configuration.c @@ -172,21 +172,21 @@ getint(int c, int *int_r, gnc_t gnc, void *closure) } static unsigned int -getuint(int c, unsigned int *int_r, gnc_t gnc, void *closure) +getuint32_t(int c, uint32_t *retval, gnc_t gnc, void *closure) { - char *t, *end; - unsigned int i; + char *t = NULL, *end = NULL; + unsigned long i; c = getword(c, &t, gnc, closure); if(c < -1) return c; errno = 0; i = strtoul(t, &end, 0); - if(*end != '\0' || errno) { + if(!t || t[0] == '-' || *end != '\0' || errno || i > (unsigned long)UINT32_MAX) { free(t); return -2; } free(t); - *int_r = i; + *retval = i; return c; } @@ -801,7 +801,7 @@ parse_option(int c, gnc_t gnc, void *closure, char *token) strcmp(token, "diversity") != 0 && strcmp(token, "diversity-factor") != 0 && strcmp(token, "smoothing-half-life") != 0 && - strcmp(token, "price") != 0) + strcmp(token, "fee") != 0) goto error; } @@ -928,16 +928,16 @@ parse_option(int c, gnc_t gnc, void *closure, char *token) goto error; diversity_factor = f; } else if(strcmp(token, "fee") == 0) { - unsigned int f = 0; - c = getuint(c, &f, gnc, closure); + uint32_t f = 0; + c = getuint32_t(c, &f, gnc, closure); if(c < -1) goto error; fee = f; check_xroutes(1); } else if (strcmp(token, "quality-multiplier") == 0) { - unsigned int f = 0; - c = getuint(c, &f, gnc, closure); + uint32_t f = 0; + c = getuint32_t(c, &f, gnc, closure); if(c < -1 || f > UINT16_MAX) goto error; quality_multiplier = f; diff --git a/tests/multihop-compat.sh b/tests/multihop-compat.sh index b961b1a9..8caf061e 100755 --- a/tests/multihop-compat.sh +++ b/tests/multihop-compat.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -eux +cd $(dirname $0) + # This script will download any two babel revisions, build them, set a netlab # mesh up and then check if all nodes can see each other. A is supposed to be a # newer revision while B is what we're trying to stay compatible with diff --git a/tests/multihop-gdb-rtt.sh b/tests/multihop-gdb-rtt.sh index 96d6ad42..8aa7b3f7 100755 --- a/tests/multihop-gdb-rtt.sh +++ b/tests/multihop-gdb-rtt.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash set -eux +cd $(dirname $0) + BABELPATH=${BABELPATH:=../babeld} -CONFIGPORT=${CONFIGPORT:=6126} +CONFIGPORT=${CONFIGPORT:=6872} GDBPATH=${GDBPATH:=gdb} LABPATH=${LABPATH:=./network-lab.sh} diff --git a/tests/multihop-gdb.sh b/tests/multihop-gdb.sh index 75539de8..ff9da8cd 100755 --- a/tests/multihop-gdb.sh +++ b/tests/multihop-gdb.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash set -eux +cd $(dirname $0) + BABELPATH=${BABELPATH:=../babeld} -CONFIGPORT=${CONFIGPORT:=6126} +CONFIGPORT=${CONFIGPORT:=6872} GDBPATH=${GDBPATH:=gdb} LABPATH=${LABPATH:=./network-lab.sh} diff --git a/tests/multihop-smoketest.sh b/tests/multihop-smoketest.sh index 46d2fa98..b10bf33d 100755 --- a/tests/multihop-smoketest.sh +++ b/tests/multihop-smoketest.sh @@ -1,9 +1,12 @@ #!/usr/bin/env bash set -eux +cd $(dirname $0) + BABELPATH=${BABELPATH:=../babeld} -LABPATH=${LABPATH:=./network-lab.sh} +CONFIGPORT=${CONFIGPORT:=6872} CONVERGENCE_DELAY_SEC=${CONVERGENCE_DELAY_SEC:=5} +LABPATH=${LABPATH:=./network-lab.sh} # This is a basic integration test for the Althea fork of Babeld, it focuses on # validating that instances actually come up and communicate @@ -177,6 +180,11 @@ pass_reachable "netlab-4" "1.0.0.2" pass_string "1.0.0.3/32 from.*price 0 fee 7.*via veth-4-3.*nexthop 1.0.0.3" "babeld-n4.log" pass_reachable "netlab-4" "1.0.0.3" +if [[ -v DEBUG ]]; then + echo "Debug mode is active, press Enter for cleanup and exit" + read -n 1 +fi + cleanup echo "$0 PASS"