Skip to content

Commit 6dd88c0

Browse files
committed
clusterer_controller: netns T34 a JOIN_REQ recorded and sent again from another address
A member's JOIN_REQ is recorded as it rejoins and sent again from a socket on the bridge's address that also listens: the master must not admit the node again, nothing may come back to that address, and the node keeps its node_id. Before the two changes the master admitted it again and sent its grant, assignments and list to the bridge.
1 parent 9b035f0 commit 6dd88c0

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

‎modules/clusterer_controller/test/netns_tests.sh‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,42 @@ M0=$(wc -l < $R/n$MN.log)
837837
python3 "$HERE/wire_tap.py" inject $R/t33s.json 10.74.0.254 >/dev/null; sleep 4
838838
check "its old GOODBYE, sent from another address, removed nothing" $(! since $MN $M0 | grep -aq "GOODBYE from $(ip4 $x)" && members $MN 741 | tr ' ' '\n' | grep -q "^$(ip4 $x):[a-z]*:[1-9]" && echo 1 || echo 0) "$(since $MN $M0 | grep -a "GOODBYE from" | tail -1 | cut -c1-120) / $(members $MN 741)"
839839

840+
echo "=== T34 a JOIN_REQ recorded and sent again from another address ==="
841+
# Bootstrap packets have no replay window. Record a member's JOIN_REQ as it
842+
# rejoins, then send it again from a socket on the bridge's address that also
843+
# listens: the master must not admit the node a second time, and must send
844+
# nothing to that address - its replies go to the joiner itself.
845+
MIP=$(members 1 741 | tr ' ' '\n' | grep ':master:' | cut -d: -f1); MN=${MIP##*.}; MN=${MN#1}
846+
for x in 4 3 2 1; do [ $x != $MN ] && break; done
847+
XID=$(nid $MN $x)
848+
stop_graceful $x; rm -f $R/n$x.pid
849+
tap $x 4 $R/t34.json >/dev/null & TP=$!
850+
sleep 0.3; start $x $NEW; wait $TP; sleep 6
851+
python3 -c '
852+
import json,sys
853+
p=[d for d in json.load(open(sys.argv[1])) if d["data"][2:4]=="01"]
854+
json.dump(p,open(sys.argv[2],"w")); print(len(p))' $R/t34.json $R/t34b.json > $R/t34b.n
855+
XID=$(nid $MN $x)
856+
check "n$x rejoined, its JOIN_REQ recorded ($(cat $R/t34b.n) bootstrap datagrams)" $([ -n "$XID" ] && [ "$(cat $R/t34b.n)" -gt 0 ] && echo 1 || echo 0) "id '$XID'"
857+
M0=$(wc -l < $R/n$MN.log)
858+
GOT=$(python3 - $R/t34b.json <<'PY'
859+
import json, socket, sys, time
860+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
861+
s.bind(("10.74.0.254", 0)); s.settimeout(0.2)
862+
s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton("10.74.0.254"))
863+
for d in json.load(open(sys.argv[1])):
864+
s.sendto(bytes.fromhex(d["data"]), (d["dst"], d["dport"])); time.sleep(0.05)
865+
n, end = 0, time.time() + 3
866+
while time.time() < end:
867+
try: s.recv(65535); n += 1
868+
except socket.timeout: pass
869+
print(n)
870+
PY
871+
)
872+
check "the master did not admit n$x again" $(! since $MN $M0 | grep -aq "JOIN_REQ from $(ip4 $x)" && echo 1 || echo 0) "$(since $MN $M0 | grep -ac "JOIN_REQ from $(ip4 $x)") JOIN_REQs processed"
873+
check "nothing was sent to the address the record came from" $([ "${GOT:-1}" = 0 ] && echo 1 || echo 0) "$GOT datagrams"
874+
check "n$x kept its node_id ($XID)" $([ "$(nid $MN $x)" = "$XID" ] && echo 1 || echo 0) "$(nid $MN $x)"
875+
840876
echo "=== replays after T12: none ==="
841877
RPN=0; for i in 1 2 3 4; do eval m=\$RP$i; RPN=$((RPN + $(since $i $m | grep -ac "already accepted, dropping\|older than the replay window, dropping"))); done
842878
check "no control packet refused as a replay since T12 (re-keys keep the sequence)" $([ $RPN = 0 ] && echo 1 || echo 0) "$RPN"

0 commit comments

Comments
 (0)