aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2010-04-13 01:03:20 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-13 17:49:33 -0400
commitd658f8a0e63b6476148162aa7a3ffffc58dcad52 (patch)
tree25087c18eb91bbe040cf5c9b5e1710d35e37328f
parente258beb22f4d3ea3dc88586ffc9c990d0eb03380 (diff)
ipv4: ipmr: remove net pointer from struct mfc_cache
Now that cache entries in unres_queue don't need to be distinguished by their network namespace pointer anymore, we can remove it from struct mfc_cache add pass the namespace as function argument to the functions that need it. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/mroute.h15
-rw-r--r--net/ipv4/ipmr.c65
2 files changed, 32 insertions, 48 deletions
diff --git a/include/linux/mroute.h b/include/linux/mroute.h
index c5f3d53548e2..de7780a6dd32 100644
--- a/include/linux/mroute.h
+++ b/include/linux/mroute.h
@@ -192,9 +192,6 @@ struct vif_device {
192 192
193struct mfc_cache { 193struct mfc_cache {
194 struct mfc_cache *next; /* Next entry on cache line */ 194 struct mfc_cache *next; /* Next entry on cache line */
195#ifdef CONFIG_NET_NS
196 struct net *mfc_net;
197#endif
198 __be32 mfc_mcastgrp; /* Group the entry belongs to */ 195 __be32 mfc_mcastgrp; /* Group the entry belongs to */
199 __be32 mfc_origin; /* Source of packet */ 196 __be32 mfc_origin; /* Source of packet */
200 vifi_t mfc_parent; /* Source interface */ 197 vifi_t mfc_parent; /* Source interface */
@@ -217,18 +214,6 @@ struct mfc_cache {
217 } mfc_un; 214 } mfc_un;
218}; 215};
219 216
220static inline
221struct net *mfc_net(const struct mfc_cache *mfc)
222{
223 return read_pnet(&mfc->mfc_net);
224}
225
226static inline
227void mfc_net_set(struct mfc_cache *mfc, struct net *net)
228{
229 write_pnet(&mfc->mfc_net, hold_net(net));
230}
231
232#define MFC_STATIC 1 217#define MFC_STATIC 1
233#define MFC_NOTIFY 2 218#define MFC_NOTIFY 2
234 219
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index d6aa65e2b08f..f8e25c8ba070 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -93,10 +93,12 @@ static DEFINE_SPINLOCK(mfc_unres_lock);
93 93
94static struct kmem_cache *mrt_cachep __read_mostly; 94static struct kmem_cache *mrt_cachep __read_mostly;
95 95
96static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local); 96static int ip_mr_forward(struct net *net, struct sk_buff *skb,
97 struct mfc_cache *cache, int local);
97static int ipmr_cache_report(struct net *net, 98static int ipmr_cache_report(struct net *net,
98 struct sk_buff *pkt, vifi_t vifi, int assert); 99 struct sk_buff *pkt, vifi_t vifi, int assert);
99static int ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm); 100static int ipmr_fill_mroute(struct net *net, struct sk_buff *skb,
101 struct mfc_cache *c, struct rtmsg *rtm);
100 102
101/* Service routines creating virtual interfaces: DVMRP tunnels and PIMREG */ 103/* Service routines creating virtual interfaces: DVMRP tunnels and PIMREG */
102 104
@@ -325,7 +327,6 @@ static int vif_delete(struct net *net, int vifi, int notify,
325 327
326static inline void ipmr_cache_free(struct mfc_cache *c) 328static inline void ipmr_cache_free(struct mfc_cache *c)
327{ 329{
328 release_net(mfc_net(c));
329 kmem_cache_free(mrt_cachep, c); 330 kmem_cache_free(mrt_cachep, c);
330} 331}
331 332
@@ -333,11 +334,10 @@ static inline void ipmr_cache_free(struct mfc_cache *c)
333 and reporting error to netlink readers. 334 and reporting error to netlink readers.
334 */ 335 */
335 336
336static void ipmr_destroy_unres(struct mfc_cache *c) 337static void ipmr_destroy_unres(struct net *net, struct mfc_cache *c)
337{ 338{
338 struct sk_buff *skb; 339 struct sk_buff *skb;
339 struct nlmsgerr *e; 340 struct nlmsgerr *e;
340 struct net *net = mfc_net(c);
341 341
342 atomic_dec(&net->ipv4.cache_resolve_queue_len); 342 atomic_dec(&net->ipv4.cache_resolve_queue_len);
343 343
@@ -392,7 +392,7 @@ static void ipmr_expire_process(unsigned long arg)
392 392
393 *cp = c->next; 393 *cp = c->next;
394 394
395 ipmr_destroy_unres(c); 395 ipmr_destroy_unres(net, c);
396 } 396 }
397 397
398 if (net->ipv4.mfc_unres_queue != NULL) 398 if (net->ipv4.mfc_unres_queue != NULL)
@@ -404,10 +404,10 @@ out:
404 404
405/* Fill oifs list. It is called under write locked mrt_lock. */ 405/* Fill oifs list. It is called under write locked mrt_lock. */
406 406
407static void ipmr_update_thresholds(struct mfc_cache *cache, unsigned char *ttls) 407static void ipmr_update_thresholds(struct net *net, struct mfc_cache *cache,
408 unsigned char *ttls)
408{ 409{
409 int vifi; 410 int vifi;
410 struct net *net = mfc_net(cache);
411 411
412 cache->mfc_un.res.minvif = MAXVIFS; 412 cache->mfc_un.res.minvif = MAXVIFS;
413 cache->mfc_un.res.maxvif = 0; 413 cache->mfc_un.res.maxvif = 0;
@@ -547,24 +547,22 @@ static struct mfc_cache *ipmr_cache_find(struct net *net,
547/* 547/*
548 * Allocate a multicast cache entry 548 * Allocate a multicast cache entry
549 */ 549 */
550static struct mfc_cache *ipmr_cache_alloc(struct net *net) 550static struct mfc_cache *ipmr_cache_alloc(void)
551{ 551{
552 struct mfc_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_KERNEL); 552 struct mfc_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_KERNEL);
553 if (c == NULL) 553 if (c == NULL)
554 return NULL; 554 return NULL;
555 c->mfc_un.res.minvif = MAXVIFS; 555 c->mfc_un.res.minvif = MAXVIFS;
556 mfc_net_set(c, net);
557 return c; 556 return c;
558} 557}
559 558
560static struct mfc_cache *ipmr_cache_alloc_unres(struct net *net) 559static struct mfc_cache *ipmr_cache_alloc_unres(void)
561{ 560{
562 struct mfc_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_ATOMIC); 561 struct mfc_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_ATOMIC);
563 if (c == NULL) 562 if (c == NULL)
564 return NULL; 563 return NULL;
565 skb_queue_head_init(&c->mfc_un.unres.unresolved); 564 skb_queue_head_init(&c->mfc_un.unres.unresolved);
566 c->mfc_un.unres.expires = jiffies + 10*HZ; 565 c->mfc_un.unres.expires = jiffies + 10*HZ;
567 mfc_net_set(c, net);
568 return c; 566 return c;
569} 567}
570 568
@@ -572,7 +570,8 @@ static struct mfc_cache *ipmr_cache_alloc_unres(struct net *net)
572 * A cache entry has gone into a resolved state from queued 570 * A cache entry has gone into a resolved state from queued
573 */ 571 */
574 572
575static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c) 573static void ipmr_cache_resolve(struct net *net, struct mfc_cache *uc,
574 struct mfc_cache *c)
576{ 575{
577 struct sk_buff *skb; 576 struct sk_buff *skb;
578 struct nlmsgerr *e; 577 struct nlmsgerr *e;
@@ -585,7 +584,7 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c)
585 if (ip_hdr(skb)->version == 0) { 584 if (ip_hdr(skb)->version == 0) {
586 struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr)); 585 struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr));
587 586
588 if (ipmr_fill_mroute(skb, c, NLMSG_DATA(nlh)) > 0) { 587 if (ipmr_fill_mroute(net, skb, c, NLMSG_DATA(nlh)) > 0) {
589 nlh->nlmsg_len = (skb_tail_pointer(skb) - 588 nlh->nlmsg_len = (skb_tail_pointer(skb) -
590 (u8 *)nlh); 589 (u8 *)nlh);
591 } else { 590 } else {
@@ -597,9 +596,9 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c)
597 memset(&e->msg, 0, sizeof(e->msg)); 596 memset(&e->msg, 0, sizeof(e->msg));
598 } 597 }
599 598
600 rtnl_unicast(skb, mfc_net(c), NETLINK_CB(skb).pid); 599 rtnl_unicast(skb, net, NETLINK_CB(skb).pid);
601 } else 600 } else
602 ip_mr_forward(skb, c, 0); 601 ip_mr_forward(net, skb, c, 0);
603 } 602 }
604} 603}
605 604
@@ -717,7 +716,7 @@ ipmr_cache_unresolved(struct net *net, vifi_t vifi, struct sk_buff *skb)
717 */ 716 */
718 717
719 if (atomic_read(&net->ipv4.cache_resolve_queue_len) >= 10 || 718 if (atomic_read(&net->ipv4.cache_resolve_queue_len) >= 10 ||
720 (c = ipmr_cache_alloc_unres(net)) == NULL) { 719 (c = ipmr_cache_alloc_unres()) == NULL) {
721 spin_unlock_bh(&mfc_unres_lock); 720 spin_unlock_bh(&mfc_unres_lock);
722 721
723 kfree_skb(skb); 722 kfree_skb(skb);
@@ -814,7 +813,7 @@ static int ipmr_mfc_add(struct net *net, struct mfcctl *mfc, int mrtsock)
814 if (c != NULL) { 813 if (c != NULL) {
815 write_lock_bh(&mrt_lock); 814 write_lock_bh(&mrt_lock);
816 c->mfc_parent = mfc->mfcc_parent; 815 c->mfc_parent = mfc->mfcc_parent;
817 ipmr_update_thresholds(c, mfc->mfcc_ttls); 816