[IPV4] net/core: Use ipv4_is_<type>
[deliverable/linux.git] / net / ipv4 / igmp.c
index f4dd47453108e5041dd4394308d64567522ec1ac..d3d5906e1b3d9ca5ca9408a6957d7749884e8815 100644 (file)
@@ -91,6 +91,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/times.h>
 
+#include <net/net_namespace.h>
 #include <net/arp.h>
 #include <net/ip.h>
 #include <net/protocol.h>
  * contradict to specs provided this delay is small enough.
  */
 
-#define IGMP_V1_SEEN(in_dev) (ipv4_devconf.force_igmp_version == 1 || \
-               (in_dev)->cnf.force_igmp_version == 1 || \
-               ((in_dev)->mr_v1_seen && \
-               time_before(jiffies, (in_dev)->mr_v1_seen)))
-#define IGMP_V2_SEEN(in_dev) (ipv4_devconf.force_igmp_version == 2 || \
-               (in_dev)->cnf.force_igmp_version == 2 || \
-               ((in_dev)->mr_v2_seen && \
-               time_before(jiffies, (in_dev)->mr_v2_seen)))
+#define IGMP_V1_SEEN(in_dev) \
+       (IPV4_DEVCONF_ALL(in_dev->dev->nd_net, FORCE_IGMP_VERSION) == 1 || \
+        IN_DEV_CONF_GET((in_dev), FORCE_IGMP_VERSION) == 1 || \
+        ((in_dev)->mr_v1_seen && \
+         time_before(jiffies, (in_dev)->mr_v1_seen)))
+#define IGMP_V2_SEEN(in_dev) \
+       (IPV4_DEVCONF_ALL(in_dev->dev->nd_net, FORCE_IGMP_VERSION) == 2 || \
+        IN_DEV_CONF_GET((in_dev), FORCE_IGMP_VERSION) == 2 || \
+        ((in_dev)->mr_v2_seen && \
+         time_before(jiffies, (in_dev)->mr_v2_seen)))
 
 static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im);
 static void igmpv3_del_delrec(struct in_device *in_dev, __be32 multiaddr);
@@ -346,17 +349,12 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
 
 static int igmpv3_sendpack(struct sk_buff *skb)
 {
-       struct iphdr *pip = ip_hdr(skb);
        struct igmphdr *pig = igmp_hdr(skb);
-       const int iplen = skb->tail - skb->network_header;
        const int igmplen = skb->tail - skb->transport_header;
 
-       pip->tot_len = htons(iplen);
-       ip_send_check(pip);
        pig->csum = ip_compute_csum(igmp_hdr(skb), igmplen);
 
-       return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dev,
-                      dst_output);
+       return ip_local_out(skb);
 }
 
 static int grec_size(struct ip_mc_list *pmc, int type, int gdel, int sdel)
@@ -677,13 +675,11 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
        iph->daddr    = dst;
        iph->saddr    = rt->rt_src;
        iph->protocol = IPPROTO_IGMP;
-       iph->tot_len  = htons(IGMP_SIZE);
        ip_select_ident(iph, &rt->u.dst, NULL);
        ((u8*)&iph[1])[0] = IPOPT_RA;
        ((u8*)&iph[1])[1] = 4;
        ((u8*)&iph[1])[2] = 0;
        ((u8*)&iph[1])[3] = 0;
-       ip_send_check(iph);
 
        ih = (struct igmphdr *)skb_put(skb, sizeof(struct igmphdr));
        ih->type=type;
@@ -692,8 +688,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
        ih->group=group;
        ih->csum=ip_compute_csum((void *)ih, sizeof(struct igmphdr));
 
-       return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
-                      dst_output);
+       return ip_local_out(skb);
 }
 
 static void igmp_gq_timer_expire(unsigned long data)
@@ -1231,9 +1226,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
        spin_lock_init(&im->lock);
 #ifdef CONFIG_IP_MULTICAST
        im->tm_running=0;
-       init_timer(&im->timer);
-       im->timer.data=(unsigned long)im;
-       im->timer.function=&igmp_timer_expire;
+       setup_timer(&im->timer, &igmp_timer_expire, (unsigned long)im);
        im->unsolicit_count = IGMP_Unsolicited_Report_Count;
        im->reporter = 0;
        im->gsquery = 0;
@@ -1335,13 +1328,11 @@ void ip_mc_init_dev(struct in_device *in_dev)
        in_dev->mc_tomb = NULL;
 #ifdef CONFIG_IP_MULTICAST
        in_dev->mr_gq_running = 0;
-       init_timer(&in_dev->mr_gq_timer);
-       in_dev->mr_gq_timer.data=(unsigned long) in_dev;
-       in_dev->mr_gq_timer.function=&igmp_gq_timer_expire;
+       setup_timer(&in_dev->mr_gq_timer, igmp_gq_timer_expire,
+                       (unsigned long)in_dev);
        in_dev->mr_ifc_count = 0;
-       init_timer(&in_dev->mr_ifc_timer);
-       in_dev->mr_ifc_timer.data=(unsigned long) in_dev;
-       in_dev->mr_ifc_timer.function=&igmp_ifc_timer_expire;
+       setup_timer(&in_dev->mr_ifc_timer, igmp_ifc_timer_expire,
+                       (unsigned long)in_dev);
        in_dev->mr_qrv = IGMP_Unsolicited_Report_Count;
 #endif
 
@@ -1692,8 +1683,8 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
                        (void) ip_mc_del1_src(pmc, sfmode, &psfsrc[i]);
        } else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) {
 #ifdef CONFIG_IP_MULTICAST
-               struct in_device *in_dev = pmc->interface;
                struct ip_sf_list *psf;
+               in_dev = pmc->interface;
 #endif
 
                /* filter mode change */
@@ -1796,7 +1787,7 @@ static int ip_mc_leave_src(struct sock *sk, struct ip_mc_socklist *iml,
 {
        int err;
 
-       if (iml->sflist == 0) {
+       if (iml->sflist == NULL) {
                /* any-source empty exclude case */
                return ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr,
                        iml->sfmode, 0, NULL, 0);
@@ -2164,7 +2155,6 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
                return -EFAULT;
        }
        for (i=0; i<copycount; i++) {
-               struct sockaddr_in *psin;
                struct sockaddr_storage ss;
 
                psin = (struct sockaddr_in *)&ss;
@@ -2289,7 +2279,7 @@ static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq)
        struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
 
        state->in_dev = NULL;
-       for_each_netdev(state->dev) {
+       for_each_netdev(&init_net, state->dev) {
                struct in_device *in_dev;
                in_dev = in_dev_get(state->dev);
                if (!in_dev)
@@ -2408,23 +2398,8 @@ static const struct seq_operations igmp_mc_seq_ops = {
 
 static int igmp_mc_seq_open(struct inode *inode, struct file *file)
 {
-       struct seq_file *seq;
-       int rc = -ENOMEM;
-       struct igmp_mc_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
-
-       if (!s)
-               goto out;
-       rc = seq_open(file, &igmp_mc_seq_ops);
-       if (rc)
-               goto out_kfree;
-
-       seq = file->private_data;
-       seq->private = s;
-out:
-       return rc;
-out_kfree:
-       kfree(s);
-       goto out;
+       return seq_open_private(file, &igmp_mc_seq_ops,
+                       sizeof(struct igmp_mc_iter_state));
 }
 
 static const struct file_operations igmp_mc_seq_fops = {
@@ -2451,7 +2426,7 @@ static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq)
 
        state->idev = NULL;
        state->im = NULL;
-       for_each_netdev(state->dev) {
+       for_each_netdev(&init_net, state->dev) {
                struct in_device *idev;
                idev = in_dev_get(state->dev);
                if (unlikely(idev == NULL))
@@ -2582,23 +2557,8 @@ static const struct seq_operations igmp_mcf_seq_ops = {
 
 static int igmp_mcf_seq_open(struct inode *inode, struct file *file)
 {
-       struct seq_file *seq;
-       int rc = -ENOMEM;
-       struct igmp_mcf_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
-
-       if (!s)
-               goto out;
-       rc = seq_open(file, &igmp_mcf_seq_ops);
-       if (rc)
-               goto out_kfree;
-
-       seq = file->private_data;
-       seq->private = s;
-out:
-       return rc;
-out_kfree:
-       kfree(s);
-       goto out;
+       return seq_open_private(file, &igmp_mcf_seq_ops,
+                       sizeof(struct igmp_mcf_iter_state));
 }
 
 static const struct file_operations igmp_mcf_seq_fops = {
@@ -2611,8 +2571,8 @@ static const struct file_operations igmp_mcf_seq_fops = {
 
 int __init igmp_mc_proc_init(void)
 {
-       proc_net_fops_create("igmp", S_IRUGO, &igmp_mc_seq_fops);
-       proc_net_fops_create("mcfilter", S_IRUGO, &igmp_mcf_seq_fops);
+       proc_net_fops_create(&init_net, "igmp", S_IRUGO, &igmp_mc_seq_fops);
+       proc_net_fops_create(&init_net, "mcfilter", S_IRUGO, &igmp_mcf_seq_fops);
        return 0;
 }
 #endif
This page took 0.0269740000000001 seconds and 5 git commands to generate.