interface: handle error during admin-up correctly 83/34083/2
authorMatthew Smith <mgsmith@netgate.com>
Mon, 4 Oct 2021 20:19:44 +0000 (15:19 -0500)
committerNeale Ranns <neale@graphiant.com>
Wed, 13 Oct 2021 07:17:54 +0000 (07:17 +0000)
commitac4e61205dcf365396ca44941ad055c7bd88c631
treefb46d814aefbdca434a2e86433f97668e9d8c9b5
parentb5dec932b78c662134bc3c93cc23a355918e1632
interface: handle error during admin-up correctly

Type: fix

In vnet_sw_interface_set_flags_helper(), the variable old_flags is set
to the original value of vnet_sw_interface_t.flags for an interface. If
an error occurs during the process of bringing an interface up, old_flags
is used to restore the original value.

Before the dev class or hw class admin_up_down_function can be called,
but after modifying vnet_sw_interface_t.flags to it's new value,
old_flags is set to the value of vnet_sw_interface_t.flags a second time.
This discards the original flags that were being preserved.

As a result, if an interface is being brought up and the dev class
or hw class function fails, at the end VPP believes that interface is up.
This can cause a crash if packets are routed through the interface
and some RX/TX initialization was not completed because of the error
while bringing the interface up.

Change-Id: Ica6b6bac13c24e88c4136bf084cd392e6217e7d9
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
src/vnet/interface.c