]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv4/ipmr.c
net: rtnetlink: decouple rtnetlink address families from real address families
[net-next-2.6.git] / net / ipv4 / ipmr.c
index 5df5fd74c6d187f4175b3028ccb690c318664b76..41e8fc0ce8b321987897a2af43dbe0ac6aee596a 100644 (file)
@@ -71,6 +71,9 @@
 
 struct mr_table {
        struct list_head        list;
+#ifdef CONFIG_NET_NS
+       struct net              *net;
+#endif
        u32                     id;
        struct sock             *mroute_sk;
        struct timer_list       ipmr_expire_timer;
@@ -213,8 +216,8 @@ static int ipmr_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
        return 0;
 }
 
-static struct fib_rules_ops ipmr_rules_ops_template = {
-       .family         = FIB_RULES_IPMR,
+static const struct fib_rules_ops __net_initdata ipmr_rules_ops_template = {
+       .family         = RTNL_FAMILY_IPMR,
        .rule_size      = sizeof(struct ipmr_rule),
        .addr_size      = sizeof(u32),
        .action         = ipmr_rule_action,
@@ -308,6 +311,7 @@ static struct mr_table *ipmr_new_table(struct net *net, u32 id)
        mrt = kzalloc(sizeof(*mrt), GFP_KERNEL);
        if (mrt == NULL)
                return NULL;
+       write_pnet(&mrt->net, net);
        mrt->id = id;
 
        /* Forwarding cache */
@@ -580,7 +584,7 @@ static inline void ipmr_cache_free(struct mfc_cache *c)
 
 static void ipmr_destroy_unres(struct mr_table *mrt, struct mfc_cache *c)
 {
-       struct net *net = NULL; //mrt->net;
+       struct net *net = read_pnet(&mrt->net);
        struct sk_buff *skb;
        struct nlmsgerr *e;
 
@@ -1089,12 +1093,14 @@ static int ipmr_mfc_add(struct net *net, struct mr_table *mrt,
         *      Check to see if we resolved a queued list. If so we
         *      need to send on the frames and tidy up.
         */
+       found = false;
        spin_lock_bh(&mfc_unres_lock);
        list_for_each_entry(uc, &mrt->mfc_unres_queue, list) {
                if (uc->mfc_origin == c->mfc_origin &&
                    uc->mfc_mcastgrp == c->mfc_mcastgrp) {
                        list_del(&uc->list);
                        atomic_dec(&mrt->cache_resolve_queue_len);
+                       found = true;
                        break;
                }
        }
@@ -1102,7 +1108,7 @@ static int ipmr_mfc_add(struct net *net, struct mr_table *mrt,
                del_timer(&mrt->ipmr_expire_timer);
        spin_unlock_bh(&mfc_unres_lock);
 
-       if (uc) {
+       if (found) {
                ipmr_cache_resolve(net, mrt, uc, c);
                ipmr_cache_free(uc);
        }
@@ -1766,10 +1772,10 @@ int ip_mr_input(struct sk_buff *skb)
 
                vif = ipmr_find_vif(mrt, skb->dev);
                if (vif >= 0) {
-                       int err = ipmr_cache_unresolved(mrt, vif, skb);
+                       int err2 = ipmr_cache_unresolved(mrt, vif, skb);
                        read_unlock(&mrt_lock);
 
-                       return err;
+                       return err2;
                }
                read_unlock(&mrt_lock);
                kfree_skb(skb);
@@ -2221,9 +2227,9 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v)
                const struct ipmr_mfc_iter *it = seq->private;
                const struct mr_table *mrt = it->mrt;
 
-               seq_printf(seq, "%08lX %08lX %-3hd",
-                          (unsigned long) mfc->mfc_mcastgrp,
-                          (unsigned long) mfc->mfc_origin,
+               seq_printf(seq, "%08X %08X %-3hd",
+                          (__force u32) mfc->mfc_mcastgrp,
+                          (__force u32) mfc->mfc_origin,
                           mfc->mfc_parent);
 
                if (it->cache != &mrt->mfc_unres_queue) {