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)
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

index ad6d9cc..ab12da5 100644 (file)
@@ -462,9 +462,6 @@ vnet_sw_interface_set_flags_helper (vnet_main_t * vnm, u32 sw_if_index,
              goto done;
            }
 
-         /* save the si admin up flag */
-         old_flags = si->flags;
-
          /* update si admin up flag in advance if we are going admin down */
          if (!(flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP))
            si->flags &= ~VNET_SW_INTERFACE_FLAG_ADMIN_UP;