From: planck kernel size experiment Subject: ipv4: remove datagram ping sockets The acceptance protocol now returns its post-fsync commit on the required TCP connection. PID 1 no longer opens SOCK_DGRAM/IPPROTO_ICMP, so the special unprivileged ping socket protocol and its hash table have no consumer. Keep raw ICMP for the moment because the generic ICMP control socket is built on it; this patch deliberately isolates the independently removable ping layer. Measured effect on RV32: Image shrank by 256 bytes (1,216,960 to 1,216,704 bytes), with the TCP/UDP/Minix acceptance proof still passing. --- a/net/ipv4/Makefile +++ b/net/ipv4/Makefile @@ -15,3 +15,3 @@ obj-y := route.o inetpeer.o protocol.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 fib_notifier.o \ - inet_fragment.o ping.o \ + inet_fragment.o \ --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1175,12 +1175,4 @@ static struct inet_protosw inetsw_array[] = .flags = INET_PROTOSW_PERMANENT, }, - { - .type = SOCK_DGRAM, - .protocol = IPPROTO_ICMP, - .prot = &ping_prot, - .ops = &inet_sockraw_ops, - .flags = INET_PROTOSW_REUSE, - }, - { @@ -1904,8 +1896,4 @@ static int __init inet_init(void) if (rc) goto out_unregister_udp_proto; - rc = proto_register(&ping_prot, 1); - if (rc) - goto out_unregister_raw_proto; - /* @@ -1977,5 +1965,3 @@ static int __init inet_init(void) raw_init(); - ping_init(); - /* @@ -2006,5 +1992,3 @@ out: return rc; -out_unregister_raw_proto: - proto_unregister(&raw_prot); out_unregister_udp_proto: proto_unregister(&udp_prot); --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -1497,7 +1497,7 @@ int icmp_rcv(struct sk_buff *skb) if (icmph->type == ICMP_EXT_ECHOREPLY || icmph->type == ICMP_ECHOREPLY) { - reason = ping_rcv(skb); - return reason ? NET_RX_DROP : NET_RX_SUCCESS; + reason = SKB_DROP_REASON_UNHANDLED_PROTO; + goto error; } /* @@ -1603,7 +1603,6 @@ int icmp_err(struct sk_buff *skb, u32 info) * triggered by ICMP_ECHOREPLY which sent from kernel. */ if (icmph->type != ICMP_ECHOREPLY) { - ping_err(skb, offset, info); return 0; } @@ -1620,7 +1619,7 @@ int icmp_err(struct sk_buff *skb, u32 info) */ static const struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = { [ICMP_ECHOREPLY] = { - .handler = ping_rcv, + .handler = icmp_discard, }, [1] = { .handler = icmp_discard,