Skip to content

zebra: Get link from the correct netns for vxlan - #8895

Merged
riw777 merged 1 commit into
FRRouting:masterfrom
leonshaw:vxlan-ns
May 18, 2026
Merged

zebra: Get link from the correct netns for vxlan#8895
riw777 merged 1 commit into
FRRouting:masterfrom
leonshaw:vxlan-ns

Conversation

@leonshaw

Copy link
Copy Markdown
Contributor

If VRF backend is netns, bridges and SVIs are in the VRF's netns.
Get link information from there, rather than NS_DEFAULT.

@polychaeta polychaeta left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for your contribution to FRR!

Click for style suggestions

To apply these suggestions:

curl -s https://gist.githubusercontent.com/polychaeta/3a197daf037246e29f9818d19414be2d/raw/08ce2bd16556525e398625a668c26e0c1a25362b/cr_8895_1624328326.diff | git apply

diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 8a7b12c0b..873e4e462 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -2032,7 +2032,8 @@ static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf, vni_t vni,
 				   vni);
 
 		/* Find VxLAN interface for this VNI. */
-		for (rn = route_top(zvrf->zns->if_table); rn; rn = route_next(rn)) {
+		for (rn = route_top(zvrf->zns->if_table); rn;
+		     rn = route_next(rn)) {
 			ifp = (struct interface *)rn->info;
 			if (!ifp)
 				continue;

If you are a new contributor to FRR, please see our contributing guidelines.

After making changes, you do not need to create a new PR. You should perform an amend or interactive rebase followed by a force push.

@NetDEF-CI

NetDEF-CI commented Jun 22, 2021

Copy link
Copy Markdown
Collaborator
Continuous Integration Result: FAILED

Continuous Integration Result: FAILED

See below for issues.
CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-19737/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

Get source / Pull Request: Failed

Checkout code: Failed (click for details) Checkout code: No useful log found

@LabN-CI

LabN-CI commented Jun 22, 2021

Copy link
Copy Markdown
Collaborator
Outdated results 💚

Basic BGPD CI results: SUCCESS, 0 tests failed

_ _
Result 0
Date
Start
Finish vncregress-2021-06-21-22:20:50.txt
Run-Time autoscript-2021-06-21-22:22:01.log.bz2
Total 516 501 424
Pass SUCCESS git merge/8584 c921cf3
Fail 04/27/2021
Valgrind-Errors 22:20:50
Valgrind-Loss 23:01:55
Details 41:05
Log 1815
Memory 1815
SUCCESS git merge/8895 33df0a8 0
06/21/2021 0
22:20:50 0
22:46:14 vncregress-2021-04-27-22:20:50.txt
25:24 autoscript-2021-04-27-22:22:00.log.bz2
1815 502 505 428
1815

For details, please contact louberger

@LabN-CI

LabN-CI commented Jun 22, 2021

Copy link
Copy Markdown
Collaborator
Outdated results 🚧

Basic BGPD CI results: Partial FAILURE, 1 tests failed

_ _
Result 1
Date
Start
Finish vncregress-2021-06-21-22:50:51.txt
Run-Time autoscript-2021-06-21-22:52:10.log.bz2
Total 510 502 429
Pass SUCCESS git merge/8556 7e0ea66
Fail 04/23/2021
Valgrind-Errors 22:50:57
Valgrind-Loss 23:32:29
Details 41:32
Log 1815
Memory 1815
SUCCESS git merge/8895 1586ab1 0
06/21/2021 0
22:50:51 0
23:16:29 vncregress-2021-04-23-22:50:57.txt
25:38 autoscript-2021-04-23-22:52:03.log.bz2
1815 502 509 429
1814

For details, please contact louberger

@NetDEF-CI

NetDEF-CI commented Jun 22, 2021

Copy link
Copy Markdown
Collaborator
Continuous Integration Result: SUCCESSFUL

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-19738/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

@pjdruddy pjdruddy assigned pjdruddy and unassigned pjdruddy Jun 25, 2021
@pjdruddy
pjdruddy self-requested a review June 25, 2021 08:26
@leonshaw

Copy link
Copy Markdown
Contributor Author

Rebased against master.
Removed zl3vni_from_svi() part as is resolved in #9416 by a walk through all namespaces. However, I think the walk could be avoided since the vxlan interface is in the same VRF of the bridge, which is already known (see original commit of this PR).

@LabN-CI

LabN-CI commented Sep 27, 2021

Copy link
Copy Markdown
Collaborator
Outdated results 💚

Basic BGPD CI results: SUCCESS, 0 tests failed

_ _
Result SUCCESS git merge/8895 c220ed4
Date 09/27/2021
Start 10:48:52
Finish 11:15:02
Run-Time 26:10
Total 1813
Pass 1813
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2021-09-27-10:48:52.txt
Log autoscript-2021-09-27-10:49:58.log.bz2
Memory 508 518 425

For details, please contact louberger

@NetDEF-CI

NetDEF-CI commented Sep 27, 2021

Copy link
Copy Markdown
Collaborator
Continuous Integration Result: SUCCESSFUL

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-361/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

@NetDEF-CI

NetDEF-CI commented Sep 7, 2022

Copy link
Copy Markdown
Collaborator
Continuous Integration Result: FAILED

Continuous Integration Result: FAILED

See below for issues.
CI System Testrun URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-7275/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

Get source / Pull Request: Successful

Building Stage: Successful

Basic Tests: Failed

Topotests debian 10 amd64 part 9: Failed (click for details) Topotests debian 10 amd64 part 9: Unknown Log URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-7275/artifact/TOPO9DEB10AMD64/ErrorLog/ Topotests debian 10 amd64 part 9: No useful log found
Successful on other platforms/tests
  • Topotests debian 10 amd64 part 4
  • Addresssanitizer topotests part 7
  • Topotests Ubuntu 18.04 arm8 part 8
  • Addresssanitizer topotests part 4
  • Topotests Ubuntu 18.04 i386 part 7
  • Topotests Ubuntu 18.04 arm8 part 3
  • Addresssanitizer topotests part 5
  • Topotests Ubuntu 18.04 amd64 part 2
  • Topotests Ubuntu 18.04 amd64 part 3
  • Topotests debian 10 amd64 part 3
  • Addresssanitizer topotests part 0
  • Topotests debian 10 amd64 part 8
  • Topotests Ubuntu 18.04 i386 part 6
  • Topotests Ubuntu 18.04 arm8 part 9
  • Topotests Ubuntu 18.04 arm8 part 4
  • Addresssanitizer topotests part 2
  • Ubuntu 20.04 deb pkg check
  • Topotests Ubuntu 18.04 amd64 part 5
  • IPv6 protocols on Ubuntu 18.04
  • IPv4 ldp protocol on Ubuntu 18.04
  • Ubuntu 16.04 deb pkg check
  • Debian 10 deb pkg check
  • Topotests Ubuntu 18.04 amd64 part 4
  • IPv4 protocols on Ubuntu 18.04
  • Topotests Ubuntu 18.04 i386 part 1
  • Topotests Ubuntu 18.04 i386 part 3
  • Addresssanitizer topotests part 9
  • Topotests Ubuntu 18.04 arm8 part 2
  • Topotests Ubuntu 18.04 i386 part 8
  • Topotests Ubuntu 18.04 amd64 part 7
  • Topotests debian 10 amd64 part 0
  • Topotests Ubuntu 18.04 arm8 part 7
  • Addresssanitizer topotests part 3
  • Topotests Ubuntu 18.04 amd64 part 9
  • Addresssanitizer topotests part 6
  • Topotests Ubuntu 18.04 arm8 part 5
  • Fedora 29 rpm pkg check
  • CentOS 7 rpm pkg check
  • Topotests debian 10 amd64 part 1
  • Topotests Ubuntu 18.04 i386 part 9
  • Topotests Ubuntu 18.04 amd64 part 8
  • Topotests debian 10 amd64 part 2
  • Topotests debian 10 amd64 part 7
  • Topotests Ubuntu 18.04 arm8 part 0
  • Topotests Ubuntu 18.04 amd64 part 0
  • Static analyzer (clang)
  • Topotests Ubuntu 18.04 i386 part 0
  • Topotests Ubuntu 18.04 i386 part 5
  • Ubuntu 18.04 deb pkg check
  • Debian 9 deb pkg check
  • Addresssanitizer topotests part 1
  • Topotests Ubuntu 18.04 i386 part 4
  • Topotests Ubuntu 18.04 amd64 part 1
  • Topotests Ubuntu 18.04 arm8 part 6
  • Topotests Ubuntu 18.04 i386 part 2
  • Topotests debian 10 amd64 part 6
  • Topotests Ubuntu 18.04 arm8 part 1
  • Addresssanitizer topotests part 8
  • Topotests Ubuntu 18.04 amd64 part 6
  • Topotests debian 10 amd64 part 5

@leonshaw

leonshaw commented Sep 7, 2022

Copy link
Copy Markdown
Contributor Author

ci:rerun

@NetDEF-CI

NetDEF-CI commented Sep 7, 2022

Copy link
Copy Markdown
Collaborator
Continuous Integration Result: SUCCESSFUL

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-7277/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

@leonshaw

leonshaw commented Sep 8, 2022

Copy link
Copy Markdown
Contributor Author

@pjdruddy It's long since this PR was open, any comments?

@pguibert6WIND Could have look at this maybe?

@github-actions

github-actions Bot commented Mar 7, 2023

Copy link
Copy Markdown

This PR is stale because it has been open 180 days with no activity. Comment or remove the autoclose label in order to avoid having this PR closed.

@NetDEF-CI

Copy link
Copy Markdown
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-10088/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

@leonshaw

Copy link
Copy Markdown
Contributor Author

rebased

@ton31337

Copy link
Copy Markdown
Member

@Mergifyio rebase

@mergify

mergify Bot commented Dec 15, 2023

Copy link
Copy Markdown

rebase

✅ Branch has been successfully rebased

@ton31337 ton31337 left a comment

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.

LGTM

@ton31337

Copy link
Copy Markdown
Member

@chiragshah6 would you like to take a look at this before merging?

@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@riw777

riw777 commented Mar 24, 2026

Copy link
Copy Markdown
Member

@Mergifyio rebase

@mergify

mergify Bot commented Mar 24, 2026

Copy link
Copy Markdown

rebase

☑️ Nothing to do, the required conditions are not met

Details
  • -conflict [📌 rebase requirement]
  • -closed [📌 rebase requirement]
  • queue-position = -1 [📌 rebase requirement]
  • any of:
    • #commits-behind > 0 [📌 rebase requirement]
    • -linear-history [📌 rebase requirement]

If VRF backend is netns, bridges and SVIs are in the VRF's netns.
Get link information from there, rather than NS_DEFAULT.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
@riw777

riw777 commented May 14, 2026

Copy link
Copy Markdown
Member

@greptile review

@greptile-apps

greptile-apps Bot commented May 14, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes VxLAN link lookups in zebra/zebra_vxlan.c to use the correct network namespace when the VRF backend is netns, replacing hard-coded NS_DEFAULT lookups with namespace-aware alternatives.

  • zebra_vxlan_handle_vni_transition: replaces zebra_ns_lookup(NS_DEFAULT) with zvrf->zns so the VxLAN interface walk searches the VRF's own namespace rather than the default one.
  • zebra_vxlan_add_del_gw_macip, zebra_vxlan_macvlan_down, zebra_vxlan_macvlan_up: replaces if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT), zif->link_ifindex) with zif->link, which is the namespace-aware cached pointer already populated by zebra_if_update_link() using the correct namespace ID.

Confidence Score: 5/5

Safe to merge — the fix is narrow and consistent with how zif->link is already populated across the codebase.

All four changed call-sites are straightforward substitutions: the zif->link pointer is already resolved namespace-correctly by zebra_if_update_link(), and zvrf->zns is the established pattern for VRF-namespace walks. No new code paths are introduced and the remaining NS_DEFAULT usages in the file are unrelated to VXLAN link resolution.

No files require special attention.

Important Files Changed

Filename Overview
zebra/zebra_vxlan.c Replaces NS_DEFAULT-based interface lookups with zvrf->zns and the pre-populated zif->link pointer; all substitutions are consistent with how zebra_if_update_link already resolves links namespace-correctly.

Sequence Diagram

sequenceDiagram
    participant Kernel as Kernel (netns VRF)
    participant ZIF as zebra_if (zif)
    participant UpdateLink as zebra_if_update_link()
    participant VXLAN as zebra_vxlan.c

    Kernel->>UpdateLink: interface event (link_ifindex, link_nsid)
    UpdateLink->>ZIF: "zif->link_nsid = ns_id"
    UpdateLink->>ZIF: "zif->link_ifindex = link_ifindex"
    UpdateLink->>ZIF: "zif->link = if_lookup_by_index_per_ns(correct NS)"

    Note over VXLAN: Old code (buggy)
    VXLAN->>VXLAN: if_lookup_by_index_per_ns(NS_DEFAULT, link_ifindex) - Wrong NS

    Note over VXLAN: New code (fixed)
    VXLAN->>ZIF: "read zif->link (already resolved to correct NS)"
    ZIF-->>VXLAN: pointer to correct interface

    Note over VXLAN: Also fixed: vni_transition walk
    VXLAN->>VXLAN: "zebra_ns_ifp_walk(zvrf->zns, ...) - Correct VRF namespace"
Loading

Reviews (1): Last reviewed commit: "zebra: Get link from the correct netns f..." | Re-trigger Greptile

@riw777 riw777 left a comment

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.

looks good

@riw777
riw777 merged commit 015d292 into FRRouting:master May 18, 2026
20 checks passed
@mergify

mergify Bot commented May 18, 2026

Copy link
Copy Markdown

rebase

☑️ Nothing to do, the required conditions are not met

Details
  • -closed [📌 rebase requirement]
  • any of:
    • #commits-behind > 0 [📌 rebase requirement]
    • -linear-history [📌 rebase requirement]
  • -conflict [📌 rebase requirement]
  • queue-position = -1 [📌 rebase requirement]

@leonshaw
leonshaw deleted the vxlan-ns branch May 19, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants