Friday 7 November 2008

Wireless Network bridging with VMware Server 1.0.7

VMware Server works very fine under OpenSuse 10 and 11. In fact, it is one of the reasons I turned to OpenSuse. But I couldn't get my wireless adapter (wlan0) working with bridged networks. So if I wanted to have my VM's bridged I was restricted to the wired-adapter (eth0).

I've searched and searched both in Google and the OpenSuse Forums. Many people struggled with the same issue, but I couldn't find any solution. Until today. It started by finding this article: http://www.hauke-m.de/artikel/vm-ware-wlan-bugfix/ It's in german, but it has an English translation too.

What it suggests is that there is a bug in the vmnet that Hauke solved. You can download his, replace your vmnet.tar that resides in /usr/lib/vmware/modules/source/ with it.
Then after running vmware-config.pl it s
hould work.

Apparently the vmnet.tar is from vmware-player 2.0 which does support kernels with a version higher then
2.6.21.

However, things often are a little more complicate than simple. In my case the kernel is 2.6.25. And I ran into compilation errors. First I ran into:

CC [M] /tmp/vmware-config1/vmnet-only/driver.o In file included from /tmp/vmware-config1/vmnet-only/compat_sock.h:5, from /tmp/vmware-config1/vmnet-only/driver.c:29: /usr/src/linux-2.6.25.18-0.2/include/net/sock.h: In function ‘sock_valbool_flag’: /usr/src/linux-2.6.25.18-0.2/include/net/sock.h:106: error: implicit declaration of function ‘sock_set_flag’ /usr/src/linux-2.6.25.18-0.2/include/net/sock.h:108: error: implicit declaration of function ‘sock_reset_flag’ /usr/src/linux-2.6.25.18-0.2/include/net/sock.h: At top level: /usr/src/linux-2.6.25.18-0.2/include/net/sock.h:431: warning: conflicting types for ‘sock_set_flag’ /usr/src/linux-2.6.25.18-0.2/include/net/sock.h:431: error: static declaration of ‘sock_set_flag’ follows non-static declaration /usr/src/linux-2.6.25.18-0.2/include/net/sock.h:106: error: previous implicit declaration of ‘sock_set_flag’ was here /usr/src/linux-2.6.25.18-0.2/include/net/sock.h:436: warning: conflicting types for ‘sock_reset_flag’ /usr/src/linux-2.6.25.18-0.2/include/net/sock.h:436: error: static declaration of ‘sock_reset_flag’ follows non-static declaration /usr/src/linux-2.6.25.18-0.2/include/net/sock.h:108: error: previous implicit declaration of ‘sock_reset_flag’ was here

I found a solution for this at: http://www.tfug.org/pipermail/tfug/2008-April/018337.html
However, it does not state precise enough where to do the change. Luckily I found that.
Open /usr/src/linux/include/net/sock.h in vi (as root).
Search for the line: extern __u32 sysctl_wmem_max;
Right above it copy the following lines:

static inline void sock_valbool_flag(struct sock *sk, int bit, int valbool)
{
if (valbool)

sock_set_flag(sk, bit);
else
sock_reset_flag(sk, bit);
}


So that it reads:

(it's allways wise to first backup the file to for example sock.h.org).
Then running vmware-config.pl again got me into the following compilation errors:
make -C /usr/src/linux-2.6.25.18-0.2 O=/usr/src/linux-2.6.25.18-0.2-obj/x86_64/default/. modules
CC [M] /tmp/vmware-config2/vmnet-only/driver.o
CC [M] /tmp/vmware-config2/vmnet-only/hub.o
CC [M] /tmp/vmware-config2/vmnet-only/userif.o
CC [M] /tmp/vmware-config2/vmnet-only/netif.o
CC [M] /tmp/vmware-config2/vmnet-only/bridge.o
CC [M] /tmp/vmware-config2/vmnet-only/filter.o
/tmp/vmware-config2/vmnet-only/filter.c:48: error: ‘NF_IP_LOCAL_IN’ undeclared here (not in a function)
/tmp/vmware-config2/vmnet-only/filter.c:53: error: ‘NF_IP_POST_ROUTING’ undeclared here (not in a function)
/tmp/vmware-config2/vmnet-only/filter.c: In function ‘VNetFilterHookFn’:
/tmp/vmware-config2/vmnet-only/filter.c:233: warning: comparison between pointer and integer
make[4]: *** [/tmp/vmware-config2/vmnet-only/filter.o] Error 1
make[3]: *** [_module_/tmp/vmware-config2/vmnet-only] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2

This is also solved using the http://www.tfug.org/pipermail/tfug/2008-April/018337.html.
In the vmnet.tar there is a c-file: vmnet-only/filter.c.
In that file search and replace NF_IP_LOCAL_IN with 1 and NF_IP_POST_ROUTING with 4. These values were found in:/usr/src/linux/include/linux/netfilter_ipv4.h.
Then copy filter.c back into vmnet.tar. Or just use mine here.

Then copy the changed vmnet.tar into /usr/lib/vmware/modules/source/.
In my case with running vmware-config.pl the last time it compiled vmnet neatly.
And now my windows-guest bridged over wireless!

Thanks to the guys behind the links, you've made my ICT-life a little more convenient.

And you guys: don't forget to come here again after the next kernel update (since the socks.h file might break again).

No comments :