chiark / gitweb /
stest: Check that received packet is as expected
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 24 Nov 2019 00:59:39 +0000 (00:59 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 30 Dec 2019 13:15:49 +0000 (13:15 +0000)
It turns out that if secnet decides the link to the peer is too
broken, it loops outbound packets back to its host.  Normally this is
not obvious, because the host naturally drops such packets.

But in stest we weren't actually looking at the incoming packets at
all, so we would treat this as success!

So, instead, match the start of the packet, including the source and
destination addresses and the icmp type.  (This crude match will fail
if the reply contains any IP options, but the ping comes from the peer
secnet so it won't have.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
stest/common.tcl

index 566757c75d4cd87b077fe76b8a4879b96545cf11..7891e1d4a4901ce696242b550c92a2767b1a0eb9 100644 (file)
@@ -180,8 +180,15 @@ proc netlink-got-packet {location site data} {
     if {![hbytes length $data]} return 
     switch -exact $site {
        inside {
-           puts OK
-           finish 0
+           switch -glob $data {
+               45000054ed9d4000fe0166d9ac12e802ac12e80900* {
+                   puts "OK $data"
+                   finish 0
+               }
+               * {
+                   error "unexpected $site $data"
+               }
+           }
        }
        outside {
            error "inside rx'd!"