]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv4/arp.c
[NET]: Make core networking code use seq_open_private
[net-next-2.6.git] / net / ipv4 / arp.c
index 7110779a0244598b17518c46cc4784370198f3d0..36d6798947b59026eb400c6b06882099fddd8ba0 100644 (file)
 #include <linux/sysctl.h>
 #endif
 
+#include <net/net_namespace.h>
 #include <net/ip.h>
 #include <net/icmp.h>
 #include <net/route.h>
@@ -252,7 +253,7 @@ static int arp_constructor(struct neighbour *neigh)
        neigh->parms = neigh_parms_clone(parms);
        rcu_read_unlock();
 
-       if (dev->hard_header == NULL) {
+       if (!dev->header_ops) {
                neigh->nud_state = NUD_NOARP;
                neigh->ops = &arp_direct_ops;
                neigh->output = neigh->ops->queue_xmit;
@@ -309,10 +310,12 @@ static int arp_constructor(struct neighbour *neigh)
                        neigh->nud_state = NUD_NOARP;
                        memcpy(neigh->ha, dev->broadcast, dev->addr_len);
                }
-               if (dev->hard_header_cache)
+
+               if (dev->header_ops->cache)
                        neigh->ops = &arp_hh_ops;
                else
                        neigh->ops = &arp_generic_ops;
+
                if (neigh->nud_state&NUD_VALID)
                        neigh->output = neigh->ops->connected_output;
                else
@@ -590,8 +593,7 @@ struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
        /*
         *      Fill the device header for the ARP frame
         */
-       if (dev->hard_header &&
-           dev->hard_header(skb,dev,ptype,dest_hw,src_hw,skb->len) < 0)
+       if (dev_hard_header(skb, dev, ptype, dest_hw, src_hw, skb->len) < 0)
                goto out;
 
        /*
@@ -877,7 +879,7 @@ static int arp_process(struct sk_buff *skb)
 
        n = __neigh_lookup(&arp_tbl, &sip, dev, 0);
 
-       if (ipv4_devconf.arp_accept) {
+       if (IPV4_DEVCONF_ALL(ARP_ACCEPT)) {
                /* Unsolicited ARP is not accepted by default.
                   It is possible, that this option should be enabled for some
                   devices (strip is candidate)
@@ -885,7 +887,7 @@ static int arp_process(struct sk_buff *skb)
                if (n == NULL &&
                    arp->ar_op == htons(ARPOP_REPLY) &&
                    inet_addr_type(sip) == RTN_UNICAST)
-                       n = __neigh_lookup(&arp_tbl, &sip, dev, -1);
+                       n = __neigh_lookup(&arp_tbl, &sip, dev, 1);
        }
 
        if (n) {
@@ -931,6 +933,9 @@ static int arp_rcv(struct sk_buff *skb, struct net_device *dev,
 {
        struct arphdr *arp;
 
+       if (dev->nd_net != &init_net)
+               goto freeskb;
+
        /* ARP header, plus 2 device addresses, plus 2 IP addresses.  */
        if (!pskb_may_pull(skb, (sizeof(struct arphdr) +
                                 (2 * dev->addr_len) +
@@ -977,7 +982,7 @@ static int arp_req_set(struct arpreq *r, struct net_device * dev)
                if (mask && mask != htonl(0xFFFFFFFF))
                        return -EINVAL;
                if (!dev && (r->arp_flags & ATF_COM)) {
-                       dev = dev_getbyhwaddr(r->arp_ha.sa_family, r->arp_ha.sa_data);
+                       dev = dev_getbyhwaddr(&init_net, r->arp_ha.sa_family, r->arp_ha.sa_data);
                        if (!dev)
                                return -ENODEV;
                }
@@ -987,11 +992,11 @@ static int arp_req_set(struct arpreq *r, struct net_device * dev)
                        return 0;
                }
                if (dev == NULL) {
-                       ipv4_devconf.proxy_arp = 1;
+                       IPV4_DEVCONF_ALL(PROXY_ARP) = 1;
                        return 0;
                }
                if (__in_dev_get_rtnl(dev)) {
-                       __in_dev_get_rtnl(dev)->cnf.proxy_arp = 1;
+                       IN_DEV_CONF_SET(__in_dev_get_rtnl(dev), PROXY_ARP, 1);
                        return 0;
                }
                return -ENXIO;
@@ -1093,11 +1098,12 @@ static int arp_req_delete(struct arpreq *r, struct net_device * dev)
                        return pneigh_delete(&arp_tbl, &ip, dev);
                if (mask == 0) {
                        if (dev == NULL) {
-                               ipv4_devconf.proxy_arp = 0;
+                               IPV4_DEVCONF_ALL(PROXY_ARP) = 0;
                                return 0;
                        }
                        if (__in_dev_get_rtnl(dev)) {
-                               __in_dev_get_rtnl(dev)->cnf.proxy_arp = 0;
+                               IN_DEV_CONF_SET(__in_dev_get_rtnl(dev),
+                                               PROXY_ARP, 0);
                                return 0;
                        }
                        return -ENXIO;
@@ -1164,7 +1170,7 @@ int arp_ioctl(unsigned int cmd, void __user *arg)
        rtnl_lock();
        if (r.arp_dev[0]) {
                err = -ENODEV;
-               if ((dev = __dev_get_by_name(r.arp_dev)) == NULL)
+               if ((dev = __dev_get_by_name(&init_net, r.arp_dev)) == NULL)
                        goto out;
 
                /* Mmmm... It is wrong... ARPHRD_NETROM==0 */
@@ -1200,6 +1206,9 @@ static int arp_netdev_event(struct notifier_block *this, unsigned long event, vo
 {
        struct net_device *dev = ptr;
 
+       if (dev->nd_net != &init_net)
+               return NOTIFY_DONE;
+
        switch (event) {
        case NETDEV_CHANGEADDR:
                neigh_changeaddr(&arp_tbl, dev);
@@ -1369,24 +1378,8 @@ static const struct seq_operations arp_seq_ops = {
 
 static int arp_seq_open(struct inode *inode, struct file *file)
 {
-       struct seq_file *seq;
-       int rc = -ENOMEM;
-       struct neigh_seq_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
-
-       if (!s)
-               goto out;
-
-       rc = seq_open(file, &arp_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, &arp_seq_ops,
+                       sizeof(struct neigh_seq_state));
 }
 
 static const struct file_operations arp_seq_fops = {
@@ -1399,7 +1392,7 @@ static const struct file_operations arp_seq_fops = {
 
 static int __init arp_proc_init(void)
 {
-       if (!proc_net_fops_create("arp", S_IRUGO, &arp_seq_fops))
+       if (!proc_net_fops_create(&init_net, "arp", S_IRUGO, &arp_seq_fops))
                return -ENOMEM;
        return 0;
 }