Skip to content

Commit

Permalink
zebra: null check re->nhe not re->nhe->nhg on attach
Browse files Browse the repository at this point in the history
We should be NULL checking the entire re->nhe struct, not
the group inside of it. When we get routes from the kernel
using a nexthop group (and future protocols) they will only
pass us an ID to use. Hence, this struct can (and will be)
NULL on first attach when only passed an ID.

There shouldn't be a situation where we have an re->nhe
and don't have an re->nhe->nhg anyway.

Before this patch you can easily make zebra crash by creating a
route in the kernel using a nexthop group and starting zebra.

`ip next add dev lo id 111`
`ip route add 1.1.1.1/32 nhid 111`

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
  • Loading branch information
sworleys committed Dec 16, 2019
1 parent 8887295 commit 84a89a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion zebra/zebra_rib.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ int route_entry_update_nhe(struct route_entry *re, struct nhg_hash_entry *new)

if (old)
zebra_nhg_decrement_ref(old);
} else if (!re->nhe->nhg)
} else if (!re->nhe)
/* This is the first time it's being attached */
route_entry_attach_ref(re, new);

Expand Down

0 comments on commit 84a89a8

Please sign in to comment.