Skip to contentSkip to conversation

IPv6/GRO: generic helper to remove temporary HBH/jumbo header in driver

PATCH In review Coco Li 2 participants 3 messages Nov 22, 2022

Subsystems (4)
lore
Share & tools
lore

Coco Li

author
#0 lore raw

PATCH 1/2 IPv6/GRO: generic helper to remove temporary HBH/jumbo header in driver

IPv6/TCP and GRO stacks can build big TCP packets with an added temporary Hop By Hop header.

Is GSO is not involved, then the temporary header needs to be removed in the driver. This patch provides a generic helper for drivers that need to modify their headers in place.

---
 include/net/ipv6.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
include/net/ipv6.h +33 -0
index d383c895592a..a11d58c85c05 100644
@@ -500,6 +500,39 @@ static inline int ipv6_has_hopopt_jumbo(const struct sk_buff *skb)
 	return jhdr->nexthdr;
 }
 
+/* Return 0 if HBH header is successfully removed
+ * Or if HBH removal is unnecessary (packet is not big TCP)
+ * Return error to indicate dropping the packet
+ */
+static inline int ipv6_hopopt_jumbo_remove(struct sk_buff *skb)
+{
+	const int hophdr_len = sizeof(struct hop_jumbo_hdr);
+	int nexthdr = ipv6_has_hopopt_jumbo(skb);
+	struct ipv6hdr *h6;
+
+	if (!nexthdr)
+		return 0;
+
+	if (skb_cow_head(skb, 0))
+		return -1;
+
+	/* Remove the HBH header.
+	 * Layout: [Ethernet header][IPv6 header][HBH][L4 Header]
+	 */
+	memmove(skb->data + hophdr_len,
+		skb->data,
+		ETH_HLEN + sizeof(struct ipv6hdr));
+
+	skb->data += hophdr_len;
+	skb->len -= hophdr_len;
+	skb->network_header += hophdr_len;
+
+	h6 = ipv6_hdr(skb);
+	h6->nexthdr = nexthdr;
+
+	return 0;
+}
+
 static inline bool ipv6_accept_ra(struct inet6_dev *idev)
 {
 	/* If forwarding is enabled, RA are not accepted unless the special
Signature · 1 line
2.38.1.584.g0f3c55d4c2-goog
author
#1 lore raw

PATCH 2/2 bnxt: Use generic HBH removal helper in tx path

Eric Dumazet implemented Big TCP that allowed bigger TSO/GRO packet sizes for IPv6 traffic. See patch series:
'commit 89527be8d8d6 ("net: add IFLA_TSO_{MAX_SIZE|SEGS} attributes")'

This reduces the number of packets traversing the networking stack and should usually improves performance. However, it also inserts a temporary Hop-by-hop IPv6 extension header.

Using the HBH header removal method in the previous path, the extra header be removed in bnxt drivers to allow it to send big TCP packets (bigger TSO packets) as well.

If bnxt folks could help with testing this patch on the driver (as I don't have access to one) that would be wonderful. Thank you!

Tested:
Compiled locally

To further test functional correctness, update the GSO/GRO limit on the physical NIC:

ip link set eth0 gso_max_size 181000
ip link set eth0 gro_max_size 181000

Note that if there are bonding or ipvan devices on top of the physical NIC, their GSO sizes need to be updated as well.

Then, IPv6/TCP packets with sizes larger than 64k can be observed.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -0
index 0fe164b42c5d..2bfa5e9fb179 100644
@@ -389,6 +389,9 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
 			return NETDEV_TX_BUSY;
 	}
 
+	if (unlikely(ipv6_hopopt_jumbo_remove(skb)))
+		goto tx_free;
+
 	length = skb->len;
 	len = skb_headlen(skb);
 	last_frag = skb_shinfo(skb)->nr_frags;
@@ -13657,6 +13660,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		dev->features &= ~NETIF_F_LRO;
 	dev->priv_flags |= IFF_UNICAST_FLT;
 
+	netif_set_tso_max_size(dev, GSO_MAX_SIZE);
 #ifdef CONFIG_BNXT_SRIOV
 	init_waitqueue_head(&bp->sriov_cfg_wait);
 #endif
Signature · 1 line
2.38.1.584.g0f3c55d4c2-goog
maintainer
#2 lore raw
In reply to Coco Li
Quoted 6 lines · On Tue, 22 Nov 2022 11:32:38 -0800 Coco Li wrote:

IPv6/TCP and GRO stacks can build big TCP packets with an added temporary Hop By Hop header.

Is GSO is not involved, then the temporary header needs to be removed in the driver. This patch provides a generic helper for drivers that need to modify their headers in place.

you need to cc: netdev