aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ipmr.c
diff options
context:
space:
mode:
authorBenjamin Thery <benjamin.thery@bull.net>2009-01-21 23:56:21 -0500
committerDavid S. Miller <davem@davemloft.net>2009-01-22 16:57:40 -0500
commit6c5143dbcfe50ac722965dc7d096abbeeec8bb33 (patch)
treeb9a78f7a700ec6a82ed05cd46e65f7c9ba2cbf60 /net/ipv4/ipmr.c
parent6f9374a9342e896c68df7cf7c0b039ab5cca994c (diff)
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: Benjamin Thery <benjamin.thery@bull.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ipmr.c')
-rw-r--r--net/ipv4/ipmr.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index d6a28acc0683..346e67b50d6c 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -197,14 +197,12 @@ failure:
197 197
198#ifdef CONFIG_IP_PIMSM 198#ifdef CONFIG_IP_PIMSM
199 199
200static int reg_vif_num = -1;
201
202static int reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) 200static int reg_vif_xmit(struct sk_buff *skb, struct net_device *dev)
203{ 201{
204 read_lock(&mrt_lock); 202 read_lock(&mrt_lock);
205 dev->stats.tx_bytes += skb->len; 203 dev->stats.tx_bytes += skb->len;
206 dev->stats.tx_packets++; 204 dev->stats.tx_packets++;
207 ipmr_cache_report(skb, reg_vif_num, IGMPMSG_WHOLEPKT); 205 ipmr_cache_report(skb, init_net.ipv4.mroute_reg_vif_num, IGMPMSG_WHOLEPKT);
208 read_unlock(&mrt_lock); 206 read_unlock(&mrt_lock);
209 kfree_skb(skb); 207 kfree_skb(skb);
210 return 0; 208 return 0;
@@ -292,8 +290,8 @@ static int vif_delete(int vifi, int notify)
292 } 290 }
293 291
294#ifdef CONFIG_IP_PIMSM 292#ifdef CONFIG_IP_PIMSM
295 if (vifi == reg_vif_num) 293 if (vifi == init_net.ipv4.mroute_reg_vif_num)
296 reg_vif_num = -1; 294 init_net.ipv4.mroute_reg_vif_num = -1;
297#endif 295#endif
298 296
299 if (vifi+1 == init_net.ipv4.maxvif) { 297 if (vifi+1 == init_net.ipv4.maxvif) {
@@ -439,7 +437,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock)
439 * Special Purpose VIF in PIM 437 * Special Purpose VIF in PIM
440 * All the packets will be sent to the daemon 438 * All the packets will be sent to the daemon
441 */ 439 */
442 if (reg_vif_num >= 0) 440 if (init_net.ipv4.mroute_reg_vif_num >= 0)
443 return -EADDRINUSE; 441 return -EADDRINUSE;
444 dev = ipmr_reg_vif(); 442 dev = ipmr_reg_vif();
445 if (!dev) 443 if (!dev)
@@ -505,7 +503,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock)
505 v->dev = dev; 503 v->dev = dev;
506#ifdef CONFIG_IP_PIMSM 504#ifdef CONFIG_IP_PIMSM
507 if (v->flags&VIFF_REGISTER) 505 if (v->flags&VIFF_REGISTER)
508 reg_vif_num = vifi; 506 init_net.ipv4.mroute_reg_vif_num = vifi;
509#endif 507#endif
510 if (vifi+1 > init_net.ipv4.maxvif) 508 if (vifi+1 > init_net.ipv4.maxvif)
511 init_net.ipv4.maxvif = vifi+1; 509 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 memcpy(msg, skb_network_header(pkt), sizeof(struct iphdr)); 621 memcpy(msg, skb_network_header(pkt), sizeof(struct iphdr));
624 msg->im_msgtype = IGMPMSG_WHOLEPKT; 622 msg->im_msgtype = IGMPMSG_WHOLEPKT;
625 msg->im_mbz = 0; 623 msg->im_mbz = 0;
626 msg->im_vif = reg_vif_num; 624 msg->im_vif = init_net.ipv4.mroute_reg_vif_num;
627 ip_hdr(skb)->ihl = sizeof(struct iphdr) >> 2; 625 ip_hdr(skb)->ihl = sizeof(struct iphdr) >> 2;
628 ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(pkt)->tot_len) + 626 ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(pkt)->tot_len) +
629 sizeof(struct iphdr)); 627 sizeof(struct iphdr));
@@ -1506,8 +1504,8 @@ static int __pim_rcv(struct sk_buff *skb, unsigned int pimlen)
1506 return 1; 1504 return 1;
1507 1505
1508 read_lock(&mrt_lock); 1506 read_lock(&mrt_lock);
1509 if (reg_vif_num >= 0) 1507 if (init_net.ipv4.mroute_reg_vif_num >= 0)
1510 reg_dev = init_net.ipv4.vif_table[reg_vif_num].dev; 1508 reg_dev = init_net.ipv4.vif_table[init_net.ipv4.mroute_reg_vif_num].dev;
1511 if (reg_dev) 1509 if (reg_dev)
1512 dev_hold(reg_dev); 1510 dev_hold(reg_dev);
1513 read_unlock(&mrt_lock); 1511 read_unlock(&mrt_lock);
@@ -1940,6 +1938,10 @@ static int __net_init ipmr_net_init(struct net *net)
1940 err = -ENOMEM; 1938 err = -ENOMEM;
1941 goto fail_mfc_cache; 1939 goto fail_mfc_cache;
1942 } 1940 }
1941
1942#ifdef CONFIG_IP_PIMSM
1943 net->ipv4.mroute_reg_vif_num = -1;
1944#endif
1943 return 0; 1945 return 0;
1944 1946
1945fail_mfc_cache: 1947fail_mfc_cache: