net: Add __icmp_send helper. [Linux 5.0]

net: Add __icmp_send helper. [Linux 5.0]

This Linux kernel change "net: Add __icmp_send helper" is included in the Linux 5.0 release. This change is authored by Nazarov Sergey <s-nazarov [at] yandex.ru> on Mon Feb 25 19:24:15 2019 +0300. The commit for this change in Linux stable tree is 9ef6b42 (patch).

net: Add __icmp_send helper.

Add __icmp_send function having ip_options struct parameter

Signed-off-by: Sergey Nazarov <[email protected]>
Reviewed-by: Paul Moore <[email protected]>
Signed-off-by: David S. Miller <[email protected]>

There are 16 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 include/net/icmp.h | 9 ++++++++-
 net/ipv4/icmp.c    | 7 ++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/net/icmp.h b/include/net/icmp.h
index 6ac3a5b..e0f709d 100644
--- a/include/net/icmp.h
+++ b/include/net/icmp.h
@@ -22,6 +22,7 @@

 #include <net/inet_sock.h>
 #include <net/snmp.h>
+#include <net/ip.h>

 struct icmp_err {
   int      errno;
@@ -39,7 +40,13 @@ struct icmp_err {
 struct sk_buff;
 struct net;

-void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info);
+void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info,
+        const struct ip_options *opt);
+static inline void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
+{
+   __icmp_send(skb_in, type, code, info, &IPCB(skb_in)->opt);
+}
+
 int icmp_rcv(struct sk_buff *skb);
 int icmp_err(struct sk_buff *skb, u32 info);
 int icmp_init(void);
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 065997f..3f24414 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -570,7 +570,8 @@ static struct rtable *icmp_route_lookup(struct net *net,
  *         MUST reply to only the first fragment.
  */

-void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
+void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info,
+        const struct ip_options *opt)
 {
    struct iphdr *iph;
    int room;
@@ -691,7 +692,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
                      iph->tos;
    mark = IP4_REPLY_MARK(net, skb_in->mark);

-   if (ip_options_echo(net, &icmp_param.replyopts.opt.opt, skb_in))
+   if (__ip_options_echo(net, &icmp_param.replyopts.opt.opt, skb_in, opt))
        goto out_unlock;

@@ -742,7 +743,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
    local_bh_enable();
 out:;
 }
-EXPORT_SYMBOL(icmp_send);
+EXPORT_SYMBOL(__icmp_send);

 static void icmp_socket_deliver(struct sk_buff *skb, u32 info)

Leave a Reply

Your email address will not be published. Required fields are marked *