Skip to content

Commit a567dd6

Browse files
Vlad Yasevichdavem330
authored andcommitted
macvtap: simplify usage of tap_features
In macvtap, tap_features specific the features of that the user has specified via ioctl(). If we treat macvtap as a macvlan+tap then we could all the tap a pseudo-device and give it other features like SG and GSO. Then we can stop using the features of lower device (macvlan) when forwarding the traffic the tap. This solves the issue of possible checksum offload mismatch between tap feature and macvlan features. Signed-off-by: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7ed5c5a commit a567dd6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/net/macvtap.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ static const struct proto_ops macvtap_socket_ops;
6868
#define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
6969
NETIF_F_TSO6 | NETIF_F_UFO)
7070
#define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
71+
#define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
72+
7173
/*
7274
* RCU usage:
7375
* The macvtap_queue and the macvlan_dev are loosely coupled, the
@@ -278,7 +280,8 @@ static int macvtap_forward(struct net_device *dev, struct sk_buff *skb)
278280
{
279281
struct macvlan_dev *vlan = netdev_priv(dev);
280282
struct macvtap_queue *q = macvtap_get_queue(dev, skb);
281-
netdev_features_t features;
283+
netdev_features_t features = TAP_FEATURES;
284+
282285
if (!q)
283286
goto drop;
284287

@@ -289,7 +292,7 @@ static int macvtap_forward(struct net_device *dev, struct sk_buff *skb)
289292
/* Apply the forward feature mask so that we perform segmentation
290293
* according to users wishes.
291294
*/
292-
features = netif_skb_features(skb) & vlan->tap_features;
295+
features |= vlan->tap_features;
293296
if (netif_needs_gso(skb, features)) {
294297
struct sk_buff *segs = __skb_gso_segment(skb, features, false);
295298

@@ -1064,8 +1067,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
10641067
/* tap_features are the same as features on tun/tap and
10651068
* reflect user expectations.
10661069
*/
1067-
vlan->tap_features = vlan->dev->features &
1068-
(feature_mask | ~TUN_OFFLOADS);
1070+
vlan->tap_features = feature_mask;
10691071
vlan->set_features = features;
10701072
netdev_update_features(vlan->dev);
10711073

0 commit comments

Comments
 (0)