summaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2019-05-24 12:03:38 -0400
committerDavid S. Miller <davem@davemloft.net>2019-05-26 17:08:05 -0400
commita39aca678a0626941aa99c18c1c452ca758e7865 (patch)
treef7b16eb9d746b1afe0b8b70c78c5bc197aef0ca4 /net/ipv4
parent9cce45f22ceedf639cbb5fb5dfe612a278d36b58 (diff)
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: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/ip_fragment.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index d95592d52981..d59269bbe1b6 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -82,9 +82,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb,
82static void ip4_frag_init(struct inet_frag_queue *q, const void *a) 82static void ip4_frag_init(struct inet_frag_queue *q, const void *a)
83{ 83{
84 struct ipq *qp = container_of(q, struct ipq, q); 84 struct ipq *qp = container_of(q, struct ipq, q);
85 struct netns_ipv4 *ipv4 = container_of(q->fqdir, struct netns_ipv4, 85 struct net *net = q->fqdir->net;
86 fqdir);
87 struct net *net = container_of(ipv4, struct net, ipv4);
88 86
89 const struct frag_v4_compare_key *key = a; 87 const struct frag_v4_compare_key *key = a;
90 88
@@ -142,7 +140,7 @@ static void ip_expire(struct timer_list *t)
142 int err; 140 int err;
143 141
144 qp = container_of(frag, struct ipq, q); 142 qp = container_of(frag, struct ipq, q);
145 net = container_of(qp->q.fqdir, struct net, ipv4.fqdir); 143 net = qp->q.fqdir->net;
146 144
147 rcu_read_lock(); 145 rcu_read_lock();
148 spin_lock(&qp->q.lock); 146 spin_lock(&qp->q.lock);
@@ -236,12 +234,8 @@ static int ip_frag_too_far(struct ipq *qp)
236 234
237 rc = qp->q.fragments_tail && (end - start) > max; 235 rc = qp->q.fragments_tail && (end - start) > max;
238 236
239 if (rc) { 237 if (rc)
240 struct net *net; 238 __IP_INC_STATS(qp->q.fqdir->net, IPSTATS_MIB_REASMFAILS);
241
242 net = container_of(qp->q.fqdir, struct net, ipv4.fqdir);
243 __IP_INC_STATS(net, IPSTATS_MIB_REASMFAILS);
244 }
245 239
246 return rc; 240 return rc;
247} 241}
@@ -273,7 +267,7 @@ static int ip_frag_reinit(struct ipq *qp)
273/* Add new segment to existing queue. */ 267/* Add new segment to existing queue. */
274static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) 268static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
275{ 269{
276 struct net *net = container_of(qp->q.fqdir, struct net, ipv4.fqdir); 270 struct net *net = qp->q.fqdir->net;
277 int ihl, end, flags, offset; 271 int ihl, end, flags, offset;
278 struct sk_buff *prev_tail; 272 struct sk_buff *prev_tail;
279 struct net_device *dev; 273 struct net_device *dev;
@@ -399,7 +393,7 @@ err:
399static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb, 393static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb,
400 struct sk_buff *prev_tail, struct net_device *dev) 394 struct sk_buff *prev_tail, struct net_device *dev)
401{ 395{
402 struct net *net = container_of(qp->q.fqdir, struct net, ipv4.fqdir); 396 struct net *net = qp->q.fqdir->net;
403 struct iphdr *iph; 397 struct iphdr *iph;
404 void *reasm_data; 398 void *reasm_data;
405 int len, err; 399 int len, err;
@@ -673,7 +667,7 @@ static int __net_init ipv4_frags_init_net(struct net *net)
673 667
674 net->ipv4.fqdir.max_dist = 64; 668 net->ipv4.fqdir.max_dist = 64;
675 669
676 res = fqdir_init(&net->ipv4.fqdir, &ip4_frags); 670 res = fqdir_init(&net->ipv4.fqdir, &ip4_frags, net);
677 if (res < 0) 671 if (res < 0)
678 return res; 672 return res;
679 res = ip4_frags_ns_ctl_register(net); 673 res = ip4_frags_ns_ctl_register(net);