Skip to content

test(cpworker): check gre, vxlan and zmq wire bytes against the wire-format docs - #315

Merged
timmy21 merged 1 commit into
0.9.xfrom
fix/243-wire-format-tests
Oct 13, 2026
Merged

timmy21 merged 1 commit into
0.9.xfrom
fix/243-wire-format-tests

Conversation

@timmy21

@timmy21 timmy21 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Problem

The GRE, VXLAN and ZMQ integration cases (testdata/cases/*/verify.json) only count packets. A wrong GRE protocol or key, a wrong VXLAN tag or check byte, or a wrong ZMQ batch header, record length, packet header or MPLS-like tag still passes (#243 item 2). Only the heartbeat record was byte-checked.

Change

  • New cpworker/tests/integration/wire_format_test.go (TestWireFormat). It builds the input frames, runs cpworker over them and compares the bytes on the wire with bytes taken from the specs, not computed by the code under test:
    • gre: flags 0x2000 and protocol 0x6558 (RFC 2784/2890); key direction << 28 | service_tag for configured service tags; inner frame unchanged.
    • vxlan: every header row of docs/VXLAN-WIRE-FORMAT.md §9 (vni1 with each direction, 0xFFFFFF, 0x123456; vni2 with each direction); inner frame unchanged; capture-time trailer (§6).
    • zmq: batch header, record framing, packet header and frame of docs/ZMQ-WIRE-FORMAT.md §3–§6, including a VLAN-tagged frame and a frame whose caplen is below its wire length.
    • zmq_example: the 142-byte message of docs/ZMQ-WIRE-FORMAT.md §10, byte for byte.
  • No product code changes.

Not changed:

Tests

The new tests pass on the current code. Each of these mutations fails only its own subtest:

  • GRE protocol 0x6559 → gre
  • GRE direction shifted by 27 → gre
  • VXLAN check-byte seed + 1 → vxlan
  • ZMQ tag direction swapped → zmq, zmq_example
  • ZMQ batch version 3 → zmq, zmq_example
  • ZMQ pkt_hdr.len from caplen → zmq (the caplen < len record)

Suites run on Ubuntu 24.04:

  • Unit tests: 12/12 ctest.
  • Integration: run_test.sh all passes (TestWireFormat 8 s).

Refs #243

…format docs

The GRE, VXLAN and ZMQ integration cases only count packets, so a wrong
header field, tag, check byte or record layout still passes (#243 item 2).

TestWireFormat builds its input frames, runs cpworker over them and
compares what goes on the wire with bytes taken from the documents:

- gre: flags 0x2000 and protocol 0x6558 (RFC 2784/2890), the key as
  direction << 28 | service_tag for configured service tags, inner frame
  unchanged. The key without a service_tag is left to #296.
- vxlan: every header row of VXLAN-WIRE-FORMAT.md section 9 (vni1 with
  each direction, 0xFFFFFF, 0x123456; vni2), inner frame unchanged, and
  the capture-time trailer of section 6.
- zmq: batch header, record framing, packet header and frame of
  ZMQ-WIRE-FORMAT.md sections 3-6, with a VLAN-tagged frame and one whose
  caplen is below len; and the 142-byte message of section 10.

Each of these mutations fails only its own subtest: GRE protocol 0x6559,
GRE direction shift 27, VXLAN check seed + 1, swapped ZMQ tag direction,
ZMQ batch version 3, ZMQ pkt_hdr.len from caplen.

Refs #243
@timmy21
timmy21 merged commit c4e1a8e into 0.9.x Oct 13, 2026
1 check passed
@timmy21
timmy21 deleted the fix/243-wire-format-tests branch October 13, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant