Commit b70432f7 authored by Yuval Mintz's avatar Yuval Mintz Committed by David S. Miller

mroute*: Make mr_table a common struct

Following previous changes to ip6mr, mr_table and mr6_table are
basically the same [up to mr6_table having additional '6' suffixes to
its variable names].
Move the common structure definition into a common header; This
requires renaming all references in ip6mr to variables that had the
distinct suffix.
Signed-off-by: default avatarYuval Mintz <yuvalm@mellanox.com>
Acked-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 87c418bf
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include <linux/in.h> #include <linux/in.h>
#include <linux/pim.h> #include <linux/pim.h>
#include <linux/rhashtable.h>
#include <net/sock.h>
#include <net/fib_rules.h> #include <net/fib_rules.h>
#include <net/fib_notifier.h> #include <net/fib_notifier.h>
#include <uapi/linux/mroute.h> #include <uapi/linux/mroute.h>
...@@ -67,25 +65,6 @@ struct vif_entry_notifier_info { ...@@ -67,25 +65,6 @@ struct vif_entry_notifier_info {
#define VIFF_STATIC 0x8000 #define VIFF_STATIC 0x8000
#define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)
struct mr_table {
struct list_head list;
possible_net_t net;
u32 id;
struct sock __rcu *mroute_sk;
struct timer_list ipmr_expire_timer;
struct list_head mfc_unres_queue;
struct vif_device vif_table[MAXVIFS];
struct rhltable mfc_hash;
struct list_head mfc_cache_list;
int maxvif;
atomic_t cache_resolve_queue_len;
bool mroute_do_assert;
bool mroute_do_pim;
int mroute_reg_vif_num;
};
/* mfc_flags: /* mfc_flags:
* MFC_STATIC - the entry was added statically (not by a routing daemon) * MFC_STATIC - the entry was added statically (not by a routing daemon)
* MFC_OFFLOAD - the entry was offloaded to the hardware * MFC_OFFLOAD - the entry was offloaded to the hardware
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <uapi/linux/mroute6.h> #include <uapi/linux/mroute6.h>
#include <linux/mroute_base.h> #include <linux/mroute_base.h>
#include <linux/rhashtable.h>
#ifdef CONFIG_IPV6_MROUTE #ifdef CONFIG_IPV6_MROUTE
static inline int ip6_mroute_opt(int opt) static inline int ip6_mroute_opt(int opt)
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
#define __LINUX_MROUTE_BASE_H #define __LINUX_MROUTE_BASE_H
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/rhashtable.h>
#include <net/net_namespace.h>
#include <net/sock.h>
/** /**
* struct vif_device - interface representor for multicast routing * struct vif_device - interface representor for multicast routing
...@@ -32,6 +35,49 @@ struct vif_device { ...@@ -32,6 +35,49 @@ struct vif_device {
__be32 local, remote; __be32 local, remote;
}; };
#ifndef MAXVIFS
/* This one is nasty; value is defined in uapi using different symbols for
* mroute and morute6 but both map into same 32.
*/
#define MAXVIFS 32
#endif
#define VIF_EXISTS(_mrt, _idx) (!!((_mrt)->vif_table[_idx].dev))
/**
* struct mr_table - a multicast routing table
* @list: entry within a list of multicast routing tables
* @net: net where this table belongs
* @id: identifier of the table
* @mroute_sk: socket associated with the table
* @ipmr_expire_timer: timer for handling unresolved routes
* @mfc_unres_queue: list of unresolved MFC entries
* @vif_table: array containing all possible vifs
* @mfc_hash: Hash table of all resolved routes for easy lookup
* @mfc_cache_list: list of resovled routes for possible traversal
* @maxvif: Identifier of highest value vif currently in use
* @cache_resolve_queue_len: current size of unresolved queue
* @mroute_do_assert: Whether to inform userspace on wrong ingress
* @mroute_do_pim: Whether to receive IGMP PIMv1
* @mroute_reg_vif_num: PIM-device vif index
*/
struct mr_table {
struct list_head list;
possible_net_t net;
u32 id;
struct sock __rcu *mroute_sk;
struct timer_list ipmr_expire_timer;
struct list_head mfc_unres_queue;
struct vif_device vif_table[MAXVIFS];
struct rhltable mfc_hash;
struct list_head mfc_cache_list;
int maxvif;
atomic_t cache_resolve_queue_len;
bool mroute_do_assert;
bool mroute_do_pim;
int mroute_reg_vif_num;
};
#ifdef CONFIG_IP_MROUTE_COMMON #ifdef CONFIG_IP_MROUTE_COMMON
void vif_device_init(struct vif_device *v, void vif_device_init(struct vif_device *v,
struct net_device *dev, struct net_device *dev,
......
...@@ -85,7 +85,7 @@ struct netns_ipv6 { ...@@ -85,7 +85,7 @@ struct netns_ipv6 {
struct sock *mc_autojoin_sk; struct sock *mc_autojoin_sk;
#ifdef CONFIG_IPV6_MROUTE #ifdef CONFIG_IPV6_MROUTE
#ifndef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES #ifndef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES
struct mr6_table *mrt6; struct mr_table *mrt6;
#else #else
struct list_head mr6_tables; struct list_head mr6_tables;
struct fib_rules_ops *mr6_rules_ops; struct fib_rules_ops *mr6_rules_ops;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <linux/cache.h> #include <linux/cache.h>
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/timer.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/fcntl.h> #include <linux/fcntl.h>
...@@ -53,7 +52,6 @@ ...@@ -53,7 +52,6 @@
#include <net/protocol.h> #include <net/protocol.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <net/route.h> #include <net/route.h>
#include <net/sock.h>
#include <net/icmp.h> #include <net/icmp.h>
#include <net/udp.h> #include <net/udp.h>
#include <net/raw.h> #include <net/raw.h>
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/timer.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/fcntl.h> #include <linux/fcntl.h>
...@@ -36,7 +35,6 @@ ...@@ -36,7 +35,6 @@
#include <linux/compat.h> #include <linux/compat.h>
#include <net/protocol.h> #include <net/protocol.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <net/sock.h>
#include <net/raw.h> #include <net/raw.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
...@@ -54,31 +52,12 @@ ...@@ -54,31 +52,12 @@
#include <net/ip6_checksum.h> #include <net/ip6_checksum.h>
#include <linux/netconf.h> #include <linux/netconf.h>
struct mr6_table {
struct list_head list;
possible_net_t net;
u32 id;
struct sock __rcu *mroute6_sk;
struct timer_list ipmr_expire_timer;
struct list_head mfc6_unres_queue;
struct vif_device vif6_table[MAXMIFS];
struct rhltable mfc6_hash;
struct list_head mfc6_cache_list;
int maxvif;
atomic_t cache_resolve_queue_len;
bool mroute_do_assert;
bool mroute_do_pim;
#ifdef CONFIG_IPV6_PIMSM_V2
int mroute_reg_vif_num;
#endif
};
struct ip6mr_rule { struct ip6mr_rule {
struct fib_rule common; struct fib_rule common;
}; };
struct ip6mr_result { struct ip6mr_result {
struct mr6_table *mrt; struct mr_table *mrt;
}; };
/* Big lock, protecting vif table, mrt cache and mroute socket state. /* Big lock, protecting vif table, mrt cache and mroute socket state.
...@@ -87,11 +66,7 @@ struct ip6mr_result { ...@@ -87,11 +66,7 @@ struct ip6mr_result {
static DEFINE_RWLOCK(mrt_lock); static DEFINE_RWLOCK(mrt_lock);
/* /* Multicast router control variables */
* Multicast router control variables
*/
#define MIF_EXISTS(_mrt, _idx) ((_mrt)->vif6_table[_idx].dev != NULL)
/* Special spinlock for queue of unresolved entries */ /* Special spinlock for queue of unresolved entries */
static DEFINE_SPINLOCK(mfc_unres_lock); static DEFINE_SPINLOCK(mfc_unres_lock);
...@@ -106,30 +81,30 @@ static DEFINE_SPINLOCK(mfc_unres_lock); ...@@ -106,30 +81,30 @@ static DEFINE_SPINLOCK(mfc_unres_lock);
static struct kmem_cache *mrt_cachep __read_mostly; static struct kmem_cache *mrt_cachep __read_mostly;
static struct mr6_table *ip6mr_new_table(struct net *net, u32 id); static struct mr_table *ip6mr_new_table(struct net *net, u32 id);
static void ip6mr_free_table(struct mr6_table *mrt); static void ip6mr_free_table(struct mr_table *mrt);
static void ip6_mr_forward(struct net *net, struct mr6_table *mrt, static void ip6_mr_forward(struct net *net, struct mr_table *mrt,
struct sk_buff *skb, struct mfc6_cache *cache); struct sk_buff *skb, struct mfc6_cache *cache);
static int ip6mr_cache_report(struct mr6_table *mrt, struct sk_buff *pkt, static int ip6mr_cache_report(struct mr_table *mrt, struct sk_buff *pkt,
mifi_t mifi, int assert); mifi_t mifi, int assert);
static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, static int __ip6mr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb,
struct mfc6_cache *c, struct rtmsg *rtm); struct mfc6_cache *c, struct rtmsg *rtm);
static void mr6_netlink_event(struct mr6_table *mrt, struct mfc6_cache *mfc, static void mr6_netlink_event(struct mr_table *mrt, struct mfc6_cache *mfc,
int cmd); int cmd);
static void mrt6msg_netlink_event(struct mr6_table *mrt, struct sk_buff *pkt); static void mrt6msg_netlink_event(struct mr_table *mrt, struct sk_buff *pkt);
static int ip6mr_rtm_dumproute(struct sk_buff *skb, static int ip6mr_rtm_dumproute(struct sk_buff *skb,
struct netlink_callback *cb); struct netlink_callback *cb);
static void mroute_clean_tables(struct mr6_table *mrt, bool all); static void mroute_clean_tables(struct mr_table *mrt, bool all);
static void ipmr_expire_process(struct timer_list *t); static void ipmr_expire_process(struct timer_list *t);
#ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES #ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES
#define ip6mr_for_each_table(mrt, net) \ #define ip6mr_for_each_table(mrt, net) \
list_for_each_entry_rcu(mrt, &net->ipv6.mr6_tables, list) list_for_each_entry_rcu(mrt, &net->ipv6.mr6_tables, list)
static struct mr6_table *ip6mr_get_table(struct net *net, u32 id) static struct mr_table *ip6mr_get_table(struct net *net, u32 id)
{ {
struct mr6_table *mrt; struct mr_table *mrt;
ip6mr_for_each_table(mrt, net) { ip6mr_for_each_table(mrt, net) {
if (mrt->id == id) if (mrt->id == id)
...@@ -139,7 +114,7 @@ static struct mr6_table *ip6mr_get_table(struct net *net, u32 id) ...@@ -139,7 +114,7 @@ static struct mr6_table *ip6mr_get_table(struct net *net, u32 id)
} }
static int ip6mr_fib_lookup(struct net *net, struct flowi6 *flp6, static int ip6mr_fib_lookup(struct net *net, struct flowi6 *flp6,
struct mr6_table **mrt) struct mr_table **mrt)
{ {
int err; int err;
struct ip6mr_result res; struct ip6mr_result res;
...@@ -160,7 +135,7 @@ static int ip6mr_rule_action(struct fib_rule *rule, struct flowi *flp, ...@@ -160,7 +135,7 @@ static int ip6mr_rule_action(struct fib_rule *rule, struct flowi *flp,
int flags, struct fib_lookup_arg *arg) int flags, struct fib_lookup_arg *arg)
{ {
struct ip6mr_result *res = arg->result; struct ip6mr_result *res = arg->result;
struct mr6_table *mrt; struct mr_table *mrt;
switch (rule->action) { switch (rule->action) {
case FR_ACT_TO_TBL: case FR_ACT_TO_TBL:
...@@ -228,7 +203,7 @@ static const struct fib_rules_ops __net_initconst ip6mr_rules_ops_template = { ...@@ -228,7 +203,7 @@ static const struct fib_rules_ops __net_initconst ip6mr_rules_ops_template = {
static int __net_init ip6mr_rules_init(struct net *net) static int __net_init ip6mr_rules_init(struct net *net)
{ {
struct fib_rules_ops *ops; struct fib_rules_ops *ops;
struct mr6_table *mrt; struct mr_table *mrt;
int err; int err;
ops = fib_rules_register(&ip6mr_rules_ops_template, net); ops = fib_rules_register(&ip6mr_rules_ops_template, net);
...@@ -259,7 +234,7 @@ static int __net_init ip6mr_rules_init(struct net *net) ...@@ -259,7 +234,7 @@ static int __net_init ip6mr_rules_init(struct net *net)
static void __net_exit ip6mr_rules_exit(struct net *net) static void __net_exit ip6mr_rules_exit(struct net *net)
{ {
struct mr6_table *mrt, *next; struct mr_table *mrt, *next;
rtnl_lock(); rtnl_lock();
list_for_each_entry_safe(mrt, next, &net->ipv6.mr6_tables, list) { list_for_each_entry_safe(mrt, next, &net->ipv6.mr6_tables, list) {
...@@ -273,13 +248,13 @@ static void __net_exit ip6mr_rules_exit(struct net *net) ...@@ -273,13 +248,13 @@ static void __net_exit ip6mr_rules_exit(struct net *net)
#define ip6mr_for_each_table(mrt, net) \ #define ip6mr_for_each_table(mrt, net) \
for (mrt = net->ipv6.mrt6; mrt; mrt = NULL) for (mrt = net->ipv6.mrt6; mrt; mrt = NULL)
static struct mr6_table *ip6mr_get_table(struct net *net, u32 id) static struct mr_table *ip6mr_get_table(struct net *net, u32 id)
{ {
return net->ipv6.mrt6; return net->ipv6.mrt6;
} }
static int ip6mr_fib_lookup(struct net *net, struct flowi6 *flp6, static int ip6mr_fib_lookup(struct net *net, struct flowi6 *flp6,
struct mr6_table **mrt) struct mr_table **mrt)
{ {
*mrt = net->ipv6.mrt6; *mrt = net->ipv6.mrt6;
return 0; return 0;
...@@ -320,9 +295,9 @@ static const struct rhashtable_params ip6mr_rht_params = { ...@@ -320,9 +295,9 @@ static const struct rhashtable_params ip6mr_rht_params = {
.automatic_shrinking = true, .automatic_shrinking = true,
}; };
static struct mr6_table *ip6mr_new_table(struct net *net, u32 id) static struct mr_table *ip6mr_new_table(struct net *net, u32 id)
{ {
struct mr6_table *mrt; struct mr_table *mrt;
mrt = ip6mr_get_table(net, id); mrt = ip6mr_get_table(net, id);
if (mrt) if (mrt)
...@@ -334,9 +309,9 @@ static struct mr6_table *ip6mr_new_table(struct net *net, u32 id) ...@@ -334,9 +309,9 @@ static struct mr6_table *ip6mr_new_table(struct net *net, u32 id)
mrt->id = id; mrt->id = id;
write_pnet(&mrt->net, net); write_pnet(&mrt->net, net);
rhltable_init(&mrt->mfc6_hash, &ip6mr_rht_params); rhltable_init(&mrt->mfc_hash, &ip6mr_rht_params);
INIT_LIST_HEAD(&mrt->mfc6_cache_list); INIT_LIST_HEAD(&mrt->mfc_cache_list);
INIT_LIST_HEAD(&mrt->mfc6_unres_queue); INIT_LIST_HEAD(&mrt->mfc_unres_queue);
timer_setup(&mrt->ipmr_expire_timer, ipmr_expire_process, 0); timer_setup(&mrt->ipmr_expire_timer, ipmr_expire_process, 0);
...@@ -349,11 +324,11 @@ static struct mr6_table *ip6mr_new_table(struct net *net, u32 id) ...@@ -349,11 +324,11 @@ static struct mr6_table *ip6mr_new_table(struct net *net, u32 id)
return mrt; return mrt;
} }
static void ip6mr_free_table(struct mr6_table *mrt) static void ip6mr_free_table(struct mr_table *mrt)
{ {
del_timer_sync(&mrt->ipmr_expire_timer); del_timer_sync(&mrt->ipmr_expire_timer);
mroute_clean_tables(mrt, true); mroute_clean_tables(mrt, true);
rhltable_destroy(&mrt->mfc6_hash); rhltable_destroy(&mrt->mfc_hash);
kfree(mrt); kfree(mrt);
} }
...@@ -361,7 +336,7 @@ static void ip6mr_free_table(struct mr6_table *mrt) ...@@ -361,7 +336,7 @@ static void ip6mr_free_table(struct mr6_table *mrt)
struct ipmr_mfc_iter { struct ipmr_mfc_iter {
struct seq_net_private p; struct seq_net_private p;
struct mr6_table *mrt; struct mr_table *mrt;
struct list_head *cache; struct list_head *cache;
}; };
...@@ -369,18 +344,18 @@ struct ipmr_mfc_iter { ...@@ -369,18 +344,18 @@ struct ipmr_mfc_iter {
static struct mfc6_cache *ipmr_mfc_seq_idx(struct net *net, static struct mfc6_cache *ipmr_mfc_seq_idx(struct net *net,
struct ipmr_mfc_iter *it, loff_t pos) struct ipmr_mfc_iter *it, loff_t pos)
{ {
struct mr6_table *mrt = it->mrt; struct mr_table *mrt = it->mrt;
struct mfc6_cache *mfc; struct mfc6_cache *mfc;
rcu_read_lock(); rcu_read_lock();
it->cache = &mrt->mfc6_cache_list; it->cache = &mrt->mfc_cache_list;
list_for_each_entry_rcu(mfc, &mrt->mfc6_cache_list, list) list_for_each_entry_rcu(mfc, &mrt->mfc_cache_list, list)
if (pos-- == 0) if (pos-- == 0)
return mfc; return mfc;
rcu_read_unlock(); rcu_read_unlock();
spin_lock_bh(&mfc_unres_lock); spin_lock_bh(&mfc_unres_lock);
it->cache = &mrt->mfc6_unres_queue; it->cache = &mrt->mfc_unres_queue;
list_for_each_entry(mfc, it->cache, list) list_for_each_entry(mfc, it->cache, list)
if (pos-- == 0) if (pos-- == 0)
return mfc; return mfc;
...@@ -396,7 +371,7 @@ static struct mfc6_cache *ipmr_mfc_seq_idx(struct net *net, ...@@ -396,7 +371,7 @@ static struct mfc6_cache *ipmr_mfc_seq_idx(struct net *net,
struct ipmr_vif_iter { struct ipmr_vif_iter {
struct seq_net_private p; struct seq_net_private p;
struct mr6_table *mrt; struct mr_table *mrt;
int ct; int ct;
}; };
...@@ -404,13 +379,13 @@ static struct vif_device *ip6mr_vif_seq_idx(struct net *net, ...@@ -404,13 +379,13 @@ static struct vif_device *ip6mr_vif_seq_idx(struct net *net,
struct ipmr_vif_iter *iter, struct ipmr_vif_iter *iter,
loff_t pos) loff_t pos)
{ {
struct mr6_table *mrt = iter->mrt; struct mr_table *mrt = iter->mrt;
for (iter->ct = 0; iter->ct < mrt->maxvif; ++iter->ct) { for (iter->ct = 0; iter->ct < mrt->maxvif; ++iter->ct) {
if (!MIF_EXISTS(mrt, iter->ct)) if (!VIF_EXISTS(mrt, iter->ct))
continue; continue;
if (pos-- == 0) if (pos-- == 0)
return &mrt->vif6_table[iter->ct]; return &mrt->vif_table[iter->ct];
} }
return NULL; return NULL;
} }
...@@ -420,7 +395,7 @@ static void *ip6mr_vif_seq_start(struct seq_file *seq, loff_t *pos) ...@@ -420,7 +395,7 @@ static void *ip6mr_vif_seq_start(struct seq_file *seq, loff_t *pos)
{ {
struct ipmr_vif_iter *iter = seq->private; struct ipmr_vif_iter *iter = seq->private;
struct net *net = seq_file_net(seq); struct net *net = seq_file_net(seq);
struct mr6_table *mrt; struct mr_table *mrt;
mrt = ip6mr_get_table(net, RT6_TABLE_DFLT); mrt = ip6mr_get_table(net, RT6_TABLE_DFLT);
if (!mrt) if (!mrt)
...@@ -437,16 +412,16 @@ static void *ip6mr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -437,16 +412,16 @@ static void *ip6mr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{ {
struct ipmr_vif_iter *iter = seq->private; struct ipmr_vif_iter *iter = seq->private;
struct net *net = seq_file_net(seq); struct net *net = seq_file_net(seq);
struct mr6_table *mrt = iter->mrt; struct mr_table *mrt = iter->mrt;
++*pos; ++*pos;
if (v == SEQ_START_TOKEN) if (v == SEQ_START_TOKEN)
return ip6mr_vif_seq_idx(net, iter, 0); return ip6mr_vif_seq_idx(net, iter, 0);
while (++iter->ct < mrt->maxvif) { while (++iter->ct < mrt->maxvif) {
if (!MIF_EXISTS(mrt, iter->ct)) if (!VIF_EXISTS(mrt, iter->ct))
continue; continue;
return &mrt->vif6_table[iter->ct]; return &mrt->vif_table[iter->ct];
} }
return NULL; return NULL;
} }
...@@ -460,7 +435,7 @@ static void ip6mr_vif_seq_stop(struct seq_file *seq, void *v) ...@@ -460,7 +435,7 @@ static void ip6mr_vif_seq_stop(struct seq_file *seq, void *v)
static int ip6mr_vif_seq_show(struct seq_file *seq, void *v) static int ip6mr_vif_seq_show(struct seq_file *seq, void *v)
{ {
struct ipmr_vif_iter *iter = seq->private; struct ipmr_vif_iter *iter = seq->private;
struct mr6_table *mrt = iter->mrt; struct mr_table *mrt = iter->mrt;
if (v == SEQ_START_TOKEN) { if (v == SEQ_START_TOKEN) {
seq_puts(seq, seq_puts(seq,
...@@ -471,7 +446,7 @@ static int ip6mr_vif_seq_show(struct seq_file *seq, void *v) ...@@ -471,7 +446,7 @@ static int ip6mr_vif_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, seq_printf(seq,
"%2td %-10s %8ld %7ld %8ld %7ld %05X\n", "%2td %-10s %8ld %7ld %8ld %7ld %05X\n",
vif - mrt->vif6_table, vif - mrt->vif_table,
name, vif->bytes_in, vif->pkt_in, name, vif->bytes_in, vif->pkt_in,
vif->bytes_out, vif->pkt_out, vif->bytes_out, vif->pkt_out,
vif->flags); vif->flags);
...@@ -503,7 +478,7 @@ static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos) ...@@ -503,7 +478,7 @@ static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos)
{ {
struct ipmr_mfc_iter *it = seq->private; struct ipmr_mfc_iter *it = seq->private;
struct net *net = seq_file_net(seq); struct net *net = seq_file_net(seq);
struct mr6_table *mrt; struct mr_table *mrt;
mrt = ip6mr_get_table(net, RT6_TABLE_DFLT); mrt = ip6mr_get_table(net, RT6_TABLE_DFLT);
if (!mrt) if (!mrt)
...@@ -520,7 +495,7 @@ static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -520,7 +495,7 @@ static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
struct mfc6_cache *mfc = v; struct mfc6_cache *mfc = v;
struct ipmr_mfc_iter *it = seq->private; struct ipmr_mfc_iter *it = seq->private;
struct net *net = seq_file_net(seq); struct net *net = seq_file_net(seq);
struct mr6_table *mrt = it->mrt; struct mr_table *mrt = it->mrt;
++*pos; ++*pos;
...@@ -530,12 +505,12 @@ static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -530,12 +505,12 @@ static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
if (mfc->list.next != it->cache) if (mfc->list.next != it->cache)
return list_entry(mfc->list.next, struct mfc6_cache, list); return list_entry(mfc->list.next, struct mfc6_cache, list);
if (it->cache == &mrt->mfc6_unres_queue) if (it->cache == &mrt->mfc_unres_queue)
goto end_of_list; goto end_of_list;
/* exhausted cache_array, show unresolved */ /* exhausted cache_array, show unresolved */
rcu_read_unlock(); rcu_read_unlock();
it->cache = &mrt->mfc6_unres_queue; it->cache = &mrt->mfc_unres_queue;
spin_lock_bh(&mfc_unres_lock); spin_lock_bh(&mfc_unres_lock);
if (!list_empty(it->cache)) if (!list_empty(it->cache))
...@@ -551,11 +526,11 @@ static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -551,11 +526,11 @@ static void *ipmr_mfc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
static void ipmr_mfc_seq_stop(struct seq_file *seq, void *v) static void ipmr_mfc_seq_stop(struct seq_file *seq, void *v)
{ {
struct ipmr_mfc_iter *it = seq->private; struct ipmr_mfc_iter *it = seq->private;
struct mr6_table *mrt = it->mrt; struct mr_table *mrt = it->mrt;
if (it->cache == &mrt->mfc6_unres_queue) if (it->cache == &mrt->mfc_unres_queue)
spin_unlock_bh(&mfc_unres_lock); spin_unlock_bh(&mfc_unres_lock);
else if (it->cache == &mrt->mfc6_cache_list) else if (it->cache == &mrt->mfc_cache_list)
rcu_read_unlock(); rcu_read_unlock();
} }
...@@ -571,20 +546,20 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v) ...@@ -571,20 +546,20 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v)
} else { } else {
const struct mfc6_cache *mfc = v; const struct mfc6_cache *mfc = v;
const struct ipmr_mfc_iter *it = seq->private; const struct ipmr_mfc_iter *it = seq->private;
struct mr6_table *mrt = it->mrt; struct mr_table *mrt = it->mrt;
seq_printf(seq, "%pI6 %pI6 %-3hd", seq_printf(seq, "%pI6 %pI6 %-3hd",
&mfc->mf6c_mcastgrp, &mfc->mf6c_origin, &mfc->mf6c_mcastgrp, &mfc->mf6c_origin,
mfc->mf6c_parent); mfc->mf6c_parent);
if (it->cache != &mrt->mfc6_unres_queue) { if (it->cache != &mrt->mfc_unres_queue) {
seq_printf(seq, " %8lu %8lu %8lu", seq_printf(seq, " %8lu %8lu %8lu",
mfc->mfc_un.res.pkt, mfc->mfc_un.res.pkt,
mfc->mfc_un.res.bytes, mfc->mfc_un.res.bytes,
mfc->mfc_un.res.wrong_if); mfc->mfc_un.res.wrong_if);
for (n = mfc->mfc_un.res.minvif; for (n = mfc->mfc_un.res.minvif;
n < mfc->mfc_un.res.maxvif; n++) { n < mfc->mfc_un.res.maxvif; n++) {
if (MIF_EXISTS(mrt, n) && if (VIF_EXISTS(mrt, n) &&
mfc->mfc_un.res.ttls[n] < 255) mfc->mfc_un.res.ttls[n] < 255)
seq_printf(seq, seq_printf(seq,
" %2d:%-3d", " %2d:%-3d",
...@@ -630,7 +605,7 @@ static int pim6_rcv(struct sk_buff *skb) ...@@ -630,7 +605,7 @@ static int pim6_rcv(struct sk_buff *skb)
struct ipv6hdr *encap; struct ipv6hdr *encap;
struct net_device *reg_dev = NULL; struct net_device *reg_dev = NULL;
struct net *net = dev_net(skb->dev); struct net *net = dev_net(skb->dev);
struct mr6_table *mrt; struct mr_table *mrt;
struct flowi6 fl6 = { struct flowi6 fl6 = {
.flowi6_iif = skb->dev->ifindex, .flowi6_iif = skb->dev->ifindex,
.flowi6_mark = skb->mark, .flowi6_mark = skb->mark,
...@@ -664,7 +639,7 @@ static int pim6_rcv(struct sk_buff *skb) ...@@ -664,7 +639,7 @@ static int pim6_rcv(struct sk_buff *skb)
read_lock(&mrt_lock); read_lock(&mrt_lock);
if (reg_vif_num >= 0) if (reg_vif_num >= 0)
reg_dev = mrt->vif6_table[reg_vif_num].dev; reg_dev = mrt->vif_table[reg_vif_num].dev;
if (reg_dev) if (reg_dev)
dev_hold(reg_dev); dev_hold(reg_dev);
read_unlock(&mrt_lock); read_unlock(&mrt_lock);
...@@ -699,7 +674,7 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, ...@@ -699,7 +674,7 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb,
struct net_device *dev) struct net_device *dev)
{ {
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
struct mr6_table *mrt; struct mr_table *mrt;
struct flowi6 fl6 = { struct flowi6 fl6 = {
.flowi6_oif = dev->ifindex, .flowi6_oif = dev->ifindex,
.flowi6_iif = skb->skb_iif ? : LOOPBACK_IFINDEX, .flowi6_iif = skb->skb_iif ? : LOOPBACK_IFINDEX,
...@@ -742,7 +717,7 @@ static void reg_vif_setup(struct net_device *dev) ...@@ -742,7 +717,7 @@ static void reg_vif_setup(struct net_device *dev)
dev->features |= NETIF_F_NETNS_LOCAL; dev->features |= NETIF_F_NETNS_LOCAL;
} }
static struct net_device *ip6mr_reg_vif(struct net *net, struct mr6_table *mrt) static struct net_device *ip6mr_reg_vif(struct net *net, struct mr_table *mrt)
{ {
struct net_device *dev; struct net_device *dev;
char name[IFNAMSIZ]; char name[IFNAMSIZ];
...@@ -779,7 +754,7 @@ static struct net_device *ip6mr_reg_vif(struct net *net, struct mr6_table *mrt) ...@@ -779,7 +754,7 @@ static struct net_device *ip6mr_reg_vif(struct net *net, struct mr6_table *mrt)
* Delete a VIF entry * Delete a VIF entry
*/ */
static int mif6_delete(struct mr6_table *mrt, int vifi, int notify, static int mif6_delete(struct mr_table *mrt, int vifi, int notify,
struct list_head *head) struct list_head *head)
{ {
struct vif_device *v; struct vif_device *v;
...@@ -789,7 +764,7 @@ static int mif6_delete(struct mr6_table *mrt, int vifi, int notify, ...@@ -789,7 +764,7 @@ static int mif6_delete(struct mr6_table *mrt, int vifi, int notify,
if (vifi < 0 || vifi >= mrt->maxvif) if (vifi < 0 || vifi >= mrt->maxvif)
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
v = &mrt->vif6_table[vifi]; v = &mrt->vif_table[vifi];
write_lock_bh(&mrt_lock); write_lock_bh(&mrt_lock);
dev = v->dev; dev = v->dev;
...@@ -808,7 +783,7 @@ static int mif6_delete(struct mr6_table *mrt, int vifi, int notify, ...@@ -808,7 +783,7 @@ static int mif6_delete(struct mr6_table *mrt, int vifi, int notify,
if (vifi + 1 == mrt->maxvif) { if (vifi + 1 == mrt->maxvif) {
int tmp; int tmp;
for (tmp = vifi - 1; tmp >= 0; tmp--) { for (tmp = vifi - 1; tmp >= 0; tmp--) {
if (MIF_EXISTS(mrt, tmp)) if (VIF_EXISTS(mrt, tmp))
break; break;
} }
mrt->maxvif = tmp + 1; mrt->maxvif = tmp + 1;
...@@ -849,7 +824,7 @@ static inline void ip6mr_cache_free(struct mfc6_cache *c) ...@@ -849,7 +824,7 @@ static inline void ip6mr_cache_free(struct mfc6_cache *c)
and reporting error to netlink readers. and reporting error to netlink readers.
*/ */
static void ip6mr_destroy_unres(struct mr6_table *mrt, struct mfc6_cache *c) static void ip6mr_destroy_unres(struct mr_table *mrt, struct mfc6_cache *c)
{ {
struct net *net = read_pnet(&mrt->net); struct net *net = read_pnet(&mrt->net);
struct sk_buff *skb; struct sk_buff *skb;
...@@ -875,13 +850,13 @@ static void ip6mr_destroy_unres(struct mr6_table *mrt, struct mfc6_cache *c) ...@@ -875,13 +850,13 @@ static void ip6mr_destroy_unres(struct mr6_table *mrt, struct mfc6_cache *c)
/* Timer process for all the unresolved queue. */ /* Timer process for all the unresolved queue. */
static void ipmr_do_expire_process(struct mr6_table *mrt) static void ipmr_do_expire_process(struct mr_table *mrt)
{ {
unsigned long now = jiffies; unsigned long now = jiffies;
unsigned long expires = 10 * HZ; unsigned long expires = 10 * HZ;
struct mfc6_cache *c, *next; struct mfc6_cache *c, *next;
list_for_each_entry_safe(c, next, &mrt->mfc6_unres_queue, list) { list_for_each_entry_safe(c, next, &mrt->mfc_unres_queue, list) {
if (time_after(c->mfc_un.unres.expires, now)) { if (time_after(c->mfc_un.unres.expires, now)) {
/* not yet... */ /* not yet... */
unsigned long interval = c->mfc_un.unres.expires - now; unsigned long interval = c->mfc_un.unres.expires - now;
...@@ -895,20 +870,20 @@ static void ipmr_do_expire_process(struct mr6_table *mrt) ...@@ -895,20 +870,20 @@ static void ipmr_do_expire_process(struct mr6_table *mrt)
ip6mr_destroy_unres(mrt, c); ip6mr_destroy_unres(mrt, c);
} }
if (!list_empty(&mrt->mfc6_unres_queue)) if (!list_empty(&mrt->mfc_unres_queue))
mod_timer(&mrt->ipmr_expire_timer, jiffies + expires); mod_timer(&mrt->ipmr_expire_timer, jiffies + expires);
} }
static void ipmr_expire_process(struct timer_list *t) static void ipmr_expire_process(struct timer_list *t)
{ {
struct mr6_table *mrt = from_timer(mrt, t, ipmr_expire_timer); struct mr_table *mrt = from_timer(mrt, t, ipmr_expire_timer);
if (!spin_trylock(&mfc_unres_lock)) { if (!spin_trylock(&mfc_unres_lock)) {
mod_timer(&mrt->ipmr_expire_timer, jiffies + 1); mod_timer(&mrt->ipmr_expire_timer, jiffies + 1);
return; return;
} }
if (!list_empty(&mrt->mfc6_unres_queue)) if (!list_empty(&mrt->mfc_unres_queue))
ipmr_do_expire_process(mrt); ipmr_do_expire_process(mrt);
spin_unlock(&mfc_unres_lock); spin_unlock(&mfc_unres_lock);
...@@ -916,7 +891,8 @@ static void ipmr_expire_process(struct timer_list *t) ...@@ -916,7 +891,8 @@ static void ipmr_expire_process(struct timer_list *t)
/* Fill oifs list. It is called under write locked mrt_lock. */ /* Fill oifs list. It is called under write locked mrt_lock. */
static void ip6mr_update_thresholds(struct mr6_table *mrt, struct mfc6_cache *cache, static void ip6mr_update_thresholds(struct mr_table *mrt,
struct mfc6_cache *cache,
unsigned char *ttls) unsigned char *ttls)
{ {
int vifi; int vifi;
...@@ -926,7 +902,7 @@ static void ip6mr_update_thresholds(struct mr6_table *mrt, struct mfc6_cache *ca ...@@ -926,7 +902,7 @@ static void ip6mr_update_thresholds(struct mr6_table *mrt, struct mfc6_cache *ca
memset(cache->mfc_un.res.ttls, 255, MAXMIFS); memset(cache->mfc_un.res.ttls, 255, MAXMIFS);
for (vifi = 0; vifi < mrt->maxvif; vifi++) { for (vifi = 0; vifi < mrt->maxvif; vifi++) {
if (MIF_EXISTS(mrt, vifi) && if (VIF_EXISTS(mrt, vifi) &&
ttls[vifi] && ttls[vifi] < 255) { ttls[vifi] && ttls[vifi] < 255) {
cache->mfc_un.res.ttls[vifi] = ttls[vifi]; cache->mfc_un.res.ttls[vifi] = ttls[vifi];
if (cache->mfc_un.res.minvif > vifi) if (cache->mfc_un.res.minvif > vifi)
...@@ -938,17 +914,17 @@ static void ip6mr_update_thresholds(struct mr6_table *mrt, struct mfc6_cache *ca ...@@ -938,17 +914,17 @@ static void ip6mr_update_thresholds(struct mr6_table *mrt, struct mfc6_cache *ca
cache->mfc_un.res.lastuse = jiffies; cache->mfc_un.res.lastuse = jiffies;
} }
static int mif6_add(struct net *net, struct mr6_table *mrt, static int mif6_add(struct net *net, struct mr_table *mrt,
struct mif6ctl *vifc, int mrtsock) struct mif6ctl *vifc, int mrtsock)
{ {
int vifi = vifc->mif6c_mifi; int vifi = vifc->mif6c_mifi;
struct vif_device *v = &mrt->vif6_table[vifi]; struct vif_device *v = &mrt->vif_table[vifi];
struct net_device *dev; struct net_device *dev;
struct inet6_dev *in6_dev; struct inet6_dev *in6_dev;
int err; int err;
/* Is vif busy ? */ /* Is vif busy ? */
if (MIF_EXISTS(mrt, vifi)) if (VIF_EXISTS(mrt, vifi))
return -EADDRINUSE; return -EADDRINUSE;
switch (vifc->mif6c_flags) { switch (vifc->mif6c_flags) {
...@@ -1011,7 +987,7 @@ static int mif6_add(struct net *net, struct mr6_table *mrt, ...@@ -1011,7 +987,7 @@ static int mif6_add(struct net *net, struct mr6_table *mrt,
return 0; return 0;
} }
static struct mfc6_cache *ip6mr_cache_find(struct mr6_table *mrt, static struct mfc6_cache *ip6mr_cache_find(struct mr_table *mrt,
const struct in6_addr *origin, const struct in6_addr *origin,
const struct in6_addr *mcastgrp) const struct in6_addr *mcastgrp)
{ {
...@@ -1022,7 +998,7 @@ static struct mfc6_cache *ip6mr_cache_find(struct mr6_table *mrt, ...@@ -1022,7 +998,7 @@ static struct mfc6_cache *ip6mr_cache_find(struct mr6_table *mrt,
struct rhlist_head *tmp, *list; struct rhlist_head *tmp, *list;
struct mfc6_cache *c; struct mfc6_cache *c;
list = rhltable_lookup(&mrt->mfc6_hash, &arg, ip6mr_rht_params); list = rhltable_lookup(&mrt->mfc_hash, &arg, ip6mr_rht_params);
rhl_for_each_entry_rcu(c, tmp, list, mnode) rhl_for_each_entry_rcu(c, tmp, list, mnode)
return c; return c;
...@@ -1030,7 +1006,7 @@ static struct mfc6_cache *ip6mr_cache_find(struct mr6_table *mrt, ...@@ -1030,7 +1006,7 @@ static struct mfc6_cache *ip6mr_cache_find(struct mr6_table *mrt,
} }
/* Look for a (*,*,oif) entry */ /* Look for a (*,*,oif) entry */
static struct mfc6_cache *ip6mr_cache_find_any_parent(struct mr6_table *mrt, static struct mfc6_cache *ip6mr_cache_find_any_parent(struct mr_table *mrt,
mifi_t mifi) mifi_t mifi)
{ {
struct mfc6_cache_cmp_arg arg = { struct mfc6_cache_cmp_arg arg = {
...@@ -1040,7 +1016,7 @@ static struct mfc6_cache *ip6mr_cache_find_any_parent(struct mr6_table *mrt, ...@@ -1040,7 +1016,7 @@ static struct mfc6_cache *ip6mr_cache_find_any_parent(struct mr6_table *mrt,
struct rhlist_head *tmp, *list; struct rhlist_head *tmp, *list;
struct mfc6_cache *c; struct mfc6_cache *c;
list = rhltable_lookup(&mrt->mfc6_hash, &arg, ip6mr_rht_params); list = rhltable_lookup(&mrt->mfc_hash, &arg, ip6mr_rht_params);
rhl_for_each_entry_rcu(c, tmp, list, mnode) rhl_for_each_entry_rcu(c, tmp, list, mnode)
if (c->mfc_un.res.ttls[mifi] < 255) if (c->mfc_un.res.ttls[mifi] < 255)
return c; return c;
...@@ -1049,7 +1025,7 @@ static struct mfc6_cache *ip6mr_cache_find_any_parent(struct mr6_table *mrt, ...@@ -1049,7 +1025,7 @@ static struct mfc6_cache *ip6mr_cache_find_any_parent(struct mr6_table *mrt,
} }
/* Look for a (*,G) entry */ /* Look for a (*,G) entry */
static struct mfc6_cache *ip6mr_cache_find_any(struct mr6_table *mrt, static struct mfc6_cache *ip6mr_cache_find_any(struct mr_table *mrt,
struct in6_addr *mcastgrp, struct in6_addr *mcastgrp,
mifi_t mifi) mifi_t mifi)
{ {
...@@ -1063,7 +1039,7 @@ static struct mfc6_cache *ip6mr_cache_find_any(struct mr6_table *mrt, ...@@ -1063,7 +1039,7 @@ static struct mfc6_cache *ip6mr_cache_find_any(struct mr6_table *mrt,
if (ipv6_addr_any(mcastgrp)) if (ipv6_addr_any(mcastgrp))
goto skip; goto skip;
list = rhltable_lookup(&mrt->mfc6_hash, &arg, ip6mr_rht_params); list = rhltable_lookup(&mrt->mfc_hash, &arg, ip6mr_rht_params);
rhl_for_each_entry_rcu(c, tmp, list, mnode) { rhl_for_each_entry_rcu(c, tmp, list, mnode) {
if (c->mfc_un.res.ttls[mifi] < 255) if (c->mfc_un.res.ttls[mifi] < 255)
return c; return c;
...@@ -1080,7 +1056,7 @@ static struct mfc6_cache *ip6mr_cache_find_any(struct mr6_table *mrt, ...@@ -1080,7 +1056,7 @@ static struct mfc6_cache *ip6mr_cache_find_any(struct mr6_table *mrt,
/* Look for a (S,G,iif) entry if parent != -1 */ /* Look for a (S,G,iif) entry if parent != -1 */
static struct mfc6_cache * static struct mfc6_cache *
ip6mr_cache_find_parent(struct mr6_table *mrt, ip6mr_cache_find_parent(struct mr_table *mrt,
const struct in6_addr *origin, const struct in6_addr *origin,
const struct in6_addr *mcastgrp, const struct in6_addr *mcastgrp,
int parent) int parent)
...@@ -1092,7 +1068,7 @@ ip6mr_cache_find_parent(struct mr6_table *mrt, ...@@ -1092,7 +1068,7 @@ ip6mr_cache_find_parent(struct mr6_table *mrt,
struct rhlist_head *tmp, *list; struct rhlist_head *tmp, *list;
struct mfc6_cache *c; struct mfc6_cache *c;
list = rhltable_lookup(&mrt->mfc6_hash, &arg, ip6mr_rht_params); list = rhltable_lookup(&mrt->mfc_hash, &arg, ip6mr_rht_params);
rhl_for_each_entry_rcu(c, tmp, list, mnode) rhl_for_each_entry_rcu(c, tmp, list, mnode)
if (parent == -1 || parent == c->mf6c_parent) if (parent == -1 || parent == c->mf6c_parent)
return c; return c;
...@@ -1127,7 +1103,7 @@ static struct mfc6_cache *ip6mr_cache_alloc_unres(void) ...@@ -1127,7 +1103,7 @@ static struct mfc6_cache *ip6mr_cache_alloc_unres(void)
* A cache entry has gone into a resolved state from queued * A cache entry has gone into a resolved state from queued
*/ */
static void ip6mr_cache_resolve(struct net *net, struct mr6_table *mrt, static void ip6mr_cache_resolve(struct net *net, struct mr_table *mrt,
struct mfc6_cache *uc, struct mfc6_cache *c) struct mfc6_cache *uc, struct mfc6_cache *c)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -1161,7 +1137,7 @@ static void ip6mr_cache_resolve(struct net *net, struct mr6_table *mrt, ...@@ -1161,7 +1137,7 @@ static void ip6mr_cache_resolve(struct net *net, struct mr6_table *mrt,
* Called under mrt_lock. * Called under mrt_lock.
*/ */
static int ip6mr_cache_report(struct mr6_table *mrt, struct sk_buff *pkt, static int ip6mr_cache_report(struct mr_table *mrt, struct sk_buff *pkt,
mifi_t mifi, int assert) mifi_t mifi, int assert)
{ {
struct sock *mroute6_sk; struct sock *mroute6_sk;
...@@ -1235,7 +1211,7 @@ static int ip6mr_cache_report(struct mr6_table *mrt, struct sk_buff *pkt, ...@@ -1235,7 +1211,7 @@ static int ip6mr_cache_report(struct mr6_table *mrt, struct sk_buff *pkt,
} }
rcu_read_lock(); rcu_read_lock();
mroute6_sk = rcu_dereference(mrt->mroute6_sk); mroute6_sk = rcu_dereference(mrt->mroute_sk);
if (!mroute6_sk) { if (!mroute6_sk) {
rcu_read_unlock(); rcu_read_unlock();
kfree_skb(skb); kfree_skb(skb);
...@@ -1260,14 +1236,14 @@ static int ip6mr_cache_report(struct mr6_table *mrt, struct sk_buff *pkt, ...@@ -1260,14 +1236,14 @@ static int ip6mr_cache_report(struct mr6_table *mrt, struct sk_buff *pkt,
*/ */
static int static int
ip6mr_cache_unresolved(struct mr6_table *mrt, mifi_t mifi, struct sk_buff *skb) ip6mr_cache_unresolved(struct mr_table *mrt, mifi_t mifi, struct sk_buff *skb)
{ {
bool found = false; bool found = false;
int err; int err;
struct mfc6_cache *c; struct mfc6_cache *c;
spin_lock_bh(&mfc_unres_lock); spin_lock_bh(&mfc_unres_lock);
list_for_each_entry(c, &mrt->mfc6_unres_queue, list) { list_for_each_entry(c, &mrt->mfc_unres_queue, list) {
if (ipv6_addr_equal(&c->mf6c_mcastgrp, &ipv6_hdr(skb)->daddr) && if (ipv6_addr_equal(&c->mf6c_mcastgrp, &ipv6_hdr(skb)->daddr) &&
ipv6_addr_equal(&c->mf6c_origin, &ipv6_hdr(skb)->saddr)) { ipv6_addr_equal(&c->mf6c_origin, &ipv6_hdr(skb)->saddr)) {
found = true; found = true;
...@@ -1311,7 +1287,7 @@ ip6mr_cache_unresolved(struct mr6_table *mrt, mifi_t mifi, struct sk_buff *skb) ...@@ -1311,7 +1287,7 @@ ip6mr_cache_unresolved(struct mr6_table *mrt, mifi_t mifi, struct sk_buff *skb)
} }
atomic_inc(&mrt->cache_resolve_queue_len); atomic_inc(&mrt->cache_resolve_queue_len);
list_add(&c->list, &mrt->mfc6_unres_queue); list_add(&c->list, &mrt->mfc_unres_queue);
mr6_netlink_event(mrt, c, RTM_NEWROUTE); mr6_netlink_event(mrt, c, RTM_NEWROUTE);
ipmr_do_expire_process(mrt); ipmr_do_expire_process(mrt);
...@@ -1336,7 +1312,7 @@ ip6mr_cache_unresolved(struct mr6_table *mrt, mifi_t mifi, struct sk_buff *skb) ...@@ -1336,7 +1312,7 @@ ip6mr_cache_unresolved(struct mr6_table *mrt, mifi_t mifi, struct sk_buff *skb)
* MFC6 cache manipulation by user space * MFC6 cache manipulation by user space
*/ */
static int ip6mr_mfc_delete(struct mr6_table *mrt, struct mf6cctl *mfc, static int ip6mr_mfc_delete(struct mr_table *mrt, struct mf6cctl *mfc,
int parent) int parent)
{ {
struct mfc6_cache *c; struct mfc6_cache *c;
...@@ -1348,7 +1324,7 @@ static int ip6mr_mfc_delete(struct mr6_table *mrt, struct mf6cctl *mfc, ...@@ -1348,7 +1324,7 @@ static int ip6mr_mfc_delete(struct mr6_table *mrt, struct mf6cctl *mfc,
rcu_read_unlock(); rcu_read_unlock();
if (!c) if (!c)
return -ENOENT; return -ENOENT;
rhltable_remove(&mrt->mfc6_hash, &c->mnode, ip6mr_rht_params); rhltable_remove(&mrt->mfc_hash, &c->mnode, ip6mr_rht_params);
list_del_rcu(&c->list); list_del_rcu(&c->list);
mr6_netlink_event(mrt, c, RTM_DELROUTE); mr6_netlink_event(mrt, c, RTM_DELROUTE);
...@@ -1361,7 +1337,7 @@ static int ip6mr_device_event(struct notifier_block *this, ...@@ -1361,7 +1337,7 @@ static int ip6mr_device_event(struct notifier_block *this,
{ {
struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
struct mr6_table *mrt; struct mr_table *mrt;
struct vif_device *v; struct vif_device *v;
int ct; int ct;
...@@ -1369,7 +1345,7 @@ static int ip6mr_device_event(struct notifier_block *this, ...@@ -1369,7 +1345,7 @@ static int ip6mr_device_event(struct notifier_block *this,
return NOTIFY_DONE; return NOTIFY_DONE;
ip6mr_for_each_table(mrt, net) { ip6mr_for_each_table(mrt, net) {
v = &mrt->vif6_table[0]; v = &mrt->vif_table[0];
for (ct = 0; ct < mrt->maxvif; ct++, v++) { for (ct = 0; ct < mrt->maxvif; ct++, v++) {
if (v->dev == dev) if (v->dev == dev)
mif6_delete(mrt, ct, 1, NULL); mif6_delete(mrt, ct, 1, NULL);
...@@ -1483,7 +1459,7 @@ void ip6_mr_cleanup(void) ...@@ -1483,7 +1459,7 @@ void ip6_mr_cleanup(void)
kmem_cache_destroy(mrt_cachep); kmem_cache_destroy(mrt_cachep);
} }
static int ip6mr_mfc_add(struct net *net, struct mr6_table *mrt, static int ip6mr_mfc_add(struct net *net, struct mr_table *mrt,
struct mf6cctl *mfc, int mrtsock, int parent) struct mf6cctl *mfc, int mrtsock, int parent)
{ {
unsigned char ttls[MAXMIFS]; unsigned char ttls[MAXMIFS];
...@@ -1531,21 +1507,21 @@ static int ip6mr_mfc_add(struct net *net, struct mr6_table *mrt, ...@@ -1531,21 +1507,21 @@ static int ip6mr_mfc_add(struct net *net, struct mr6_table *mrt,
if (!mrtsock) if (!mrtsock)
c->mfc_flags |= MFC_STATIC; c->mfc_flags |= MFC_STATIC;
err = rhltable_insert_key(&mrt->mfc6_hash, &c->cmparg, &c->mnode, err = rhltable_insert_key(&mrt->mfc_hash, &c->cmparg, &c->mnode,
ip6mr_rht_params); ip6mr_rht_params);
if (err) { if (err) {
pr_err("ip6mr: rhtable insert error %d\n", err); pr_err("ip6mr: rhtable insert error %d\n", err);
ip6mr_cache_free(c); ip6mr_cache_free(c);
return err; return err;
} }
list_add_tail_rcu(&c->list, &mrt->mfc6_cache_list); list_add_tail_rcu(&c->list, &mrt->mfc_cache_list);
/* Check to see if we resolved a queued list. If so we /* Check to see if we resolved a queued list. If so we
* need to send on the frames and tidy up. * need to send on the frames and tidy up.
*/ */
found = false; found = false;
spin_lock_bh(&mfc_unres_lock); spin_lock_bh(&mfc_unres_lock);
list_for_each_entry(uc, &mrt->mfc6_unres_queue, list) { list_for_each_entry(uc, &mrt->mfc_unres_queue, list) {
if (ipv6_addr_equal(&uc->mf6c_origin, &c->mf6c_origin) && if (ipv6_addr_equal(&uc->mf6c_origin, &c->mf6c_origin) &&
ipv6_addr_equal(&uc->mf6c_mcastgrp, &c->mf6c_mcastgrp)) { ipv6_addr_equal(&uc->mf6c_mcastgrp, &c->mf6c_mcastgrp)) {
list_del(&uc->list); list_del(&uc->list);
...@@ -1554,7 +1530,7 @@ static int ip6mr_mfc_add(struct net *net, struct mr6_table *mrt, ...@@ -1554,7 +1530,7 @@ static int ip6mr_mfc_add(struct net *net, struct mr6_table *mrt,
break; break;
} }
} }
if (list_empty(&mrt->mfc6_unres_queue)) if (list_empty(&mrt->mfc_unres_queue))
del_timer(&mrt->ipmr_expire_timer); del_timer(&mrt->ipmr_expire_timer);
spin_unlock_bh(&mfc_unres_lock); spin_unlock_bh(&mfc_unres_lock);
...@@ -1570,7 +1546,7 @@ static int ip6mr_mfc_add(struct net *net, struct mr6_table *mrt, ...@@ -1570,7 +1546,7 @@ static int ip6mr_mfc_add(struct net *net, struct mr6_table *mrt,
* Close the multicast socket, and clear the vif tables etc * Close the multicast socket, and clear the vif tables etc
*/ */
static void mroute_clean_tables(struct mr6_table *mrt, bool all) static void mroute_clean_tables(struct mr_table *mrt, bool all)
{ {
struct mfc6_cache *c, *tmp; struct mfc6_cache *c, *tmp;
LIST_HEAD(list); LIST_HEAD(list);
...@@ -1578,17 +1554,17 @@ static void mroute_clean_tables(struct mr6_table *mrt, bool all) ...@@ -1578,17 +1554,17 @@ static void mroute_clean_tables(struct mr6_table *mrt, bool all)
/* Shut down all active vif entries */ /* Shut down all active vif entries */
for (i = 0; i < mrt->maxvif; i++) { for (i = 0; i < mrt->maxvif; i++) {
if (!all && (mrt->vif6_table[i].flags & VIFF_STATIC)) if (!all && (mrt->vif_table[i].flags & VIFF_STATIC))
continue; continue;
mif6_delete(mrt, i, 0, &list); mif6_delete(mrt, i, 0, &list);
} }
unregister_netdevice_many(&list); unregister_netdevice_many(&list);
/* Wipe the cache */ /* Wipe the cache */
list_for_each_entry_safe(c, tmp, &mrt->mfc6_cache_list, list) { list_for_each_entry_safe(c, tmp, &mrt->mfc_cache_list, list) {
if (!all && (c->mfc_flags & MFC_STATIC)) if (!all && (c->mfc_flags & MFC_STATIC))
continue; continue;
rhltable_remove(&mrt->mfc6_hash, &c->mnode, ip6mr_rht_params); rhltable_remove(&mrt->mfc_hash, &c->mnode, ip6mr_rht_params);
list_del_rcu(&c->list); list_del_rcu(&c->list);
mr6_netlink_event(mrt, c, RTM_DELROUTE); mr6_netlink_event(mrt, c, RTM_DELROUTE);
ip6mr_cache_free(c); ip6mr_cache_free(c);
...@@ -1596,7 +1572,7 @@ static void mroute_clean_tables(struct mr6_table *mrt, bool all) ...@@ -1596,7 +1572,7 @@ static void mroute_clean_tables(struct mr6_table *mrt, bool all)
if (atomic_read(&mrt->cache_resolve_queue_len) != 0) { if (atomic_read(&mrt->cache_resolve_queue_len) != 0) {
spin_lock_bh(&mfc_unres_lock); spin_lock_bh(&mfc_unres_lock);
list_for_each_entry_safe(c, tmp, &mrt->mfc6_unres_queue, list) { list_for_each_entry_safe(c, tmp, &mrt->mfc_unres_queue, list) {
list_del(&c->list); list_del(&c->list);
mr6_netlink_event(mrt, c, RTM_DELROUTE); mr6_netlink_event(mrt, c, RTM_DELROUTE);
ip6mr_destroy_unres(mrt, c); ip6mr_destroy_unres(mrt, c);
...@@ -1605,17 +1581,17 @@ static void mroute_clean_tables(struct mr6_table *mrt, bool all) ...@@ -1605,17 +1581,17 @@ static void mroute_clean_tables(struct mr6_table *mrt, bool all)
} }
} }
static int ip6mr_sk_init(struct mr6_table *mrt, struct sock *sk) static int ip6mr_sk_init(struct mr_table *mrt, struct sock *sk)
{ {
int err = 0; int err = 0;
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
rtnl_lock(); rtnl_lock();
write_lock_bh(&mrt_lock); write_lock_bh(&mrt_lock);
if (rtnl_dereference(mrt->mroute6_sk)) { if (rtnl_dereference(mrt->mroute_sk)) {
err = -EADDRINUSE; err = -EADDRINUSE;
} else { } else {
rcu_assign_pointer(mrt->mroute6_sk, sk); rcu_assign_pointer(mrt->mroute_sk, sk);
net->ipv6.devconf_all->mc_forwarding++; net->ipv6.devconf_all->mc_forwarding++;
} }
write_unlock_bh(&mrt_lock); write_unlock_bh(&mrt_lock);
...@@ -1634,7 +1610,7 @@ int ip6mr_sk_done(struct sock *sk) ...@@ -1634,7 +1610,7 @@ int ip6mr_sk_done(struct sock *sk)
{ {
int err = -EACCES; int err = -EACCES;
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
struct mr6_table *mrt; struct mr_table *mrt;
if (sk->sk_type != SOCK_RAW || if (sk->sk_type != SOCK_RAW ||
inet_sk(sk)->inet_num != IPPROTO_ICMPV6) inet_sk(sk)->inet_num != IPPROTO_ICMPV6)
...@@ -1642,9 +1618,9 @@ int ip6mr_sk_done(struct sock *sk) ...@@ -1642,9 +1618,9 @@ int ip6mr_sk_done(struct sock *sk)
rtnl_lock(); rtnl_lock();
ip6mr_for_each_table(mrt, net) { ip6mr_for_each_table(mrt, net) {
if (sk == rtnl_dereference(mrt->mroute6_sk)) { if (sk == rtnl_dereference(mrt->mroute_sk)) {
write_lock_bh(&mrt_lock); write_lock_bh(&mrt_lock);
RCU_INIT_POINTER(mrt->mroute6_sk, NULL); RCU_INIT_POINTER(mrt->mroute_sk, NULL);
net->ipv6.devconf_all->mc_forwarding--; net->ipv6.devconf_all->mc_forwarding--;
write_unlock_bh(&mrt_lock); write_unlock_bh(&mrt_lock);
inet6_netconf_notify_devconf(net, RTM_NEWNETCONF, inet6_netconf_notify_devconf(net, RTM_NEWNETCONF,
...@@ -1665,7 +1641,7 @@ int ip6mr_sk_done(struct sock *sk) ...@@ -1665,7 +1641,7 @@ int ip6mr_sk_done(struct sock *sk)
bool mroute6_is_socket(struct net *net, struct sk_buff *skb) bool mroute6_is_socket(struct net *net, struct sk_buff *skb)
{ {
struct mr6_table *mrt; struct mr_table *mrt;
struct flowi6 fl6 = { struct flowi6 fl6 = {
.flowi6_iif = skb->skb_iif ? : LOOPBACK_IFINDEX, .flowi6_iif = skb->skb_iif ? : LOOPBACK_IFINDEX,
.flowi6_oif = skb->dev->ifindex, .flowi6_oif = skb->dev->ifindex,
...@@ -1675,7 +1651,7 @@ bool mroute6_is_socket(struct net *net, struct sk_buff *skb) ...@@ -1675,7 +1651,7 @@ bool mroute6_is_socket(struct net *net, struct sk_buff *skb)
if (ip6mr_fib_lookup(net, &fl6, &mrt) < 0) if (ip6mr_fib_lookup(net, &fl6, &mrt) < 0)
return NULL; return NULL;
return rcu_access_pointer(mrt->mroute6_sk); return rcu_access_pointer(mrt->mroute_sk);
} }
EXPORT_SYMBOL(mroute6_is_socket); EXPORT_SYMBOL(mroute6_is_socket);
...@@ -1693,7 +1669,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns ...@@ -1693,7 +1669,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns
struct mf6cctl mfc; struct mf6cctl mfc;
mifi_t mifi; mifi_t mifi;
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
struct mr6_table *mrt; struct mr_table *mrt;
if (sk->sk_type != SOCK_RAW || if (sk->sk_type != SOCK_RAW ||
inet_sk(sk)->inet_num != IPPROTO_ICMPV6) inet_sk(sk)->inet_num != IPPROTO_ICMPV6)
...@@ -1704,7 +1680,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns ...@@ -1704,7 +1680,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns
return -ENOENT; return -ENOENT;
if (optname != MRT6_INIT) { if (optname != MRT6_INIT) {
if (sk != rcu_access_pointer(mrt->mroute6_sk) && if (sk != rcu_access_pointer(mrt->mroute_sk) &&
!ns_capable(net->user_ns, CAP_NET_ADMIN)) !ns_capable(net->user_ns, CAP_NET_ADMIN))
return -EACCES; return -EACCES;
} }
...@@ -1728,7 +1704,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns ...@@ -1728,7 +1704,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns
return -ENFILE; return -ENFILE;
rtnl_lock(); rtnl_lock();
ret = mif6_add(net, mrt, &vif, ret = mif6_add(net, mrt, &vif,
sk == rtnl_dereference(mrt->mroute6_sk)); sk == rtnl_dereference(mrt->mroute_sk));
rtnl_unlock(); rtnl_unlock();
return ret; return ret;
...@@ -1764,7 +1740,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns ...@@ -1764,7 +1740,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns
else else
ret = ip6mr_mfc_add(net, mrt, &mfc, ret = ip6mr_mfc_add(net, mrt, &mfc,
sk == sk ==
rtnl_dereference(mrt->mroute6_sk), rtnl_dereference(mrt->mroute_sk),
parent); parent);
rtnl_unlock(); rtnl_unlock();
return ret; return ret;
...@@ -1817,7 +1793,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns ...@@ -1817,7 +1793,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns
/* "pim6reg%u" should not exceed 16 bytes (IFNAMSIZ) */ /* "pim6reg%u" should not exceed 16 bytes (IFNAMSIZ) */
if (v != RT_TABLE_DEFAULT && v >= 100000000) if (v != RT_TABLE_DEFAULT && v >= 100000000)
return -EINVAL; return -EINVAL;
if (sk == rcu_access_pointer(mrt->mroute6_sk)) if (sk == rcu_access_pointer(mrt->mroute_sk))
return -EBUSY; return -EBUSY;
rtnl_lock(); rtnl_lock();
...@@ -1848,7 +1824,7 @@ int ip6_mroute_getsockopt(struct sock *sk, int optname, char __user *optval, ...@@ -1848,7 +1824,7 @@ int ip6_mroute_getsockopt(struct sock *sk, int optname, char __user *optval,
int olr; int olr;
int val; int val;
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
struct mr6_table *mrt; struct mr_table *mrt;
if (sk->sk_type != SOCK_RAW || if (sk->sk_type != SOCK_RAW ||
inet_sk(sk)->inet_num != IPPROTO_ICMPV6) inet_sk(sk)->inet_num != IPPROTO_ICMPV6)
...@@ -1899,7 +1875,7 @@ int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg) ...@@ -1899,7 +1875,7 @@ int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg)
struct vif_device *vif; struct vif_device *vif;
struct mfc6_cache *c; struct mfc6_cache *c;
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
struct mr6_table *mrt; struct mr_table *mrt;
mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT);
if (!mrt) if (!mrt)
...@@ -1912,8 +1888,8 @@ int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg) ...@@ -1912,8 +1888,8 @@ int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg)
if (vr.mifi >= mrt->maxvif) if (vr.mifi >= mrt->maxvif)
return -EINVAL; return -EINVAL;
read_lock(&mrt_lock); read_lock(&mrt_lock);
vif = &mrt->vif6_table[vr.mifi]; vif = &mrt->vif_table[vr.mifi];
if (MIF_EXISTS(mrt, vr.mifi)) { if (VIF_EXISTS(mrt, vr.mifi)) {
vr.icount = vif->pkt_in; vr.icount = vif->pkt_in;
vr.ocount = vif->pkt_out; vr.ocount = vif->pkt_out;
vr.ibytes = vif->bytes_in; vr.ibytes = vif->bytes_in;
...@@ -1973,7 +1949,7 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg) ...@@ -1973,7 +1949,7 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg)
struct vif_device *vif; struct vif_device *vif;
struct mfc6_cache *c; struct mfc6_cache *c;
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
struct mr6_table *mrt; struct mr_table *mrt;
mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT);
if (!mrt) if (!mrt)
...@@ -1986,8 +1962,8 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg) ...@@ -1986,8 +1962,8 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg)
if (vr.mifi >= mrt->maxvif) if (vr.mifi >= mrt->maxvif)
return -EINVAL; return -EINVAL;
read_lock(&mrt_lock); read_lock(&mrt_lock);
vif = &mrt->vif6_table[vr.mifi]; vif = &mrt->vif_table[vr.mifi];
if (MIF_EXISTS(mrt, vr.mifi)) { if (VIF_EXISTS(mrt, vr.mifi)) {
vr.icount = vif->pkt_in; vr.icount = vif->pkt_in;
vr.ocount = vif->pkt_out; vr.ocount = vif->pkt_out;
vr.ibytes = vif->bytes_in; vr.ibytes = vif->bytes_in;
...@@ -2037,11 +2013,11 @@ static inline int ip6mr_forward2_finish(struct net *net, struct sock *sk, struct ...@@ -2037,11 +2013,11 @@ static inline int ip6mr_forward2_finish(struct net *net, struct sock *sk, struct
* Processing handlers for ip6mr_forward * Processing handlers for ip6mr_forward
*/ */
static int ip6mr_forward2(struct net *net, struct mr6_table *mrt, static int ip6mr_forward2(struct net *net, struct mr_table *mrt,
struct sk_buff *skb, struct mfc6_cache *c, int vifi) struct sk_buff *skb, struct mfc6_cache *c, int vifi)
{ {
struct ipv6hdr *ipv6h; struct ipv6hdr *ipv6h;
struct vif_device *vif = &mrt->vif6_table[vifi]; struct vif_device *vif = &mrt->vif_table[vifi];
struct net_device *dev; struct net_device *dev;
struct dst_entry *dst; struct dst_entry *dst;
struct flowi6 fl6; struct flowi6 fl6;
...@@ -2111,18 +2087,18 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt, ...@@ -2111,18 +2087,18 @@ static int ip6mr_forward2(struct net *net, struct mr6_table *mrt,
return 0; return 0;
} }
static int ip6mr_find_vif(struct mr6_table *mrt, struct net_device *dev) static int ip6mr_find_vif(struct mr_table *mrt, struct net_device *dev)
{ {
int ct; int ct;
for (ct = mrt->maxvif - 1; ct >= 0; ct--) { for (ct = mrt->maxvif - 1; ct >= 0; ct--) {
if (mrt->vif6_table[ct].dev == dev) if (mrt->vif_table[ct].dev == dev)
break; break;
} }
return ct; return ct;
} }
static void ip6_mr_forward(struct net *net, struct mr6_table *mrt, static void ip6_mr_forward(struct net *net, struct mr_table *mrt,
struct sk_buff *skb, struct mfc6_cache *cache) struct sk_buff *skb, struct mfc6_cache *cache)
{ {
int psend = -1; int psend = -1;
...@@ -2153,7 +2129,7 @@ static void ip6_mr_forward(struct net *net, struct mr6_table *mrt, ...@@ -2153,7 +2129,7 @@ static void ip6_mr_forward(struct net *net, struct mr6_table *mrt,
/* /*
* Wrong interface: drop packet and (maybe) send PIM assert. * Wrong interface: drop packet and (maybe) send PIM assert.
*/ */
if (mrt->vif6_table[vif].dev != skb->dev) { if (mrt->vif_table[vif].dev != skb->dev) {
cache->mfc_un.res.wrong_if++; cache->mfc_un.res.wrong_if++;
if (true_vifi >= 0 && mrt->mroute_do_assert && if (true_vifi >= 0 && mrt->mroute_do_assert &&
...@@ -2173,8 +2149,8 @@ static void ip6_mr_forward(struct net *net, struct mr6_table *mrt, ...@@ -2173,8 +2149,8 @@ static void ip6_mr_forward(struct net *net, struct mr6_table *mrt,
} }
forward: forward:
mrt->vif6_table[vif].pkt_in++; mrt->vif_table[vif].pkt_in++;
mrt->vif6_table[vif].bytes_in += skb->len; mrt->vif_table[vif].bytes_in += skb->len;
/* /*
* Forward the frame * Forward the frame
...@@ -2225,7 +2201,7 @@ int ip6_mr_input(struct sk_buff *skb) ...@@ -2225,7 +2201,7 @@ int ip6_mr_input(struct sk_buff *skb)
{ {
struct mfc6_cache *cache; struct mfc6_cache *cache;
struct net *net = dev_net(skb->dev); struct net *net = dev_net(skb->dev);
struct mr6_table *mrt; struct mr_table *mrt;
struct flowi6 fl6 = { struct flowi6 fl6 = {
.flowi6_iif = skb->dev->ifindex, .flowi6_iif = skb->dev->ifindex,
.flowi6_mark = skb->mark, .flowi6_mark = skb->mark,
...@@ -2276,7 +2252,7 @@ int ip6_mr_input(struct sk_buff *skb) ...@@ -2276,7 +2252,7 @@ int ip6_mr_input(struct sk_buff *skb)
} }
static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, static int __ip6mr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb,
struct mfc6_cache *c, struct rtmsg *rtm) struct mfc6_cache *c, struct rtmsg *rtm)
{ {
struct rta_mfc_stats mfcs; struct rta_mfc_stats mfcs;
...@@ -2291,15 +2267,16 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, ...@@ -2291,15 +2267,16 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb,
return -ENOENT; return -ENOENT;
} }
if (MIF_EXISTS(mrt, c->mf6c_parent) && if (VIF_EXISTS(mrt, c->mf6c_parent) &&
nla_put_u32(skb, RTA_IIF, mrt->vif6_table[c->mf6c_parent].dev->ifindex) < 0) nla_put_u32(skb, RTA_IIF,
mrt->vif_table[c->mf6c_parent].dev->ifindex) < 0)
return -EMSGSIZE; return -EMSGSIZE;
mp_attr = nla_nest_start(skb, RTA_MULTIPATH); mp_attr = nla_nest_start(skb, RTA_MULTIPATH);
if (!mp_attr) if (!mp_attr)
return -EMSGSIZE; return -EMSGSIZE;
for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) { for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) {
if (MIF_EXISTS(mrt, ct) && c->mfc_un.res.ttls[ct] < 255) { if (VIF_EXISTS(mrt, ct) && c->mfc_un.res.ttls[ct] < 255) {
nhp = nla_reserve_nohdr(skb, sizeof(*nhp)); nhp = nla_reserve_nohdr(skb, sizeof(*nhp));
if (!nhp) { if (!nhp) {
nla_nest_cancel(skb, mp_attr); nla_nest_cancel(skb, mp_attr);
...@@ -2308,7 +2285,7 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, ...@@ -2308,7 +2285,7 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb,
nhp->rtnh_flags = 0; nhp->rtnh_flags = 0;
nhp->rtnh_hops = c->mfc_un.res.ttls[ct]; nhp->rtnh_hops = c->mfc_un.res.ttls[ct];
nhp->rtnh_ifindex = mrt->vif6_table[ct].dev->ifindex; nhp->rtnh_ifindex = mrt->vif_table[ct].dev->ifindex;
nhp->rtnh_len = sizeof(*nhp); nhp->rtnh_len = sizeof(*nhp);
} }
} }
...@@ -2334,7 +2311,7 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm, ...@@ -2334,7 +2311,7 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm,
u32 portid) u32 portid)
{ {
int err; int err;
struct mr6_table *mrt; struct mr_table *mrt;
struct mfc6_cache *cache; struct mfc6_cache *cache;
struct rt6_info *rt = (struct rt6_info *)skb_dst(skb); struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
...@@ -2403,7 +2380,7 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm, ...@@ -2403,7 +2380,7 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm,
return err; return err;
} }
static int ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, static int ip6mr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb,
u32 portid, u32 seq, struct mfc6_cache *c, int cmd, u32 portid, u32 seq, struct mfc6_cache *c, int cmd,
int flags) int flags)
{ {
...@@ -2468,7 +2445,7 @@ static int mr6_msgsize(bool unresolved, int maxvif) ...@@ -2468,7 +2445,7 @@ static int mr6_msgsize(bool unresolved, int maxvif)
return len; return len;
} }
static void mr6_netlink_event(struct mr6_table *mrt, struct mfc6_cache *mfc, static void mr6_netlink_event(struct mr_table *mrt, struct mfc6_cache *mfc,
int cmd) int cmd)
{ {
struct net *net = read_pnet(&mrt->net); struct net *net = read_pnet(&mrt->net);
...@@ -2510,7 +2487,7 @@ static size_t mrt6msg_netlink_msgsize(size_t payloadlen) ...@@ -2510,7 +2487,7 @@ static size_t mrt6msg_netlink_msgsize(size_t payloadlen)
return len; return len;
} }
static void mrt6msg_netlink_event(struct mr6_table *mrt, struct sk_buff *pkt) static void mrt6msg_netlink_event(struct mr_table *mrt, struct sk_buff *pkt)
{ {
struct net *net = read_pnet(&mrt->net); struct net *net = read_pnet(&mrt->net);
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
...@@ -2561,7 +2538,7 @@ static void mrt6msg_netlink_event(struct mr6_table *mrt, struct sk_buff *pkt) ...@@ -2561,7 +2538,7 @@ static void mrt6msg_netlink_event(struct mr6_table *mrt, struct sk_buff *pkt)
static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb) static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)
{ {
struct net *net = sock_net(skb->sk); struct net *net = sock_net(skb->sk);
struct mr6_table *mrt; struct mr_table *mrt;
struct mfc6_cache *mfc; struct mfc6_cache *mfc;
unsigned int t = 0, s_t; unsigned int t = 0, s_t;
unsigned int e = 0, s_e; unsigned int e = 0, s_e;
...@@ -2573,7 +2550,7 @@ static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -2573,7 +2550,7 @@ static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)
ip6mr_for_each_table(mrt, net) { ip6mr_for_each_table(mrt, net) {
if (t < s_t) if (t < s_t)
goto next_table; goto next_table;
list_for_each_entry_rcu(mfc, &mrt->mfc6_cache_list, list) { list_for_each_entry_rcu(mfc, &mrt->mfc_cache_list, list) {
if (e < s_e) if (e < s_e)
goto next_entry; goto next_entry;
if (ip6mr_fill_mroute(mrt, skb, if (ip6mr_fill_mroute(mrt, skb,
...@@ -2589,7 +2566,7 @@ static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -2589,7 +2566,7 @@ static int ip6mr_rtm_dumproute(struct sk_buff *skb, struct netlink_callback *cb)
s_e = 0; s_e = 0;
spin_lock_bh(&mfc_unres_lock); spin_lock_bh(&mfc_unres_lock);
list_for_each_entry(mfc, &mrt->mfc6_unres_queue, list) { list_for_each_entry(mfc, &mrt->mfc_unres_queue, list) {
if (e < s_e) if (e < s_e)
goto next_entry2; goto next_entry2;
if (ip6mr_fill_mroute(mrt, skb, if (ip6mr_fill_mroute(mrt, skb,
......
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