Do not drop DNATed 6to4/6rd packets
Subsystems (3)
PATCH 1/1 Do not drop DNATed 6to4/6rd packets
From: "Catalin(ux) M. BOIE" <[email protected]>
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora and IPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).
--- include/net/addrconf.h | 5 +++++ net/ipv6/addrconf.c | 28 ++++++++++++++++++++++++++++ net/ipv6/sit.c | 50 +++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 76 insertions(+), 7 deletions(-)
include/net/addrconf.h +5 -0
@@ -73,6 +73,11 @@ extern int ipv6_chk_home_addr(struct net *net, const struct in6_addr *addr);#endif +extern bool ipv6_chk_custom_prefix ( +const struct in6_addr *addr, +const unsigned int prefix_len, +struct net_device *dev); +extern int ipv6_chk_prefix (const struct in6_addr *addr,struct net_device *dev);
net/ipv6/addrconf.c +28 -0
@@ -1527,6 +1527,34 @@ static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,return false; } +/* +* Compares an address/prefix_len with addresses on device @dev. +* If one is found it returns true. +*/ +bool ipv6_chk_custom_prefix (const struct in6_addr *addr, +const unsigned int prefix_len,struct net_device *dev) +{ +struct inet6_dev *idev; +struct inet6_ifaddr *ifa; +bool ret = false; + +rcu_read_lock (); + idev =__in6_dev_get (dev); +if (idev) { +read_lock_bh (&idev->lock); +list_for_each_entry (ifa, &idev->addr_list, if_list) { + ret =ipv6_prefix_equal (addr, &ifa->addr, prefix_len); +if (ret) +break ; + } +read_unlock_bh (&idev->lock); + } +rcu_read_unlock (); + +return ret; +} +EXPORT_SYMBOL (ipv6_chk_custom_prefix); +int ipv6_chk_prefix (const struct in6_addr *addr,struct net_device *dev) {struct inet6_dev *idev;
net/ipv6/sit.c +43 -7
74 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 10 lines · Catalin(ux) M. BOIE
From: "Catalin(ux) M. BOIE" <[email protected]>
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (
218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora andIPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).Signed-off-by Catalin(ux) M. BOIE <[email protected]>
Pretty neat idea, I think. Could you rebase the patch ontop of net or net-next and have a look at the warnings when you feed your patch to ./scripts/checkpatch --strict?
Greetings,
Hannes
PATCH 1/1 Do not drop DNATed 6to4/6rd packets
From: "Catalin(ux) M. BOIE" <[email protected]>
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora and IPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).
--- include/net/addrconf.h | 4 +++ net/ipv6/addrconf.c | 27 ++++++++++++++++ net/ipv6/sit.c | 83 +++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 99 insertions(+), 15 deletions(-)
include/net/addrconf.h +4 -0
@@ -67,6 +67,10 @@ int ipv6_chk_addr(struct net *net, const struct in6_addr *addr,int ipv6_chk_home_addr (struct net *net,const struct in6_addr *addr);#endif +extern bool ipv6_chk_custom_prefix (const struct in6_addr *addr, +const unsigned int prefix_len, +struct net_device *dev); +int ipv6_chk_prefix (const struct in6_addr *addr,struct net_device *dev); struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
net/ipv6/addrconf.c +27 -0
@@ -1499,6 +1499,33 @@ static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,return false; } +/* Compares an address/prefix_len with addresses on device @dev. +* If one is found it returns true. +*/ +bool ipv6_chk_custom_prefix (const struct in6_addr *addr, +const unsigned int prefix_len,struct net_device *dev) +{ +struct inet6_dev *idev; +struct inet6_ifaddr *ifa; +bool ret = false; + +rcu_read_lock (); + idev =__in6_dev_get (dev); +if (idev) { +read_lock_bh (&idev->lock); +list_for_each_entry (ifa, &idev->addr_list, if_list) { + ret =ipv6_prefix_equal (addr, &ifa->addr, prefix_len); +if (ret) +break ; + } +read_unlock_bh (&idev->lock); + } +rcu_read_unlock (); + +return ret; +} +EXPORT_SYMBOL (ipv6_chk_custom_prefix); +int ipv6_chk_prefix (const struct in6_addr *addr,struct net_device *dev) {struct inet6_dev *idev;
net/ipv6/sit.c +68 -15
107 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 8 lines · Catalin(ux) M. BOIE
From: "Catalin(ux) M. BOIE" <[email protected]>
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (
218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora andIPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).
Thanks. trivial nits which maybe fixed later:
net/ipv6/sit.c
Quoted 1 line
net/ipv6/sit.c +0
-0
[]
Quoted 2 lines
+/* Returns true if a packet is spoofed
+ */
probably nicer as single line /* Returns true ... */
Quoted 4 lines
net/ipv6/sit.c +4
-0+static bool packet_is_spoofed (struct sk_buff *skb, +const struct iphdr *iph, +struct ip_tunnel *tunnel) +{
net/ipv6/sit.c static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr, · line 610
Quoted 10 lines
net/ipv6/sit.c +10
-0+const struct ipv6hdr *ipv6h =ipv6_hdr (skb); + +if (tunnel->dev->priv_flags &IFF_ISATAP ) { +if (!isatap_chksrc (skb, iph, tunnel)) +return true; + +return false; + } + +if ((tunnel->dev->flags&IFF_POINTOPOINT ))
It'd be nicer with spaces around the &
net/ipv6/sit.c
Quoted 1 line
net/ipv6/sit.c +1
-0+return false;
It'd be slightly faster code moving the ipv6_hdr(skb) assignment below these tests.
Hello!
Quoted 36 lines · Joe Perches
Quoted 8 lines · Catalin(ux) M. BOIE
From: "Catalin(ux) M. BOIE" <[email protected]>
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (
218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora andIPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).Thanks. trivial nits which maybe fixed later:
net/ipv6/sit.c
Quoted 1 line
net/ipv6/sit.c +0
-0[]
Quoted 2 lines
+/* Returns true if a packet is spoofed
+ */probably nicer as single line /* Returns true ... */
Quoted 4 lines
net/ipv6/sit.c +4
-0+static bool packet_is_spoofed (struct sk_buff *skb, +const struct iphdr *iph, +struct ip_tunnel *tunnel) +{net/ipv6/sit.c static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr, · line 610
Quoted 10 lines
net/ipv6/sit.c +10
-0+const struct ipv6hdr *ipv6h =ipv6_hdr (skb); + +if (tunnel->dev->priv_flags &IFF_ISATAP ) { +if (!isatap_chksrc (skb, iph, tunnel)) +return true; + +return false; + } + +if ((tunnel->dev->flags&IFF_POINTOPOINT ))It'd be nicer with spaces around the &
Quoted 4 lines
net/ipv6/sit.c
Quoted 1 line
net/ipv6/sit.c +1
-0+return false;It'd be slightly faster code moving the
ipv6_hdr(skb)assignment below these tests.
Patch (v3) will follow.
Thank you, Hannes!
Thank you, Joe!
--
Catalin(ux) M. BOIE
http://kernel.embedromix.ro/
PATCH 1/1 Do not drop DNATed 6to4/6rd packets (v3)
In reply to Joe PerchesFrom: "Catalin(ux) M. BOIE" <[email protected]>
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora and IPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).
--- include/net/addrconf.h | 4 +++ net/ipv6/addrconf.c | 27 ++++++++++++++++ net/ipv6/sit.c | 83 +++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 99 insertions(+), 15 deletions(-)
include/net/addrconf.h +4 -0
@@ -67,6 +67,10 @@ int ipv6_chk_addr(struct net *net, const struct in6_addr *addr,int ipv6_chk_home_addr (struct net *net,const struct in6_addr *addr);#endif +extern bool ipv6_chk_custom_prefix (const struct in6_addr *addr, +const unsigned int prefix_len, +struct net_device *dev); +int ipv6_chk_prefix (const struct in6_addr *addr,struct net_device *dev); struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
net/ipv6/addrconf.c +27 -0
@@ -1499,6 +1499,33 @@ static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,return false; } +/* Compares an address/prefix_len with addresses on device @dev. +* If one is found it returns true. +*/ +bool ipv6_chk_custom_prefix (const struct in6_addr *addr, +const unsigned int prefix_len,struct net_device *dev) +{ +struct inet6_dev *idev; +struct inet6_ifaddr *ifa; +bool ret = false; + +rcu_read_lock (); + idev =__in6_dev_get (dev); +if (idev) { +read_lock_bh (&idev->lock); +list_for_each_entry (ifa, &idev->addr_list, if_list) { + ret =ipv6_prefix_equal (addr, &ifa->addr, prefix_len); +if (ret) +break ; + } +read_unlock_bh (&idev->lock); + } +rcu_read_unlock (); + +return ret; +} +EXPORT_SYMBOL (ipv6_chk_custom_prefix); +int ipv6_chk_prefix (const struct in6_addr *addr,struct net_device *dev) {struct inet6_dev *idev;
net/ipv6/sit.c +68 -15
107 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 36 lines · Joe Perches
Quoted 8 lines · Catalin(ux) M. BOIE
From: "Catalin(ux) M. BOIE" <[email protected]>
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (
218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora andIPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).Thanks. trivial nits which maybe fixed later:
net/ipv6/sit.c
Quoted 1 line
net/ipv6/sit.c +0
-0[]
Quoted 2 lines
+/* Returns true if a packet is spoofed
+ */probably nicer as single line /* Returns true ... */
Quoted 4 lines
net/ipv6/sit.c +4
-0+static bool packet_is_spoofed (struct sk_buff *skb, +const struct iphdr *iph, +struct ip_tunnel *tunnel) +{net/ipv6/sit.c static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr, · line 610
Quoted 10 lines
net/ipv6/sit.c +10
-0+const struct ipv6hdr *ipv6h =ipv6_hdr (skb); + +if (tunnel->dev->priv_flags &IFF_ISATAP ) { +if (!isatap_chksrc (skb, iph, tunnel)) +return true; + +return false; + } + +if ((tunnel->dev->flags&IFF_POINTOPOINT ))It'd be nicer with spaces around the &
Quoted 4 lines
net/ipv6/sit.c
Quoted 1 line
net/ipv6/sit.c +1
-0+return false;It'd be slightly faster code moving the
ipv6_hdr(skb)assignment below these tests.
Sorry, v3 was missing the changes suggested.
v4 fill fix it.
Sorry.
--
Catalin(ux) M. BOIE
http://kernel.embedromix.ro/
PATCH 1/1 Do not drop DNATed 6to4/6rd packets (v4)
In reply to Joe PerchesFrom: "Catalin(ux) M. BOIE" <[email protected]>
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora and IPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).
--- include/net/addrconf.h | 4 +++ net/ipv6/addrconf.c | 27 ++++++++++++++++ net/ipv6/sit.c | 84 +++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 100 insertions(+), 15 deletions(-)
include/net/addrconf.h +4 -0
@@ -67,6 +67,10 @@ int ipv6_chk_addr(struct net *net, const struct in6_addr *addr,int ipv6_chk_home_addr (struct net *net,const struct in6_addr *addr);#endif +extern bool ipv6_chk_custom_prefix (const struct in6_addr *addr, +const unsigned int prefix_len, +struct net_device *dev); +int ipv6_chk_prefix (const struct in6_addr *addr,struct net_device *dev); struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
net/ipv6/addrconf.c +27 -0
@@ -1499,6 +1499,33 @@ static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,return false; } +/* Compares an address/prefix_len with addresses on device @dev. +* If one is found it returns true. +*/ +bool ipv6_chk_custom_prefix (const struct in6_addr *addr, +const unsigned int prefix_len,struct net_device *dev) +{ +struct inet6_dev *idev; +struct inet6_ifaddr *ifa; +bool ret = false; + +rcu_read_lock (); + idev =__in6_dev_get (dev); +if (idev) { +read_lock_bh (&idev->lock); +list_for_each_entry (ifa, &idev->addr_list, if_list) { + ret =ipv6_prefix_equal (addr, &ifa->addr, prefix_len); +if (ret) +break ; + } +read_unlock_bh (&idev->lock); + } +rcu_read_unlock (); + +return ret; +} +EXPORT_SYMBOL (ipv6_chk_custom_prefix); +int ipv6_chk_prefix (const struct in6_addr *addr,struct net_device *dev) {struct inet6_dev *idev;
net/ipv6/sit.c +69 -15
108 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH] Do not drop DNATed 6to4/6rd packets (v4)
Quoted 8 lines · Catalin(ux) M. BOIE
From: "Catalin(ux) M. BOIE" <[email protected]>
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (
218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora andIPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).
A few more trivialities:
When you send revisions to patches, please put the revision number inside the brackets like:
[PATCH V4] subject
Also, use a prefix for the patch like:
[PATCH V4] IPv6 NAT: Don't drop DNAT 6to4 or 6RD packets
include/net/addrconf.h
Quoted 1 line
include/net/addrconf.h +0
-0
[]
include/net/addrconf.h int ipv6_chk_addr(struct net *net, const struct in6_addr *addr, · line 73
Quoted 8 lines
include/net/addrconf.h +4
-0@@ -67,6 +67,10 @@ int ipv6_chk_addr(struct net *net, const struct in6_addr *addr,int ipv6_chk_home_addr (struct net *net,const struct in6_addr *addr);#endif +extern bool ipv6_chk_custom_prefix (const struct in6_addr *addr, +const unsigned int prefix_len, +struct net_device *dev); +
extern isn't required.
net/ipv6/sit.c
Quoted 1 line
net/ipv6/sit.c +0
-0
[]
net/ipv6/sit.c static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr,
Quoted 1 line
net/ipv6/sit.c +0
-0@@ -566,6 +566,70 @@ static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr,
[]
net/ipv6/sit.c static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr, · line 599
Quoted 5 lines
net/ipv6/sit.c +5
-0+/* Returns true if a packet is spoofed */ +static bool packet_is_spoofed (struct sk_buff *skb, +const struct iphdr *iph, +struct ip_tunnel *tunnel) +{
[]
net/ipv6/sit.c static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr, · line 572
Quoted 2 lines
net/ipv6/sit.c +2
-0+if ((tunnel->dev->flags &IFF_POINTOPOINT )) +return false;
One too many parentheses
if (tunnel->dev->flags & IFF_POINTTOPOINT) return false;
PATCH v5 1/1 IPv6 NAT: Do not drop DNATed 6to4/6rd packets
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora and IPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).
--- include/net/addrconf.h | 4 +++ net/ipv6/addrconf.c | 27 ++++++++++++++++ net/ipv6/sit.c | 84 +++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 100 insertions(+), 15 deletions(-)
include/net/addrconf.h +4 -0
@@ -67,6 +67,10 @@ int ipv6_chk_addr(struct net *net, const struct in6_addr *addr,int ipv6_chk_home_addr (struct net *net,const struct in6_addr *addr);#endif +bool ipv6_chk_custom_prefix (const struct in6_addr *addr, +const unsigned int prefix_len, +struct net_device *dev); +int ipv6_chk_prefix (const struct in6_addr *addr,struct net_device *dev); struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
net/ipv6/addrconf.c +27 -0
@@ -1499,6 +1499,33 @@ static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,return false; } +/* Compares an address/prefix_len with addresses on device @dev. +* If one is found it returns true. +*/ +bool ipv6_chk_custom_prefix (const struct in6_addr *addr, +const unsigned int prefix_len,struct net_device *dev) +{ +struct inet6_dev *idev; +struct inet6_ifaddr *ifa; +bool ret = false; + +rcu_read_lock (); + idev =__in6_dev_get (dev); +if (idev) { +read_lock_bh (&idev->lock); +list_for_each_entry (ifa, &idev->addr_list, if_list) { + ret =ipv6_prefix_equal (addr, &ifa->addr, prefix_len); +if (ret) +break ; + } +read_unlock_bh (&idev->lock); + } +rcu_read_unlock (); + +return ret; +} +EXPORT_SYMBOL (ipv6_chk_custom_prefix); +int ipv6_chk_prefix (const struct in6_addr *addr,struct net_device *dev) {struct inet6_dev *idev;
net/ipv6/sit.c +69 -15
108 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH v5] IPv6 NAT: Do not drop DNATed 6to4/6rd packets
Quoted 8 lines · Catalin(ux) M. BOIE
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (
218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora andIPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).Signed-off-by Catalin(ux) M. BOIE <[email protected]>
Thanks,
Hannes
Re: [PATCH v5] IPv6 NAT: Do not drop DNATed 6to4/6rd packets
From: Hannes Frederic Sowa <[email protected]>
Date: Tue, 24 Sep 2013 23:36:06 +0200
Quoted 11 lines · Catalin(ux) M. BOIE
Quoted 8 lines
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (
218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora andIPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).Signed-off-by Catalin(ux) M. BOIE <[email protected]>
Applied, but Catalin please strictly refer to changes in the following precise format:
commit $SHA1_ID ("Commit message header line text")
Because SHA1_IDs are ambiguous, especially when the change in question is backported into various -stable branches.
The only way to resolve the ambiguity is to provide the commit message text (in parenthesis and double quotes).
Re: [PATCH v5] IPv6 NAT: Do not drop DNATed 6to4/6rd packets
Quoted 7 lines · David Miller
Applied, but Catalin please strictly refer to changes in the following precise format:
commit $SHA1_ID ("Commit message header line text")
Because
SHA1_IDsare ambiguous, especially when the change in question is backported into various -stable branches.
There are now enough commits that using only
8 byte SHA1 IDs generates some collisions so
please use 12 bytes or so of the SHA1.
Re: [PATCH v5] IPv6 NAT: Do not drop DNATed 6to4/6rd packets
In reply to David MillerQuoted 18 lines · David Miller
From: Hannes Frederic Sowa <[email protected]>
Date: Tue, 24 Sep 2013 23:36:06 +0200Quoted 11 lines · Catalin(ux) M. BOIE
Quoted 8 lines
When a router is doing DNAT for 6to4/6rd packets the latest anti-spoofing patch (
218774dc) will drop them because the IPv6 address embedded does not match the IPv4 destination. This patch will allow them to pass by testing if we have an address that matches on 6to4/6rd interface. I have been hit by this problem using Fedora andIPV6TO4_IPV4ADDR. Also, log the dropped packets (with rate limit).Signed-off-by Catalin(ux) M. BOIE <[email protected]>Applied, but Catalin please strictly refer to changes in the following precise format:
Quoted 7 lines
commit $SHA1_ID ("Commit message header line text")
Because
SHA1_IDsare ambiguous, especially when the change in question is backported into various -stable branches.The only way to resolve the ambiguity is to provide the commit message text (in parenthesis and double quotes).
Roger.
Should I resubmit it?
Should I send it also to 'stable'?
Thank you.
--
Catalin(ux) M. BOIE
http://kernel.embedromix.ro/