Commit 8e5574f983 for frr
commit 8e5574f9833ffb7e2492c43425ff576512055e64
Author: Enke Chen <enchen@paloaltonetworks.com>
Date: Wed Oct 21 11:29:41 2026 -0700
tests: add topotest for default-originate with set-only route-map
Add test to verify that default-originate with a set-only route-map
(no match clauses) works correctly even when the BGP table is empty.
The test configures R1 with default-originate using a route-map that
only sets community 65001:200, with no other BGP routes. R2 should
receive the default route with the community applied.
Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
diff --git a/tests/topotests/bgp_default_originate_setonly/__init__.py b/tests/topotests/bgp_default_originate_setonly/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/topotests/bgp_default_originate_setonly/r1/frr.conf b/tests/topotests/bgp_default_originate_setonly/r1/frr.conf
new file mode 100644
index 0000000000..08fbca5215
--- /dev/null
+++ b/tests/topotests/bgp_default_originate_setonly/r1/frr.conf
@@ -0,0 +1,18 @@
+!
+interface r1-eth0
+ ip address 192.168.1.1/24
+!
+route-map SET_COMM permit 10
+ set community 65001:200
+!
+router bgp 65001
+ no bgp ebgp-requires-policy
+ bgp default-originate set-only-unconditional
+ neighbor 192.168.1.2 remote-as external
+ neighbor 192.168.1.2 timers 1 3
+ neighbor 192.168.1.2 timers connect 1
+ address-family ipv4 unicast
+ neighbor 192.168.1.2 default-originate route-map SET_COMM
+ neighbor 192.168.1.2 send-community
+ exit-address-family
+!
diff --git a/tests/topotests/bgp_default_originate_setonly/r2/frr.conf b/tests/topotests/bgp_default_originate_setonly/r2/frr.conf
new file mode 100644
index 0000000000..7213975cc0
--- /dev/null
+++ b/tests/topotests/bgp_default_originate_setonly/r2/frr.conf
@@ -0,0 +1,10 @@
+!
+interface r2-eth0
+ ip address 192.168.1.2/24
+!
+router bgp 65002
+ no bgp ebgp-requires-policy
+ neighbor 192.168.1.1 remote-as external
+ neighbor 192.168.1.1 timers 1 3
+ neighbor 192.168.1.1 timers connect 1
+!
diff --git a/tests/topotests/bgp_default_originate_setonly/test_bgp_default_originate_setonly.py b/tests/topotests/bgp_default_originate_setonly/test_bgp_default_originate_setonly.py
new file mode 100644
index 0000000000..2919c1eda9
--- /dev/null
+++ b/tests/topotests/bgp_default_originate_setonly/test_bgp_default_originate_setonly.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: ISC
+
+# Copyright (c) 2026, Palo Alto Networks, Inc.
+# Enke Chen <enchen@paloaltonetworks.com>
+
+"""
+Test BGP default-originate with set-only route-map.
+
+When default-originate is configured with a route-map that has only "set"
+clauses (no "match" clauses), the default route should be originated
+unconditionally, with the set clauses applied. This should work even
+when the BGP table is empty.
+
+Topology:
+ R1 (AS 65001) ---- R2 (AS 65002)
+
+R1 configuration:
+ - default-originate with route-map SET_COMM (sets community 65001:200)
+ - NO other BGP routes (empty table)
+"""
+
+import os
+import sys
+import json
+import pytest
+import functools
+
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+
+from lib import topotest
+from lib.topogen import Topogen, get_topogen
+from lib.common_config import step
+
+pytestmark = [pytest.mark.bgpd]
+
+
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
+
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+
+
+def setup_module(mod):
+ tgen = Topogen(build_topo, mod.__name__)
+ tgen.start_topology()
+
+ router_list = tgen.routers()
+
+ for _, (rname, router) in enumerate(router_list.items(), 1):
+ router.load_frr_config(os.path.join(CWD, "{}/frr.conf".format(rname)))
+
+ tgen.start_router()
+
+
+def teardown_module(mod):
+ tgen = get_topogen()
+ tgen.stop_topology()
+
+
+def test_setonly_routemap():
+ """
+ Verify set-only route-map works with empty BGP table.
+
+ R1 has default-originate with a route-map that only sets community
+ (no match clauses). R1's BGP table is empty. R2 should receive
+ the default route with the community set.
+ """
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ r2 = tgen.gears["r2"]
+
+ step("Verify R2 receives default route with community 65001:200")
+
+ def _check_default_with_community():
+ output = json.loads(r2.vtysh_cmd("show bgp ipv4 unicast 0.0.0.0/0 json"))
+ if "paths" not in output:
+ return "No paths for default route"
+ community = output["paths"][0].get("community", {}).get("string", "")
+ if "65001:200" not in community:
+ return "Community '{}' missing 65001:200".format(community)
+ return None
+
+ test_func = functools.partial(_check_default_with_community)
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ assert result is None, "R2 should receive default route with community 65001:200"
+
+
+if __name__ == "__main__":
+ args = ["-s"] + sys.argv[1:]
+ sys.exit(pytest.main(args))