summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEyal Soha <eyalsoha@google.com>2020-04-11 06:45:15 -0700
committergVisor bot <gvisor-bot@google.com>2020-04-11 06:46:27 -0700
commit20203494680f869669ab5318b36e9470ad4b3e7b (patch)
tree0fd977f22a31325f7421d9cc046b82b90d6213d6
parentdaf3322498b698518a3c8545ad05f790deb3848c (diff)
Improve error messages when parsing headers.
Tested: Looked at output of failing tests. PiperOrigin-RevId: 306031407
-rw-r--r--test/packetimpact/testbench/connections.go2
-rw-r--r--test/packetimpact/testbench/layers.go8
2 files changed, 5 insertions, 5 deletions
diff --git a/test/packetimpact/testbench/connections.go b/test/packetimpact/testbench/connections.go
index ed8689fd3..b11a534ac 100644
--- a/test/packetimpact/testbench/connections.go
+++ b/test/packetimpact/testbench/connections.go
@@ -213,7 +213,7 @@ func (conn *TCPIPv4) RecvFrame(timeout time.Duration) Layers {
}
layers, err := ParseEther(b)
if err != nil {
- conn.t.Logf("can't parse frame: %s", err)
+ conn.t.Logf("debug: can't parse frame, ignoring: %s", err)
continue // Ignore packets that can't be parsed.
}
if !conn.incoming.match(layers) {
diff --git a/test/packetimpact/testbench/layers.go b/test/packetimpact/testbench/layers.go
index 093a46e23..ff800377e 100644
--- a/test/packetimpact/testbench/layers.go
+++ b/test/packetimpact/testbench/layers.go
@@ -153,7 +153,7 @@ func (l *Ether) toBytes() ([]byte, error) {
fields.Type = header.IPv4ProtocolNumber
default:
// TODO(b/150301488): Support more protocols, like IPv6.
- return nil, fmt.Errorf("can't deduce the ethernet header's next protocol: %d", n)
+ return nil, fmt.Errorf("ethernet header's next layer is unrecognized: %#v", n)
}
}
h.Encode(fields)
@@ -191,7 +191,7 @@ func ParseEther(b []byte) (Layers, error) {
return append(layers, moreLayers...), nil
default:
// TODO(b/150301488): Support more protocols, like IPv6.
- return nil, fmt.Errorf("can't deduce the ethernet header's next protocol: %#v", b)
+ return nil, fmt.Errorf("ethernet header's type field is unrecognized: %#04x", h.Type())
}
}
@@ -274,7 +274,7 @@ func (l *IPv4) toBytes() ([]byte, error) {
fields.Protocol = uint8(header.UDPProtocolNumber)
default:
// TODO(b/150301488): Support more protocols as needed.
- return nil, fmt.Errorf("can't deduce the ip header's next protocol: %#v", n)
+ return nil, fmt.Errorf("ipv4 header's next layer is unrecognized: %#v", n)
}
}
if l.SrcAddr != nil {
@@ -344,7 +344,7 @@ func ParseIPv4(b []byte) (Layers, error) {
}
return append(layers, moreLayers...), nil
}
- return nil, fmt.Errorf("can't deduce the ethernet header's next protocol: %d", h.Protocol())
+ return nil, fmt.Errorf("ipv4 header's protocol field is unrecognized: %#02x", h.Protocol())
}
func (l *IPv4) match(other Layer) bool {