Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ubridge for openSUSE:Factory checked in at 2026-12-01 16:58:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ubridge (Old) and /work/SRC/openSUSE:Factory/.ubridge.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ubridge" Tue Dec 1 16:58:49 2026 rev:12 rq:1401714 version:1.3.3 Changes: -------- --- /work/SRC/openSUSE:Factory/ubridge/ubridge.changes 2026-11-21 12:34:11.790939344 +0100 +++ /work/SRC/openSUSE:Factory/.ubridge.new.1340718/ubridge.changes 2026-12-01 17:01:04.200365321 +0100 @@ -1,0 +2,7 @@ +Mon Nov 30 14:38:54 UTC 2026 - Martin Hauke <[email protected]> + +- Update to version 1.3.3 + * fix(capture,marker): re-insert VLAN tags of bridge-forwarded + frames (PACKET_AUXDATA). + +------------------------------------------------------------------- Old: ---- ubridge-1.3.2.tar.gz New: ---- ubridge-1.3.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ubridge.spec ++++++ --- /var/tmp/diff_new_pack.METXS1/_old 2026-12-01 17:01:05.084402326 +0100 +++ /var/tmp/diff_new_pack.METXS1/_new 2026-12-01 17:01:05.085402368 +0100 @@ -17,7 +17,7 @@ Name: ubridge -Version: 1.3.2 +Version: 1.3.3 Release: 0 Summary: Bridging between UDP tunnels, Ethernet and TAP interfaces License: GPL-3.0-only ++++++ ubridge-1.3.2.tar.gz -> ubridge-1.3.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/.github/release.yml new/ubridge-1.3.3/.github/release.yml --- old/ubridge-1.3.2/.github/release.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/ubridge-1.3.3/.github/release.yml 2026-11-30 11:57:30.000000000 +0100 @@ -0,0 +1,39 @@ +changelog: + exclude: + labels: + - ignore-for-release + - test + - chore + - build + - ci + - style + authors: + - dependabot + categories: + - title: Breaking Changes + labels: + - breaking-change + - title: New Features + labels: + - enhancement + - feature + - feat + - title: Bug Fixes + labels: + - bug + - bugfix + - fix + - title: Performance + labels: + - performance + - perf + - title: Refactoring♻️ + labels: + - refactor + - title: Documentation + labels: + - documentation + - docs + - title: Other Changes + labels: + - "*" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/.github/workflows/add-new-issues-to-project.yml new/ubridge-1.3.3/.github/workflows/add-new-issues-to-project.yml --- old/ubridge-1.3.2/.github/workflows/add-new-issues-to-project.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/ubridge-1.3.3/.github/workflows/add-new-issues-to-project.yml 2026-11-30 11:57:30.000000000 +0100 @@ -0,0 +1,16 @@ +name: Add new issues to GNS3 project + +on: + issues: + types: + - opened + +jobs: + add-to-project: + name: Add issue to project + runs-on: ubuntu-latest + steps: + - uses: actions/[email protected] + with: + project-url: https://github.com/orgs/GNS3/projects/3 + github-token: ${{ secrets.ADD_NEW_ISSUES_TO_PROJECT }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/.github/workflows/pr-labeler.yml new/ubridge-1.3.3/.github/workflows/pr-labeler.yml --- old/ubridge-1.3.2/.github/workflows/pr-labeler.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/ubridge-1.3.3/.github/workflows/pr-labeler.yml 2026-11-30 11:57:30.000000000 +0100 @@ -0,0 +1,51 @@ +name: Lint and Label PR + +on: + pull_request_target: + types: [opened, edited, synchronize, reopened] + +permissions: + pull-requests: write + +jobs: + lint-and-label: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v9 + with: + script: | + const title = context.payload.pull_request.title + const allowedTypes = ['fix', 'feat', 'build', 'chore', 'ci', 'docs', 'style', 'refactor', 'perf', 'test', 'revert']; + + // Match: type(optional-scope)!: description + const match = title.match(/^([a-zA-Z]+)(?:\([^)]+\))?(!)?:\s.+/); + + if (!match || !allowedTypes.includes(match[1].toLowerCase())) { + core.setFailed( + `PR title "${title}" must follow Conventional Commits (e.g., "feat: add login" or "fix(api): handle timeout"). Allowed types: ${allowedTypes.join(', ')}` + ); + return; + } + + const type = match[1].toLowerCase(); + const isBreaking = Boolean(match[2]); + const labelsToAdd = []; + + if (isBreaking) labelsToAdd.push('breaking-change'); + + const typeMap = { + feat: 'feature', + fix: 'bugfix', + docs: 'documentation', + perf: 'performance', + refactor: 'refactor' + }; + + labelsToAdd.push(typeMap[type] || 'chore'); + + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + labels: labelsToAdd + }); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/src/hypervisor_capture.c new/ubridge-1.3.3/src/hypervisor_capture.c --- old/ubridge-1.3.2/src/hypervisor_capture.c 2026-10-31 15:20:39.000000000 +0100 +++ new/ubridge-1.3.3/src/hypervisor_capture.c 2026-11-30 11:57:30.000000000 +0100 @@ -85,10 +85,16 @@ { kernel_capture_t *kc = (kernel_capture_t *)arg; unsigned char buf[65535]; + /* Room for both the timestamp and the PACKET_AUXDATA cmsgs: the kernel + * stops at the first cmsg that does not fit (MSG_CTRUNC), dropping + * everything behind it. */ union { struct cmsghdr cmsg; - char buf[CMSG_SPACE(sizeof(struct timespec))]; + char buf[CMSG_SPACE(sizeof(struct timespec)) + + CMSG_SPACE(sizeof(struct tpacket_auxdata))]; } cmsg_buf; + /* VLAN tags are only re-inserted into Ethernet-framed captures. */ + int ethernet = (pcap_datalink(kc->cap->fd) == DLT_EN10MB); while (!kc->stop) { struct timeval ts, *tsp = NULL; /* kernel rx stamp, when supplied */ @@ -114,7 +120,21 @@ /* The kernel stamped the frame when it entered the socket * (CLOCK_REALTIME) — keep that instead of "when this thread got * scheduled to read it". Absent cmsg (no SO_TIMESTAMPNS support) - * leaves tsp NULL and the writer stamps at read time. */ + * leaves tsp NULL and the writer stamps at read time. + * + * With vlan_filtering, the 802.1Q tag of bridge-forwarded frames + * travels as skb metadata at both AF_PACKET tap points + * (dev_queue_xmit_nit on TX, the early taps in + * __netif_receive_skb_core on RX): the frame data itself is + * headerless. PACKET_AUXDATA reports that tag out of band — and on + * a SOCK_RAW socket TP_STATUS_VLAN_VALID is only set when the skb + * carries the tag as metadata, so re-insertion can never duplicate + * a tag already present in the frame data. QinQ: the bridge only + * manages its own (outer) tag — an 802.1Q tag still present in the + * data is the inner, customer tag, and the metadata one goes back + * in front of it. Write the 4-byte header back after the MAC + * addresses so the pcap shows what tcpdump/Wireshark show; libpcap + * does the same with its Linux backend. */ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_TIMESTAMPNS && cmsg->cmsg_len >= CMSG_LEN(sizeof(struct timespec))) { @@ -123,7 +143,23 @@ ts.tv_sec = kts.tv_sec; ts.tv_usec = kts.tv_nsec / 1000; tsp = &ts; - break; + } else if (ethernet + && cmsg->cmsg_level == SOL_PACKET && cmsg->cmsg_type == PACKET_AUXDATA + && cmsg->cmsg_len >= CMSG_LEN(sizeof(struct tpacket_auxdata))) { + struct tpacket_auxdata aux; + uint16_t half; + + memcpy(&aux, CMSG_DATA(cmsg), sizeof(aux)); + if (!(aux.tp_status & TP_STATUS_VLAN_VALID) + || n < (ssize_t)ETH_HLEN || n > (ssize_t)(sizeof(buf) - 4)) + continue; + memmove(buf + 16, buf + 12, n - 12); + half = htons((aux.tp_status & TP_STATUS_VLAN_TPID_VALID) + ? aux.tp_vlan_tpid : ETH_P_8021Q); + memcpy(buf + 12, &half, sizeof(half)); + half = htons(aux.tp_vlan_tci); + memcpy(buf + 14, &half, sizeof(half)); + n += 4; } } pcap_capture_packet_ts(kc->cap, buf, (size_t)n, tsp); @@ -141,7 +177,7 @@ struct packet_mreq mreq; struct timeval tv; kernel_capture_t *kc; - int ifindex, err, ts_on = 1; + int ifindex, err, ts_on = 1, aux_on = 1; pthread_mutex_lock(&g_captures_lock); @@ -197,6 +233,13 @@ * promiscuous mode above: the reader stamps "now" without them. */ setsockopt(kc->sock, SOL_SOCKET, SO_TIMESTAMPNS, &ts_on, sizeof(ts_on)); + /* 802.1Q tags of bridge-forwarded frames, delivered as PACKET_AUXDATA + * cmsgs: at the packet-tap points the tag lives as skb metadata, not in + * the frame data. Best-effort like the two above; without it such frames + * end up in the pcap headerless. The reader re-inserts the header on + * Ethernet-framed captures. */ + setsockopt(kc->sock, SOL_PACKET, PACKET_AUXDATA, &aux_on, sizeof(aux_on)); + strncpy(kc->ifname, ifname, IFNAMSIZ - 1); kc->ifname[IFNAMSIZ - 1] = '\0'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/src/hypervisor_marker.c new/ubridge-1.3.3/src/hypervisor_marker.c --- old/ubridge-1.3.2/src/hypervisor_marker.c 2026-10-31 15:20:39.000000000 +0100 +++ new/ubridge-1.3.3/src/hypervisor_marker.c 2026-11-30 11:57:30.000000000 +0100 @@ -224,6 +224,7 @@ pcap_capture_t *cap; /* optional: append matched packets to this pcap */ struct bpf_program fp; /* compiled cBPF, applied in user space per packet */ int dir_match; /* KMARK_DIR_* */ + int ethernet; /* DLT_EN10MB: bridge-forwarded VLAN tags re-inserted */ volatile int enabled; /* 0 = installed but silent (enable off) */ volatile int stop; /* cooperative stop flag for the reader thread */ volatile int dead; /* reader exited on a hard error (interface gone) */ @@ -249,9 +250,13 @@ kernel_marker_t *km = (kernel_marker_t *)arg; const size_t buf_len = 65535; unsigned char *buf = malloc(buf_len); + /* Room for both the timestamp and the PACKET_AUXDATA cmsgs: the kernel + * stops at the first cmsg that does not fit (MSG_CTRUNC), dropping + * everything behind it. */ union { struct cmsghdr cmsg; - char buf[CMSG_SPACE(sizeof(struct timespec))]; + char buf[CMSG_SPACE(sizeof(struct timespec)) + + CMSG_SPACE(sizeof(struct tpacket_auxdata))]; } cmsg_buf; if (buf == NULL) { @@ -294,7 +299,20 @@ /* Kernel receive timestamp (CLOCK_REALTIME, when the frame entered * the socket) for the MARK signal and the pcap append — absent cmsg * (no SO_TIMESTAMPNS support) leaves tsp NULL and both fall back to - * stamping at read/emit time. */ + * stamping at read/emit time. + * + * PACKET_AUXDATA, Ethernet captures only: with vlan_filtering the + * 802.1Q tag of bridge-forwarded frames travels as skb metadata at + * the AF_PACKET tap points, so the frame data is headerless. On a + * SOCK_RAW socket TP_STATUS_VLAN_VALID is only set when the skb + * carries the tag as metadata, so a re-insertion can never + * duplicate a tag already in the data. QinQ: the bridge only + * manages its own (outer) tag — an 802.1Q tag still present in the + * data is the inner, customer tag, and the metadata one goes back + * in front of it. Keep the tag aside: it goes back into the frame + * after the first (untagged view) filter miss, below. */ + uint16_t vlan_tci = 0, vlan_tpid = 0; + int vlan_meta = 0; for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_TIMESTAMPNS && cmsg->cmsg_len >= CMSG_LEN(sizeof(struct timespec))) { @@ -303,7 +321,19 @@ ts.tv_sec = kts.tv_sec; ts.tv_usec = kts.tv_nsec / 1000; tsp = &ts; - break; + } else if (km->ethernet + && cmsg->cmsg_level == SOL_PACKET && cmsg->cmsg_type == PACKET_AUXDATA + && cmsg->cmsg_len >= CMSG_LEN(sizeof(struct tpacket_auxdata))) { + struct tpacket_auxdata aux; + + memcpy(&aux, CMSG_DATA(cmsg), sizeof(aux)); + if (!(aux.tp_status & TP_STATUS_VLAN_VALID) + || n < (ssize_t)ETH_HLEN || n > (ssize_t)(buf_len - 4)) + continue; + vlan_tpid = (aux.tp_status & TP_STATUS_VLAN_TPID_VALID) + ? aux.tp_vlan_tpid : ETH_P_8021Q; + vlan_tci = aux.tp_vlan_tci; + vlan_meta = 1; } } @@ -317,10 +347,31 @@ (km->dir_match == KMARK_DIR_RX && from.sll_pkttype != PACKET_OUTGOING)) continue; + /* First match on the raw bytes: that keeps the L3-offset semantics + * of untagged frames (ip/tcp-style filters) exactly as before. Only + * on a miss, re-insert the metadata tag and retry — the tagged view + * is the only one where vlan-style filters can ever match here, + * because at the tap points such frames carry their tag as metadata. + * A hit on the tagged view emits/writes the tagged frame (its pcap + * is DLT_EN10MB, so the tag belongs in the data, like libpcap's). */ memset(&pkthdr, 0, sizeof(pkthdr)); pkthdr.caplen = (u_int)n; pkthdr.len = (u_int)n; - if (pcap_offline_filter(&km->fp, &pkthdr, buf)) { + int matched = pcap_offline_filter(&km->fp, &pkthdr, buf); + if (!matched && vlan_meta) { + uint16_t half; + + memmove(buf + 16, buf + 12, n - 12); + half = htons(vlan_tpid); + memcpy(buf + 12, &half, sizeof(half)); + half = htons(vlan_tci); + memcpy(buf + 14, &half, sizeof(half)); + n += 4; + pkthdr.caplen = (u_int)n; + pkthdr.len = (u_int)n; + matched = pcap_offline_filter(&km->fp, &pkthdr, buf); + } + if (matched) { if (km->enabled) { /* enable off: keep reading, no emit / no pcap */ marker_emit(km->name, km->tag, km->link, (size_t)n, dir, tsp); if (km->cap) @@ -457,7 +508,7 @@ pcap_t *pd; struct sockaddr_ll sll; struct timeval tv; - int link_type, ifindex, err, i, started = 0, ts_on = 1; + int link_type, ifindex, err, i, started = 0, ts_on = 1, aux_on = 1; int have_linktype = 0, have_tag = 0, have_link = 0, have_dir = 0, have_pcap = 0; /* an odd trailing token is a value without a keyword (same rule as mark_setup) */ @@ -584,13 +635,27 @@ * and the pcap append, best-effort: both stamp at read time without it. */ setsockopt(km->sock, SOL_SOCKET, SO_TIMESTAMPNS, &ts_on, sizeof(ts_on)); + /* 802.1Q tags of bridge-forwarded frames, delivered as PACKET_AUXDATA + * cmsgs: at the packet-tap points the tag lives as skb metadata, not in + * the frame data. Best-effort; the reader re-inserts the header on the + * tagged-view filter pass (Ethernet captures only). */ + setsockopt(km->sock, SOL_PACKET, PACKET_AUXDATA, &aux_on, sizeof(aux_on)); + + km->ethernet = (link_type == DLT_EN10MB); + /* Prune in the kernel where the frame layout matches what the filter was * compiled for: for DLT_EN10MB the AF_PACKET frame is byte-identical to * the offsets pcap_compile assumed, so non-matching frames never cross * to user space. Other linktypes (C_HDLC/PPP offsets differ at the * AF_PACKET boundary) keep the user-space pcap_offline_filter path, - * which also re-checks every delivered frame. */ - if (link_type == DLT_EN10MB) { + * which also re-checks every delivered frame. + * + * vlan-aware filters skip the pruning: bridge-forwarded frames carry + * their tag as skb metadata, so in the kernel's headerless view such a + * filter never matches and the frames the tagged-view user-space pass + * would match never get delivered at all. pcap's grammar has no other + * use for the "vlan" token, so a substring test is exact enough. */ + if (km->ethernet && strstr(filter, "vlan") == NULL) { struct sock_fprog fprog; fprog.len = (unsigned short)km->fp.bf_len; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/src/ubridge.h new/ubridge-1.3.3/src/ubridge.h --- old/ubridge-1.3.2/src/ubridge.h 2026-10-31 15:20:39.000000000 +0100 +++ new/ubridge-1.3.3/src/ubridge.h 2026-11-30 11:57:30.000000000 +0100 @@ -32,7 +32,7 @@ #include "ubridge_options.h" #define NAME "ubridge" -#define VERSION "1.3.2" +#define VERSION "1.3.3" #define CONFIG_FILE "ubridge.ini" /* Default MTU applied to every device ubridge creates (veth ends, TAPs). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/tests/capture/run_all.py new/ubridge-1.3.3/tests/capture/run_all.py --- old/ubridge-1.3.2/tests/capture/run_all.py 2026-10-31 15:20:39.000000000 +0100 +++ new/ubridge-1.3.3/tests/capture/run_all.py 2026-11-30 11:57:30.000000000 +0100 @@ -5,6 +5,7 @@ SUITES = [ "test_basic", "test_multi", + "test_kernel_vlan", ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/tests/capture/test_kernel_vlan.py new/ubridge-1.3.3/tests/capture/test_kernel_vlan.py --- old/ubridge-1.3.2/tests/capture/test_kernel_vlan.py 1970-01-01 01:00:00.000000000 +0100 +++ new/ubridge-1.3.3/tests/capture/test_kernel_vlan.py 2026-11-30 11:57:30.000000000 +0100 @@ -0,0 +1,248 @@ +"""VLAN-tag regression for kernel captures (gns3-server#3116). + +With vlan_filtering, the 802.1Q tag of bridge-forwarded frames travels as +skb metadata at both AF_PACKET tap points (the frame data is headerless), +so without PACKET_AUXDATA a kernel capture wrote such frames 4 bytes +short. This suite drives two vlan-filtering bridges joined by a veth +trunk, injects raw tagged frames (one injector per side so both the TX and +the RX tap directions are exercised), and asserts — byte for byte — that +every captured frame equals the frame as injected: + +- single 802.1Q tag (vid 10, bridge protocol 0x8100); +- QinQ with both tags sharing TPID 0x8100 (outer 10 / inner 20): the + kernel only manages the outer tag in metadata, the inner stays in the + data, and a wrong re-insertion point mangles the IP header instead; +- QinQ with an 802.1ad outer tag (bridge vlan_protocol 802.1ad), skipped + with a NOTE when the kernel rejects the attribute. + +The byte-for-byte comparison is the point: len/ethertype/vid checks are +blind to a 2-byte shift of the IP header, which is exactly the bug a +first cut of the fix had. Stdlib only. Requires CAP_NET_ADMIN/CAP_NET_RAW +— run under sudo (or unshare -Urn). Uses the in-repo ./ubridge. +""" +import os +import shutil as _sh +import socket +import struct +import subprocess +import sys +import time + +sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "brctl")) +from common import Ubridge, Results # noqa: E402 + +PREFIX = "ubcapv-" +PORT = 13048 +TRUNK_A = PREFIX + "ta" # br1 side of the trunk (captured) +TRUNK_B = PREFIX + "tb" # br2 side of the trunk +HOST_E = PREFIX + "he" # br1 host port; peer he2 is the TX injector +HOST_E2 = PREFIX + "he2" +HOST_C = PREFIX + "hc" # br2 host port; peer hc2 is the RX injector +HOST_C2 = PREFIX + "hc2" +BR1 = PREFIX + "br1" +BR2 = PREFIX + "br2" +PCAP = "/tmp/ubcapv.pcap" +REPO_UBRIDGE = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "ubridge")) +VID = 10 +INNER_VID = 20 +N = 5 + +# bridge(8) sits in /sbin on most distros — see tests/brctl/test_vlan.py. +BRIDGE = _sh.which("bridge") +if BRIDGE is None: + BRIDGE = next((p for p in ("/sbin/bridge", "/usr/sbin/bridge", "/usr/local/sbin/bridge") + if os.path.isfile(p) and os.access(p, os.X_OK)), None) + + +def _ip(args): + return subprocess.run(["ip"] + args, capture_output=True, text=True) + + +def _icmp(seq, src): + payload = bytes(i & 0xFF for i in range(56)) + icmp = struct.pack("!BBHHH", 8, 0, 0, 0x1234, seq) + payload + icmp = icmp[:2] + struct.pack("!H", _csum(icmp)) + icmp[4:] + ip = struct.pack("!BBHHHBBH4s4s", 0x45, 0, 84, 0x2345, 0, 64, 1, 0, + bytes([10, 97, 0, 1]), bytes([10, 97, 0, 2])) + ip = ip[:10] + struct.pack("!H", _csum(ip)) + ip[12:] + return ip + icmp # the caller builds the Ethernet header (incl. tags) + + +def _csum(d): + if len(d) % 2: + d += b"\0" + s = sum(struct.unpack("!%dH" % (len(d) // 2), d)) + s = (s >> 16) + (s & 0xFFFF) + s += s >> 16 + return (~s) & 0xFFFF + + +def _tagged(seq, src, tags): + """ICMP frame behind the given tag chain: [(tpid, vid), ...].""" + eth = (b"\xff" * 6 + src + + b"".join(struct.pack("!HH", tpid, vid) for tpid, vid in tags) + + b"\x08\x00") + return eth + _icmp(seq, src) + + +def _seq(frame): + """ICMP echo sequence, behind any tag chain — identifies a frame.""" + off = 12 + while frame[off:off + 2] in (b"\x81\x00", b"\x88\xa8", b"\x91\x00"): + off += 4 + off += 2 # the inner ethertype + return struct.unpack("!H", frame[off + 20 + 6:off + 20 + 8])[0] # ip hdr + icmp hdr + + +def _no_ipv6(*ifaces): + """The veth/bridge bring-up floods IPv6 multicast; the pcaps must contain + only the injected frames, so switch IPv6 off on each fixture interface + (before bring-up). Per-interface, never all/default: this suite shares + its network namespace with every other suite in the CI job, and a + netns-wide disable_ipv6 outlives the test — it silently broke the + nio_raw GSO suite later in the job (its IPv6 address add failed, its + bind then died with EADDRNOTAVAIL). Per-interface settings die with + the interface.""" + for k in ifaces: + try: + with open("/proc/sys/net/ipv6/conf/%s/disable_ipv6" % k, "w") as f: + f.write("1") + except OSError: + pass + + +SRC_TX = bytes([0xaa, 0x01]) + b"\x11" * 4 # injected into br1 -> out trunk (TX tap) +SRC_RX = bytes([0xaa, 0x02]) + b"\x22" * 4 # injected into br2 -> trunk ingress (RX tap) + +SCENARIOS = [ + ("single-8100", [], [(0x8100, VID)]), + ("qinq-8100-8100", [], [(0x8100, VID), (0x8100, INNER_VID)]), + ("qinq-88a8-8100", ["vlan_protocol", "802.1ad"], [(0x88A8, VID), (0x8100, INNER_VID)]), +] + + +def _topology(br_args): + subprocess.run(["ip", "link", "add", BR1, "type", "bridge", "vlan_filtering", "1"] + br_args, + capture_output=True, check=True) + subprocess.run(["ip", "link", "add", BR2, "type", "bridge", "vlan_filtering", "1"] + br_args, + capture_output=True, check=True) + subprocess.run(["ip", "link", "add", TRUNK_A, "type", "veth", "peer", "name", TRUNK_B], + capture_output=True, check=True) + subprocess.run(["ip", "link", "add", HOST_E, "type", "veth", "peer", "name", HOST_E2], + capture_output=True, check=True) + subprocess.run(["ip", "link", "add", HOST_C, "type", "veth", "peer", "name", HOST_C2], + capture_output=True, check=True) + _no_ipv6(BR1, BR2, TRUNK_A, TRUNK_B, HOST_E, HOST_E2, HOST_C, HOST_C2) + for br in (BR1, BR2): + subprocess.run(["ip", "link", "set", br, "up"], capture_output=True, check=True) + subprocess.run(["ip", "link", "set", TRUNK_A, "master", BR1], capture_output=True, check=True) + subprocess.run(["ip", "link", "set", HOST_E, "master", BR1], capture_output=True, check=True) + subprocess.run(["ip", "link", "set", TRUNK_B, "master", BR2], capture_output=True, check=True) + subprocess.run(["ip", "link", "set", HOST_C, "master", BR2], capture_output=True, check=True) + for i in (TRUNK_A, TRUNK_B, HOST_E, HOST_E2, HOST_C, HOST_C2): + subprocess.run(["ip", "link", "set", i, "up"], capture_output=True, check=True) + for i in (TRUNK_A, TRUNK_B, HOST_E, HOST_C): + subprocess.run([BRIDGE, "vlan", "add", "dev", i, "vid", str(VID)], + capture_output=True, check=True) + + +def _teardown(): + for i in (BR1, BR2, TRUNK_A, TRUNK_B, HOST_E, HOST_E2, HOST_C, HOST_C2): + subprocess.run(["ip", "link", "del", i], capture_output=True) + + +def _pcap_frames(path): + data = open(path, "rb").read() + out, off = [], 24 + while off + 16 <= len(data): + incl = struct.unpack("<I", data[off + 8:off + 12])[0] + out.append(data[off + 16:off + 16 + incl]) + off += 16 + incl + return out + + +def _inject_sockets(): + s_tx = socket.socket(socket.AF_PACKET, socket.SOCK_RAW) + s_tx.bind((HOST_E2, 0)) + s_rx = socket.socket(socket.AF_PACKET, socket.SOCK_RAW) + s_rx.bind((HOST_C2, 0)) + return s_tx, s_rx + + +def main(): + r = Results() + if os.geteuid() != 0 or BRIDGE is None: + print(" [SKIP] needs root + bridge(8) (run under sudo or unshare -Urn)") + return 0 + if os.path.exists(PCAP): + os.remove(PCAP) + + try: + with Ubridge(port=PORT, binary=REPO_UBRIDGE) as ub: + c = ub.connect() + try: + for name, br_args, tags in SCENARIOS: + frames = [_tagged(i, SRC_TX, tags) for i in range(1, N + 1)] + frames += [_tagged(100 + i, SRC_RX, tags) for i in range(1, N + 1)] + _teardown() # previous scenario's bridges would collide by name + time.sleep(0.2) + try: + _topology(br_args) + except subprocess.CalledProcessError: + r.check("%s: topology skipped (kernel rejects %s)" % (name, br_args or "defaults"), + name == "qinq-88a8-8100") + continue + + if os.path.exists(PCAP): + os.remove(PCAP) + r.check("%s: capture start" % name, + c.code("capture start_kernel %s %s" % (TRUNK_A, PCAP)) == "100") + s_tx, s_rx = _inject_sockets() + try: + # one direction at a time, matching the frames built above + for i in range(1, N + 1): + s_tx.send(_tagged(i, SRC_TX, tags)) + time.sleep(0.02) + for i in range(1, N + 1): + s_rx.send(_tagged(100 + i, SRC_RX, tags)) + time.sleep(0.02) + time.sleep(0.8) + finally: + s_tx.close() + s_rx.close() + r.check("%s: capture stop" % name, + c.code("capture stop_kernel %s" % TRUNK_A) == "100") + + got = _pcap_frames(PCAP) + want = set(frames) + # every injected frame (both directions) captured byte-identically. + # The pcap may also hold kernel-side extras (occasional GRO + # concatenations, IGMP reports the bridges emit) — those are + # delivered to the tap exactly as libpcap would see them, so + # the assertions are: full byte-identical coverage of the + # injected set, and no tag-stripped copy anywhere. + matched = {f for f in got if f in want} + missing = sorted(_seq(f) for f in want - matched) + r.check("%s: %d/%d injected frames byte-identical (both directions)" + % (name, len(matched), len(want)), + matched == want, + "matched=%d got=%d missing seqs=%s" + % (len(matched), len(got), missing)) + # and nothing degraded: no frame equal to the tag-stripped view + stripped = {f[0:12] + f[16:] for f in want} + r.check("%s: no tagless 4-byte-short copies in the pcap" % name, + not (set(got) & stripped)) + finally: + c.send("capture stop_kernel") + c.close() + finally: + _teardown() + + npass = sum(1 for _, ok, _ in r.items if ok) + nfail = sum(1 for _, ok, _ in r.items if not ok) + r.summary() + return 0 if nfail == 0 else 1 + + +if __name__ == "__main__": + sys.exit(main()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/tests/marker/run_all.py new/ubridge-1.3.3/tests/marker/run_all.py --- old/ubridge-1.3.2/tests/marker/run_all.py 2026-10-31 15:20:39.000000000 +0100 +++ new/ubridge-1.3.3/tests/marker/run_all.py 2026-11-30 11:57:30.000000000 +0100 @@ -7,6 +7,7 @@ "test_dir_filter", "test_linktype", "test_pause", + "test_kernel_vlan", "test_reset_preserves_mark", "test_kernel", # self-skips without CAP_NET_ADMIN (userspace CI) ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/tests/marker/test_kernel_vlan.py new/ubridge-1.3.3/tests/marker/test_kernel_vlan.py --- old/ubridge-1.3.2/tests/marker/test_kernel_vlan.py 1970-01-01 01:00:00.000000000 +0100 +++ new/ubridge-1.3.3/tests/marker/test_kernel_vlan.py 2026-11-30 11:57:30.000000000 +0100 @@ -0,0 +1,247 @@ +"""VLAN-filter regression for kernel markers (`marker add_kernel`). + +Same root cause as the capture fix (gns3-server#3116): with vlan_filtering +the 802.1Q tag of bridge-forwarded frames travels as skb metadata at the +AF_PACKET tap points, so the frame data a kernel marker sees is headerless +and a vlan-style filter never matched. The fix re-inserts the metadata tag +after a first-pass (untagged view) filter miss. + +Drives two vlan-filtering bridges joined by a veth trunk and asserts: +- `vlan 10` matches bridge-forwarded vid-10 frames in BOTH directions and + emits the tagged frame length (102 -> the pcap view has the tag); +- `ip proto 1` keeps matching on the untagged view (no L3-offset change); +- QinQ [8100 10][8100 20]: `vlan 20` matches the inner tag on the raw + data (like tcpdump on the same bytes), `vlan 10` matches only after the + tagged-view retry, at the full QinQ length; +- the pcap appended on a tagged-view hit contains the frames as injected, + byte for byte. + +Stdlib only. Requires CAP_NET_ADMIN/CAP_NET_RAW — run under sudo (or +unshare -Urn). Uses the in-repo ./ubridge. +""" +import os +import shutil as _sh +import re +import socket +import struct +import subprocess +import sys +import time + +sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "brctl")) +from common import Ubridge, Results # noqa: E402 + +PREFIX = "ubmkv-" +PORT = 13091 +TRUNK_A = PREFIX + "ta" +TRUNK_B = PREFIX + "tb" +HOST_E = PREFIX + "he" +HOST_E2 = PREFIX + "he2" +HOST_C = PREFIX + "hc" +HOST_C2 = PREFIX + "hc2" +BR1 = PREFIX + "br1" +BR2 = PREFIX + "br2" +PCAP = "/tmp/ubmkv.pcap" +REPO_UBRIDGE = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "ubridge")) +VID = 10 +INNER_VID = 20 +N = 3 + +BRIDGE = _sh.which("bridge") +if BRIDGE is None: + BRIDGE = next((p for p in ("/sbin/bridge", "/usr/sbin/bridge", "/usr/local/sbin/bridge") + if os.path.isfile(p) and os.access(p, os.X_OK)), None) + + +def _ip(args): + return subprocess.run(["ip"] + args, capture_output=True, text=True) + + +def _csum(d): + if len(d) % 2: + d += b"\0" + s = sum(struct.unpack("!%dH" % (len(d) // 2), d)) + s = (s >> 16) + (s & 0xFFFF) + s += s >> 16 + return (~s) & 0xFFFF + + +def _icmp(seq, src): + payload = bytes(i & 0xFF for i in range(56)) + icmp = struct.pack("!BBHHH", 8, 0, 0, 0x1234, seq) + payload + icmp = icmp[:2] + struct.pack("!H", _csum(icmp)) + icmp[4:] + ip = struct.pack("!BBHHHBBH4s4s", 0x45, 0, 84, 0x2345, 0, 64, 1, 0, + bytes([10, 97, 0, 1]), bytes([10, 97, 0, 2])) + ip = ip[:10] + struct.pack("!H", _csum(ip)) + ip[12:] + return ip + icmp # the caller builds the Ethernet header (incl. tags) + + +def _tagged(seq, src, tags): + eth = (b"\xff" * 6 + src + + b"".join(struct.pack("!HH", tpid, vid) for tpid, vid in tags) + + b"\x08\x00") + return eth + _icmp(seq, src) + + +SRC_TX = bytes([0xaa, 0x01]) + b"\x11" * 4 +SRC_RX = bytes([0xaa, 0x02]) + b"\x22" * 4 + + +def _inject(iface, frame): + s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW) + try: + s.bind((iface, 0)) + s.send(frame) + finally: + s.close() + + +def _drain(sock, timeout): + out = [] + end = time.time() + timeout + while True: + remaining = end - time.time() + if remaining <= 0: + break + sock.settimeout(remaining) + try: + data, _ = sock.recvfrom(4096) + except socket.timeout: + break + out.append(data.decode(errors="replace").strip()) + return out + + +def _kv(line): + return dict(tok.split("=", 1) for tok in line.split() if "=" in tok) + + +def _free_udp(): + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + s.bind(("127.0.0.1", 0)) + p = s.getsockname()[1] + s.close() + return p + + +def _topology(): + for br in (BR1, BR2): + subprocess.run(["ip", "link", "add", br, "type", "bridge", "vlan_filtering", "1"], + capture_output=True, check=True) + subprocess.run(["ip", "link", "set", br, "up"], capture_output=True, check=True) + subprocess.run(["ip", "link", "add", TRUNK_A, "type", "veth", "peer", "name", TRUNK_B], + capture_output=True, check=True) + subprocess.run(["ip", "link", "add", HOST_E, "type", "veth", "peer", "name", HOST_E2], + capture_output=True, check=True) + subprocess.run(["ip", "link", "add", HOST_C, "type", "veth", "peer", "name", HOST_C2], + capture_output=True, check=True) + subprocess.run(["ip", "link", "set", TRUNK_A, "master", BR1], capture_output=True, check=True) + subprocess.run(["ip", "link", "set", HOST_E, "master", BR1], capture_output=True, check=True) + subprocess.run(["ip", "link", "set", TRUNK_B, "master", BR2], capture_output=True, check=True) + subprocess.run(["ip", "link", "set", HOST_C, "master", BR2], capture_output=True, check=True) + for i in (TRUNK_A, TRUNK_B, HOST_E, HOST_E2, HOST_C, HOST_C2): + subprocess.run(["ip", "link", "set", i, "up"], capture_output=True, check=True) + for i in (TRUNK_A, TRUNK_B, HOST_E, HOST_C): + subprocess.run([BRIDGE, "vlan", "add", "dev", i, "vid", str(VID)], + capture_output=True, check=True) + + +def _teardown(): + for i in (BR1, BR2, TRUNK_A, TRUNK_B, HOST_E, HOST_E2, HOST_C, HOST_C2): + subprocess.run(["ip", "link", "del", i], capture_output=True) + + +def _pcap_frames(path): + data = open(path, "rb").read() + out, off = [], 24 + while off + 16 <= len(data): + incl = struct.unpack("<I", data[off + 8:off + 12])[0] + out.append(data[off + 16:off + 16 + incl]) + off += 16 + incl + return out + + +def main(): + r = Results() + if os.geteuid() != 0 or BRIDGE is None: + print(" [SKIP] needs root + bridge(8) (run under sudo or unshare -Urn)") + return 0 + if os.path.exists(PCAP): + os.remove(PCAP) + + subprocess.run(["ip", "link", "set", "lo", "up"], capture_output=True) + marker_port = _free_udp() + ms = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + ms.bind(("127.0.0.1", marker_port)) + + single = [_tagged(i, SRC_TX, [(0x8100, VID)]) for i in range(1, N + 1)] + single += [_tagged(100 + i, SRC_RX, [(0x8100, VID)]) for i in range(1, N + 1)] + qinq = [_tagged(200 + i, SRC_TX, [(0x8100, VID), (0x8100, INNER_VID)]) for i in range(1, N + 1)] + qinq += [_tagged(300 + i, SRC_RX, [(0x8100, VID), (0x8100, INNER_VID)]) for i in range(1, N + 1)] + + try: + with Ubridge(port=PORT, binary=REPO_UBRIDGE) as ub: + c = ub.connect() + try: + r.check("marker sink", c.code("marker sink 127.0.0.1 %d" % marker_port) == "100") + r.check("topology", _topology() or True) + + r.check("add vlan 10 marker", + c.code('marker add_kernel mvlan %s "vlan 10" tag 10 pcap %s' + % (TRUNK_A, PCAP)) == "100") + r.check("add ip proto 1 marker", + c.code('marker add_kernel mip %s "ip proto 1" tag 11' + % TRUNK_A) == "100") + r.check("add vlan 20 marker", + c.code('marker add_kernel mvlan20 %s "vlan 20" tag 12' + % TRUNK_A) == "100") + + for f in single: + # TX frames (seq < 100) enter br1 from the h-e side; RX + # frames enter br2 from the h-c side. One side each — the + # lists already cover both directions. + _inject(HOST_E2 if f[6:12] == SRC_TX else HOST_C2, f) + time.sleep(0.02) + time.sleep(0.8) + marks = [_kv(l) for l in _drain(ms, 1.0)] + + mvlan = [m for m in marks if m.get("filter") == "mvlan"] + mip = [m for m in marks if m.get("filter") == "mip"] + r.check("vlan 10 matched in both directions (%d marks)" % (2 * N), + len(mvlan) == 2 * N, "got %d" % len(mvlan)) + r.check("vlan 10 marks carry the tagged length (102)", + all(m.get("len") == "102" for m in mvlan)) + r.check("ip proto 1 still matches (untagged view)", + len(mip) == 2 * N, "got %d" % len(mip)) + + # QinQ: inner tag matches on the raw data, outer only after the retry + for f in qinq: + _inject(HOST_E2 if f[6:12] == SRC_TX else HOST_C2, f) + time.sleep(0.02) + time.sleep(0.8) + marks = [_kv(l) for l in _drain(ms, 1.0)] + q10 = [m for m in marks if m.get("filter") == "mvlan" and m.get("len") == "106"] + q20 = [m for m in marks if m.get("filter") == "mvlan20"] + r.check("QinQ outer vid 10 matched after the tagged-view retry (%d)" % (2 * N), + len(q10) == 2 * N, "got %d" % len(q10)) + r.check("QinQ inner vid 20 matched on the raw data (%d)" % (2 * N), + len(q20) == 2 * N, "got %d" % len(q20)) + + r.check("vlan 10 marker pcap has the tagged frames", + set(_pcap_frames(PCAP)) == set(single + qinq), + "%d frames" % len(_pcap_frames(PCAP))) + + r.check("marker off", c.code("marker off") == "100") + finally: + c.close() + finally: + _teardown() + + npass = sum(1 for _, ok, _ in r.items if ok) + nfail = sum(1 for _, ok, _ in r.items if not ok) + r.summary() + return 0 if nfail == 0 else 1 + + +if __name__ == "__main__": + sys.exit(main()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/tests/nio_raw/helpers.py new/ubridge-1.3.3/tests/nio_raw/helpers.py --- old/ubridge-1.3.2/tests/nio_raw/helpers.py 2026-10-31 15:20:39.000000000 +0100 +++ new/ubridge-1.3.3/tests/nio_raw/helpers.py 2026-11-30 11:57:30.000000000 +0100 @@ -48,6 +48,17 @@ return subprocess.run(args, capture_output=True, text=True) +def sh_ok(*args): + """Run a command, raise with the command line and stderr on failure — + for setup steps whose silent failure would only surface much later as + an unrelated-looking error (a skipped 'ip addr add' shows up as bind + EADDRNOTAVAIL in the first stream, not here).""" + r = sh(*args) + if r.returncode != 0: + raise RuntimeError("%s failed: %s" % (" ".join(args), r.stderr.strip())) + return r + + def veth_up(a, b): """Create a veth pair a<->b (idempotent: delete a stale pair first) and bring both ends UP. Also brings loopback UP — a fresh network namespace diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ubridge-1.3.2/tests/nio_raw/test_linux_raw_gso.py new/ubridge-1.3.3/tests/nio_raw/test_linux_raw_gso.py --- old/ubridge-1.3.2/tests/nio_raw/test_linux_raw_gso.py 2026-10-31 15:20:39.000000000 +0100 +++ new/ubridge-1.3.3/tests/nio_raw/test_linux_raw_gso.py 2026-11-30 11:57:30.000000000 +0100 @@ -25,7 +25,7 @@ import threading import time -from helpers import Ubridge, Results, HOST, ubridge_binary, sh, free_udp_port, ETH_P_ALL +from helpers import Ubridge, Results, HOST, ubridge_binary, sh, sh_ok, free_udp_port, ETH_P_ALL PORT = 13182 A, B = "vgso0", "vgso1" @@ -103,14 +103,21 @@ if r.returncode != 0: child.kill() raise RuntimeError("veth add failed: %s" % r.stderr.strip()) - sh("ip", "link", "set", B, "netns", str(child.pid)) - sh("ip", "link", "set", A, "mtu", str(MTU), "up") - sh(*ns, "ip", "link", "set", "lo", "up") - sh(*ns, "ip", "link", "set", B, "mtu", str(MTU), "up") - for _, family, local, peer, plen in FAMILIES: - extra = ("nodad",) if family == socket.AF_INET6 else () - sh("ip", "addr", "add", "%s/%d" % (local, plen), "dev", A, *extra) - sh(*ns, "ip", "addr", "add", "%s/%d" % (peer, plen), "dev", B, *extra) + try: + sh_ok("ip", "link", "set", B, "netns", str(child.pid)) + sh_ok("ip", "link", "set", A, "mtu", str(MTU), "up") + sh_ok(*ns, "ip", "link", "set", "lo", "up") + sh_ok(*ns, "ip", "link", "set", B, "mtu", str(MTU), "up") + for _, family, local, peer, plen in FAMILIES: + extra = ("nodad",) if family == socket.AF_INET6 else () + sh_ok("ip", "addr", "add", "%s/%d" % (local, plen), "dev", A, *extra) + sh_ok(*ns, "ip", "addr", "add", "%s/%d" % (peer, plen), "dev", B, *extra) + except RuntimeError: + # never leave the fixtures behind: the caller only cleans up when + # setup() returns, and a half-set-up pair outlives the child anyway + child.kill() + sh("ip", "link", "del", A) + raise return child
