@@ -48,4 +48,10 @@ extern void icmp_out_count(struct net *net, unsigned char type);
/* Move into dst.h ? */
extern int xrlim_allow(struct dst_entry *dst, int timeout);
+extern int register_icmpv6_send(void (*func)(struct sk_buff *skb, u8 type,
+ u8 code, __u32 info));
+extern int unregister_icmpv6_send(void);
+extern void call_icmpv6_send(struct sk_buff *skb, u8 type,
+ u8 code, __u32 info);
+
#endif /* _ICMP_H */
@@ -1217,3 +1217,36 @@ int __init icmp_init(void)
{
return register_pernet_subsys(&icmp_sk_ops);
}
+
+
+/* wrappers to call icmpv6_send() if ipv6 module is loaded */
+
+static void __rcu (*icmpv6_send_ptr)(struct sk_buff *skb, u8 type, u8 code,
+ __u32 info);
+
+int register_icmpv6_send(void (*func)(struct sk_buff *skb, u8 type, u8 code,
+ __u32 info))
+{
+ rcu_assign_pointer(icmpv6_send_ptr, func);
+ return 0;
+}
+EXPORT_SYMBOL(register_icmpv6_send);
+
+int unregister_icmpv6_send(void)
+{
+ rcu_assign_pointer(icmpv6_send_ptr, NULL);
+ synchronize_rcu();
+ return 0;
+}
+EXPORT_SYMBOL(unregister_icmpv6_send);
+
+/* called with rcu_read_lock */
+void call_icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
+{
+ void (*func)(struct sk_buff *skb, u8 type, u8 code, __u32 info);
+
+ func = rcu_dereference(icmpv6_send_ptr);
+ if (func)
+ (*func)(skb, type, code, info);
+}
+EXPORT_SYMBOL(call_icmpv6_send);
@@ -788,7 +788,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
}
if (mtu >= IPV6_MIN_MTU && mtu < skb->len - tunnel->hlen + gre_hlen) {
- icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
+ call_icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
ip_rt_put(rt);
goto tx_error;
}
@@ -862,6 +862,7 @@ int __init icmpv6_init(void)
err = -EAGAIN;
if (inet6_add_protocol(&icmpv6_protocol, IPPROTO_ICMPV6) < 0)
goto fail;
+ register_icmpv6_send(icmpv6_send);
return 0;
fail:
@@ -874,6 +875,7 @@ void icmpv6_cleanup(void)
{
unregister_pernet_subsys(&icmpv6_sk_ops);
inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6);
+ unregister_icmpv6_send();
}