Skip to content

Commit

Permalink
zebra: fix crash if macvlan link in another netns
Browse files Browse the repository at this point in the history
A macvlan interface can have its underlying link-interface in another
namespace (aka. netns). However, by default, zebra does not know the
interface from the other namespaces. It results in a crash the pointer
to the link interface is NULL.

> 6  0x0000559d77a329d3 in zebra_vxlan_macvlan_up (ifp=0x559d798b8e00) at /root/frr/zebra/zebra_vxlan.c:4676
> 4676		link_zif = link_ifp->info;
> (gdb) list
> 4671		struct interface *link_ifp, *link_if;
> 4672
> 4673		zif = ifp->info;
> 4674		assert(zif);
> 4675		link_ifp = zif->link;
> 4676		link_zif = link_ifp->info;
> 4677		assert(link_zif);
> 4678
> (gdb) p zif->link
> $2 = (struct interface *) 0x0
> (gdb) p zif->link_ifindex
> $3 = 15

Fix the crash by returning when the macvlan link-interface is in another
namespace. No need to go further because any vxlan under the macvlan
interface would not be accessible by zebra.

Link: #15370
Signed-off-by: Louis Scalbert <[email protected]>
(cherry picked from commit 44e6e38)
  • Loading branch information
louis-6wind authored and mergify[bot] committed Feb 27, 2024
1 parent 4c16604 commit 016eb0c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions zebra/zebra_vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -5110,6 +5110,11 @@ void zebra_vxlan_macvlan_up(struct interface *ifp)

zif = ifp->info;
assert(zif);

if (zif->link_nsid)
/* the link interface is another namespace */
return;

link_ifp = zif->link;
link_zif = link_ifp->info;
assert(link_zif);
Expand Down

0 comments on commit 016eb0c

Please sign in to comment.