]> git.baikalelectronics.ru Git - kernel.git/commit
macvlan: filter out unsupported feature flags
authorShannon Nelson <shannon.nelson@oracle.com>
Fri, 9 Mar 2018 00:17:23 +0000 (16:17 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Mar 2018 02:46:16 +0000 (22:46 -0400)
commita37697f7131b159b3e270b7ddf88118fcf4ee8e9
tree027a61caa102eb5047d306ff06037241a36e17cb
parentb210781827e1ab47d44fdfe0ce7b540c39046c19
macvlan: filter out unsupported feature flags

Adding a macvlan device on top of a lowerdev that supports
the xfrm offloads fails with a new regression:
  # ip link add link ens1f0 mv0 type macvlan
  RTNETLINK answers: Operation not permitted

Tracing down the failure shows that the macvlan device inherits
the NETIF_F_HW_ESP and NETIF_F_HW_ESP_TX_CSUM feature flags
from the lowerdev, but with no dev->xfrmdev_ops API filled
in, it doesn't actually support xfrm.  When the request is
made to add the new macvlan device, the XFRM listener for
NETDEV_REGISTER calls xfrm_api_check() which fails the new
registration because dev->xfrmdev_ops is NULL.

The macvlan creation succeeds when we filter out the ESP
feature flags in macvlan_fix_features(), so let's filter them
out like we're already filtering out ~NETIF_F_NETNS_LOCAL.
When XFRM support is added in the future, we can add the flags
into MACVLAN_FEATURES.

This same problem could crop up in the future with any other
new feature flags, so let's filter out any flags that aren't
defined as supported in macvlan.

Fixes: a0adf2600184 ("xfrm: Add an IPsec hardware offloading API")
Reported-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Signed-off-by: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/macvlan.c