From: planck kernel size experiment Subject: [PATCH 7/7] net: remove ethtool and per-device RSS control state The appliance configures net0 only through the four legacy ioctls used by planck-init. It never issues SIOCETHTOOL, and the one virtio-net device is never reconfigured after probe. The ethtool command switch, its large name tables, virtio callbacks, and the RSS xarray/mutex allocation are therefore permanent code/data and runtime memory with no path to the logger contract. Reject SIOCETHTOOL and stop publishing driver ethtool operations. Removing the directory costs no packet-path behavior; exact TCP/UDP delivery followed by the PCAP commit proof validates virtio RX and TX after this cut. --- a/net/Makefile +++ b/net/Makefile @@ -12,7 +12,7 @@ # LLC has to be linked before the files in net/802/ obj-$(CONFIG_LLC) += llc/ -obj-y += ethernet/ 802/ sched/ netlink/ bpf/ ethtool/ +obj-y += ethernet/ 802/ sched/ netlink/ bpf/ obj-$(CONFIG_NETFILTER) += netfilter/ obj-$(CONFIG_INET) += ipv4/ obj-$(CONFIG_TLS) += tls/ --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -773,11 +773,7 @@ return ret; case SIOCETHTOOL: - dev_load(net, ifr->ifr_name); - ret = dev_ethtool(net, ifr, data); - if (colon) - *colon = ':'; - return ret; + return -EOPNOTSUPP; /* * These ioctl calls: --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11338,14 +11338,6 @@ BUG_ON(dev->reg_state != NETREG_UNINITIALIZED); BUG_ON(!net); - ret = ethtool_check_ops(dev->ethtool_ops); - if (ret) - return ret; - - /* rss ctx ID 0 is reserved for the default context, start from 1 */ - xa_init_flags(&dev->ethtool->rss_ctx, XA_FLAGS_ALLOC1); - mutex_init(&dev->ethtool->rss_lock); - spin_lock_init(&dev->addr_list_lock); netdev_set_addr_lockdep_class(dev); @@ -11978,16 +11970,6 @@ return queue; } -static const struct ethtool_ops default_ethtool_ops; - -void netdev_set_default_ethtool_ops(struct net_device *dev, - const struct ethtool_ops *ops) -{ - if (dev->ethtool_ops == &default_ethtool_ops) - dev->ethtool_ops = ops; -} -EXPORT_SYMBOL_GPL(netdev_set_default_ethtool_ops); - /** * netdev_sw_irq_coalesce_default_on() - enable SW IRQ coalescing by default * @dev: netdev to enable the IRQ coalescing on @@ -12114,10 +12096,6 @@ dev->real_num_rx_queues = rxqs; if (netif_alloc_rx_queues(dev)) goto free_all; - dev->ethtool = kzalloc(sizeof(*dev->ethtool), GFP_KERNEL_ACCOUNT); - if (!dev->ethtool) - goto free_all; - dev->cfg = kzalloc(sizeof(*dev->cfg), GFP_KERNEL_ACCOUNT); if (!dev->cfg) goto free_all; @@ -12132,9 +12110,6 @@ strscpy(dev->name, name); dev->name_assign_type = name_assign_type; dev->group = INIT_NETDEV_GROUP; - if (!dev->ethtool_ops) - dev->ethtool_ops = &default_ethtool_ops; - nf_hook_netdev_init(dev); return dev; @@ -12194,7 +12169,6 @@ WARN_ON(dev->cfg != dev->cfg_pending); kfree(dev->cfg); - kfree(dev->ethtool); netif_free_tx_queues(dev); netif_free_rx_queues(dev); @@ -12267,17 +12241,6 @@ static void netdev_rss_contexts_free(struct net_device *dev) { - struct ethtool_rxfh_context *ctx; - unsigned long context; - - mutex_lock(&dev->ethtool->rss_lock); - xa_for_each(&dev->ethtool->rss_ctx, context, ctx) { - xa_erase(&dev->ethtool->rss_ctx, context); - dev->ethtool_ops->remove_rxfh_context(dev, ctx, context, NULL); - kfree(ctx); - } - xa_destroy(&dev->ethtool->rss_ctx); - mutex_unlock(&dev->ethtool->rss_lock); } /** @@ -12449,8 +12412,6 @@ if (dev->netdev_ops->ndo_uninit) dev->netdev_ops->ndo_uninit(dev); - mutex_destroy(&dev->ethtool->rss_lock); - net_shaper_flush_netdev(dev); if (skb) --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -6732,7 +6732,6 @@ dev->stat_ops = &virtnet_stat_ops; dev->features = NETIF_F_HIGHDMA; - dev->ethtool_ops = &virtnet_ethtool_ops; SET_NETDEV_DEV(dev, &vdev->dev); /* Do we support "hardware" checksums? */ --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -199,7 +199,7 @@ */ static void loopback_setup(struct net_device *dev) { - gen_lo_setup(dev, (64 * 1024), &loopback_ethtool_ops, ð_header_ops, + gen_lo_setup(dev, (64 * 1024), NULL, ð_header_ops, &loopback_ops, loopback_dev_free); } --- a/drivers/net/net_failover.c +++ b/drivers/net/net_failover.c @@ -723,7 +723,6 @@ SET_NETDEV_DEV(failover_dev, dev); failover_dev->netdev_ops = &failover_dev_ops; - failover_dev->ethtool_ops = &failover_ethtool_ops; /* Initialize the device options */ failover_dev->priv_flags |= IFF_UNICAST_FLT | IFF_NO_QUEUE; --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -4207,7 +4207,7 @@ vi->rss_trailer.hash_key_length = vi->rss_key_size; - netdev_rss_key_fill(vi->rss_hash_key_data, vi->rss_key_size); + memset(vi->rss_hash_key_data, 0, vi->rss_key_size); } static int virtnet_get_hashflow(struct net_device *dev, --- a/net/core/sock.c +++ b/net/core/sock.c @@ -891,6 +891,8 @@ int sock_set_timestamping(struct sock *sk, int optname, struct so_timestamping timestamping) { + return -EOPNOTSUPP; +#if 0 int val = timestamping.flags; int ret; @@ -937,6 +939,7 @@ sock_disable_timestamp(sk, (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE)); return 0; +#endif } #if defined(CONFIG_CGROUP_BPF)