]> git.puffer.fish Git - matthieu/frr.git/commit
lib: handle failure to change ifindex
authorQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 2 Mar 2020 23:50:58 +0000 (18:50 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 13 Apr 2020 17:25:25 +0000 (13:25 -0400)
commit67f81586203a970d89d989aa3cc58a87779de37f
tree43c537481ab16739d1b8b3567f332fc465984472
parentf17a9d0a0769be32ecde09d63dbee3745d6c1177
lib: handle failure to change ifindex

This fixes a theoretical bug that could occur when trying to change an
ifindex on an interface to that of an existing interface. We would
remove the interface from the ifindex tree, and change the ifindex, but
when we tried to reinsert the interface, the insert would fail. It was
impossible to know if this failed due to the insertion / deletion macros
capturing the result value of the underlying BSD tree macros. So we
would effectively delete the interface.

Instead of failing on insert, we just check if the prospective ifindex
already exists and return -1 if it does.

Macros have been changed to statement expressions so the result can be
checked, and bubbled up.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/if.c
lib/if.h