From: planck kernel size experiment Subject: ipv4: reject fragments instead of reassembling or creating them The log-server profile uses MTU-sized-or-smaller UDP records, while TCP already segments its byte stream. Drop fragmented input and return EMSGSIZE for output that would need IP fragmentation. This removes the IPv4 reassembly queues, timers and generic inet fragment engine, and compiles out the output fragment builder. The operational constraint is explicit: one UDP record must fit in a single IPv4 packet; ordinary TCP traffic is unchanged. Measured effect on RV32: 1,192,120 -> 1,183,864 bytes in the raw Image (-8,256 bytes). Linked sections fell by 9,014 bytes: text -8,714, data -228, and BSS -72. The exact UDP + TCP + fsync + disk-readback proof passes. --- a/net/ipv4/Makefile +++ b/net/ipv4/Makefile @@ -4,7 +4,7 @@ # obj-y := route.o inetpeer.o protocol.o \ - ip_input.o ip_fragment.o ip_forward.o planck_no_options.o \ + ip_input.o ip_forward.o planck_no_options.o \ ip_output.o ip_sockglue.o inet_hashtables.o \ inet_timewait_sock.o inet_connection_sock.o \ tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \ @@ -13,7 +13,6 @@ tcp_offload.o tcp_plb.o datagram.o raw.o udp.o \ udp_offload.o arp.o icmp.o devinet.o af_inet.o planck_unicast.o \ fib_frontend.o fib_semantics.o fib_trie.o \ - inet_fragment.o \ planck_fib_control.o udp_tunnel_stub.o obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -254,9 +254,10 @@ */ struct net *net = dev_net(skb->dev); - if (ip_is_fragment(ip_hdr(skb))) { - if (ip_defrag(net, skb, IP_DEFRAG_LOCAL_DELIVER)) - return 0; + if (unlikely(ip_is_fragment(ip_hdr(skb)))) { + __IP_INC_STATS(net, IPSTATS_MIB_INDISCARDS); + kfree_skb_reason(skb, SKB_DROP_REASON_IP_INHDR); + return 0; } return NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_IN, --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -595,6 +595,16 @@ return ip_do_fragment(net, sk, skb, output); } +/* This profile never emits IPv4 fragments; callers retain normal error semantics. */ +int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, + int (*output)(struct net *, struct sock *, struct sk_buff *)) +{ + kfree_skb(skb); + IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS); + return -EMSGSIZE; +} + +#if 0 /* planck: fragmentation helpers are outside the log-server contract */ void ip_fraglist_init(struct sk_buff *skb, struct iphdr *iph, unsigned int hlen, struct ip_fraglist_iter *iter) { @@ -928,6 +938,7 @@ return err; } EXPORT_SYMBOL(ip_do_fragment); +#endif int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb) --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1985,8 +1985,6 @@ ipv4_proc_init(); - ipfrag_init(); - dev_add_pack(&ip_packet_type); rc = 0;