Repository navigation
zebra: ignore events of a vxlan the VNI is not bound to - #24239
bchanot-alphalink wants to merge 3 commits into
Conversation
[Medium impact] The PR appears safe to merge, with a non-blocking gap in the regression test. Findings
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.SummaryThe PR ignores VXLAN events when the VNI belongs to another interface.
Reviews (2) · Last reviewed commit: "tests: zebra_evpn_netns_vxlan_stale" · Reviewed by Greptile |
| create_vrfs(r1, first) | ||
| time.sleep(10) | ||
| assert not r1.check_router_running(), "a daemon crashed, round {}".format(n) |
There was a problem hiding this comment.
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!
3985db1 to
e860840
Compare
| first = VNI0 + n * VRFS | ||
| logger.info("round %d: VRFs %d..%d", n, first, first + VRFS - 1) | ||
| create_vrfs(r1, first) | ||
| time.sleep(10) |
There was a problem hiding this comment.
straight up sleeps are a nak. You must use run_and_expect and look for appropriate state if you must wait.
There was a problem hiding this comment.
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().
edc966e to
7e71c9b
Compare
|
I added a third commit, "zebra: do not join netlink groups to read a The cause is the socket of The remaining CI failure, |
ddb6c61 to
965cc5b
Compare
| } | ||
|
|
||
| assert(zevpn->vxlan_if == ifp); | ||
| /* Not the interface the VNI is bound to, see zebra_vxlan_if_del_vni() */ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
965cc5b to
ed392f1
Compare
Summary
With netns VRFs (
-n), a vxlan interface is commonly created in onenetns 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)inzebra_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 itsnetlink socket with
nl_groups = RTNLGRP_NSID.nl_groupsis a bitmaskof 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:
(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 atonce, 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.
L3-VNI without its vxlan, in 1 run out of 7 on our rig.
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.
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