summaryrefslogtreecommitdiff
path: root/include/linux/icmpv6.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/icmpv6.h
parentb8fed591df6bf7a86a5f55a3d67a3a1a4d0fce73 (diff)
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/icmpv6.h')
-rw-r--r--include/linux/icmpv6.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h
index a8f888976137..ef1cbb5f454f 100644
--- a/include/linux/icmpv6.h
+++ b/include/linux/icmpv6.h
@@ -46,4 +46,18 @@ extern void icmpv6_flow_init(struct sock *sk,
const struct in6_addr *saddr,
const struct in6_addr *daddr,
int oif);
+
+static inline bool icmpv6_is_err(int type)
+{
+ switch (type) {
+ case ICMPV6_DEST_UNREACH:
+ case ICMPV6_PKT_TOOBIG:
+ case ICMPV6_TIME_EXCEED:
+ case ICMPV6_PARAMPROB:
+ return true;
+ }
+
+ return false;
+}
+
#endif