]> git.puffer.fish Git - matthieu/frr.git/commit
lib: fix crashes with leafrefs that point to non-implemented modules
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 11 Sep 2020 13:43:49 +0000 (10:43 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 11 Sep 2020 17:42:35 +0000 (14:42 -0300)
commitf267201bf56852741cec89a05e13b75d14225143
tree96cdca54983173206afc387a24b9cfd384aba2bf
parenta77bd0f4e6b7d63e6f66288d7ea715ae8c55feee
lib: fix crashes with leafrefs that point to non-implemented modules

Whenever libyang loads a module that contains a leafref, it will
also implicitly load the module of the referring node if it's
not loaded already. That makes sense as otherwise it wouldn't be
possible to validate the leafref value correctly.

The problem is that loading a module implicitly violates the
assumption of the northbound layer that all loaded modules
are implemented (i.e. they have a northbound node associated
to each schema node). This means that loading a module that
isn't implemented can lead to crashes as the "priv" pointer
of schema nodes is no longer guaranteed to be valid. To fix this
problem, add a few null checks to ignore data nodes associated
to non-implemented modules.

The side effect of this change is harmless. If a daemon receives
configuration it doesn't support (e.g. BFD peers on staticd),
that configuration will be stored but otherwise ignored. This can
only happen when using a northbound client like gRPC, as the CLI
will never send to a daemon a command it doesn't support. This
minor problem should go away in the long run as FRR migrates to
a centralized management model, at which point the YANG-modeled
configuration of all daemons will be maintained in a single place.

Finally, update some daemons to stop implementing YANG modules
they don't need to (i.e. revert 1b741a01c and a74b47f5).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
lib/northbound.c
lib/northbound_cli.c
nhrpd/nhrp_main.c
pbrd/pbr_main.c