[Devel] [PATCH RH9 2/3] ve/net/features: put per-ve netdev features to separate struct member
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Wed Oct 27 16:05:20 MSK 2021
Replace features member uses for per-ve features with ve_features member
under CONFIG_VE.
Later we would likely want to split this patch and put each fixup hunk
in proper base patch:
Fixes: be40f8f443f9 ("ve/net/dummy: enable support in a container")
Fixes: b3345177cf1f ("net: Add NETIF_F_VIRTUAL feature to mask devices allowed in CT")
Fixes: cba4909419c9 ("ve/net/ppp: introduce VE_FEATURE_PPP feature")
Fixes: 0046628c2a38 ("ve/net/vxlan: enable support in a container")
Fixes: 69dfb70e37e3 ("ve/net/ip_gre: containerize per-net devices")
Fixes: b06f5ab814de ("net: Make ipip feature optional")
Fixes: 5b9aaf63d0d3 ("ve/net/ipv6 tunnels: Enable GRE netdevice register inside container")
Fixes: 466db989d34e ("ve/net/sit: Enable SIT devices in Containers")
Fixes: 6b4bc35aae98 ("openvswitch: allow to create ovs bridges inside Containers")
Fixes: 12b9b0869be8 ("drivers/net/ve: venet network device introduced")
Fixes: 2339b008fbf7 ("net: optimized skb forwarding for venet")
Fixes: 00e7dbe29105 ("ve/net,netfilter: Adjust REDIRECT target on venet device")
https://jira.sw.ru/browse/PSBM-135200
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
drivers/net/dummy.c | 4 +++-
drivers/net/loopback.c | 4 +++-
drivers/net/ppp/ppp_generic.c | 5 ++++-
drivers/net/tun.c | 6 ++++--
drivers/net/venetdev.c | 7 +++++--
drivers/net/vxlan.c | 4 +++-
include/linux/netdev_features.h | 16 ++++++++++------
include/linux/netdevice.h | 8 ++++++--
net/8021q/vlan_dev.c | 5 ++++-
net/bridge/br_forward.c | 5 ++++-
net/core/dev.c | 4 ++--
net/ipv4/fib_frontend.c | 5 ++++-
net/ipv4/ip_forward.c | 4 +++-
net/ipv4/ip_gre.c | 4 +++-
net/ipv4/ipip.c | 4 +++-
net/ipv6/ip6_gre.c | 4 +++-
net/ipv6/ip6_output.c | 5 ++++-
net/ipv6/ip6_tunnel.c | 5 ++++-
net/ipv6/sit.c | 4 +++-
net/netfilter/nf_nat_redirect.c | 2 +-
net/openvswitch/vport-internal_dev.c | 6 ++++--
21 files changed, 80 insertions(+), 31 deletions(-)
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index 83c3f72e737d..8df21e3316e9 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -127,7 +127,9 @@ static void dummy_setup(struct net_device *dev)
dev->features |= NETIF_F_GSO_SOFTWARE;
dev->features |= NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_LLTX;
dev->features |= NETIF_F_GSO_ENCAP_ALL;
- dev->features |= NETIF_F_VIRTUAL;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VIRTUAL;
+#endif
dev->hw_features |= dev->features;
dev->hw_enc_features |= dev->features;
eth_hw_addr_random(dev);
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index a2424255661a..dc1c0b7b5ac0 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -183,9 +183,11 @@ static void gen_lo_setup(struct net_device *dev,
| NETIF_F_HIGHDMA
| NETIF_F_LLTX
| NETIF_F_NETNS_LOCAL
- | NETIF_F_VIRTUAL
| NETIF_F_VLAN_CHALLENGED
| NETIF_F_LOOPBACK;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VIRTUAL;
+#endif
dev->ethtool_ops = eth_ops;
dev->header_ops = hdr_ops;
dev->netdev_ops = dev_ops;
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 327c58c2dce9..075de0a20f6c 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -1628,7 +1628,10 @@ static void ppp_setup(struct net_device *dev)
dev->netdev_ops = &ppp_netdev_ops;
SET_NETDEV_DEVTYPE(dev, &ppp_type);
- dev->features |= NETIF_F_LLTX | NETIF_F_VIRTUAL;
+ dev->features |= NETIF_F_LLTX;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VIRTUAL;
+#endif
dev->hard_header_len = PPP_HDRLEN;
dev->mtu = PPP_MRU;
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 5c2b35902604..5f77d2ca0fad 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2729,8 +2729,10 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST |
TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX;
- dev->features = dev->hw_features | NETIF_F_LLTX |
- NETIF_F_VIRTUAL;
+ dev->features = dev->hw_features | NETIF_F_LLTX;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VIRTUAL;
+#endif
dev->vlan_features = dev->features &
~(NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX);
diff --git a/drivers/net/venetdev.c b/drivers/net/venetdev.c
index ca80cc5efd24..f478d644e08b 100644
--- a/drivers/net/venetdev.c
+++ b/drivers/net/venetdev.c
@@ -703,8 +703,11 @@ static void venet_setup(struct net_device *dev)
* No other features, as they are:
* - checksumming is required, and nobody else will done our job
*/
- dev->features |= NETIF_F_VENET | NETIF_F_VIRTUAL | NETIF_F_LLTX |
- NETIF_F_HIGHDMA | NETIF_F_VLAN_CHALLENGED;
+ dev->features |= NETIF_F_LLTX | NETIF_F_HIGHDMA |
+ NETIF_F_VLAN_CHALLENGED;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VENET | NETIF_F_VIRTUAL;
+#endif
dev->netdev_ops = &venet_netdev_ops;
dev->ethtool_ops = &venet_ethtool_ops;
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 17a30edea97c..49770468e689 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -3298,7 +3298,9 @@ static void vxlan_setup(struct net_device *dev)
dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST;
dev->features |= NETIF_F_RXCSUM;
dev->features |= NETIF_F_GSO_SOFTWARE;
- dev->features |= NETIF_F_VIRTUAL;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VIRTUAL;
+#endif
dev->vlan_features = dev->features;
dev->hw_features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_FRAGLIST;
diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index fbc8d5dd9799..9945162fa074 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -14,7 +14,7 @@ typedef u64 netdev_features_t;
enum {
NETIF_F_SG_BIT, /* Scatter/gather IO. */
NETIF_F_IP_CSUM_BIT, /* Can checksum TCP/UDP over IPv4. */
- NETIF_F_VIRTUAL_BIT, /* Can be registered inside VE */
+ __UNUSED_NETIF_F_1,
NETIF_F_HW_CSUM_BIT, /* Can checksum all the packets. */
NETIF_F_IPV6_CSUM_BIT, /* Can checksum TCP/UDP over IPV6 */
NETIF_F_HIGHDMA_BIT, /* Can DMA to high memory. */
@@ -84,9 +84,6 @@ enum {
NETIF_F_GRO_FRAGLIST_BIT, /* Fraglist GRO */
NETIF_F_GRO_UDP_FWD_BIT, /* Allow UDP GRO for forwarding */
- /* here goes NETIF_F_HW_MACSEC_BIT in ms, temporarily reverted */
- /* Offload MACsec operations */
- NETIF_F_VENET_BIT, /* Device is venet device */
NETIF_F_HW_HSR_TAG_INS_BIT, /* Offload HSR tag insertion */
NETIF_F_HW_HSR_TAG_RM_BIT, /* Offload HSR tag removal */
@@ -170,8 +167,16 @@ enum {
#define NETIF_F_HW_HSR_FWD __NETIF_F(HW_HSR_FWD)
#define NETIF_F_HW_HSR_DUP __NETIF_F(HW_HSR_DUP)
+#ifdef CONFIG_VE
+/* For net_device->ve_features */
+enum {
+ NETIF_F_VIRTUAL_BIT, /* Device is venet device */
+ NETIF_F_VENET_BIT, /* Device is venet device */
+};
+
#define NETIF_F_VIRTUAL __NETIF_F(VIRTUAL)
#define NETIF_F_VENET __NETIF_F(VENET)
+#endif
/* Finds the next feature with the highest number of the range of start till 0.
*/
@@ -256,8 +261,7 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start)
NETIF_F_HW_VLAN_CTAG_TX | \
NETIF_F_HW_VLAN_STAG_FILTER | \
NETIF_F_HW_VLAN_STAG_RX | \
- NETIF_F_HW_VLAN_STAG_TX | \
- NETIF_F_VIRTUAL)
+ NETIF_F_HW_VLAN_STAG_TX)
#define NETIF_F_GSO_ENCAP_ALL (NETIF_F_GSO_GRE | \
NETIF_F_GSO_GRE_CSUM | \
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index bb7e2749f884..37d51d24aff4 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1986,6 +1986,10 @@ struct net_device {
netdev_features_t mpls_features;
netdev_features_t gso_partial_features;
+#ifdef CONFIG_VE
+ netdev_features_t ve_features;
+#endif
+
unsigned int min_mtu;
unsigned int max_mtu;
unsigned short type;
@@ -5016,10 +5020,10 @@ netdev_features_t passthru_features_check(struct sk_buff *skb,
netdev_features_t features);
netdev_features_t netif_skb_features(struct sk_buff *skb);
-#if defined(CONFIG_VE) && defined(CONFIG_NET)
+#ifdef CONFIG_VE
static inline int ve_is_dev_movable(struct net_device *dev)
{
- return !(dev->features & (NETIF_F_VIRTUAL | NETIF_F_NETNS_LOCAL));
+ return !(dev->ve_features & (NETIF_F_VIRTUAL | NETIF_F_NETNS_LOCAL));
}
#else
static inline int ve_is_dev_movable(struct net_device *dev)
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index fc1b32f60f4e..dde3d3e32092 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -572,7 +572,10 @@ static int vlan_dev_init(struct net_device *dev)
NETIF_F_HIGHDMA | NETIF_F_SCTP_CRC |
NETIF_F_ALL_FCOE;
- dev->features |= dev->hw_features | NETIF_F_LLTX | NETIF_F_VIRTUAL;
+ dev->features |= dev->hw_features | NETIF_F_LLTX;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VIRTUAL;
+#endif
dev->gso_max_size = real_dev->gso_max_size;
dev->gso_max_segs = real_dev->gso_max_segs;
if (dev->features & NETIF_F_VLAN_FEATURES)
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 2b1d004d6a1f..dfd0a989c4ab 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -33,7 +33,10 @@ static inline int should_deliver(const struct net_bridge_port *p,
int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb)
{
skb_push(skb, ETH_HLEN);
- if (!(skb->dev->features & NETIF_F_VENET) &&
+ if (
+#ifdef CONFIG_VE
+ !(skb->dev->ve_features & NETIF_F_VENET) &&
+#endif
!is_skb_forwardable(skb->dev, skb))
goto drop;
diff --git a/net/core/dev.c b/net/core/dev.c
index d257a67adb88..b6dbbe7bf34b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10301,7 +10301,7 @@ int register_netdevice(struct net_device *dev)
ret = -EPERM;
if (!ve_is_super(net->owner_ve) && ve_is_dev_movable(dev))
- goto out;
+ return ret;
ret = ethtool_check_ops(dev->ethtool_ops);
if (ret)
@@ -11425,7 +11425,7 @@ netdev_features_t netdev_increment_features(netdev_features_t all,
mask |= NETIF_F_CSUM_MASK;
mask |= NETIF_F_VLAN_CHALLENGED;
- all |= one & (NETIF_F_ONE_FOR_ALL|NETIF_F_CSUM_MASK|NETIF_F_VIRTUAL) & mask;
+ all |= one & (NETIF_F_ONE_FOR_ALL | NETIF_F_CSUM_MASK) & mask;
all &= one | ~NETIF_F_ALL_FOR_ALL;
/* If one device supports hw checksumming, set for all. */
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index bf4d8cdb9725..54964c5d3f1f 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -378,7 +378,10 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
if (fib_lookup(net, &fl4, &res, 0))
goto last_resort;
if (res.type != RTN_UNICAST &&
- (!(dev->features & NETIF_F_VENET) ||
+ (
+#ifdef CONFIG_VE
+ !(dev->ve_features & NETIF_F_VENET) ||
+#endif
res.type != RTN_LOCAL || !IN_DEV_ACCEPT_LOCAL(idev)))
goto e_inval;
fib_combine_itag(itag, &res);
diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index 2a150ffb0214..e0ad0b0ba8ca 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -151,7 +151,9 @@ int ip_forward(struct sk_buff *skb)
#ifdef CONFIG_IP_ROUTE_NAT
(rt->rt_flags & RTCF_NAT) == 0 && /* no NAT mangling expected */
#endif /* and */
- (skb->dev->features & NETIF_F_VENET) && /* src is VENET device and */
+#ifdef CONFIG_VE
+ (skb->dev->ve_features & NETIF_F_VENET) && /* src is VENET device and */
+#endif
(skb_headroom(skb) >= hroom)) { /* skb has enough headroom */
iph = ip_hdr(skb);
goto no_ttl_decr;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index b1087eefb6e5..a5497bfa3dfd 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -977,7 +977,9 @@ static void __gre_tunnel_init(struct net_device *dev)
*/
dev->features |= NETIF_F_LLTX;
}
- dev->features |= NETIF_F_VIRTUAL;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VIRTUAL;
+#endif
}
static int ipgre_tunnel_init(struct net_device *dev)
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index fb8552aa83a6..b180d31c23b6 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -384,7 +384,9 @@ static void ipip_tunnel_setup(struct net_device *dev)
netif_keep_dst(dev);
dev->features |= IPIP_FEATURES;
- dev->features |= NETIF_F_VIRTUAL;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VIRTUAL;
+#endif
dev->hw_features |= IPIP_FEATURES;
ip_tunnel_setup(dev, ipip_net_id);
}
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 3d06e3c485e7..4c2023ccec54 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1430,7 +1430,9 @@ static void ip6gre_tunnel_setup(struct net_device *dev)
dev->type = ARPHRD_IP6GRE;
- dev->features |= NETIF_F_VIRTUAL;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VIRTUAL;
+#endif
dev->flags |= IFF_NOARP;
dev->addr_len = sizeof(struct in6_addr);
netif_keep_dst(dev);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 11f8238111b9..62e94ad6df97 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -635,7 +635,10 @@ int ip6_forward(struct sk_buff *skb)
* sufficient to prevent routing loops.
*/
hroom = dst->dev->hard_header_len;
- if ((skb->dev->features & NETIF_F_VENET) && /* src is VENET device */
+ if (
+#ifdef CONFIG_VE
+ (skb->dev->ve_features & NETIF_F_VENET) && /* src is VENET device */
+#endif
(skb_headroom(skb) >= hroom)) /* and skb has enough headroom */
goto no_ttl_decr;
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index b9f7466b995c..cf9c1f85094b 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1840,7 +1840,10 @@ static void ip6_tnl_dev_setup(struct net_device *dev)
dev->type = ARPHRD_TUNNEL6;
dev->flags |= IFF_NOARP;
dev->addr_len = sizeof(struct in6_addr);
- dev->features |= NETIF_F_LLTX | NETIF_F_VIRTUAL;
+ dev->features |= NETIF_F_LLTX;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VIRTUAL;
+#endif
netif_keep_dst(dev);
dev->features |= IPXIPX_FEATURES;
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 36006b957366..dcc0e6a36797 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1445,7 +1445,9 @@ static void ipip6_tunnel_setup(struct net_device *dev)
dev->addr_len = 4;
dev->features |= NETIF_F_LLTX;
dev->features |= SIT_FEATURES;
- dev->features |= NETIF_F_VIRTUAL;
+#ifdef CONFIG_VE
+ dev->ve_features = NETIF_F_VIRTUAL;
+#endif
dev->hw_features |= SIT_FEATURES;
}
diff --git a/net/netfilter/nf_nat_redirect.c b/net/netfilter/nf_nat_redirect.c
index 3a49e27fee25..f4d813d6a30c 100644
--- a/net/netfilter/nf_nat_redirect.c
+++ b/net/netfilter/nf_nat_redirect.c
@@ -60,7 +60,7 @@ nf_nat_redirect_ipv4(struct sk_buff *skb,
* should use first nonloopback ifa in
* the list.
*/
- if (skb->dev->features & NETIF_F_VENET) {
+ if (skb->dev->ve_features & NETIF_F_VENET) {
while (IN_LOOPBACK(ntohl(ifa->ifa_local)) &&
ifa->ifa_next)
ifa = ifa->ifa_next;
diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
index 334185261746..1c25158fbdf2 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -110,8 +110,10 @@ static void do_setup(struct net_device *netdev)
netdev->features = NETIF_F_LLTX | NETIF_F_SG | NETIF_F_FRAGLIST |
NETIF_F_HIGHDMA | NETIF_F_HW_CSUM |
- NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ENCAP_ALL |
- NETIF_F_VIRTUAL;
+ NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ENCAP_ALL;
+#ifdef CONFIG_VE
+ netdev->ve_features = NETIF_F_VIRTUAL;
+#endif
netdev->vlan_features = netdev->features;
netdev->hw_enc_features = netdev->features;
--
2.31.1
More information about the Devel
mailing list