From: Richard Gobert <richardbgobert@gmail.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, corbet@lwn.net, yoshfuji@linux-ipv6.org,
dsahern@kernel.org, alex.aring@gmail.com,
stefan@datenfreihafen.org, pablo@netfilter.org,
kadlec@netfilter.org, fw@strlen.de, kafai@fb.com,
netdev@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-wpan@vger.kernel.org,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org
Subject: [PATCH 1/4] net-next: frags: move inetpeer from ip4 to inet
Date: Mon, 29 Aug 2022 13:45:20 +0200 [thread overview]
Message-ID: <20220829114507.GA2348@debian> (raw)
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
reply other threads:[~2022-08-29 12:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220829114507.GA2348@debian \
--to=richardbgobert@gmail.com \
--cc=alex.aring@gmail.com \
--cc=corbet@lwn.net \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=kafai@fb.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=stefan@datenfreihafen.org \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.