Skip to content

zebra: ignore events of a vxlan the VNI is not bound to - #24239

Open
bchanot-alphalink wants to merge 3 commits into
FRRouting:masterfrom
Alphalink:pr/vxlan-stale-events
Open

bchanot-alphalink wants to merge 3 commits into
FRRouting:masterfrom
Alphalink:pr/vxlan-stale-events

Conversation

@bchanot-alphalink

@bchanot-alphalink bchanot-alphalink commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

With netns VRFs (-n), a vxlan interface is commonly created in one
netns and then moved into the netns of its VRF. Two problems leave an
L3-VNI without its vxlan in that setup.

Events of the old interface (first commit). For a while zebra sees
two interfaces with the same VNI, and the netlink sockets of the two
netns deliver their events in any order. The add binds the VNI to the
new interface; a down or delete of the old one, handled after it,
unbinds the VNI (the L3-VNI stays down with no vxlan) or makes zebra
abort on assert(zevpn->vxlan_if == ifp) in
zebra_vxlan_if_vni_down() / zebra_vxlan_if_vni_up().

This change handles the down and delete events of a vxlan, and the
L2-VNI up event, only when the VNI is bound to that interface: the
check is added to the L3-VNI delete and down, and the two L2-VNI
assertions become this check. The L2-VNI delete already has it since
080f85a (#23659).

Unknown netns id (third commit). zebra_ns_id_get() binds its
netlink socket with nl_groups = RTNLGRP_NSID. nl_groups is a bitmask
of groups 1 to 32, so the value 28 joins RTNLGRP_NEIGH, RTNLGRP_TC and
RTNLGRP_IPV4_IFADDR, never RTNLGRP_NSID. The reply to RTM_GETNSID is
read as the first message on the socket: when an address notification
of the netns arrives first (lo being set up while zebra discovers the
netns), the sequence check fails and the id is NS_UNKNOWN. When that id
is the one of the default netns seen from the new netns, every
interface moved into the netns gets an unknown link netns, and the
L3-VNI is never bound to its vxlan:

netlink recvmsg: bad sequence number 82411 (expected 0)
Intf vx1110(114) VNI 1110, link not in same namespace as BGP EVPN core instance

(the log prints the two values swapped: 0 is the sequence number
received, from the notification.) When it is the id of the new netns
itself, the netns is ignored. RTM_GETNSID is answered on the socket
itself, so the fix binds with no group.

Testing

New topotest zebra_evpn_netns_vxlan_stale: 120 netns VRFs created at
once, three times, each with a bridge and a vxlan created in the
default netns and moved into the VRF netns; after each round, every
L3-VNI must still be bound to its vxlan interface.

  • 10.7.1 without the fix: zebra aborts on the assertion, or leaves an
    L3-VNI without its vxlan, in 1 run out of 7 on our rig.
  • Builds with the first two commits only: the test still failed in 9
    runs out of 60, always one L3-VNI out of 120 with no vxlan. Tracing
    zebra with uprobes on two of these failures showed the netns id read
    as unknown for that VRF (and only that one), with the "bad sequence
    number" above in zebra.log.
  • With the three commits: 60 runs out of 60 pass, on two builds. A
    further 20 traced runs saw 7200 netns discoveries, none with an
    unknown id, and no "bad sequence number".

The zebra, static and EVPN topotests touching netns VRFs
(zebra_vrf_netns, zebra_netns_vrf_delete, bgp_evpn_vxlan_topo1,
bgp_evpn_rt5, bgp_evpn_l3vni_modify, evpn_type5_test_topo1, ...)
pass on the same rig.

On our lab, creating 70 EVPN domains at once with the vxlan moved into
the netns (as our orchestrator does) left up to 54 of 70 L3-VNIs down
and made zebra abort on 10.7.1; with the fix, 70 of 70 L3-VNIs are up
on every pass.

Related Issue

None. Related: #23659.

Components

zebra, tests

@frrbot frrbot Bot added tests Topotests, make check, etc zebra labels Nov 6, 2026
@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with a non-blocking gap in the regression test.

Findings

  1. P2 Broken VNIs pass the test ▶
Fix with agent prompt
### Issue 1
tests/topotests/zebra_evpn_netns_vxlan_stale/test_zebra_evpn_netns_vxlan_stale.py:126-128
The new test only checks whether daemons are alive. It still passes if stale events leave an L3-VNI down or without its VXLAN interface-the other failure this PR fixes. It also configures L3-VNIs after moving the interfaces, so it does not reliably exercise that failure.

Configure L3-VNIs before moving the interfaces in a test round, then wait for every expected VNI to be up and bound to the destination interface.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR ignores VXLAN events when the VNI belongs to another interface.

  • Zebra ignores stale VXLAN events from interfaces no longer bound to a VNI.

Reviews (2) · Last reviewed commit: "tests: zebra_evpn_netns_vxlan_stale" · Reviewed by Greptile

Comment on lines +113 to +115
create_vrfs(r1, first)
time.sleep(10)
assert not r1.check_router_running(), "a daemon crashed, round {}".format(n)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Broken VNIs pass the test

The new test only checks whether daemons are alive. It still passes if stale events leave an L3-VNI down or without its VXLAN interface—the other failure this PR fixes. It also configures L3-VNIs after moving the interfaces, so it does not reliably exercise that failure.

Configure L3-VNIs before moving the interfaces in a test round, then wait for every expected VNI to be up and bound to the destination interface.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/topotests/zebra_evpn_netns_vxlan_stale/test_zebra_evpn_netns_vxlan_stale.py
Line: 113-115

Comment:
**Broken VNIs pass the test**

The new test only checks whether daemons are alive. It still passes if stale events leave an L3-VNI down or without its VXLAN interface—the other failure this PR fixes. It also configures L3-VNIs after moving the interfaces, so it does not reliably exercise that failure.

Configure L3-VNIs before moving the interfaces in a test round, then wait for every expected VNI to be up and bound to the destination interface.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@bchanot-alphalink bchanot-alphalink changed the title zebra: ignore events of a vxlan the VNI is not bound to zebra: ignore events of a vxlan the VNI is not bound to Nov 6, 2026
first = VNI0 + n * VRFS
logger.info("round %d: VRFs %d..%d", n, first, first + VRFS - 1)
create_vrfs(r1, first)
time.sleep(10)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

straight up sleeps are a nak. You must use run_and_expect and look for appropriate state if you must wait.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: the sleep calls are gone. The test now polls with run_and_expect() until no daemon has died and every L3-VNI of the round has its vxlan interface, and vtep0 is created with create_interface_in_kernel().

@bchanot-alphalink
bchanot-alphalink force-pushed the pr/vxlan-stale-events branch 2 times, most recently from edc966e to 7e71c9b Compare November 10, 2026 12:09
@github-actions github-actions Bot added the rebase PR needs rebase label Nov 11, 2026
@bchanot-alphalink

Copy link
Copy Markdown
Contributor Author

I added a third commit, "zebra: do not join netlink groups to read a
netns id". Under load, the new topotest still failed about once in 7
runs with the first two commits: one L3-VNI out of 120 left with no
vxlan. Tracing zebra on the failing runs showed the id of the default
netns, seen from that VRF's netns, read as unknown, so the vxlan moved
into it was rejected as "link not in same namespace as BGP EVPN core
instance".

The cause is the socket of zebra_ns_id_get(): nl_groups = RTNLGRP_NSID is a bitmask, 28 joins the NEIGH, TC and IPV4_IFADDR
groups, and an address notification can be read in place of the
RTM_GETNSID reply. The line dates from the netns id support (2017), so
master has it too. With the fix, 60 runs out of 60 pass and no netns id
is read as unknown; the description has the details.

The remaining CI failure, bgp_extcommunity_invalid_config, fails on
master as well (the test expects a message bgpd no longer prints; see
#24357 and #24316). The grpc_basic core and the bgp_evpn_mh failure on
one job passed when rerun.

@github-actions github-actions Bot removed the rebase PR needs rebase label Nov 12, 2026
Comment thread zebra/zebra_vxlan_if.c Outdated
}

assert(zevpn->vxlan_if == ifp);
/* Not the interface the VNI is bound to, see zebra_vxlan_if_del_vni() */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go through and remove the obvious comments that the LLM has introduced. There is nothing hard or strange here, the comments add nothing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, sorry about those, removed the three of them. I kept the one in zebra_vxlan_if_del_vni function since it says why a vxlan can be seen twice, but I can drop it too if you'd rather.

for i in $(seq {first} {last}); do
ip netns add vrf$i
(
ip -n vrf$i link set lo up

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the appropriate helper functions in tests/topotests/lib. Just straight up adding a bajillion creation is not the right way to do this. If there is no appropriate functionality add one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the creation into a new helper in lib/evpn.py

With netns VRFs (-n), a vxlan interface is commonly created in one
netns and then moved into the netns of its VRF. For a while zebra sees
two interfaces with the same VNI: the old one is deleted from the first
netns while the new one is added to the second, and the netlink sockets
of the two netns deliver these events in any order.

The add binds the VNI to the new interface. A down or a delete of the
old interface, handled after it, then unbinds the VNI (the L3-VNI stays
down without a vxlan interface), or zebra aborts on
assert(zevpn->vxlan_if == ifp) in zebra_vxlan_if_vni_down() or
zebra_vxlan_if_vni_up().

Handle the down and delete events of a vxlan, and the L2-VNI up event,
only when the VNI is bound to that interface: add the check to the
L3-VNI delete and down, and turn the two L2-VNI assertions into it.
The L2-VNI delete already has it since 080f85a.

Signed-off-by: Bastien CHANOT <b.chanot@alphalink.fr>
Create 120 netns VRFs at once, three times, each with a bridge and a
vxlan created next to zebra and moved into the netns, then give each
VRF its L3-VNI. zebra sees two interfaces with the same VNI for a
while and gets their events in any order. It aborted on
assert(zevpn->vxlan_if == ifp) in zebra_vxlan_if_vni_down(), or the
delete of the old vxlan unbound the VNI from the new one: check that
zebra survives and that every L3-VNI keeps its vxlan interface.

Signed-off-by: Bastien CHANOT <b.chanot@alphalink.fr>
zebra_ns_id_get() binds its netlink socket with nl_groups set to
RTNLGRP_NSID. nl_groups is a bitmask of the groups 1 to 32: the value
28 joins RTNLGRP_NEIGH, RTNLGRP_TC and RTNLGRP_IPV4_IFADDR, and never
RTNLGRP_NSID. The reply is read as the first message on the socket, so
an address or neighbor notification of the netns, as when lo is set up
while zebra discovers the netns, is taken for the reply: the sequence
check fails and the netns id is unknown.

For the id of the default netns seen from a new netns, every interface
moved into that netns then gets an unknown link netns, and an L3-VNI
is never bound to its vxlan ("link not in same namespace as BGP EVPN
core instance"). For the id of the new netns itself, the netns is
ignored.

The id is always read with RTM_GETNSID, answered on the socket itself:
no group is needed.

Signed-off-by: Bastien CHANOT <b.chanot@alphalink.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

master size/L tests Topotests, make check, etc zebra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants