Overview
This guide describes how to configure and test Huawei Layer 2 Loop Detection on an Ethernet subinterface bound to an MPLS L2VPN VSI.
The LAB demonstrates how to capture Huawei Loop Detection frames, simulate an Ethernet loop using a Linux-based frame reflector, verify automatic interface blocking, and confirm service recovery.
Platform: Huawei S6730-H48X6C
Technology: MPLS L2VPN / LDP / Ethernet Loop Detection
LAB Environment
The test environment consists of two Huawei switches interconnected through an LDP-signaled MPLS pseudowire. Each switch uses an Ethernet subinterface bound to the same VSI.
Two Linux hosts are connected to VLAN 2323 for traffic generation, packet capture, and loop simulation. Loop Detection is enabled on the Side-A Ethernet subinterface.
SIDE-A SIDE-B
tpc-side-a tpc-side-b
10.23.23.1/24 10.23.23.2/24
| |
VLAN 2323 VLAN 2323
| |
swi-lab-a swi-lab-b
XGE0/0/36.2323 XGE0/0/30.2323
| |
+---------- MPLS L2VPN ------------+
SIDE-A-SIDE-B_TEST
VSI ID 2323232323
LDP Signaling
LAB Parameters:
- Side-A switch: swi-lab-a, XGE0/0/36.2323
- Side-B switch: swi-lab-b, XGE0/0/30.2323
- Linux endpoints: tpc-side-a and tpc-side-b
- Test network: 10.23.23.0/24
- Service VLAN: 2323
- VSI: SIDE-A-SIDE-B_TEST
- VSI ID: 2323232323
- Loop Detection recovery timer: 60 seconds
The MPLS transport network and LDP connectivity between both switches must already be operational.
Huawei Configuration
Side-A: swi-lab-a
Configure the MPLS L2VPN VSI, remote LDP peer, and Ethernet subinterface with Loop Detection enabled.
vsi SIDE-A-SIDE-B_TEST
pwsignal ldp
vsi-id 2323232323
peer 10.255.232.2
mtu 9216
mpls ldp remote-peer swi-lab-b
remote-ip 10.255.232.2
interface XGigabitEthernet0/0/36.2323
description SIDE-A-SIDE-B_TEST
mtu 9216
dot1q termination vid 2323
l2 binding vsi SIDE-A-SIDE-B_TEST
loop-detect enable
loop-detect recovery-time 60
loop-detect detection vid 2323
Loop Detection commands:
loop-detect enable enables Loop Detection on the Ethernet subinterface.loop-detect detection vid 2323 configures VLAN 2323 for loop detection.loop-detect recovery-time 60 configures a 60-second recovery timer.
Side-B: swi-lab-b
Configure the remote MPLS L2VPN endpoint without Loop Detection.
vsi SIDE-A-SIDE-B_TEST
pwsignal ldp
vsi-id 2323232323
peer 10.255.232.1
mtu 9216
mpls ldp remote-peer swi-lab-a
remote-ip 10.255.232.1
interface XGigabitEthernet0/0/30.2323
description SIDE-A-SIDE-B_TEST
mtu 9216
dot1q termination vid 2323
l2 binding vsi SIDE-A-SIDE-B_TEST
Both endpoints use the same VSI ID, VLAN, and MTU. Loop Detection is enabled only on the Side-A subinterface.
Linux Test Host Configuration
Configure VLAN 2323 on both Linux hosts to provide IP connectivity through the MPLS L2VPN service.
Side-A: tpc-side-a
root@tpc-side-a:~# ip link add link eth0 vlan2323 type vlan id 2323
root@tpc-side-a:~# ip link set vlan2323 up
root@tpc-side-a:~# ip a a 10.23.23.1/24 dev vlan2323
Side-B: tpc-side-b
root@tpc-side-b:~# ip link set vlan2323 up
root@tpc-side-b:~# ip a a 10.23.23.2/24 dev vlan2323
The VLAN interface on Side-B was already created before the test. If it does not exist, create it using the same VLAN configuration as Side-A.
Verify MPLS L2VPN Connectivity
Verify bidirectional IP connectivity between the two Linux hosts before performing Loop Detection tests.
Side-A to Side-B:
root@tpc-side-a:~# ping 10.23.23.2
PING 10.23.23.2 (10.23.23.2) 56(84) bytes of data.
64 bytes from 10.23.23.2: icmp_seq=1 ttl=64 time=14.2 ms
64 bytes from 10.23.23.2: icmp_seq=2 ttl=64 time=7.07 ms
64 bytes from 10.23.23.2: icmp_seq=3 ttl=64 time=7.08 ms
Side-B to Side-A:
root@tpc-side-b:~# ping 10.23.23.1
PING 10.23.23.1 (10.23.23.1) 56(84) bytes of data.
64 bytes from 10.23.23.1: icmp_req=1 ttl=64 time=14.1 ms
64 bytes from 10.23.23.1: icmp_req=2 ttl=64 time=7.08 ms
Bidirectional connectivity is operational, with a typical RTT of approximately 7 ms.
Capture Huawei Loop Detection Frames
Huawei generates Ethernet Loop Detection frames using EtherType 0x9998. These frames can be captured on the Linux VLAN interface using tcpdump.
Execute the following command on Side-A:
root@tpc-side-a:~# tcpdump -i vlan2323 -n
Actual tcpdump output:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on vlan2323, link-type EN10MB (Ethernet), snapshot length 262144 bytes
16:10:42.347608 IP6 fe80::9657:a5ff:fe53:950c > ff02::2: ICMP6, router solicitation, length 16
16:13:48.728878 02:00:23:23:00:01 > ff:ff:ff:ff:ff:ff, ethertype Unknown (0x9998), length 60:
0x0000: 0003 0000 0076 0000 0006 0000 0913 0000 .....v..........
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
16:13:51.736874 02:00:23:23:00:01 > ff:ff:ff:ff:ff:ff, ethertype Unknown (0x9998), length 60:
0x0000: 0003 0000 0076 0000 0006 0000 0913 0000 .....v..........
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
16:13:56.758238 02:00:23:23:00:01 > ff:ff:ff:ff:ff:ff, ethertype Unknown (0x9998), length 60:
0x0000: 0003 0000 0076 0000 0006 0000 0913 0000 .....v..........
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
16:14:01.837065 02:00:23:23:00:01 > ff:ff:ff:ff:ff:ff, ethertype Unknown (0x9998), length 60:
0x0000: 0003 0000 0076 0000 0006 0000 0913 0000 .....v..........
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
16:14:06.858249 02:00:23:23:00:01 > ff:ff:ff:ff:ff:ff, ethertype Unknown (0x9998), length 60:
0x0000: 0003 0000 0076 0000 0006 0000 0913 0000 .....v..........
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
16:14:11.885543 02:00:23:23:00:01 > ff:ff:ff:ff:ff:ff, ethertype Unknown (0x9998), length 60:
0x0000: 0003 0000 0076 0000 0006 0000 0913 0000 .....v..........
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
16:14:16.932627 02:00:23:23:00:01 > ff:ff:ff:ff:ff:ff, ethertype Unknown (0x9998), length 60:
0x0000: 0003 0000 0076 0000 0006 0000 0913 0000 .....v..........
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
16:14:21.950802 02:00:23:23:00:01 > ff:ff:ff:ff:ff:ff, ethertype Unknown (0x9998), length 60:
0x0000: 0003 0000 0076 0000 0006 0000 0913 0000 .....v..........
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
16:14:26.978270 02:00:23:23:00:01 > ff:ff:ff:ff:ff:ff, ethertype Unknown (0x9998), length 60:
0x0000: 0003 0000 0076 0000 0006 0000 0913 0000 .....v..........
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
16:14:31.524963 02:00:23:23:00:01 > ff:ff:ff:ff:ff:ff, ethertype Unknown (0x9998), length 60:
0x0000: 0003 0000 0076 0000 0006 0000 0913 0000 .....v..........
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
16:14:36.669029 02:00:23:23:00:01 > ff:ff:ff:ff:ff:ff, ethertype Unknown (0x9998), length 60:
0x0000: 0003 0000 0076 0000 0006 0000 0913 0000 .....v..........
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
Captured frame characteristics:
- EtherType:
0x9998 - Source MAC:
02:00:23:23:00:01 - Destination MAC:
ff:ff:ff:ff:ff:ff - Frame length: 60 bytes
- Observed interval: approximately 5 seconds
Passive Loop Detection Monitoring
The Python utility huawei_loop_test.py can capture Huawei Loop Detection frames without transmitting reflected traffic.
Run the script in listen-only mode:
root@tpc-side-a:~# sudo python3 huawei_loop_test.py -i vlan2323 --timeout 20
16:33:53 LISTEN ONLY: vlan2323, VLAN 2323, source=any, timeout=20s
16:33:58 RX #1: src=02:00:23:23:00:01, length=60
16:34:03 RX #2: src=02:00:23:23:00:01, length=60
16:34:08 RX #3: src=02:00:23:23:00:01, length=60
16:34:13 RX #4: src=02:00:23:23:00:01, length=60
16:34:13 Finished: matched=4, reflected=0
Four Loop Detection frames were received during the monitoring period. No frames were reflected.
Simulate an Ethernet Loop
The Loop Detection validation uses controlled Ethernet frame reflection to simulate a Layer 2 loop.
The Python utility captures Huawei Loop Detection frames and retransmits matching frames through the same Linux VLAN interface. The original destination MAC, source MAC, EtherType, and payload are preserved.
Frame reflection is restricted to the configured source MAC address, VLAN interface, and maximum number of frames.
Warning: A successful reflection test can activate Loop Detection protection and interrupt traffic forwarding. Perform this test only on dedicated LAB or authorized test services.
Execute the Loop Simulation
Run the following command on Side-A:
root@tpc-side-a:~# sudo python3 huawei_loop_test.py \
-i vlan2323 \
--src-mac 02:00:23:23:00:01 \
--reflect \
--count 3 \
--timeout 20
Actual test output:
16:36:04 REFLECT: vlan2323, VLAN 2323, source=02:00:23:23:00:01, timeout=20s
16:36:04 WARNING: service may be blocked. Maximum reflections: 3
16:36:08 RX #1: src=02:00:23:23:00:01, length=60
16:36:08 REFLECTED 1/3: unchanged frame
16:36:13 RX #2: src=02:00:23:23:00:01, length=60
16:36:13 REFLECTED 2/3: unchanged frame
16:36:18 RX #3: src=02:00:23:23:00:01, length=60
16:36:18 REFLECTED 3/3: unchanged frame
16:36:18 Finished: matched=3, reflected=3
All three matching Huawei Loop Detection frames were successfully received and reflected.
Verify Loop Detection Blocking
Immediately check the Ethernet subinterface status on swi-lab-a.
<swi-lab-a>display interface XGigabitEthernet 0/0/36.2323
XGigabitEthernet0/0/36.2323 current state : UP
Line protocol current state : UP (LOOP-DETECT BLOCK)
Description:SIDE-A-SIDE-B_TEST
Route Port,The Maximum Transmit Unit is 9216
Loop Detection successfully triggered.
The UP (LOOP-DETECT BLOCK) status confirms that Huawei detected the reflected Loop Detection frames and activated interface protection.
The physical interface remains UP, while the Loop Detection mechanism blocks forwarding on the affected subinterface.
Repeat the Loop Simulation
The reflection test was repeated to verify consistent Loop Detection behavior.
root@tpc-side-a:~# sudo python3 huawei_loop_test.py \
-i vlan2323 \
--src-mac 02:00:23:23:00:01 \
--reflect \
--count 3 \
--timeout 20
16:43:11 REFLECT: vlan2323, VLAN 2323, source=02:00:23:23:00:01, timeout=20s
16:43:11 WARNING: service may be blocked. Maximum reflections: 3
16:43:14 RX #1: src=02:00:23:23:00:01, length=60
16:43:14 REFLECTED 1/3: unchanged frame
16:43:19 RX #2: src=02:00:23:23:00:01, length=60
16:43:19 REFLECTED 2/3: unchanged frame
16:43:24 RX #3: src=02:00:23:23:00:01, length=60
16:43:24 REFLECTED 3/3: unchanged frame
16:43:24 Finished: matched=3, reflected=3
Huawei interface status after the second reflection test:
<swi-lab-a>display interface XGigabitEthernet 0/0/36.2323
XGigabitEthernet0/0/36.2323 current state : UP
Line protocol current state : UP (LOOP-DETECT BLOCK)
Description:SIDE-A-SIDE-B_TEST
Route Port,The Maximum Transmit Unit is 9216
Both reflection tests successfully triggered LOOP-DETECT BLOCK on the protected subinterface.
Verify Automatic Interface Recovery
The Python reflector automatically terminates after transmitting the configured three frames. It does not continuously replay frames or wait for the Huawei interface to recover.
Once the loop condition is removed, Huawei automatically clears Loop Detection protection according to the configured recovery timer.
loop-detect recovery-time 60
Verify Interface Status
Check the interface after the recovery period:
<swi-lab-a>display interface XGigabitEthernet 0/0/36.2323
XGigabitEthernet0/0/36.2323 current state : UP
Line protocol current state : UP
Description:SIDE-A-SIDE-B_TEST
Route Port,The Maximum Transmit Unit is 9216
Internet protocol processing : disabled
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 0200-2323-0001
The LOOP-DETECT BLOCK state has cleared, and the subinterface has returned to normal UP/UP operation.
Verify End-to-End Connectivity
Verify connectivity between Side-B and Side-A after recovery.
root@tpc-side-b:~# ping 10.23.23.1
PING 10.23.23.1 (10.23.23.1) 56(84) bytes of data.
64 bytes from 10.23.23.1: icmp_req=1 ttl=64 time=7.10 ms
64 bytes from 10.23.23.1: icmp_req=2 ttl=64 time=7.06 ms
64 bytes from 10.23.23.1: icmp_req=3 ttl=64 time=7.08 ms
64 bytes from 10.23.23.1: icmp_req=4 ttl=64 time=7.07 ms
64 bytes from 10.23.23.1: icmp_req=68 ttl=64 time=14.1 ms
64 bytes from 10.23.23.1: icmp_req=69 ttl=64 time=7.10 ms
64 bytes from 10.23.23.1: icmp_req=70 ttl=64 time=7.07 ms
The interface recovered automatically, and ICMP connectivity was confirmed. The configured recovery timer is 60 seconds; the exact recovery duration was not separately measured.
Conclusion
The LAB successfully demonstrated Huawei Layer 2 Loop Detection on an Ethernet subinterface bound to an MPLS L2VPN VSI.
Controlled reflection of Huawei Loop Detection frames with EtherType 0x9998 triggered LOOP-DETECT BLOCK on the protected subinterface.
After the reflection stopped, the interface automatically recovered to its normal UP/UP state. The test was repeated with consistent results.
The validation confirms that Huawei Loop Detection operates correctly on the tested VSI-bound Ethernet subinterface. End-to-end MPLS L2VPN connectivity was also verified independently.
To validate remote loop detection through the MPLS pseudowire itself, an additional frame reflection test must be performed from Side-B.
Here is the Python script for the loopback test simulations (huawei_loop_test.py):
#!/usr/bin/env python3
"""Bounded Huawei 0x9998 probe reflector for a Linux VLAN interface.
Listen only by default. --reflect requires one explicit source MAC.
Use only on an authorized test service: a successful test can block it.
"""
import argparse
import re
import socket
import sys
import time
from pathlib import Path
ETHERTYPE = 0x9998
BROADCAST = b"\xff" * 6
MIN_INTERVAL = 1.0 # Never reflect more than one frame per second.
def log(message: str) -> None:
print(time.strftime("%H:%M:%S"), message, flush=True)
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("-i", "--interface", required=True,
help="Linux VLAN interface, e.g. vlan2323")
parser.add_argument("--vlan", type=int, default=2323,
help="Required VLAN ID (default: 2323)")
parser.add_argument("--src-mac", help="Reflect only this probe source MAC")
parser.add_argument("--reflect", action="store_true",
help="Transmit matching probes back; otherwise listen only")
parser.add_argument("--count", type=int, default=1,
help="Maximum frames to reflect: 1-5 (default: 1)")
parser.add_argument("--timeout", type=int, default=20,
help="Maximum run time: 1-30 seconds (default: 20)")
args = parser.parse_args()
if not 1 <= args.count <= 5 or not 1 <= args.timeout <= 30:
parser.error("--count must be 1-5 and --timeout must be 1-30")
if not 1 <= args.vlan <= 4094:
parser.error("--vlan must be 1-4094")
if args.reflect and not args.src_mac:
parser.error("--reflect requires --src-mac")
source = None
if args.src_mac:
if not re.fullmatch(r"(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}", args.src_mac):
parser.error("Use MAC format aa:bb:cc:dd:ee:ff")
source = bytes.fromhex(args.src_mac.replace(":", ""))
if source == b"\x00" * 6 or source[0] & 1:
parser.error("The source MAC must be a nonzero unicast MAC")
# Refuse a physical trunk or an interface on the wrong VLAN.
socket.if_nametoindex(args.interface)
try:
vlan_info = Path("/proc/net/vlan", args.interface).read_text()
except OSError:
parser.error("Use an existing Linux VLAN interface, not its parent trunk")
match = re.search(r"\bVID:\s*(\d+)", vlan_info)
if not match or int(match.group(1)) != args.vlan:
parser.error(f"{args.interface} is not VLAN {args.vlan}")
matched = sent = 0
last_sent = float("-inf")
mode = "REFLECT" if args.reflect else "LISTEN ONLY"
log(f"{mode}: {args.interface}, VLAN {args.vlan}, "
f"source={args.src_mac or 'any'}, timeout={args.timeout}s")
if args.reflect:
log(f"WARNING: service may be blocked. Maximum reflections: {args.count}")
# Start with protocol 0 (receive nothing), then bind to this interface
# and EtherType only. The Python AF_PACKET bind protocol is host-order.
with socket.socket(socket.AF_PACKET, socket.SOCK_RAW, 0) as sock:
sock.bind((args.interface, ETHERTYPE))
deadline = time.monotonic() + args.timeout
try:
while time.monotonic() < deadline:
sock.settimeout(max(0.001, min(1.0, deadline - time.monotonic())))
try:
frame, address = sock.recvfrom(65535)
except socket.timeout:
continue
# Only incoming Ethernet broadcasts, never our own TX copies.
if address[0] != args.interface or address[2] != socket.PACKET_BROADCAST:
continue
if len(frame) < 14 or frame[:6] != BROADCAST:
continue
if frame[12:14] != b"\x99\x98":
continue
if source is not None and frame[6:12] != source:
continue
matched += 1
mac = frame[6:12].hex(":")
log(f"RX #{matched}: src={mac}, length={len(frame)}")
now = time.monotonic()
if not args.reflect or now >= deadline:
continue
if now - last_sent < MIN_INTERVAL:
log("Skipped: rate limit")
continue
# Preserve destination, source, EtherType, and payload exactly.
# The VLAN device supplies its VLAN tag on egress.
if sock.send(frame) != len(frame):
raise OSError("Incomplete frame transmission")
sent += 1
last_sent = time.monotonic()
log(f"REFLECTED {sent}/{args.count}: unchanged frame")
if sent >= args.count:
break
except KeyboardInterrupt:
log("Stopped by Ctrl+C")
finally:
log(f"Finished: matched={matched}, reflected={sent}")
return 0
if __name__ == "__main__":
try:
sys.exit(main())
except PermissionError:
sys.exit("ERROR: run with sudo/root (CAP_NET_RAW is required)")
except OSError as exc:
sys.exit(f"ERROR: {exc}")
root@terminal-nkf-ams:~#