This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / net / ipv4 / devinet.c
index c9cd619..2dc4e7a 100644 (file)
@@ -489,7 +489,7 @@ static __inline__ int inet_abc_len(u32 addr)
 }
 
 
-int devinet_ioctl(unsigned int cmd, void *arg)
+int devinet_ioctl(unsigned int cmd, void __user *arg)
 {
        struct ifreq ifr;
        struct sockaddr_in sin_orig;
@@ -699,6 +699,20 @@ int devinet_ioctl(unsigned int cmd, void *arg)
                        inet_del_ifa(in_dev, ifap, 0);
                        ifa->ifa_mask = sin->sin_addr.s_addr;
                        ifa->ifa_prefixlen = inet_mask_len(ifa->ifa_mask);
+
+                       /* See if current broadcast address matches
+                        * with current netmask, then recalculate
+                        * the broadcast address. Otherwise it's a
+                        * funny address, so don't touch it since
+                        * the user seems to know what (s)he's doing...
+                        */
+                       if ((dev->flags & IFF_BROADCAST) &&
+                           (ifa->ifa_prefixlen < 31) &&
+                           (ifa->ifa_broadcast ==
+                            (ifa->ifa_local|~ifa->ifa_mask))) {
+                               ifa->ifa_broadcast = (ifa->ifa_local |
+                                                     ~sin->sin_addr.s_addr);
+                       }
                        inet_insert_ifa(ifa);
                }
                break;
@@ -713,7 +727,7 @@ rarok:
        goto out;
 }
 
-static int inet_gifconf(struct net_device *dev, char *buf, int len)
+static int inet_gifconf(struct net_device *dev, char __user *buf, int len)
 {
        struct in_device *in_dev = __in_dev_get(dev);
        struct in_ifaddr *ifa;
@@ -1136,7 +1150,7 @@ void inet_forward_change(void)
 }
 
 static int devinet_sysctl_forward(ctl_table *ctl, int write,
-                                 struct file* filp, void *buffer,
+                                 struct file* filp, void __user *buffer,
                                  size_t *lenp)
 {
        int *valp = ctl->data;
@@ -1154,7 +1168,7 @@ static int devinet_sysctl_forward(ctl_table *ctl, int write,
 }
 
 int ipv4_doint_and_flush(ctl_table *ctl, int write,
-                        struct file* filp, void *buffer,
+                        struct file* filp, void __user *buffer,
                         size_t *lenp)
 {
        int *valp = ctl->data;
@@ -1167,9 +1181,9 @@ int ipv4_doint_and_flush(ctl_table *ctl, int write,
        return ret;
 }
 
-int ipv4_doint_and_flush_strategy(ctl_table *table, int *name, int nlen,
-                                 void *oldval, size_t *oldlenp,
-                                 void *newval, size_t newlen, 
+int ipv4_doint_and_flush_strategy(ctl_table *table, int __user *name, int nlen,
+                                 void __user *oldval, size_t __user *oldlenp,
+                                 void __user *newval, size_t newlen, 
                                  void **context)
 {
        int *valp = table->data;
@@ -1181,7 +1195,7 @@ int ipv4_doint_and_flush_strategy(ctl_table *table, int *name, int nlen,
        if (newlen != sizeof(int))
                return -EINVAL;
 
-       if (get_user(new, (int *)newval))
+       if (get_user(new, (int __user *)newval))
                return -EFAULT;
 
        if (new == *valp)