From: planck kernel size experiment Subject: net: replace the generic flow dissector with fixed one-queue behavior RPS, traffic control, tunnels, RSS and multiqueue are absent. Specialize the virtio header paths for the already-negotiated no-offload contract, keep up to 160 bytes linear for any large Ethernet frame, and use a fixed nonzero hash if generic code asks for one. This removes recursive VLAN/tunnel/IPv6/MPLS flow parsing and keyed flow hashing while preserving ordinary IPv4 TCP/UDP delivery. Measured effect on RV32: 1,159,160 -> 1,150,964 bytes in the raw Image (-8,196 bytes). Linked sections fell by 8,358 bytes: text -7,806, data -296, and BSS -256. The exact UDP + TCP + fsync + disk-readback proof passes. --- a/net/core/Makefile +++ b/net/core/Makefile @@ -5,7 +5,7 @@ obj-y := sock.o request_sock.o skbuff.o datagram.o stream.o scm.o \ gen_stats.o gen_estimator.o net_namespace.o secure_seq.o \ - flow_dissector.o planck_minimal.o + planck_flow.o planck_minimal.o obj-$(CONFIG_SYSCTL) += sysctl_net_core.o --- /dev/null +++ b/net/core/planck_flow.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* One queue needs no flow classification; retain the lazy hash ABI only. */ + +#include +#include + +void __skb_get_hash_net(const struct net *net, struct sk_buff *skb) +{ + /* skb_get_hash() uses zero as "not computed", so keep this nonzero. */ + skb_set_hash(skb, 1, PKT_HASH_TYPE_L3); +} --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -124,22 +124,8 @@ */ u32 eth_get_headlen(const struct net_device *dev, const void *data, u32 len) { - const unsigned int flags = FLOW_DISSECTOR_F_PARSE_1ST_FRAG; - const struct ethhdr *eth = (const struct ethhdr *)data; - struct flow_keys_basic keys; - - /* this should never happen, but better safe than sorry */ - if (unlikely(len < sizeof(*eth))) - return len; - - /* parse any remaining L2/L3 headers, check for L4 */ - if (!skb_flow_dissect_flow_keys_basic(dev_net(dev), NULL, &keys, data, - eth->h_proto, sizeof(*eth), - len, flags)) - return max_t(u32, keys.control.thoff, sizeof(*eth)); - - /* parse for any L4 headers */ - return min_t(u32, __skb_get_poff(NULL, data, &keys, len), len); + /* Ethernet + maximal IPv4 and TCP headers fit; small frames stay whole. */ + return min_t(u32, len, 160); } EXPORT_SYMBOL(eth_get_headlen); --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2577,22 +2577,9 @@ virtio_skb_set_hash(&hdr->hash_v1_hdr, skb); hdr->hdr.flags = flags; - if (virtio_net_handle_csum_offload(skb, &hdr->hdr, vi->rx_tnl_csum)) { - net_warn_ratelimited("%s: bad csum: flags: %x, gso_type: %x rx_tnl_csum %d\n", - dev->name, hdr->hdr.flags, - hdr->hdr.gso_type, vi->rx_tnl_csum); + if (unlikely(flags || hdr->hdr.gso_type != VIRTIO_NET_HDR_GSO_NONE)) goto frame_err; - } - - if (virtio_net_hdr_tnl_to_skb(skb, &hdr->tnl_hdr, vi->rx_tnl, - vi->rx_tnl_csum, - virtio_is_little_endian(vi->vdev))) { - net_warn_ratelimited("%s: bad gso: type: %x, size: %u, flags %x tunnel %d tnl csum %d\n", - dev->name, hdr->hdr.gso_type, - hdr->hdr.gso_size, hdr->hdr.flags, - vi->rx_tnl, vi->rx_tnl_csum); - goto frame_err; - } + skb_reset_mac_header(skb); skb_record_rx_queue(skb, vq2rxq(rq->vq)); skb->protocol = eth_type_trans(skb, dev); @@ -3261,12 +3248,8 @@ struct virtio_net_hdr_v1_hash_tunnel *hdr; int num_sg; unsigned hdr_len = vi->hdr_len; - bool feature_hdrlen; bool can_push; - feature_hdrlen = virtio_has_feature(vi->vdev, - VIRTIO_NET_F_GUEST_HDRLEN); - pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest); /* Make sure it's safe to cast between formats */ @@ -3284,10 +3267,9 @@ else hdr = &skb_vnet_common_hdr(skb)->tnl_hdr; - if (virtio_net_hdr_tnl_from_skb(skb, hdr, vi->tx_tnl, - virtio_is_little_endian(vi->vdev), 0, - false, feature_hdrlen)) + if (unlikely(skb_is_gso(skb) || skb->ip_summed == CHECKSUM_PARTIAL)) return -EPROTO; + memset(hdr, 0, hdr_len); if (vi->mergeable_rx_bufs) hdr->hash_hdr.hdr.num_buffers = 0;