Skip to contentSkip to conversation

net-next: ip6: fetch inetpeer in ip6frag_init

PATCH In review Richard Gobert 2 participants 3 messages Aug 29, 2022 – Sep 1, 2022

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 2/4 net-next: ip6: fetch inetpeer in ip6frag_init

Obtain the IPv6 peer in ip6frag_init, to allow for peer memory tracking in the IPv6 fragment reassembly logic.

---
 include/net/ipv6_frag.h | 3 +++
 1 file changed, 3 insertions(+)
include/net/ipv6_frag.h +3 -0
index 5052c66e22d2..62760cd3bdd1 100644
@@ -6,6 +6,7 @@
 #include <net/addrconf.h>
 #include <net/ipv6.h>
 #include <net/inet_frag.h>
+#include <net/inetpeer.h>
 
 enum ip6_defrag_Richard Goberts {
 	IP6_DEFRAG_LOCAL_DELIVER,
@@ -33,9 +34,11 @@ static inline void ip6frag_init(struct inet_frag_queue *q, const void *a)
 {
 	struct frag_queue *fq = container_of(q, struct frag_queue, q);
 	const struct frag_v6_compare_key *key = a;
+	const struct net *net = q->fqdir->net;
 
 	q->key.v6 = *key;
 	fq->ecn = 0;
+	q->peer = inet_getpeer_v6(net->ipv6.peers, &key->saddr, 1);
 }
 
 static inline u32 ip6frag_key_hashfn(const void *data, u32 len, u32 seed)
Signature · 1 line
2.36.1
#1 lore raw
Quoted 3 lines · Richard Gobert

Obtain the IPv6 peer in ip6frag_init, to allow for peer memory tracking in the IPv6 fragment reassembly logic.

Sorry, this is adding yet another bottleneck, and will make DDOS attacks based on fragments more effective.

Whole concept of 'peers' based on IPv6 addresses is rather weak, as hosts with IPv6 can easily
get millions of different 'addresses'.

Quoted 33 lines
---
 include/net/ipv6_frag.h | 3 +++
 1 file changed, 3 insertions(+)
include/net/ipv6_frag.h +3 -1
index 5052c66e22d2..62760cd3bdd1 100644
@@ -6,6 +6,7 @@
 #include <net/addrconf.h>
 #include <net/ipv6.h>
 #include <net/inet_frag.h>
+#include <net/inetpeer.h>
 
 enum ip6_defrag_Richard Goberts {
        IP6_DEFRAG_LOCAL_DELIVER,
@@ -33,9 +34,11 @@ static inline void ip6frag_init(struct inet_frag_queue *q, const void *a)
 {
        struct frag_queue *fq = container_of(q, struct frag_queue, q);
        const struct frag_v6_compare_key *key = a;
+       const struct net *net = q->fqdir->net;
 
        q->key.v6 = *key;
        fq->ecn = 0;
+       q->peer = inet_getpeer_v6(net->ipv6.peers, &key->saddr, 1);
 }
 
 static inline u32 ip6frag_key_hashfn(const void *data, u32 len, u32 seed)
--

2.36.1

#2 lore raw
Quoted 6 lines · Eric Dumazet

Sorry, this is adding yet another bottleneck, and will make DDOS attacks based on fragments more effective.

Whole concept of 'peers' based on IPv6 addresses is rather weak, as hosts with IPv6 can easily
get millions of different 'addresses'.

I understand the problem with the implementation. Since peers don't carry much weight in IPv6, this patch can be dropped.