Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 133890
b: refs/heads/master
c: 5c0a66f
h: refs/heads/master
v: v3
  • Loading branch information
Benjamin Thery authored and David S. Miller committed Jan 22, 2009
1 parent d7c190b commit 9292dd3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cf958ae377ee2545ae70cf48d38e7eb4308c27ea
refs/heads/master: 5c0a66f5f3c9c59e2c341400048e2cff768e67a9
15 changes: 15 additions & 0 deletions trunk/include/linux/mroute.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ struct vif_device
struct mfc_cache
{
struct mfc_cache *next; /* Next entry on cache line */
#ifdef CONFIG_NET_NS
struct net *mfc_net;
#endif
__be32 mfc_mcastgrp; /* Group the entry belongs to */
__be32 mfc_origin; /* Source of packet */
vifi_t mfc_parent; /* Source interface */
Expand All @@ -215,6 +218,18 @@ struct mfc_cache
} mfc_un;
};

static inline
struct net *mfc_net(const struct mfc_cache *mfc)
{
return read_pnet(&mfc->mfc_net);
}

static inline
void mfc_net_set(struct mfc_cache *mfc, struct net *net)
{
write_pnet(&mfc->mfc_net, hold_net(net));
}

#define MFC_STATIC 1
#define MFC_NOTIFY 2

Expand Down
26 changes: 17 additions & 9 deletions trunk/net/ipv4/ipmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ static int vif_delete(int vifi, int notify)
return 0;
}

static inline void ipmr_cache_free(struct mfc_cache *c)
{
release_net(mfc_net(c));
kmem_cache_free(mrt_cachep, c);
}

/* Destroy an unresolved cache entry, killing queued skbs
and reporting error to netlink readers.
*/
Expand All @@ -353,7 +359,7 @@ static void ipmr_destroy_unres(struct mfc_cache *c)
kfree_skb(skb);
}

kmem_cache_free(mrt_cachep, c);
ipmr_cache_free(c);
}


Expand Down Expand Up @@ -528,22 +534,24 @@ static struct mfc_cache *ipmr_cache_find(__be32 origin, __be32 mcastgrp)
/*
* Allocate a multicast cache entry
*/
static struct mfc_cache *ipmr_cache_alloc(void)
static struct mfc_cache *ipmr_cache_alloc(struct net *net)
{
struct mfc_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_KERNEL);
if (c == NULL)
return NULL;
c->mfc_un.res.minvif = MAXVIFS;
mfc_net_set(c, net);
return c;
}

static struct mfc_cache *ipmr_cache_alloc_unres(void)
static struct mfc_cache *ipmr_cache_alloc_unres(struct net *net)
{
struct mfc_cache *c = kmem_cache_zalloc(mrt_cachep, GFP_ATOMIC);
if (c == NULL)
return NULL;
skb_queue_head_init(&c->mfc_un.unres.unresolved);
c->mfc_un.unres.expires = jiffies + 10*HZ;
mfc_net_set(c, net);
return c;
}

Expand Down Expand Up @@ -695,7 +703,7 @@ ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb)
*/

if (atomic_read(&cache_resolve_queue_len) >= 10 ||
(c=ipmr_cache_alloc_unres())==NULL) {
(c = ipmr_cache_alloc_unres(&init_net)) == NULL) {
spin_unlock_bh(&mfc_unres_lock);

kfree_skb(skb);
Expand All @@ -718,7 +726,7 @@ ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb)
*/
spin_unlock_bh(&mfc_unres_lock);

kmem_cache_free(mrt_cachep, c);
ipmr_cache_free(c);
kfree_skb(skb);
return err;
}
Expand Down Expand Up @@ -763,7 +771,7 @@ static int ipmr_mfc_delete(struct mfcctl *mfc)
*cp = c->next;
write_unlock_bh(&mrt_lock);

kmem_cache_free(mrt_cachep, c);
ipmr_cache_free(c);
return 0;
}
}
Expand Down Expand Up @@ -796,7 +804,7 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock)
if (!ipv4_is_multicast(mfc->mfcc_mcastgrp.s_addr))
return -EINVAL;

c = ipmr_cache_alloc();
c = ipmr_cache_alloc(&init_net);
if (c == NULL)
return -ENOMEM;

Expand Down Expand Up @@ -831,7 +839,7 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock)

if (uc) {
ipmr_cache_resolve(uc, c);
kmem_cache_free(mrt_cachep, uc);
ipmr_cache_free(uc);
}
return 0;
}
Expand Down Expand Up @@ -868,7 +876,7 @@ static void mroute_clean_tables(struct sock *sk)
*cp = c->next;
write_unlock_bh(&mrt_lock);

kmem_cache_free(mrt_cachep, c);
ipmr_cache_free(c);
}
}

Expand Down

0 comments on commit 9292dd3

Please sign in to comment.