From: planck kernel size experiment Subject: [PATCH 9/9] net: disable route netlink control and notifications planck-init creates the IPv4 address, flags and default route with ioctls. It never opens NETLINK_ROUTE. Registering route/link command handlers and nexthop-object management therefore retains large dump, validation, bridge, notification and resilient-group code which cannot affect the logger. Keep rtnl_lock and the in-kernel route/FIB implementation, but do not create the route-netlink socket or register command/notifier tables. Notification entry points consume their skb without delivery so existing device and route callers retain their ownership contract. The legacy FIB route used by TCP, UDP and the final ICMP proof does not use nexthop objects. --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -943,33 +943,26 @@ int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int group, int echo) { - struct sock *rtnl = net->rtnl; - - return nlmsg_notify(rtnl, skb, pid, group, echo, GFP_KERNEL); + kfree_skb(skb); + return 0; } int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid) { - struct sock *rtnl = net->rtnl; - - return nlmsg_unicast(rtnl, skb, pid); + kfree_skb(skb); + return 0; } EXPORT_SYMBOL(rtnl_unicast); void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group, const struct nlmsghdr *nlh, gfp_t flags) { - struct sock *rtnl = net->rtnl; - - nlmsg_notify(rtnl, skb, pid, group, nlmsg_report(nlh), flags); + kfree_skb(skb); } EXPORT_SYMBOL(rtnl_notify); void rtnl_set_sk_err(struct net *net, u32 group, int error) { - struct sock *rtnl = net->rtnl; - - netlink_set_err(rtnl, 0, group, error); } EXPORT_SYMBOL(rtnl_set_sk_err); @@ -4415,41 +4408,13 @@ int new_ifindex, u32 portid, const struct nlmsghdr *nlh) { - struct net *net = dev_net(dev); - struct sk_buff *skb; - int err = -ENOBUFS; - u32 seq = 0; - - skb = nlmsg_new(if_nlmsg_size(dev, 0), flags); - if (skb == NULL) - goto errout; - - if (nlmsg_report(nlh)) - seq = nlmsg_seq(nlh); - else - portid = 0; - - err = rtnl_fill_ifinfo(skb, dev, dev_net(dev), - type, portid, seq, change, 0, 0, event, - new_nsid, new_ifindex, -1, flags); - if (err < 0) { - /* -EMSGSIZE implies BUG in if_nlmsg_size() */ - WARN_ON(err == -EMSGSIZE); - kfree_skb(skb); - goto errout; - } - return skb; -errout: - rtnl_set_sk_err(net, RTNLGRP_LINK, err); return NULL; } void rtmsg_ifinfo_send(struct sk_buff *skb, struct net_device *dev, gfp_t flags, u32 portid, const struct nlmsghdr *nlh) { - struct net *net = dev_net(dev); - - rtnl_notify(skb, net, portid, RTNLGRP_LINK, nlh, flags); + kfree_skb(skb); } static void rtmsg_ifinfo_event(int type, struct net_device *dev, @@ -4471,15 +4436,11 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned int change, gfp_t flags, u32 portid, const struct nlmsghdr *nlh) { - rtmsg_ifinfo_event(type, dev, change, rtnl_get_event(0), flags, - NULL, 0, portid, nlh); } void rtmsg_ifinfo_newnet(int type, struct net_device *dev, unsigned int change, gfp_t flags, int *new_nsid, int new_ifindex) { - rtmsg_ifinfo_event(type, dev, change, rtnl_get_event(0), flags, - new_nsid, new_ifindex, 0, NULL); } static int nlmsg_populate_fdb_fill(struct sk_buff *skb, @@ -7110,10 +7071,4 @@ void __init rtnetlink_init(void) { - if (register_pernet_subsys(&rtnetlink_net_ops)) - panic("rtnetlink_init: cannot initialize rtnetlink\n"); - - register_netdevice_notifier(&rtnetlink_dev_notifier); - - rtnl_register_many(rtnetlink_rtnl_msg_handlers); } --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -4154,12 +4154,6 @@ static int __init nexthop_init(void) { - register_pernet_subsys(&nexthop_net_ops); - - register_netdevice_notifier(&nh_netdev_notifier); - - rtnl_register_many(nexthop_rtnl_msg_handlers); - return 0; } subsys_initcall(nexthop_init);