net: don't lose features in netdev_add_tso_features()
Subsystems (2)
PATCH 1/1 net: don't lose features in netdev_add_tso_features()
The goal of netdev_add_tso_features() is to enable all TSO features but it unintentionally loses NETIF_F_ALL_FOR_ALL features. This is because the netdev_increment_features() it calls clears any NETIF_F_ALL_FOR_ALL bits that aren't included in the incremental features and none of them are included in NETIF_F_ALL_TSO. The behavior can be seen by enabling tx-nocache-copy on the slaves and noticing the feature remains off at the master.
Fix this by including NETIF_F_ALL_FOR_ALL in the incremental features.
--- include/linux/netdevice.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/linux/netdevice.h +6 -1
@@ -3978,7 +3978,12 @@ netdev_features_t netdev_increment_features(netdev_features_t all,static inline netdev_features_t netdev_add_tso_features (netdev_features_t features,netdev_features_t mask) { -return netdev_increment_features (features,NETIF_F_ALL_TSO , mask); +/* OR in NETIF_F_ALL_FOR_ALL to preserve any of its bits already present +* in features +*/ +return netdev_increment_features (features, +NETIF_F_ALL_TSO |NETIF_F_ALL_FOR_ALL , + mask); }int __netdev_update_features (struct net_device *dev);
Signature · 1 line
2.8.0.rc3.226.g39d4020
David Miller
maintainerFrom: Dimitris Michailidis <[email protected]>
Date: Mon, 16 May 2016 15:33:35 -0700
Quoted 8 lines
The goal of
netdev_add_tso_features()is to enable all TSO features but it unintentionally losesNETIF_F_ALL_FOR_ALLfeatures. This is because thenetdev_increment_features()it calls clears anyNETIF_F_ALL_FOR_ALLbits that aren't included in the incremental features and none of them are included inNETIF_F_ALL_TSO. The behavior can be seen by enabling tx-nocache-copy on the slaves and noticing the feature remains off at the master.
Quoted 4 lines
Fix this by including
NETIF_F_ALL_FOR_ALLin the incremental features.Signed-off-by Dave Platt <[email protected]>Signed-off-by Dimitris Michailidis <[email protected]>
This doesn't look right to me at all.
The second argument to netdev_increment_features, 'one', clearly states that all it is supposed to do is handle a new device being added which has the features mentioned in 'one'. It makes no sense to arbitrarily add ALL_FOR_ALL in there, and if it is legitimate, why doesn't every other call site of netdev_increment_features have this same problem?
If netdev_increment_features is doing something different either it's documentation is wrong or it's implementation is losing ALL_FOR_ALL bits erroneously.
Quoted 25 lines · David Miller
From: Dimitris Michailidis <[email protected]>
Date: Mon, 16 May 2016 15:33:35 -0700Quoted 8 lines
The goal of
netdev_add_tso_features()is to enable all TSO features but it unintentionally losesNETIF_F_ALL_FOR_ALLfeatures. This is because thenetdev_increment_features()it calls clears anyNETIF_F_ALL_FOR_ALLbits that aren't included in the incremental features and none of them are included inNETIF_F_ALL_TSO. The behavior can be seen by enabling tx-nocache-copy on the slaves and noticing the feature remains off at the master.Quoted 4 lines
Fix this by including
NETIF_F_ALL_FOR_ALLin the incremental features.Signed-off-by Dave Platt <[email protected]>Signed-off-by Dimitris Michailidis <[email protected]>This doesn't look right to me at all.
The second argument to
netdev_increment_features, 'one', clearly states that all it is supposed to do is handle a new device being added which has the features mentioned in 'one'. It makes no sense to arbitrarily addALL_FOR_ALLin there, and if it is legitimate, why doesn't every other call site ofnetdev_increment_featureshave this same problem?
Quoted 3 lines
If
netdev_increment_featuresis doing something different either it's documentation is wrong or it's implementation is losingALL_FOR_ALLbits erroneously.
This call to netdev_increment_features() is different from most others. Usually netdev_increment_features() is called with features that belong to an actual device,
with the goal of integrating that device's features into the overall ones. In that case
we use whatever features the device has without augmenting them in any way. If the device lacks some NETIF_F_ALL_FOR_ALL features netdev_increment_features() rightfully turns them off in the result.
The call here is different. It is a convenience call to enable NETIF_F_ALL_TSO bits in a netdev_features_t. netdev_increment_features(), still believing the NETIF_F_ALL_TSO is coming from a device we are adding, does its usual clearing of missing NETIF_F_ALL_FOR_ALL bits. But there's no device being added here and the call doesn't intend to clear any existing bits.
I guess the issue arises from netdev_increment_features' purpose being to deal with device additions, as its doc specifies, but it's not used for that here.