Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 093ba729 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

inet: frags: add a pointer to struct netns_frags



In order to simplify the API, add a pointer to struct inet_frags.
This will allow us to make things less complex.

These functions no longer have a struct inet_frags parameter :

inet_frag_destroy(struct inet_frag_queue *q  /*, struct inet_frags *f */)
inet_frag_put(struct inet_frag_queue *q /*, struct inet_frags *f */)
inet_frag_kill(struct inet_frag_queue *q /*, struct inet_frags *f */)
inet_frags_exit_net(struct netns_frags *nf /*, struct inet_frags *f */)
ip6_expire_frag_queue(struct net *net, struct frag_queue *fq)

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 787bea77
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ struct netns_frags {
	int			high_thresh;
	int			low_thresh;
	int			max_dist;
	struct inet_frags	*f;
};

/**
@@ -109,20 +110,20 @@ static inline int inet_frags_init_net(struct netns_frags *nf)
	atomic_set(&nf->mem, 0);
	return 0;
}
void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);
void inet_frags_exit_net(struct netns_frags *nf);

void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f);
void inet_frag_kill(struct inet_frag_queue *q);
void inet_frag_destroy(struct inet_frag_queue *q);
struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
		struct inet_frags *f, void *key, unsigned int hash);

void inet_frag_maybe_warn_overflow(struct inet_frag_queue *q,
				   const char *prefix);

static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
static inline void inet_frag_put(struct inet_frag_queue *q)
{
	if (refcount_dec_and_test(&q->refcnt))
		inet_frag_destroy(q, f);
		inet_frag_destroy(q);
}

static inline bool inet_frag_evicting(struct inet_frag_queue *q)
+1 −2
Original line number Diff line number Diff line
@@ -607,8 +607,7 @@ struct frag_queue {
	u8			ecn;
};

void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq,
			   struct inet_frags *frags);
void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq);

static inline bool ipv6_addr_any(const struct in6_addr *a)
{
+7 −6
Original line number Diff line number Diff line
@@ -94,10 +94,10 @@ static void lowpan_frag_expire(struct timer_list *t)
	if (fq->q.flags & INET_FRAG_COMPLETE)
		goto out;

	inet_frag_kill(&fq->q, &lowpan_frags);
	inet_frag_kill(&fq->q);
out:
	spin_unlock(&fq->q.lock);
	inet_frag_put(&fq->q, &lowpan_frags);
	inet_frag_put(&fq->q);
}

static inline struct lowpan_frag_queue *
@@ -230,7 +230,7 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *prev,
	struct sk_buff *fp, *head = fq->q.fragments;
	int sum_truesize;

	inet_frag_kill(&fq->q, &lowpan_frags);
	inet_frag_kill(&fq->q);

	/* Make the one we just received the head. */
	if (prev) {
@@ -438,7 +438,7 @@ int lowpan_frag_rcv(struct sk_buff *skb, u8 frag_type)
		ret = lowpan_frag_queue(fq, skb, frag_type);
		spin_unlock(&fq->q.lock);

		inet_frag_put(&fq->q, &lowpan_frags);
		inet_frag_put(&fq->q);
		return ret;
	}

@@ -586,13 +586,14 @@ static int __net_init lowpan_frags_init_net(struct net *net)
	ieee802154_lowpan->frags.high_thresh = IPV6_FRAG_HIGH_THRESH;
	ieee802154_lowpan->frags.low_thresh = IPV6_FRAG_LOW_THRESH;
	ieee802154_lowpan->frags.timeout = IPV6_FRAG_TIMEOUT;
	ieee802154_lowpan->frags.f = &lowpan_frags;

	res = inet_frags_init_net(&ieee802154_lowpan->frags);
	if (res < 0)
		return res;
	res = lowpan_frags_ns_sysctl_register(net);
	if (res < 0)
		inet_frags_exit_net(&ieee802154_lowpan->frags, &lowpan_frags);
		inet_frags_exit_net(&ieee802154_lowpan->frags);
	return res;
}

@@ -602,7 +603,7 @@ static void __net_exit lowpan_frags_exit_net(struct net *net)
		net_ieee802154_lowpan(net);

	lowpan_frags_ns_sysctl_unregister(net);
	inet_frags_exit_net(&ieee802154_lowpan->frags, &lowpan_frags);
	inet_frags_exit_net(&ieee802154_lowpan->frags);
}

static struct pernet_operations lowpan_frags_ops = {
+10 −7
Original line number Diff line number Diff line
@@ -219,8 +219,9 @@ void inet_frags_fini(struct inet_frags *f)
}
EXPORT_SYMBOL(inet_frags_fini);

void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f)
void inet_frags_exit_net(struct netns_frags *nf)
{
	struct inet_frags *f =nf->f;
	unsigned int seq;
	int i;

@@ -264,33 +265,34 @@ __acquires(hb->chain_lock)
	return hb;
}

static inline void fq_unlink(struct inet_frag_queue *fq, struct inet_frags *f)
static inline void fq_unlink(struct inet_frag_queue *fq)
{
	struct inet_frag_bucket *hb;

	hb = get_frag_bucket_locked(fq, f);
	hb = get_frag_bucket_locked(fq, fq->net->f);
	hlist_del(&fq->list);
	fq->flags |= INET_FRAG_COMPLETE;
	spin_unlock(&hb->chain_lock);
}

void inet_frag_kill(struct inet_frag_queue *fq, struct inet_frags *f)
void inet_frag_kill(struct inet_frag_queue *fq)
{
	if (del_timer(&fq->timer))
		refcount_dec(&fq->refcnt);

	if (!(fq->flags & INET_FRAG_COMPLETE)) {
		fq_unlink(fq, f);
		fq_unlink(fq);
		refcount_dec(&fq->refcnt);
	}
}
EXPORT_SYMBOL(inet_frag_kill);

void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f)
void inet_frag_destroy(struct inet_frag_queue *q)
{
	struct sk_buff *fp;
	struct netns_frags *nf;
	unsigned int sum, sum_truesize = 0;
	struct inet_frags *f;

	WARN_ON(!(q->flags & INET_FRAG_COMPLETE));
	WARN_ON(del_timer(&q->timer) != 0);
@@ -298,6 +300,7 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f)
	/* Release all fragment data. */
	fp = q->fragments;
	nf = q->net;
	f = nf->f;
	while (fp) {
		struct sk_buff *xp = fp->next;

@@ -333,7 +336,7 @@ static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf,
			refcount_inc(&qp->refcnt);
			spin_unlock(&hb->chain_lock);
			qp_in->flags |= INET_FRAG_COMPLETE;
			inet_frag_put(qp_in, f);
			inet_frag_put(qp_in);
			return qp;
		}
	}
+5 −4
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ static void ip4_frag_free(struct inet_frag_queue *q)

static void ipq_put(struct ipq *ipq)
{
	inet_frag_put(&ipq->q, &ip4_frags);
	inet_frag_put(&ipq->q);
}

/* Kill ipq entry. It is not destroyed immediately,
@@ -176,7 +176,7 @@ static void ipq_put(struct ipq *ipq)
 */
static void ipq_kill(struct ipq *ipq)
{
	inet_frag_kill(&ipq->q, &ip4_frags);
	inet_frag_kill(&ipq->q);
}

static bool frag_expire_skip_icmp(u32 user)
@@ -872,20 +872,21 @@ static int __net_init ipv4_frags_init_net(struct net *net)
	net->ipv4.frags.timeout = IP_FRAG_TIME;

	net->ipv4.frags.max_dist = 64;
	net->ipv4.frags.f = &ip4_frags;

	res = inet_frags_init_net(&net->ipv4.frags);
	if (res < 0)
		return res;
	res = ip4_frags_ns_ctl_register(net);
	if (res < 0)
		inet_frags_exit_net(&net->ipv4.frags, &ip4_frags);
		inet_frags_exit_net(&net->ipv4.frags);
	return res;
}

static void __net_exit ipv4_frags_exit_net(struct net *net)
{
	ip4_frags_ns_ctl_unregister(net);
	inet_frags_exit_net(&net->ipv4.frags, &ip4_frags);
	inet_frags_exit_net(&net->ipv4.frags);
}

static struct pernet_operations ip4_frags_ops = {
Loading