* [PATCH 1/4] net-next: frags: move inetpeer from ip4 to inet
@ 2022-08-29 11:45 Richard Gobert
0 siblings, 0 replies; only message in thread
From: Richard Gobert @ 2022-08-29 11:45 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, corbet, yoshfuji, dsahern,
alex.aring, stefan, pablo, kadlec, fw, kafai, netdev, linux-doc,
linux-kernel, linux-wpan, netfilter-devel, coreteam
Move frags-related inetpeer logic from ip4 to inet. This allows us to
access peer information inside inet_frag logic.
Signed-off-by: Richard Gobert <richardbgobert@gmail.com>
---
include/net/inet_frag.h | 1 +
net/ipv4/inet_fragment.c | 11 ++++++++++-
net/ipv4/ip_fragment.c | 19 +++----------------
3 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index 0b0876610553..05d95fad8a1a 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -98,6 +98,7 @@ struct inet_frag_queue {
__u8 flags;
u16 max_size;
struct fqdir *fqdir;
+ struct inet_peer *peer;
struct rcu_head rcu;
};
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index c9f9ac5013a7..c3ec1dbe7081 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -23,6 +23,7 @@
#include <net/inet_ecn.h>
#include <net/ip.h>
#include <net/ipv6.h>
+#include <net/inetpeer.h>
/* Use skb->cb to track consecutive/adjacent fragments coming at
* the end of the queue. Nodes in the rb-tree queue will
@@ -282,6 +283,14 @@ unsigned int inet_frag_rbtree_purge(struct rb_root *root)
}
EXPORT_SYMBOL(inet_frag_rbtree_purge);
+void inet_frag_free(struct inet_frag_queue *q)
+{
+ if (q->peer)
+ inet_putpeer(q->peer);
+
+ call_rcu(&q->rcu, inet_frag_destroy_rcu);
+}
+
void inet_frag_destroy(struct inet_frag_queue *q)
{
struct fqdir *fqdir;
@@ -297,7 +306,7 @@ void inet_frag_destroy(struct inet_frag_queue *q)
sum_truesize = inet_frag_rbtree_purge(&q->rb_fragments);
sum = sum_truesize + f->qsize;
- call_rcu(&q->rcu, inet_frag_destroy_rcu);
+ inet_frag_free(q);
sub_frag_mem_limit(fqdir, sum);
}
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index fb153569889e..d0c22c41cf26 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -65,7 +65,6 @@ struct ipq {
u16 max_df_size; /* largest frag with DF set seen */
int iif;
unsigned int rid;
- struct inet_peer *peer;
};
static u8 ip4_frag_ecn(u8 tos)
@@ -88,21 +87,9 @@ static void ip4_frag_init(struct inet_frag_queue *q, const void *a)
q->key.v4 = *key;
qp->ecn = 0;
- qp->peer = q->fqdir->max_dist ?
- inet_getpeer_v4(net->ipv4.peers, key->saddr, key->vif, 1) :
- NULL;
+ q->peer = inet_getpeer_v4(net->ipv4.peers, key->saddr, key->vif, 1);
}
-static void ip4_frag_free(struct inet_frag_queue *q)
-{
- struct ipq *qp;
-
- qp = container_of(q, struct ipq, q);
- if (qp->peer)
- inet_putpeer(qp->peer);
-}
-
-
/* Destruction primitives. */
static void ipq_put(struct ipq *ipq)
@@ -224,7 +211,7 @@ static struct ipq *ip_find(struct net *net, struct iphdr *iph,
/* Is the fragment too far ahead to be part of ipq? */
static int ip_frag_too_far(struct ipq *qp)
{
- struct inet_peer *peer = qp->peer;
+ struct inet_peer *peer = qp->q.peer;
unsigned int max = qp->q.fqdir->max_dist;
unsigned int start, end;
@@ -741,7 +728,7 @@ static const struct rhashtable_params ip4_rhash_params = {
void __init ipfrag_init(void)
{
ip4_frags.constructor = ip4_frag_init;
- ip4_frags.destructor = ip4_frag_free;
+ ip4_frags.destructor = NULL;
ip4_frags.qsize = sizeof(struct ipq);
ip4_frags.frag_expire = ip_expire;
ip4_frags.frags_cache_name = ip_frag_cache_name;
--
2.36.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-29 12:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-29 11:45 [PATCH 1/4] net-next: frags: move inetpeer from ip4 to inet Richard Gobert
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.