Commit a39aca67 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: add a net pointer to struct fqdir

fqdir will soon be dynamically allocated.

We need to reach the struct net pointer from fqdir,
so add it, and replace the various container_of() constructs
by direct access to the new field.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9cce45f2
...@@ -12,6 +12,7 @@ struct fqdir { ...@@ -12,6 +12,7 @@ struct fqdir {
int timeout; int timeout;
int max_dist; int max_dist;
struct inet_frags *f; struct inet_frags *f;
struct net *net;
struct rhashtable rhashtable ____cacheline_aligned_in_smp; struct rhashtable rhashtable ____cacheline_aligned_in_smp;
...@@ -104,9 +105,11 @@ struct inet_frags { ...@@ -104,9 +105,11 @@ struct inet_frags {
int inet_frags_init(struct inet_frags *); int inet_frags_init(struct inet_frags *);
void inet_frags_fini(struct inet_frags *); void inet_frags_fini(struct inet_frags *);
static inline int fqdir_init(struct fqdir *fqdir, struct inet_frags *f) static inline int fqdir_init(struct fqdir *fqdir, struct inet_frags *f,
struct net *net)
{ {
fqdir->f = f; fqdir->f = f;
fqdir->net = net;
atomic_long_set(&fqdir->mem, 0); atomic_long_set(&fqdir->mem, 0);
return rhashtable_init(&fqdir->rhashtable, &fqdir->f->rhash_params); return rhashtable_init(&fqdir->rhashtable, &fqdir->f->rhash_params);
} }
......
...@@ -453,7 +453,7 @@ static int __net_init lowpan_frags_init_net(struct net *net) ...@@ -453,7 +453,7 @@ static int __net_init lowpan_frags_init_net(struct net *net)
ieee802154_lowpan->fqdir.low_thresh = IPV6_FRAG_LOW_THRESH; ieee802154_lowpan->fqdir.low_thresh = IPV6_FRAG_LOW_THRESH;
ieee802154_lowpan->fqdir.timeout = IPV6_FRAG_TIMEOUT; ieee802154_lowpan->fqdir.timeout = IPV6_FRAG_TIMEOUT;
res = fqdir_init(&ieee802154_lowpan->fqdir, &lowpan_frags); res = fqdir_init(&ieee802154_lowpan->fqdir, &lowpan_frags, net);
if (res < 0) if (res < 0)
return res; return res;
res = lowpan_frags_ns_sysctl_register(net); res = lowpan_frags_ns_sysctl_register(net);
......
...@@ -82,9 +82,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb, ...@@ -82,9 +82,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb,
static void ip4_frag_init(struct inet_frag_queue *q, const void *a) static void ip4_frag_init(struct inet_frag_queue *q, const void *a)
{ {
struct ipq *qp = container_of(q, struct ipq, q); struct ipq *qp = container_of(q, struct ipq, q);
struct netns_ipv4 *ipv4 = container_of(q->fqdir, struct netns_ipv4, struct net *net = q->fqdir->net;
fqdir);
struct net *net = container_of(ipv4, struct net, ipv4);
const struct frag_v4_compare_key *key = a; const struct frag_v4_compare_key *key = a;
...@@ -142,7 +140,7 @@ static void ip_expire(struct timer_list *t) ...@@ -142,7 +140,7 @@ static void ip_expire(struct timer_list *t)
int err; int err;
qp = container_of(frag, struct ipq, q); qp = container_of(frag, struct ipq, q);
net = container_of(qp->q.fqdir, struct net, ipv4.fqdir); net = qp->q.fqdir->net;
rcu_read_lock(); rcu_read_lock();
spin_lock(&qp->q.lock); spin_lock(&qp->q.lock);
...@@ -236,12 +234,8 @@ static int ip_frag_too_far(struct ipq *qp) ...@@ -236,12 +234,8 @@ static int ip_frag_too_far(struct ipq *qp)
rc = qp->q.fragments_tail && (end - start) > max; rc = qp->q.fragments_tail && (end - start) > max;
if (rc) { if (rc)
struct net *net; __IP_INC_STATS(qp->q.fqdir->net, IPSTATS_MIB_REASMFAILS);
net = container_of(qp->q.fqdir, struct net, ipv4.fqdir);
__IP_INC_STATS(net, IPSTATS_MIB_REASMFAILS);
}
return rc; return rc;
} }
...@@ -273,7 +267,7 @@ static int ip_frag_reinit(struct ipq *qp) ...@@ -273,7 +267,7 @@ static int ip_frag_reinit(struct ipq *qp)
/* Add new segment to existing queue. */ /* Add new segment to existing queue. */
static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
{ {
struct net *net = container_of(qp->q.fqdir, struct net, ipv4.fqdir); struct net *net = qp->q.fqdir->net;
int ihl, end, flags, offset; int ihl, end, flags, offset;
struct sk_buff *prev_tail; struct sk_buff *prev_tail;
struct net_device *dev; struct net_device *dev;
...@@ -399,7 +393,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) ...@@ -399,7 +393,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb, static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb,
struct sk_buff *prev_tail, struct net_device *dev) struct sk_buff *prev_tail, struct net_device *dev)
{ {
struct net *net = container_of(qp->q.fqdir, struct net, ipv4.fqdir); struct net *net = qp->q.fqdir->net;
struct iphdr *iph; struct iphdr *iph;
void *reasm_data; void *reasm_data;
int len, err; int len, err;
...@@ -673,7 +667,7 @@ static int __net_init ipv4_frags_init_net(struct net *net) ...@@ -673,7 +667,7 @@ static int __net_init ipv4_frags_init_net(struct net *net)
net->ipv4.fqdir.max_dist = 64; net->ipv4.fqdir.max_dist = 64;
res = fqdir_init(&net->ipv4.fqdir, &ip4_frags); res = fqdir_init(&net->ipv4.fqdir, &ip4_frags, net);
if (res < 0) if (res < 0)
return res; return res;
res = ip4_frags_ns_ctl_register(net); res = ip4_frags_ns_ctl_register(net);
......
...@@ -143,12 +143,10 @@ static void nf_ct_frag6_expire(struct timer_list *t) ...@@ -143,12 +143,10 @@ static void nf_ct_frag6_expire(struct timer_list *t)
{ {
struct inet_frag_queue *frag = from_timer(frag, t, timer); struct inet_frag_queue *frag = from_timer(frag, t, timer);
struct frag_queue *fq; struct frag_queue *fq;
struct net *net;
fq = container_of(frag, struct frag_queue, q); fq = container_of(frag, struct frag_queue, q);
net = container_of(fq->q.fqdir, struct net, nf_frag.fqdir);
ip6frag_expire_frag_queue(net, fq); ip6frag_expire_frag_queue(fq->q.fqdir->net, fq);
} }
/* Creation primitives. */ /* Creation primitives. */
...@@ -495,7 +493,7 @@ static int nf_ct_net_init(struct net *net) ...@@ -495,7 +493,7 @@ static int nf_ct_net_init(struct net *net)
net->nf_frag.fqdir.low_thresh = IPV6_FRAG_LOW_THRESH; net->nf_frag.fqdir.low_thresh = IPV6_FRAG_LOW_THRESH;
net->nf_frag.fqdir.timeout = IPV6_FRAG_TIMEOUT; net->nf_frag.fqdir.timeout = IPV6_FRAG_TIMEOUT;
res = fqdir_init(&net->nf_frag.fqdir, &nf_frags); res = fqdir_init(&net->nf_frag.fqdir, &nf_frags, net);
if (res < 0) if (res < 0)
return res; return res;
res = nf_ct_frag6_sysctl_register(net); res = nf_ct_frag6_sysctl_register(net);
......
...@@ -76,12 +76,10 @@ static void ip6_frag_expire(struct timer_list *t) ...@@ -76,12 +76,10 @@ static void ip6_frag_expire(struct timer_list *t)
{ {
struct inet_frag_queue *frag = from_timer(frag, t, timer); struct inet_frag_queue *frag = from_timer(frag, t, timer);
struct frag_queue *fq; struct frag_queue *fq;
struct net *net;
fq = container_of(frag, struct frag_queue, q); fq = container_of(frag, struct frag_queue, q);
net = container_of(fq->q.fqdir, struct net, ipv6.fqdir);
ip6frag_expire_frag_queue(net, fq); ip6frag_expire_frag_queue(fq->q.fqdir->net, fq);
} }
static struct frag_queue * static struct frag_queue *
...@@ -254,7 +252,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -254,7 +252,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *skb, static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *skb,
struct sk_buff *prev_tail, struct net_device *dev) struct sk_buff *prev_tail, struct net_device *dev)
{ {
struct net *net = container_of(fq->q.fqdir, struct net, ipv6.fqdir); struct net *net = fq->q.fqdir->net;
unsigned int nhoff; unsigned int nhoff;
void *reasm_data; void *reasm_data;
int payload_len; int payload_len;
...@@ -516,7 +514,7 @@ static int __net_init ipv6_frags_init_net(struct net *net) ...@@ -516,7 +514,7 @@ static int __net_init ipv6_frags_init_net(struct net *net)
net->ipv6.fqdir.low_thresh = IPV6_FRAG_LOW_THRESH; net->ipv6.fqdir.low_thresh = IPV6_FRAG_LOW_THRESH;
net->ipv6.fqdir.timeout = IPV6_FRAG_TIMEOUT; net->ipv6.fqdir.timeout = IPV6_FRAG_TIMEOUT;
res = fqdir_init(&net->ipv6.fqdir, &ip6_frags); res = fqdir_init(&net->ipv6.fqdir, &ip6_frags, net);
if (res < 0) if (res < 0)
return res; return res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment