Skip to content

Commit

Permalink
Merge pull request #19 from drozdziak1/15-runtime-price
Browse files Browse the repository at this point in the history
Fix runtime price-setting
  • Loading branch information
drozdziak1 authored Oct 26, 2018
2 parents da0f6b6 + 6bc78ec commit fae24ac
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
20 changes: 10 additions & 10 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tests/multihop-compat.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/multihop-gdb-rtt.sh
Original file line number Diff line number Diff line change
@@ -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}

Expand Down
4 changes: 3 additions & 1 deletion tests/multihop-gdb.sh
Original file line number Diff line number Diff line change
@@ -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}

Expand Down
10 changes: 9 additions & 1 deletion tests/multihop-smoketest.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"

0 comments on commit fae24ac

Please sign in to comment.