aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/icmp.h
diff options
context:
space:
mode:
authorMatteo Croce <mcroce@redhat.com>2019-11-02 01:12:03 +0100
committerDavid S. Miller <davem@davemloft.net>2019-11-05 14:03:11 -0800
commit15122464d525f684a61806d28597050cdcef0f32 (patch)
tree756dfcf379828884fe9d13c62ff1048fb058516f /include/linux/icmp.h
parentMerge branch 'netvsc-RSS-related-patches' (diff)
downloadlinux-dev-15122464d525f684a61806d28597050cdcef0f32.tar.xz
linux-dev-15122464d525f684a61806d28597050cdcef0f32.zip
icmp: add helpers to recognize ICMP error packets
Add two helper functions, one for IPv4 and one for IPv6, to recognize the ICMP packets which are error responses. This packets are special because they have as payload the original header of the packet which generated it (RFC 792 says at least 8 bytes, but Linux actually includes much more than that). Signed-off-by: Matteo Croce <mcroce@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/icmp.h')
-rw-r--r--include/linux/icmp.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/icmp.h b/include/linux/icmp.h
index 2d8aaf7d4b9e..81ca84ce3119 100644
--- a/include/linux/icmp.h
+++ b/include/linux/icmp.h
@@ -20,4 +20,19 @@ static inline struct icmphdr *icmp_hdr(const struct sk_buff *skb)
{
return (struct icmphdr *)skb_transport_header(skb);
}
+
+static inline bool icmp_is_err(int type)
+{
+ switch (type) {
+ case ICMP_DEST_UNREACH:
+ case ICMP_SOURCE_QUENCH:
+ case ICMP_REDIRECT:
+ case ICMP_TIME_EXCEEDED:
+ case ICMP_PARAMETERPROB:
+ return true;
+ }
+
+ return false;
+}
+
#endif /* _LINUX_ICMP_H */