ip: convert to net_device_ops for ioctl
authorStephen Hemminger <shemminger@vyatta.com>
Thu, 20 Nov 2008 05:52:05 +0000 (21:52 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Nov 2008 06:42:41 +0000 (22:42 -0800)
Convert to net_device_ops function table pointer for ioctl.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ipmr.c
net/ipv6/addrconf.c

index 05ed336f798aad2782a909290d32390842aa9a26..ed372f3983e578d15ee7334bbaf8a6bf19467563 100644 (file)
@@ -124,8 +124,8 @@ static void ipmr_del_tunnel(struct net_device *dev, struct vifctl *v)
 
        dev = __dev_get_by_name(&init_net, "tunl0");
        if (dev) {
+               const struct net_device_ops *ops = dev->netdev_ops;
                struct ifreq ifr;
-               mm_segment_t    oldfs;
                struct ip_tunnel_parm p;
 
                memset(&p, 0, sizeof(p));
@@ -137,9 +137,13 @@ static void ipmr_del_tunnel(struct net_device *dev, struct vifctl *v)
                sprintf(p.name, "dvmrp%d", v->vifc_vifi);
                ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
 
-               oldfs = get_fs(); set_fs(KERNEL_DS);
-               dev->do_ioctl(dev, &ifr, SIOCDELTUNNEL);
-               set_fs(oldfs);
+               if (ops->ndo_do_ioctl) {
+                       mm_segment_t oldfs = get_fs();
+
+                       set_fs(KERNEL_DS);
+                       ops->ndo_do_ioctl(dev, &ifr, SIOCDELTUNNEL);
+                       set_fs(oldfs);
+               }
        }
 }
 
@@ -151,9 +155,9 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v)
        dev = __dev_get_by_name(&init_net, "tunl0");
 
        if (dev) {
+               const struct net_device_ops *ops = dev->netdev_ops;
                int err;
                struct ifreq ifr;
-               mm_segment_t    oldfs;
                struct ip_tunnel_parm p;
                struct in_device  *in_dev;
 
@@ -166,9 +170,14 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v)
                sprintf(p.name, "dvmrp%d", v->vifc_vifi);
                ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
 
-               oldfs = get_fs(); set_fs(KERNEL_DS);
-               err = dev->do_ioctl(dev, &ifr, SIOCADDTUNNEL);
-               set_fs(oldfs);
+               if (ops->ndo_do_ioctl) {
+                       mm_segment_t oldfs = get_fs();
+
+                       set_fs(KERNEL_DS);
+                       err = ops->ndo_do_ioctl(dev, &ifr, SIOCADDTUNNEL);
+                       set_fs(oldfs);
+               } else
+                       err = -EOPNOTSUPP;
 
                dev = NULL;
 
index 0e41f1be6dc9ca0694a91f592e65b5bd46be65f2..e92ad8455c63a851ef9966705b627299459f0bb2 100644 (file)
@@ -2031,8 +2031,8 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
 
 #if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
        if (dev->type == ARPHRD_SIT) {
+               const struct net_device_ops *ops = dev->netdev_ops;
                struct ifreq ifr;
-               mm_segment_t    oldfs;
                struct ip_tunnel_parm p;
 
                err = -EADDRNOTAVAIL;
@@ -2048,9 +2048,14 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
                p.iph.ttl = 64;
                ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
 
-               oldfs = get_fs(); set_fs(KERNEL_DS);
-               err = dev->do_ioctl(dev, &ifr, SIOCADDTUNNEL);
-               set_fs(oldfs);
+               if (ops->ndo_do_ioctl) {
+                       mm_segment_t oldfs = get_fs();
+
+                       set_fs(KERNEL_DS);
+                       err = ops->ndo_do_ioctl(dev, &ifr, SIOCADDTUNNEL);
+                       set_fs(oldfs);
+               } else
+                       err = -EOPNOTSUPP;
 
                if (err == 0) {
                        err = -ENOBUFS;