tools/hotplug: only attempt to call 'ip route' if there is valid command
authorPaul Durrant <pdurrant@amazon.com>
Fri, 8 Nov 2019 09:42:33 +0000 (09:42 +0000)
committerWei Liu <wl@xen.org>
Tue, 12 Nov 2019 10:40:05 +0000 (10:40 +0000)
commit3683290fc0b0d6500392db733811cc78bcb35eab
treee90268e86af0e4975b1604f21b0b41fc6df4dced
parentcda8f7e8576503b5e16fdf48d2630ad40cb7c7ef
tools/hotplug: only attempt to call 'ip route' if there is valid command

The vif-route script should only call 'ip route' when 'ipcmd' has been
set, otherwise it will fail due to an incorrect command string.

This patch also adds routes for 'tap' (i.e. emulated) devices as well as
'vif' (i.e. PV) devices. Empirically offline/online commands relate to
'vif' devices, and add/remove commands relate to 'tap' devices. However,
this patch treats them equally and uses ${type_if} to distinguish. By
adding cases for add/remove the command list becomes exhaustive and hence
'ipcmd' is guaranteed to be set.

Routes for 'tap' and 'vif' devices are distinguished by a route metric.
Emulated devices are used by HVM guests until they are unplugged, at which
point the PV device becomes active. Thus 'tap' devices should get a higher
priority (i.e. lower numbered) metric than 'vif' devices.

There is also one small whitespace fix.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Acked-by: Wei Liu <wl@xen.org>
Release-acked-by: Juergen Gross <jgross@suse.com>
tools/hotplug/Linux/vif-route [changed mode: 0644->0755]