From 2c2079f1694d9526e2ac2e54aa15a716633a4a0a Mon Sep 17 00:00:00 2001 From: Vadim Semenov Date: Sun, 25 Oct 2026 12:57:41 +0000 Subject: [PATCH] Macvlan connection mode: template, manifest, docs The watcher's FRR gets a private macvlan on a host interface and peers with a device over L2. eth1 stays down until the announcement filter is attached. The watcher never sets the ATT bit. --- README.md | 14 ++- docs/exporters.md | 18 +++- onboarding/manifest.json | 39 ++++++++ tests/test_stop.py | 24 +++++ .../watcher-template/config.macvlan.template | 90 +++++++++++++++++++ watcher/watcher-template/router/frr.template | 6 +- 6 files changed, 187 insertions(+), 4 deletions(-) create mode 100644 watcher/watcher-template/config.macvlan.template diff --git a/README.md b/README.md index 826e0e7..6ea3dda 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ IS-IS Watcher is a monitoring tool of IS-IS topology changes for network enginee ![Link metric change highlighted on the graph](docs/ui/cost-change-on-graph.png) ## Quick start -1. Enterprise: in Topolograph open **Add → Watcher**, choose the type (IS-IS Watcher) and the mode (GRE or BGP-LS) and fill in the form. The wizard issues a watcher token and shows one install command. +1. Enterprise: in Topolograph open **Add → Watcher**, choose the type (IS-IS Watcher) and the mode (GRE, Macvlan or BGP-LS) and fill in the form. The wizard issues a watcher token and shows one install command. ![Add watcher: choose type and mode](docs/ui/watcher-mode.png) @@ -87,11 +87,21 @@ To remove every watcher of the host: `sudo systemctl disable --now topolograph-i ### Connection Modes -IS-IS Watcher supports two connection modes: +IS-IS Watcher supports three connection modes: #### GRE Mode (Traditional) The FRR container is isolated in an individual network namespace and establishes an IS-IS adjacency over a GRE tunnel with a network device. The **announcement filter** (a tc-BPF program on the egress of `gre1`) lets out the hellos and sequence-number PDUs, but of all LSPs only the watcher's own one, and only with the tunnel subnet as its prefix. Any other LSP, extra prefix or malformed PDU is dropped, so the watcher cannot populate the network with unexpected prefixes or forward the network's LSPs. +#### Macvlan Mode +The watcher's FRR gets a macvlan interface (`eth1`, private mode) on a host network interface, physical or a VLAN subinterface such as `ens192.100`, and forms an IS-IS adjacency directly with the network device on that L2 segment. There is no GRE tunnel, no iptables and no NAT. The announcement filter is always attached to `eth1` egress and passes only the watcher's own LSP; `eth1` is held down until the filter is attached, so a failed filter means no adjacency. + +Limits: +* The router needs L2 reachability to the host interface (access port or VLAN) and point-to-point IS-IS on its side, with the same MTU. +* The switch port must accept the watcher's extra MAC address: with port security, allow it; on a virtual switch allow MAC changes and forged transmits. Public clouds usually do not. +* One watcher per host interface. +* `onboarding/diagnostic.sh` covers GRE mode only. +* `onboarding/stop.sh` and `containerlab destroy` remove the macvlan interface only; the host interface stays. + #### BGP-LS Mode The watcher connects to a network router via BGP-LS (BGP Link-State) protocol. The router must be configured to advertise IS-IS topology information via BGP-LS. The watcher uses GoBGP (bgplswatcher) to establish a BGP session and receive BGP-LS updates, which are then processed by the IS-IS watcher component. This mode eliminates the need for GRE tunnels and IS-IS adjacencies, making it easier to deploy in environments where GRE tunnels are not feasible. diff --git a/docs/exporters.md b/docs/exporters.md index 5772f19..28e240a 100644 --- a/docs/exporters.md +++ b/docs/exporters.md @@ -131,6 +131,21 @@ GRE mode, with the explanation of each field (JSON has no comments, so they foll } } ``` +Macvlan mode: +```json +{ + "watcher_id": "lab3", + "name": "isis-lab-3", + "connection_mode": "macvlan", + "answers": { + "macvlan_parent_interface": "ens192.100", + "macvlan_ip_w_mask_watcher": "10.20.30.2/24", + "isis_area_num": "49.0001", + "organisation_name": "my-org", + "asn": "65001" + } +} +``` BGP-LS mode: ```json { @@ -151,10 +166,11 @@ BGP-LS mode: ``` * `watcher_id` - any unique id you choose: 1 to 64 letters, digits, `.`, `_` or `-`. A watcher is found again by it, so keep it when you change the answers. * `name` - the watcher's name in messages and log lines. -* `connection_mode` - `gre` or `bgpls`. +* `connection_mode` - `gre`, `macvlan` or `bgpls`. * `gre_tunnel_network_device_ip` - the router's own IPv4 address the GRE tunnel ends on; `host_interface_device_ip` - this host's IPv4 address the router sends GRE to. They must differ. * `gre_tunnel_ip_w_mask_network_device` and `gre_tunnel_ip_w_mask_watcher` - the two tunnel addresses with their mask; they must be in one network and differ from each other and from the two outer addresses. * `gre_tunnel_number` - a number from 1 to 9999 that names the host-side interface (`isis-gre`, at most 15 characters). +* `macvlan_parent_interface` - an existing host interface (at most 15 characters of letters, digits, `.`, `_`, `-`), such as `ens192` or `ens192.100`; one watcher per interface. `macvlan_ip_w_mask_watcher` - the watcher's IPv4 address with the mask of the segment. * `isis_area_num` - the area, `49.` and four digits, such as `49.0001`. * `is_filter_enabled` - `true` attaches the announcement filter, `false` leaves the tunnel unfiltered. Change it and run `render` again to switch. * `bgpls_router_ip`, `bgpls_router_as`, `bgpls_watcher_as`, `bgpls_router_id` - the BGP peer and the watcher's AS and router id; AS numbers are 1 to 4294967295, and different ones make the session eBGP with multihop TTL 255. `bgpls_passive_mode` - `true` waits for the router to connect, and only one passive BGP-LS watcher fits a host (port 179). diff --git a/onboarding/manifest.json b/onboarding/manifest.json index 634dd30..20de714 100644 --- a/onboarding/manifest.json +++ b/onboarding/manifest.json @@ -28,6 +28,23 @@ } ] }, + { + "id": "macvlan", + "title": "Macvlan", + "description": "The watcher gets a macvlan interface on a host network interface and forms an IS-IS adjacency directly with a network device on the same L2 segment. No tunnel. The announcement filter is always on and passes only the watcher's own announcement.", + "router_requirements": [ + "L2 segment (access port or VLAN) from the router to the watcher host network interface", + "The switch port accepts the watcher's extra MAC address (port security off or allowing it; on a virtual switch allow MAC changes and forged transmits)", + "IS-IS on the segment, point-to-point network type", + "The same MTU on both ends" + ], + "router_examples": [ + { + "vendor": "Cisco", + "config": "interface \n ip address
\n ip router isis \n isis network point-to-point" + } + ] + }, { "id": "bgpls", "title": "BGP-LS", @@ -148,6 +165,28 @@ "gre" ] }, + { + "id": "macvlan_parent_interface", + "label": "Host interface the watcher attaches to, physical or VLAN subinterface", + "diagram_label": "1", + "type": "string", + "source": "user", + "pattern": "^[A-Za-z0-9._-]{1,15}$", + "help": "An existing interface of the watcher host, for example ens192 or ens192.100. One watcher per interface.", + "modes": [ + "macvlan" + ] + }, + { + "id": "macvlan_ip_w_mask_watcher", + "label": "Watcher IP on the segment, with mask", + "diagram_label": "2", + "type": "ip_interface", + "source": "user", + "modes": [ + "macvlan" + ] + }, { "id": "is_filter_enabled", "label": "Announcement filter: only the watcher's own LSP leaves the tunnel", diff --git a/tests/test_stop.py b/tests/test_stop.py index 90375f1..b1b9016 100644 --- a/tests/test_stop.py +++ b/tests/test_stop.py @@ -120,3 +120,27 @@ def test_stop_of_one_watcher_leaves_the_other(tmp_path, has_containers): ] assert (tmp_path / "iptables").read_text().splitlines() == [ line for rule in rules for line in (f"-w -C {rule}", f"-w -D {rule}")] + + +def test_stop_of_a_macvlan_watcher_only_destroys_its_lab(tmp_path): + (tmp_path / "onboarding").mkdir() + shutil.copy(REPO_ROOT / "onboarding" / "stop.sh", tmp_path / "onboarding" / "stop.sh") + bin_path = tmp_path / "bin" + bin_path.mkdir() + fakes = {**FAKE_COMMANDS, + "containerlab": 'echo "$*" >> "$LOG_DIR/containerlab"; exit 0', + "docker": "echo abc123; exit 0", + "ip": 'echo "$*" >> "$LOG_DIR/ip"; exit 0'} + for name, fake_body in fakes.items(): + (bin_path / name).write_text(f"#!/bin/sh\n{fake_body}\n") + (bin_path / name).chmod(0o755) + config = tmp_path / "config.yml" + config.write_text("name: watcher1-mv-ens192-100-isis\n") + environment = {**os.environ, "PATH": f"{bin_path}:{os.environ['PATH']}", "LOG_DIR": str(tmp_path)} + + result = subprocess.run(["bash", str(tmp_path / "onboarding" / "stop.sh"), str(config)], env=environment) + + assert result.returncode == 0 + assert (tmp_path / "containerlab").read_text().splitlines() == [f"destroy -t {config}"] + # The parent interface belongs to the host: nothing may delete it, and no GRE flow exists to clean + assert not (tmp_path / "ip").exists() and not (tmp_path / "iptables").exists() and not (tmp_path / "conntrack").exists() diff --git a/watcher/watcher-template/config.macvlan.template b/watcher/watcher-template/config.macvlan.template new file mode 100644 index 0000000..e0c8e36 --- /dev/null +++ b/watcher/watcher-template/config.macvlan.template @@ -0,0 +1,90 @@ +name: {{watcher_folder_name}} +prefix: __lab-name + +topology: + defaults: + env-files: + - ../../.env + labels: + connection_mode: macvlan + macvlan_parent_interface: {{macvlan_parent_interface}} + macvlan_ip_w_mask_watcher: {{macvlan_ip_w_mask_watcher}} + area_num: {{area_num}} + asn: {{asn}} + organisation_name: {{organisation_name}} + watcher_name: {{watcher_name}} + watcher_id: {{watcher_id}} + nodes: + isis-watcher: + kind: linux + image: {{image_watcher}} + network-mode: container:router + env: + ASN: {{asn}} + WATCHER_NAME: {{watcher_name}} + AREA_NUM: {{area_num}} + WATCHER_INTERFACE: eth1 + WATCHER_LOGFILE: /home/watcher/watcher/logs/watcher.log + WATCHER_IP: {{macvlan_watcher_ip}} +{{#server}} + TOPOLOGRAPH_HOST: {{topolograph_host}} + TOPOLOGRAPH_PORT: {{topolograph_port}} + TOPOLOGRAPH_API_TOKEN: {{watcher_token}} +{{/server}} + binds: + - ../logs/:/home/watcher/watcher/logs/ + - ../logs/{{watcher_folder_name}}.isis.log:/home/watcher/watcher/logs/watcher.log + stages: + create: + wait-for: + - node: receive_only_filter + stage: exit + logrotation: + kind: linux + # https://github.com/Vadims06/docker-logrotate + image: {{image_logrotation}} + env: + LOGROTATE_FILE_PATTERN: '*.log' + # don't rotate at all but truncate log, because only single log file is bind to this container + LOGROTATE_ROTATE: '0' + LOGROTATE_SIZE: 500M + # once a day + LOGROTATE_CRON: 0 0 * * * + binds: + - ../logs/{{watcher_folder_name}}.isis.log:/logs/watcher.log + router: + kind: linux + image: {{image_router}} + binds: + - router/daemons:/etc/frr/daemons + - router/frr.conf:/etc/frr/frr.conf + - router/vtysh.conf:/etc/frr/vtysh.conf + exec: + # containerlab brings the macvlan up; it stays down until the filter is attached, so no filter means no adjacency + - ip link set dev eth1 down + receive_only_filter: + kind: linux + image: {{image_filter}} + startup-delay: 2 + # in the FRR namespace: eth1 is there, and the host network stays out of reach + network-mode: container:router + # one-shot node: it attaches the announcement filter, brings eth1 up and exits, so it must not be restarted + restart-policy: no + env: + FILTER_INTERFACE: eth1 + WATCHER_SYSTEM_ID: {{watcher_system_id}} + TUNNEL_NETWORK: {{tunnel_network}} + TUNNEL_PREFIX_LEN: '{{tunnel_prefix_len}}' + stages: + create: + wait-for: + - node: router + stage: configure + links: + # private: two watchers on one parent interface never see each other + - type: macvlan + endpoint: + node: router + interface: eth1 + host-interface: {{macvlan_parent_interface}} + mode: private diff --git a/watcher/watcher-template/router/frr.template b/watcher/watcher-template/router/frr.template index 2e350bc..a95f4e3 100644 --- a/watcher/watcher-template/router/frr.template +++ b/watcher/watcher-template/router/frr.template @@ -7,7 +7,10 @@ ipv6 forwarding password zebra enable password zebra ! -interface gre1 +interface {{interface_name}} +{{#macvlan}} + ip address {{macvlan_ip_w_mask_watcher}} +{{/macvlan}} ip router isis watcher1 ipv6 router isis watcher1 isis csnp-interval 600 @@ -19,6 +22,7 @@ exit router isis watcher1 net {{system_id}} no hostname dynamic + no attached-bit send ! route-map TO_KERNEL deny 200 exit