]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: gro: remove unnecessary df checks
authorRichard Gobert <richardbgobert@gmail.com>
Tue, 23 Sep 2025 08:59:07 +0000 (10:59 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 25 Sep 2025 10:42:49 +0000 (12:42 +0200)
Currently, packets with fixed IDs will be merged only if their
don't-fragment bit is set. This restriction is unnecessary since
packets without the don't-fragment bit will be forwarded as-is even
if they were merged together. The merged packets will be segmented
into their original forms before being forwarded, either by GSO or
by TSO. The IDs will also remain identical unless NETIF_F_TSO_MANGLEID
is set, in which case the IDs can become incrementing, which is also fine.

Clean up the code by removing the unnecessary don't-fragment checks.

Signed-off-by: Richard Gobert <richardbgobert@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20250923085908.4687-5-richardbgobert@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/gro.h
net/ipv4/af_inet.c
tools/testing/selftests/net/gro.c

index e7997a9fb30b1cc8ce3500cdcd99b4d5fcc4b3bc..e3affb2e2ca8b2c89a9ffd6f7fb1219a42200ac3 100644 (file)
@@ -448,17 +448,16 @@ static inline int inet_gro_flush(const struct iphdr *iph, const struct iphdr *ip
        const u32 id2 = ntohl(*(__be32 *)&iph2->id);
        const u16 ipid_offset = (id >> 16) - (id2 >> 16);
        const u16 count = NAPI_GRO_CB(p)->count;
-       const u32 df = id & IP_DF;
 
        /* All fields must match except length and checksum. */
-       if ((iph->ttl ^ iph2->ttl) | (iph->tos ^ iph2->tos) | (df ^ (id2 & IP_DF)))
+       if ((iph->ttl ^ iph2->ttl) | (iph->tos ^ iph2->tos) | ((id ^ id2) & IP_DF))
                return true;
 
        /* When we receive our second frame we can make a decision on if we
         * continue this flow as an atomic flow with a fixed ID or if we use
         * an incrementing ID.
         */
-       if (count == 1 && df && !ipid_offset)
+       if (count == 1 && !ipid_offset)
                NAPI_GRO_CB(p)->ip_fixedid |= 1 << inner;
 
        return ipid_offset ^ (count * !(NAPI_GRO_CB(p)->ip_fixedid & (1 << inner)));
index 804c51296c5596fb0af831c05a4b9c13a41be979..3109c5ec38f39de7295f6f50068c42d5fd23b43d 100644 (file)
@@ -1395,10 +1395,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb,
 
        segs = ERR_PTR(-EPROTONOSUPPORT);
 
-       /* fixed ID is invalid if DF bit is not set */
        fixedid = !!(skb_shinfo(skb)->gso_type & (SKB_GSO_TCP_FIXEDID << encap));
-       if (fixedid && !(ip_hdr(skb)->frag_off & htons(IP_DF)))
-               goto out;
 
        if (!skb->encapsulation || encap)
                udpfrag = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP);
index d5824eadea1093cfb5d1dc5551af64783ce22f29..3d4a82a2607c7d0bac8477b2a7671760eeb3f6fe 100644 (file)
@@ -670,7 +670,7 @@ static void send_flush_id_case(int fd, struct sockaddr_ll *daddr, int tcase)
                iph2->id = htons(9);
                break;
 
-       case 3: /* DF=0, Fixed - should not coalesce */
+       case 3: /* DF=0, Fixed - should coalesce */
                iph1->frag_off &= ~htons(IP_DF);
                iph1->id = htons(8);
 
@@ -1188,10 +1188,9 @@ static void gro_receiver(void)
                        correct_payload[0] = PAYLOAD_LEN * 2;
                        check_recv_pkts(rxfd, correct_payload, 1);
 
-                       printf("DF=0, Fixed - should not coalesce: ");
-                       correct_payload[0] = PAYLOAD_LEN;
-                       correct_payload[1] = PAYLOAD_LEN;
-                       check_recv_pkts(rxfd, correct_payload, 2);
+                       printf("DF=0, Fixed - should coalesce: ");
+                       correct_payload[0] = PAYLOAD_LEN * 2;
+                       check_recv_pkts(rxfd, correct_payload, 1);
 
                        printf("DF=1, 2 Incrementing and one fixed - should coalesce only first 2 packets: ");
                        correct_payload[0] = PAYLOAD_LEN * 2;