You need to sign in or sign up before continuing.
提交 6c5143db 编写于 作者: B Benjamin Thery 提交者: David S. Miller

netns: ipmr: declare reg_vif_num per-namespace

Preliminary work to make IPv4 multicast routing netns-aware.

Declare variable 'reg_vif_num' per-namespace, move into struct netns_ipv4.

At the moment, this variable is only referenced in init_net.
Signed-off-by: NBenjamin Thery <benjamin.thery@bull.net>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6f9374a9
...@@ -63,6 +63,9 @@ struct netns_ipv4 { ...@@ -63,6 +63,9 @@ struct netns_ipv4 {
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;
#if defined(CONFIG_IP_PIMSM_V1) || defined(CONFIG_IP_PIMSM_V2)
int mroute_reg_vif_num;
#endif
#endif #endif
}; };
#endif #endif
...@@ -197,14 +197,12 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v) ...@@ -197,14 +197,12 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v)
#ifdef CONFIG_IP_PIMSM #ifdef CONFIG_IP_PIMSM
static int reg_vif_num = -1;
static int reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) 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++;
ipmr_cache_report(skb, reg_vif_num, IGMPMSG_WHOLEPKT); ipmr_cache_report(skb, init_net.ipv4.mroute_reg_vif_num, IGMPMSG_WHOLEPKT);
read_unlock(&mrt_lock); read_unlock(&mrt_lock);
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
...@@ -292,8 +290,8 @@ static int vif_delete(int vifi, int notify) ...@@ -292,8 +290,8 @@ static int vif_delete(int vifi, int notify)
} }
#ifdef CONFIG_IP_PIMSM #ifdef CONFIG_IP_PIMSM
if (vifi == reg_vif_num) if (vifi == init_net.ipv4.mroute_reg_vif_num)
reg_vif_num = -1; init_net.ipv4.mroute_reg_vif_num = -1;
#endif #endif
if (vifi+1 == init_net.ipv4.maxvif) { if (vifi+1 == init_net.ipv4.maxvif) {
...@@ -439,7 +437,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock) ...@@ -439,7 +437,7 @@ static int vif_add(struct vifctl *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.ipv4.mroute_reg_vif_num >= 0)
return -EADDRINUSE; return -EADDRINUSE;
dev = ipmr_reg_vif(); dev = ipmr_reg_vif();
if (!dev) if (!dev)
...@@ -505,7 +503,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock) ...@@ -505,7 +503,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock)
v->dev = dev; v->dev = dev;
#ifdef CONFIG_IP_PIMSM #ifdef CONFIG_IP_PIMSM
if (v->flags&VIFF_REGISTER) if (v->flags&VIFF_REGISTER)
reg_vif_num = vifi; init_net.ipv4.mroute_reg_vif_num = vifi;
#endif #endif
if (vifi+1 > init_net.ipv4.maxvif) if (vifi+1 > init_net.ipv4.maxvif)
init_net.ipv4.maxvif = vifi+1; init_net.ipv4.maxvif = vifi+1;
...@@ -623,7 +621,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) ...@@ -623,7 +621,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
memcpy(msg, skb_network_header(pkt), sizeof(struct iphdr)); memcpy(msg, skb_network_header(pkt), sizeof(struct iphdr));
msg->im_msgtype = IGMPMSG_WHOLEPKT; msg->im_msgtype = IGMPMSG_WHOLEPKT;
msg->im_mbz = 0; msg->im_mbz = 0;
msg->im_vif = reg_vif_num; msg->im_vif = init_net.ipv4.mroute_reg_vif_num;
ip_hdr(skb)->ihl = sizeof(struct iphdr) >> 2; ip_hdr(skb)->ihl = sizeof(struct iphdr) >> 2;
ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(pkt)->tot_len) + ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(pkt)->tot_len) +
sizeof(struct iphdr)); sizeof(struct iphdr));
...@@ -1506,8 +1504,8 @@ static int __pim_rcv(struct sk_buff *skb, unsigned int pimlen) ...@@ -1506,8 +1504,8 @@ static int __pim_rcv(struct sk_buff *skb, unsigned int pimlen)
return 1; return 1;
read_lock(&mrt_lock); read_lock(&mrt_lock);
if (reg_vif_num >= 0) if (init_net.ipv4.mroute_reg_vif_num >= 0)
reg_dev = init_net.ipv4.vif_table[reg_vif_num].dev; reg_dev = init_net.ipv4.vif_table[init_net.ipv4.mroute_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);
...@@ -1940,6 +1938,10 @@ static int __net_init ipmr_net_init(struct net *net) ...@@ -1940,6 +1938,10 @@ static int __net_init ipmr_net_init(struct net *net)
err = -ENOMEM; err = -ENOMEM;
goto fail_mfc_cache; goto fail_mfc_cache;
} }
#ifdef CONFIG_IP_PIMSM
net->ipv4.mroute_reg_vif_num = -1;
#endif
return 0; return 0;
fail_mfc_cache: fail_mfc_cache:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册