Sitelet https://github.com/Netis/cloud-probe/pull/287
Skip to content

fix(cpworker): walk QinQ tag stacks in custom req_pattern direction detection - #287

Open
timmy21 wants to merge 1 commit into
0.9.xfrom
fix/270-req-pattern-qinq
Open

timmy21 wants to merge 1 commit into
0.9.xfrom
fix/270-req-pattern-qinq

Conversation

@timmy21

@timmy21 timmy21 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Problem

With a custom req_pattern, req_pattern_judge_pkt_direction() parses the IP/port of each frame. The parser followed only 0x8100 tags. A frame whose tag stack contains an 802.1ad (0x88a8) or 0x9100/0x9200 tag never reached the IP layer, was judged PKT_DIR_UNKNOWN, and every output dropped it as a direction drop. With a custom pattern, all QinQ traffic on the interface was lost.

parse_packet (packet_split.c) and output_zmq.c already accept all four TPIDs.

Changes

  • vlan.h: add is_vlan_ethertype() for the four tag TPIDs.
  • req_pattern.c: extract_ipport_from_ether_layer skips the whole tag stack in a loop, bounded by caplen, then dispatches to IPv4/IPv6. extract_ipport_from_vlan_layer is removed: it recursed once per tag, so its depth was bounded only by caplen.
  • output_zmq.c: use is_vlan_ethertype() in the existing tag walk (no behaviour change).
  • The VXLAN inner frame goes through the same Ethernet parser, so QinQ inside VXLAN is also fixed.

packet_split.c keeps its own four-way check for now.

Tests

New tests/unit/req_pattern.c (14 tests). Before the fix, the 7 QinQ cases failed and the controls passed.

  • Request/reply direction through: untagged, 802.1Q, 802.1Q×2, 0x88a8+0x8100, 0x9100+0x8100, 0x9200+0x8100, single 0x88a8, a 4-tag mixed stack
  • QinQ + IPv6; QinQ inside VXLAN
  • Tag stack or IP header cut by caplen → unknown; a frame made only of tags → unknown

Unit tests 9/9 and the integration suite pass (Ubuntu 24.04).

Fixes #270

…etection

The custom req_pattern parser only followed 0x8100 tags, so frames with an
802.1ad (0x88a8) or 0x9100/0x9200 outer tag never reached the IP layer, were
judged PKT_DIR_UNKNOWN and dropped by every output.

Skip the whole tag stack in a loop, as parse_packet and output_zmq already
do, and drop the per-tag recursion, whose depth was bounded only by caplen.
Add is_vlan_ethertype() to vlan.h and use it in output_zmq.c as well.

Fixes #270
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.

cpworker: req_pattern ignores 802.1ad (QinQ) tags, so QinQ frames are judged unknown and dropped

1 participant