]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ipv6: remove dynamic ICMPv6 sender registration infrastructure
authorFernando Fernandez Mancera <fmancera@suse.de>
Wed, 25 Mar 2026 12:08:45 +0000 (13:08 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sun, 29 Mar 2026 18:21:23 +0000 (11:21 -0700)
As IPv6 is built-in only, there is no need to maintain the sender
registration infrastructure used to allow built-in subsystems to send
ICMPv6 messages when IPv6 was compiled as a module.

Drop the registration mechanism and the __icmpv6_send() sender
implementation. While icmpv6_send() users could be converted to
icmp6_send() that doesn't seems necessary as none of them are using the
force_saddr parameter.

Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
Tested-by: Ricardo B. Marlière <rbm@suse.com>
Link: https://patch.msgid.link/20260325120928.15848-5-fmancera@suse.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/icmpv6.h
net/ipv6/icmp.c
net/ipv6/ip6_icmp.c

index e3b3b0fa2a8f8d95f4238da86d0bedff622b7a26..2bd9f2157e6cf4918b61074ba7fbd87e3e1a6b5d 100644 (file)
@@ -15,38 +15,13 @@ static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb)
 
 #if IS_ENABLED(CONFIG_IPV6)
 
-typedef void ip6_icmp_send_t(struct sk_buff *skb, u8 type, u8 code, __u32 info,
-                            const struct in6_addr *force_saddr,
-                            const struct inet6_skb_parm *parm);
 void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
                const struct in6_addr *force_saddr,
                const struct inet6_skb_parm *parm);
-#if IS_BUILTIN(CONFIG_IPV6)
-static inline void __icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
-                                const struct inet6_skb_parm *parm)
-{
-       icmp6_send(skb, type, code, info, NULL, parm);
-}
-static inline int inet6_register_icmp_sender(ip6_icmp_send_t *fn)
-{
-       BUILD_BUG_ON(fn != icmp6_send);
-       return 0;
-}
-static inline int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn)
-{
-       BUILD_BUG_ON(fn != icmp6_send);
-       return 0;
-}
-#else
-extern void __icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
-                         const struct inet6_skb_parm *parm);
-extern int inet6_register_icmp_sender(ip6_icmp_send_t *fn);
-extern int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn);
-#endif
 
 static inline void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
 {
-       __icmpv6_send(skb, type, code, info, IP6CB(skb));
+       icmp6_send(skb, type, code, info, NULL, IP6CB(skb));
 }
 
 int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type,
@@ -58,7 +33,7 @@ void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info);
 static inline void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info)
 {
        struct inet6_skb_parm parm = { 0 };
-       __icmpv6_send(skb_in, type, code, info, &parm);
+       icmp6_send(skb_in, type, code, info, NULL, &parm);
 }
 #endif
 
index 813d2e9edb8bed7c1649e279cea9229806af4132..8e8d7bd84a4c6162571feb231fca42ded3b2da13 100644 (file)
@@ -1288,13 +1288,8 @@ int __init icmpv6_init(void)
        if (inet6_add_protocol(&icmpv6_protocol, IPPROTO_ICMPV6) < 0)
                goto fail;
 
-       err = inet6_register_icmp_sender(icmp6_send);
-       if (err)
-               goto sender_reg_err;
        return 0;
 
-sender_reg_err:
-       inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6);
 fail:
        pr_err("Failed to register ICMP6 protocol\n");
        return err;
@@ -1302,7 +1297,6 @@ fail:
 
 void icmpv6_cleanup(void)
 {
-       inet6_unregister_icmp_sender(icmp6_send);
        inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6);
 }
 
index 233914b63bdb823d0bc5d3900e0032c1df1526e5..e43ea9492332d3cfe630277cf80220dda1f2e114 100644 (file)
@@ -7,47 +7,8 @@
 
 #include <net/ipv6.h>
 
-#if IS_ENABLED(CONFIG_IPV6)
+#if IS_ENABLED(CONFIG_IPV6) && IS_ENABLED(CONFIG_NF_NAT)
 
-#if !IS_BUILTIN(CONFIG_IPV6)
-
-static ip6_icmp_send_t __rcu *ip6_icmp_send;
-
-int inet6_register_icmp_sender(ip6_icmp_send_t *fn)
-{
-       return (cmpxchg((ip6_icmp_send_t **)&ip6_icmp_send, NULL, fn) == NULL) ?
-               0 : -EBUSY;
-}
-EXPORT_SYMBOL(inet6_register_icmp_sender);
-
-int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn)
-{
-       int ret;
-
-       ret = (cmpxchg((ip6_icmp_send_t **)&ip6_icmp_send, fn, NULL) == fn) ?
-             0 : -EINVAL;
-
-       synchronize_net();
-
-       return ret;
-}
-EXPORT_SYMBOL(inet6_unregister_icmp_sender);
-
-void __icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
-                  const struct inet6_skb_parm *parm)
-{
-       ip6_icmp_send_t *send;
-
-       rcu_read_lock();
-       send = rcu_dereference(ip6_icmp_send);
-       if (send)
-               send(skb, type, code, info, NULL, parm);
-       rcu_read_unlock();
-}
-EXPORT_SYMBOL(__icmpv6_send);
-#endif
-
-#if IS_ENABLED(CONFIG_NF_NAT)
 #include <net/netfilter/nf_conntrack.h>
 void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info)
 {
@@ -60,7 +21,7 @@ void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info)
 
        ct = nf_ct_get(skb_in, &ctinfo);
        if (!ct || !(READ_ONCE(ct->status) & IPS_NAT_MASK)) {
-               __icmpv6_send(skb_in, type, code, info, &parm);
+               icmp6_send(skb_in, type, code, info, NULL, &parm);
                return;
        }
 
@@ -76,11 +37,10 @@ void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info)
        orig_ip = ipv6_hdr(skb_in)->saddr;
        dir = CTINFO2DIR(ctinfo);
        ipv6_hdr(skb_in)->saddr = ct->tuplehash[dir].tuple.src.u3.in6;
-       __icmpv6_send(skb_in, type, code, info, &parm);
+       icmp6_send(skb_in, type, code, info, NULL, &parm);
        ipv6_hdr(skb_in)->saddr = orig_ip;
 out:
        consume_skb(cloned_skb);
 }
 EXPORT_SYMBOL(icmpv6_ndo_send);
 #endif
-#endif