net: Check UFO offloading support for tap driver

In Linux commit fb652fdfe83710da0ca13448a41b7ed027d0a984:
https://www.spinics.net/lists/netdev/msg443562.html
The UFO support had been removed.

If we use tap mode for network (--network mode=tap,tapif=...),
we will get following error:
"Warning: Config tap device TUNSETOFFLOAD error
 You have requested a TAP device,
 but creation of one has failed because: Invalid argument"

So, if we're running with latest kernel, we'd better to remove
TUN_F_UFO from TAP init. But if we're running with older kernels
without above commit. We'll miss the UFO feature. In this case,
we'd better to check the kernel UFO support status for tap driver.

The tap UFO state will used in get_host_features to return correct
VIRTIO_NET features. If we defer the tap UFO support check in
virtio_net__tap_init, it will be too later. So we separate the
tap create code from tap_init to a standalone function. This new
function will be used in virtio_net_init to create tap device and
check the tap UFO support status at the very beginning.

Signed-off-by: Wei Chen <Wei.Chen@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
1 file changed