Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipv6: remove dynamic ICMPv6 sender registration infrastructure

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>

authored by

Fernando Fernandez Mancera and committed by
Jakub Kicinski
d2042d35 fde39f7d

+5 -76
+2 -27
include/linux/icmpv6.h
··· 15 15 16 16 #if IS_ENABLED(CONFIG_IPV6) 17 17 18 - typedef void ip6_icmp_send_t(struct sk_buff *skb, u8 type, u8 code, __u32 info, 19 - const struct in6_addr *force_saddr, 20 - const struct inet6_skb_parm *parm); 21 18 void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, 22 19 const struct in6_addr *force_saddr, 23 20 const struct inet6_skb_parm *parm); 24 - #if IS_BUILTIN(CONFIG_IPV6) 25 - static inline void __icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, 26 - const struct inet6_skb_parm *parm) 27 - { 28 - icmp6_send(skb, type, code, info, NULL, parm); 29 - } 30 - static inline int inet6_register_icmp_sender(ip6_icmp_send_t *fn) 31 - { 32 - BUILD_BUG_ON(fn != icmp6_send); 33 - return 0; 34 - } 35 - static inline int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn) 36 - { 37 - BUILD_BUG_ON(fn != icmp6_send); 38 - return 0; 39 - } 40 - #else 41 - extern void __icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, 42 - const struct inet6_skb_parm *parm); 43 - extern int inet6_register_icmp_sender(ip6_icmp_send_t *fn); 44 - extern int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn); 45 - #endif 46 21 47 22 static inline void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info) 48 23 { 49 - __icmpv6_send(skb, type, code, info, IP6CB(skb)); 24 + icmp6_send(skb, type, code, info, NULL, IP6CB(skb)); 50 25 } 51 26 52 27 int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type, ··· 33 58 static inline void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info) 34 59 { 35 60 struct inet6_skb_parm parm = { 0 }; 36 - __icmpv6_send(skb_in, type, code, info, &parm); 61 + icmp6_send(skb_in, type, code, info, NULL, &parm); 37 62 } 38 63 #endif 39 64
-6
net/ipv6/icmp.c
··· 1288 1288 if (inet6_add_protocol(&icmpv6_protocol, IPPROTO_ICMPV6) < 0) 1289 1289 goto fail; 1290 1290 1291 - err = inet6_register_icmp_sender(icmp6_send); 1292 - if (err) 1293 - goto sender_reg_err; 1294 1291 return 0; 1295 1292 1296 - sender_reg_err: 1297 - inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6); 1298 1293 fail: 1299 1294 pr_err("Failed to register ICMP6 protocol\n"); 1300 1295 return err; ··· 1297 1302 1298 1303 void icmpv6_cleanup(void) 1299 1304 { 1300 - inet6_unregister_icmp_sender(icmp6_send); 1301 1305 inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6); 1302 1306 } 1303 1307
+3 -43
net/ipv6/ip6_icmp.c
··· 7 7 8 8 #include <net/ipv6.h> 9 9 10 - #if IS_ENABLED(CONFIG_IPV6) 10 + #if IS_ENABLED(CONFIG_IPV6) && IS_ENABLED(CONFIG_NF_NAT) 11 11 12 - #if !IS_BUILTIN(CONFIG_IPV6) 13 - 14 - static ip6_icmp_send_t __rcu *ip6_icmp_send; 15 - 16 - int inet6_register_icmp_sender(ip6_icmp_send_t *fn) 17 - { 18 - return (cmpxchg((ip6_icmp_send_t **)&ip6_icmp_send, NULL, fn) == NULL) ? 19 - 0 : -EBUSY; 20 - } 21 - EXPORT_SYMBOL(inet6_register_icmp_sender); 22 - 23 - int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn) 24 - { 25 - int ret; 26 - 27 - ret = (cmpxchg((ip6_icmp_send_t **)&ip6_icmp_send, fn, NULL) == fn) ? 28 - 0 : -EINVAL; 29 - 30 - synchronize_net(); 31 - 32 - return ret; 33 - } 34 - EXPORT_SYMBOL(inet6_unregister_icmp_sender); 35 - 36 - void __icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, 37 - const struct inet6_skb_parm *parm) 38 - { 39 - ip6_icmp_send_t *send; 40 - 41 - rcu_read_lock(); 42 - send = rcu_dereference(ip6_icmp_send); 43 - if (send) 44 - send(skb, type, code, info, NULL, parm); 45 - rcu_read_unlock(); 46 - } 47 - EXPORT_SYMBOL(__icmpv6_send); 48 - #endif 49 - 50 - #if IS_ENABLED(CONFIG_NF_NAT) 51 12 #include <net/netfilter/nf_conntrack.h> 52 13 void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info) 53 14 { ··· 21 60 22 61 ct = nf_ct_get(skb_in, &ctinfo); 23 62 if (!ct || !(READ_ONCE(ct->status) & IPS_NAT_MASK)) { 24 - __icmpv6_send(skb_in, type, code, info, &parm); 63 + icmp6_send(skb_in, type, code, info, NULL, &parm); 25 64 return; 26 65 } 27 66 ··· 37 76 orig_ip = ipv6_hdr(skb_in)->saddr; 38 77 dir = CTINFO2DIR(ctinfo); 39 78 ipv6_hdr(skb_in)->saddr = ct->tuplehash[dir].tuple.src.u3.in6; 40 - __icmpv6_send(skb_in, type, code, info, &parm); 79 + icmp6_send(skb_in, type, code, info, NULL, &parm); 41 80 ipv6_hdr(skb_in)->saddr = orig_ip; 42 81 out: 43 82 consume_skb(cloned_skb); 44 83 } 45 84 EXPORT_SYMBOL(icmpv6_ndo_send); 46 - #endif 47 85 #endif