Commit d6bd6619 authored by Stephen Hemminger's avatar Stephen Hemminger

[BRIDGE]: Compat hooks for new-ioctl interface.

Replacement 64 bit compatibility code for the new ioctl's.  The new 
ioctl's all pass through clean, but for the old style ioctl's it uses
the mis-feature of the earlier bridge-utils that they check the API version.

So if an old 32bit version of brctl is run on a 64bit platform it will
report
	bridge utilities not compatible with kernel version

Tested on Itanium 1; but should solve issue for sparc, ppc, and x86_64
parent 5075405c
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/if.h> #include <linux/if.h>
#include <linux/if_bridge.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <linux/raid/md.h> #include <linux/raid/md.h>
...@@ -3072,18 +3073,19 @@ static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar ...@@ -3072,18 +3073,19 @@ static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar
return sys_ioctl(fd, cmd, (unsigned long) iwr); return sys_ioctl(fd, cmd, (unsigned long) iwr);
} }
/* Emulate old style bridge ioctls */ /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE
static int do_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) * for some operations; this forces use of the newer bridge-utils that
* use compatiable ioctls
*/
static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
{ {
u32 tmp; u32 tmp;
unsigned long *argbuf = compat_alloc_user_space(3 * sizeof(unsigned long));
int i; if (get_user(tmp, (u32 *) arg))
for (i = 0; i < 3; i++) { return -EFAULT;
if (get_user(tmp, i + ((u32 *)arg)) || if (tmp == BRCTL_GET_VERSION)
put_user(tmp, i + argbuf)) return BRCTL_VERSION + 1;
return -EFAULT; return -EINVAL;
}
return sys_ioctl(fd, cmd, (unsigned long)argbuf);
} }
#undef CODE #undef CODE
...@@ -3133,6 +3135,8 @@ HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl) ...@@ -3133,6 +3135,8 @@ HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl) HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
HANDLE_IOCTL(SIOCADDRT, routing_ioctl) HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
HANDLE_IOCTL(SIOCDELRT, routing_ioctl) HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc)
HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc)
/* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */ /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
HANDLE_IOCTL(SIOCRTMSG, ret_einval) HANDLE_IOCTL(SIOCRTMSG, ret_einval)
HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp) HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
...@@ -3263,8 +3267,8 @@ HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl) ...@@ -3263,8 +3267,8 @@ HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl)
HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl) HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl)
HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl) HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl)
HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl) HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl)
HANDLE_IOCTL(SIOCSIFBR, do_bridge_ioctl) HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl)
HANDLE_IOCTL(SIOCGIFBR, do_bridge_ioctl) HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl)
#undef DECLARES #undef DECLARES
#endif #endif
...@@ -275,6 +275,8 @@ COMPATIBLE_IOCTL(SIOCGMIIREG) ...@@ -275,6 +275,8 @@ COMPATIBLE_IOCTL(SIOCGMIIREG)
COMPATIBLE_IOCTL(SIOCSMIIREG) COMPATIBLE_IOCTL(SIOCSMIIREG)
COMPATIBLE_IOCTL(SIOCGIFVLAN) COMPATIBLE_IOCTL(SIOCGIFVLAN)
COMPATIBLE_IOCTL(SIOCSIFVLAN) COMPATIBLE_IOCTL(SIOCSIFVLAN)
COMPATIBLE_IOCTL(SIOCBRADDBR)
COMPATIBLE_IOCTL(SIOCBRDELBR)
/* SG stuff */ /* SG stuff */
COMPATIBLE_IOCTL(SG_SET_TIMEOUT) COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
COMPATIBLE_IOCTL(SG_GET_TIMEOUT) COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment