@@ -293,20 +293,21 @@ static int veth_forward_skb(struct net_device *dev, struct sk_buff *skb,
293
293
/* return true if the specified skb has chances of GRO aggregation
294
294
* Don't strive for accuracy, but try to avoid GRO overhead in the most
295
295
* common scenarios.
296
- * When XDP is enabled, all traffic is considered eligible, as the xmit
297
- * device has TSO off.
296
+ * When XDP is enabled, all traffic is considered eligible.
298
297
* When TSO is enabled on the xmit device, we are likely interested only
299
298
* in UDP aggregation, explicitly check for that if the skb is suspected
300
299
* - the sock_wfree destructor is used by UDP, ICMP and XDP sockets -
301
300
* to belong to locally generated UDP traffic.
302
301
*/
303
302
static bool veth_skb_is_eligible_for_gro (const struct net_device * dev ,
304
303
const struct net_device * rcv ,
304
+ const struct veth_rq * rq ,
305
305
const struct sk_buff * skb )
306
306
{
307
- return !(dev -> features & NETIF_F_ALL_TSO ) ||
308
- (skb -> destructor == sock_wfree &&
309
- rcv -> features & (NETIF_F_GRO_FRAGLIST | NETIF_F_GRO_UDP_FWD ));
307
+ return rcu_access_pointer (rq -> xdp_prog ) ||
308
+ !(dev -> features & NETIF_F_ALL_TSO ) ||
309
+ (skb -> destructor == sock_wfree &&
310
+ rcv -> features & (NETIF_F_GRO_FRAGLIST | NETIF_F_GRO_UDP_FWD ));
310
311
}
311
312
312
313
static netdev_tx_t veth_xmit (struct sk_buff * skb , struct net_device * dev )
@@ -335,7 +336,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
335
336
* Don't bother with napi/GRO if the skb can't be aggregated
336
337
*/
337
338
use_napi = rcu_access_pointer (rq -> napi ) &&
338
- veth_skb_is_eligible_for_gro (dev , rcv , skb );
339
+ veth_skb_is_eligible_for_gro (dev , rcv , rq , skb );
339
340
}
340
341
341
342
skb_tx_timestamp (skb );
@@ -1525,9 +1526,14 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog,
1525
1526
goto err ;
1526
1527
}
1527
1528
1528
- max_mtu = PAGE_SIZE - VETH_XDP_HEADROOM -
1529
- peer -> hard_header_len -
1530
- SKB_DATA_ALIGN (sizeof (struct skb_shared_info ));
1529
+ max_mtu = SKB_WITH_OVERHEAD (PAGE_SIZE - VETH_XDP_HEADROOM ) -
1530
+ peer -> hard_header_len ;
1531
+ /* Allow increasing the max_mtu if the program supports
1532
+ * XDP fragments.
1533
+ */
1534
+ if (prog -> aux -> xdp_has_frags )
1535
+ max_mtu += PAGE_SIZE * MAX_SKB_FRAGS ;
1536
+
1531
1537
if (peer -> mtu > max_mtu ) {
1532
1538
NL_SET_ERR_MSG_MOD (extack , "Peer MTU is too large to set XDP" );
1533
1539
err = - ERANGE ;
@@ -1549,7 +1555,7 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog,
1549
1555
}
1550
1556
1551
1557
if (!old_prog ) {
1552
- peer -> hw_features &= ~NETIF_F_GSO_SOFTWARE ;
1558
+ peer -> hw_features &= ~NETIF_F_GSO_FRAGLIST ;
1553
1559
peer -> max_mtu = max_mtu ;
1554
1560
}
1555
1561
}
@@ -1560,7 +1566,7 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog,
1560
1566
veth_disable_xdp (dev );
1561
1567
1562
1568
if (peer ) {
1563
- peer -> hw_features |= NETIF_F_GSO_SOFTWARE ;
1569
+ peer -> hw_features |= NETIF_F_GSO_FRAGLIST ;
1564
1570
peer -> max_mtu = ETH_MAX_MTU ;
1565
1571
}
1566
1572
}
0 commit comments