Commit 950d5704 authored by Benjamin Thery's avatar Benjamin Thery Committed by David S. Miller

netns: ip6mr: declare reg_vif_num per-namespace

Preliminary work to make IPv6 multicast forwarding netns-aware.

Declare variable 'reg_vif_num' per-namespace, moves into struct netns_ipv6.

At the moment, this variable is only referenced in init_net.
Signed-off-by: default avatarBenjamin Thery <benjamin.thery@bull.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a21f3f99
...@@ -63,6 +63,9 @@ struct netns_ipv6 { ...@@ -63,6 +63,9 @@ struct netns_ipv6 {
atomic_t cache_resolve_queue_len; atomic_t cache_resolve_queue_len;
int mroute_do_assert; int mroute_do_assert;
int mroute_do_pim; int mroute_do_pim;
#ifdef CONFIG_IPV6_PIMSM_V2
int mroute_reg_vif_num;
#endif
#endif #endif
}; };
#endif #endif
...@@ -333,13 +333,13 @@ static struct file_operations ip6mr_mfc_fops = { ...@@ -333,13 +333,13 @@ static struct file_operations ip6mr_mfc_fops = {
#endif #endif
#ifdef CONFIG_IPV6_PIMSM_V2 #ifdef CONFIG_IPV6_PIMSM_V2
static int reg_vif_num = -1;
static int pim6_rcv(struct sk_buff *skb) static int pim6_rcv(struct sk_buff *skb)
{ {
struct pimreghdr *pim; struct pimreghdr *pim;
struct ipv6hdr *encap; struct ipv6hdr *encap;
struct net_device *reg_dev = NULL; struct net_device *reg_dev = NULL;
int reg_vif_num = init_net.ipv6.mroute_reg_vif_num;
if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap)))
goto drop; goto drop;
...@@ -401,7 +401,7 @@ static int reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -401,7 +401,7 @@ static int reg_vif_xmit(struct sk_buff *skb, struct net_device *dev)
read_lock(&mrt_lock); read_lock(&mrt_lock);
dev->stats.tx_bytes += skb->len; dev->stats.tx_bytes += skb->len;
dev->stats.tx_packets++; dev->stats.tx_packets++;
ip6mr_cache_report(skb, reg_vif_num, MRT6MSG_WHOLEPKT); ip6mr_cache_report(skb, init_net.ipv6.mroute_reg_vif_num, MRT6MSG_WHOLEPKT);
read_unlock(&mrt_lock); read_unlock(&mrt_lock);
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
...@@ -473,8 +473,8 @@ static int mif6_delete(int vifi) ...@@ -473,8 +473,8 @@ static int mif6_delete(int vifi)
} }
#ifdef CONFIG_IPV6_PIMSM_V2 #ifdef CONFIG_IPV6_PIMSM_V2
if (vifi == reg_vif_num) if (vifi == init_net.ipv6.mroute_reg_vif_num)
reg_vif_num = -1; init_net.ipv6.mroute_reg_vif_num = -1;
#endif #endif
if (vifi + 1 == init_net.ipv6.maxvif) { if (vifi + 1 == init_net.ipv6.maxvif) {
...@@ -610,7 +610,7 @@ static int mif6_add(struct mif6ctl *vifc, int mrtsock) ...@@ -610,7 +610,7 @@ static int mif6_add(struct mif6ctl *vifc, int mrtsock)
* Special Purpose VIF in PIM * Special Purpose VIF in PIM
* All the packets will be sent to the daemon * All the packets will be sent to the daemon
*/ */
if (reg_vif_num >= 0) if (init_net.ipv6.mroute_reg_vif_num >= 0)
return -EADDRINUSE; return -EADDRINUSE;
dev = ip6mr_reg_vif(); dev = ip6mr_reg_vif();
if (!dev) if (!dev)
...@@ -658,7 +658,7 @@ static int mif6_add(struct mif6ctl *vifc, int mrtsock) ...@@ -658,7 +658,7 @@ static int mif6_add(struct mif6ctl *vifc, int mrtsock)
v->dev = dev; v->dev = dev;
#ifdef CONFIG_IPV6_PIMSM_V2 #ifdef CONFIG_IPV6_PIMSM_V2
if (v->flags & MIFF_REGISTER) if (v->flags & MIFF_REGISTER)
reg_vif_num = vifi; init_net.ipv6.mroute_reg_vif_num = vifi;
#endif #endif
if (vifi + 1 > init_net.ipv6.maxvif) if (vifi + 1 > init_net.ipv6.maxvif)
init_net.ipv6.maxvif = vifi + 1; init_net.ipv6.maxvif = vifi + 1;
...@@ -777,7 +777,7 @@ static int ip6mr_cache_report(struct sk_buff *pkt, mifi_t mifi, int assert) ...@@ -777,7 +777,7 @@ static int ip6mr_cache_report(struct sk_buff *pkt, mifi_t mifi, int assert)
msg = (struct mrt6msg *)skb_transport_header(skb); msg = (struct mrt6msg *)skb_transport_header(skb);
msg->im6_mbz = 0; msg->im6_mbz = 0;
msg->im6_msgtype = MRT6MSG_WHOLEPKT; msg->im6_msgtype = MRT6MSG_WHOLEPKT;
msg->im6_mif = reg_vif_num; msg->im6_mif = init_net.ipv6.mroute_reg_vif_num;
msg->im6_pad = 0; msg->im6_pad = 0;
ipv6_addr_copy(&msg->im6_src, &ipv6_hdr(pkt)->saddr); ipv6_addr_copy(&msg->im6_src, &ipv6_hdr(pkt)->saddr);
ipv6_addr_copy(&msg->im6_dst, &ipv6_hdr(pkt)->daddr); ipv6_addr_copy(&msg->im6_dst, &ipv6_hdr(pkt)->daddr);
...@@ -964,7 +964,6 @@ static struct notifier_block ip6_mr_notifier = { ...@@ -964,7 +964,6 @@ static struct notifier_block ip6_mr_notifier = {
static int __net_init ip6mr_net_init(struct net *net) static int __net_init ip6mr_net_init(struct net *net)
{ {
int err = 0; int err = 0;
net->ipv6.vif6_table = kcalloc(MAXMIFS, sizeof(struct mif_device), net->ipv6.vif6_table = kcalloc(MAXMIFS, sizeof(struct mif_device),
GFP_KERNEL); GFP_KERNEL);
if (!net->ipv6.vif6_table) { if (!net->ipv6.vif6_table) {
...@@ -980,6 +979,10 @@ static int __net_init ip6mr_net_init(struct net *net) ...@@ -980,6 +979,10 @@ static int __net_init ip6mr_net_init(struct net *net)
err = -ENOMEM; err = -ENOMEM;
goto fail_mfc6_cache; goto fail_mfc6_cache;
} }
#ifdef CONFIG_IPV6_PIMSM_V2
net->ipv6.mroute_reg_vif_num = -1;
#endif
return 0; return 0;
fail_mfc6_cache: fail_mfc6_cache:
......
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