Files
wlan-ap/feeds/ipq807x/ipq807x/patches/231-icmp-add-helpers-to-recognize-ICMP-error-packets.patch
Felix Fietkau 7bab50dd3c ipq807x: backport vxlan path mtu changes
Fixes: WIFI-7571
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-07-11 07:40:09 +02:00

58 lines
1.4 KiB
Diff

From: Matteo Croce <mcroce@redhat.com>
Date: Sat, 2 Nov 2019 01:12:03 +0100
Subject: [PATCH] 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>
---
--- a/include/linux/icmp.h
+++ b/include/linux/icmp.h
@@ -24,4 +24,19 @@ static inline struct icmphdr *icmp_hdr(c
{
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 */
--- a/include/linux/icmpv6.h
+++ b/include/linux/icmpv6.h
@@ -42,4 +42,18 @@ extern void icmpv6_flow_init(struct s
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