Problem with sheep_net networking on Ubuntu 14.04
Moderators: Cat_7, Ronald P. Regensburg
Problem with sheep_net networking on Ubuntu 14.04
Hello,
I can't get networking with sheep_net to go for Basilisk 2 on Ubuntu 14.04. I'm not sure whether the kernel module or the Mac OS network configuration is causing my problem.
I have been running Basilisk II on Windows XP for a long time now. With the EOL of Windows XP, I would like to move my virtual Mac to Ubuntu. Ubuntu 14.04 includes a package basilisk2 0.9.20120331-2, which I installed without problems. That package also includes the sheep_net source. I compiled and installed the kernel module without any errors for the current kernel 3.13.0-34-generic, following the instructions in the wiki (both on real hardware an on an Ubuntu installation in VirtualBox).
Using my existing virtual disks (i.e. *.hfv files), I could run my old virtual Mac. But I can't get access to the local network. The Basilisk configuration is set to use eth0.
What's my mistake? Does the (old) sheep_net kernel source still work with recent kernels? Is there any way to test sheep_net networking without the emulator? Are there any restrictions regarding the network configuration in Mac OS, e.g. can I use DHCP?
Thanks in advance,
Malte
I can't get networking with sheep_net to go for Basilisk 2 on Ubuntu 14.04. I'm not sure whether the kernel module or the Mac OS network configuration is causing my problem.
I have been running Basilisk II on Windows XP for a long time now. With the EOL of Windows XP, I would like to move my virtual Mac to Ubuntu. Ubuntu 14.04 includes a package basilisk2 0.9.20120331-2, which I installed without problems. That package also includes the sheep_net source. I compiled and installed the kernel module without any errors for the current kernel 3.13.0-34-generic, following the instructions in the wiki (both on real hardware an on an Ubuntu installation in VirtualBox).
Using my existing virtual disks (i.e. *.hfv files), I could run my old virtual Mac. But I can't get access to the local network. The Basilisk configuration is set to use eth0.
What's my mistake? Does the (old) sheep_net kernel source still work with recent kernels? Is there any way to test sheep_net networking without the emulator? Are there any restrictions regarding the network configuration in Mac OS, e.g. can I use DHCP?
Thanks in advance,
Malte
Re: Problem with sheep_net networking on Ubuntu 14.04
Hi,
Do you load the module as root and run Basilisk as root?
Is there a specific reason you need to use the sheep_net module? You can also use the slirp networking option.
Edit: I tried building a newer version of the module, including a change proposed on github.
With both the older and newer module (and with slirp networking) Basilisk crashed as soon as I requested an Internet page. This is using Ubuntu 14.04 LTS.
It might be best if you raised an issue on github.
Best,
Cat_7
Do you load the module as root and run Basilisk as root?
Is there a specific reason you need to use the sheep_net module? You can also use the slirp networking option.
Edit: I tried building a newer version of the module, including a change proposed on github.
With both the older and newer module (and with slirp networking) Basilisk crashed as soon as I requested an Internet page. This is using Ubuntu 14.04 LTS.
It might be best if you raised an issue on github.
Best,
Cat_7
Last edited by Cat_7 on Sat Aug 30, 2014 3:38 pm, edited 2 times in total.
Re: Problem with sheep_net networking on Ubuntu 14.04
Hi,
thanks for your help!
Your question made me try starting Basilisk as root. If I do that and have a static IP address configured in TCP/IP, a line like "sheep_net: ipfilter set to <ip_addr>" is written to the kernel log file. This does not happen if I run Basilisk as a regular user. But even as root, I don't have network access. If I specify DHCP in TCP/IP, it takes a long time until the Mac desktop is shown.
Where could I read up on the networking concepts of in Basilisk? I'd feel better if I could answer at least some of the following questions myself:
- Would sheep_net be any faster than slirp?
- If it was, what should I try to get it going?
- I guess Basilisk is acting as some sort of router to my local network, hence the 10.0.2.0/24 address range? Can I configure that?
Best regards,
Malte
thanks for your help!
I load the module as root, change the owner of /dev/sheep_net to my regular account and run Basilisk as that regular user.Cat_7 wrote: Do you load the module as root and run Basilisk as root?
Your question made me try starting Basilisk as root. If I do that and have a static IP address configured in TCP/IP, a line like "sheep_net: ipfilter set to <ip_addr>" is written to the kernel log file. This does not happen if I run Basilisk as a regular user. But even as root, I don't have network access. If I specify DHCP in TCP/IP, it takes a long time until the Mac desktop is shown.
No, I simply was not familiar with slirp. I have now tried it and it worked right out of the box. Great!Cat_7 wrote: Is there a specific reason you need to use the sheep_net module? You can also use the slirp networking option.
Where could I read up on the networking concepts of in Basilisk? I'd feel better if I could answer at least some of the following questions myself:
- Would sheep_net be any faster than slirp?
- If it was, what should I try to get it going?
- I guess Basilisk is acting as some sort of router to my local network, hence the 10.0.2.0/24 address range? Can I configure that?
Best regards,
Malte
Re: Problem with sheep_net networking on Ubuntu 14.04
Hi,
The sheep_net module (if working) would allow appletalk to work.
It is not faster (in my experience). Slirp creates a local dhcp server, and thus gives you the 10.0.2.15 ip address. The numbering scheme can only be changed in the source code before compiling.
I don't know what would be needed to get the module to work again.
Best,
Cat_7
The sheep_net module (if working) would allow appletalk to work.
It is not faster (in my experience). Slirp creates a local dhcp server, and thus gives you the 10.0.2.15 ip address. The numbering scheme can only be changed in the source code before compiling.
I don't know what would be needed to get the module to work again.
Best,
Cat_7
Re: Problem with sheep_net networking on Ubuntu 14.04
Hi,
Has anyone of you used sheep_net with kernel 3.13? If not, what's the last kernel version sheep_net is known to work with?
Regard,
Malte
Has anyone of you used sheep_net with kernel 3.13? If not, what's the last kernel version sheep_net is known to work with?
Regard,
Malte
- rickyzhang
- Apple Corer
- Posts: 205
- Joined: Mon Sep 15, 2014 7:59 pm
Re: Problem with sheep_net networking on Ubuntu 14.04
sheep_net module is broken due to interrupt API deprecation in Linux.maf wrote:Hi,
Has anyone of you used sheep_net with kernel 3.13? If not, what's the last kernel version sheep_net is known to work with?
Regard,
Malte
I tried to replace it with the new one:
https://github.com/rickyzhang82/macemu/ ... 87c2052388
With the patch, I can ping to outside URL and ftp to my local host under Fedora 20 with kernel 3.15. But it doesn't seem to work fully functional. I can't use web browser. I'm not an expert on Linux device driver. I'm still trying to figure it out. It requires a lot of reading.
Also, I tried on tun/tap. You can find my another thread here: http://www.emaculation.com/forum/viewto ... f=6&t=8426
There is an App for that!
https://github.com/rickyzhang82
https://github.com/rickyzhang82
Re: Problem with sheep_net networking on Ubuntu 14.04
Hi Ricky,
thanks for your explanation and the links.
Which kernel would be the last one before that interrupt API deprecation? Was that a change from 2.4 to 2.6 or from 2.6 to 3.x? Could you recommend any documentation for that API change or some migration guide I should read?
Regards,
Malte
thanks for your explanation and the links.
Which kernel would be the last one before that interrupt API deprecation? Was that a change from 2.4 to 2.6 or from 2.6 to 3.x? Could you recommend any documentation for that API change or some migration guide I should read?
Regards,
Malte
- rickyzhang
- Apple Corer
- Posts: 205
- Joined: Mon Sep 15, 2014 7:59 pm
Re: Problem with sheep_net networking on Ubuntu 14.04
I can't give you a definite answer since I'm not an expert on device driver.
In any case, you can google function call "interruptible_sleep_on". That's the one cause race condition thus deprecated.
In any case, you can google function call "interruptible_sleep_on". That's the one cause race condition thus deprecated.
There is an App for that!
https://github.com/rickyzhang82
https://github.com/rickyzhang82
- adespoton
- Forum All-Star
- Posts: 4274
- Joined: Fri Nov 27, 2009 5:11 am
- Location: Emaculation.com
- Contact:
Re: Problem with sheep_net networking on Ubuntu 14.04
Wasn't that replaced with a better way of doing things? After googling, please let us know what the accepted method is now, as that way we might actually be able to fix the issue.
Re: Problem with sheep_net networking on Ubuntu 14.04
I've found this post which suggests a couple of patches to other drivers in order replace calls to sleep_on.
- rickyzhang
- Apple Corer
- Posts: 205
- Joined: Mon Sep 15, 2014 7:59 pm
Re: Problem with sheep_net networking on Ubuntu 14.04
Using git blame on Linux kernel repo, I guess the patch is applied in 3.15 kernel. Feel free to try the patch below. I'm still testing it.
updated Sep-18. I should use atomic to avoid race condition:
--- /tmp/sTCQJh_sheep_net.c
+++ /home/Ricky/repo/github/macemu/BasiliskII/src/Unix/Linux/NetDriver/sheep_net.c
@@ -21,7 +21,11 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/version.h>
-
+#include <linux/init.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+#define LINUX_3_15
+#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
#define LINUX_26_35
@@ -153,6 +157,9 @@
u32 ipfilter; /* Only receive IP packets destined for this address (host byte order) */
char eth_addr[6]; /* Hardware address of the Ethernet card */
char fake_addr[6]; /* Local faked hardware address (what SheepShaver sees) */
+#ifdef LINUX_3_15
+ atomic_t got_packet;
+#endif
};
@@ -390,7 +397,12 @@
break;
/* No packet in queue and in blocking mode, so block */
- interruptible_sleep_on(&v->wait);
+ #ifdef LINUX_3_15
+ atomic_set(&v->got_packet, 0);
+ wait_event_interruptible(v->wait, atomic_read(&v->got_packet));
+ #else
+ interruptible_sleep_on(&v->wait);
+ #endif
/* Signal received? Then bail out */
if (signal_pending(current))
@@ -670,7 +682,7 @@
case SIOC_MOL_SET_IPFILTER:
v->ipfilter = arg;
- return 0;
+ return 0;
default:
return -ENOIOCTLCMD;
@@ -730,8 +742,18 @@
/* Enqueue packet */
skb_queue_tail(&v->queue, skb);
- /* Unblock blocked read */
- wake_up(&v->wait);
+ /* Unblock blocked read */
+ #ifdef LINUX_3_15
+
+ atomic_set(&v->got_packet, 1);
+
+ wake_up_interruptible(&v->wait);
+
+ #else
+
+ wake_up(&v->wait);
+
+ #endif
return 0;
drop:
updated Sep-18. I should use atomic to avoid race condition:
--- /tmp/sTCQJh_sheep_net.c
+++ /home/Ricky/repo/github/macemu/BasiliskII/src/Unix/Linux/NetDriver/sheep_net.c
@@ -21,7 +21,11 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/version.h>
-
+#include <linux/init.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)
+#define LINUX_3_15
+#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
#define LINUX_26_35
@@ -153,6 +157,9 @@
u32 ipfilter; /* Only receive IP packets destined for this address (host byte order) */
char eth_addr[6]; /* Hardware address of the Ethernet card */
char fake_addr[6]; /* Local faked hardware address (what SheepShaver sees) */
+#ifdef LINUX_3_15
+ atomic_t got_packet;
+#endif
};
@@ -390,7 +397,12 @@
break;
/* No packet in queue and in blocking mode, so block */
- interruptible_sleep_on(&v->wait);
+ #ifdef LINUX_3_15
+ atomic_set(&v->got_packet, 0);
+ wait_event_interruptible(v->wait, atomic_read(&v->got_packet));
+ #else
+ interruptible_sleep_on(&v->wait);
+ #endif
/* Signal received? Then bail out */
if (signal_pending(current))
@@ -670,7 +682,7 @@
case SIOC_MOL_SET_IPFILTER:
v->ipfilter = arg;
- return 0;
+ return 0;
default:
return -ENOIOCTLCMD;
@@ -730,8 +742,18 @@
/* Enqueue packet */
skb_queue_tail(&v->queue, skb);
- /* Unblock blocked read */
- wake_up(&v->wait);
+ /* Unblock blocked read */
+ #ifdef LINUX_3_15
+
+ atomic_set(&v->got_packet, 1);
+
+ wake_up_interruptible(&v->wait);
+
+ #else
+
+ wake_up(&v->wait);
+
+ #endif
return 0;
drop:
There is an App for that!
https://github.com/rickyzhang82
https://github.com/rickyzhang82
- rickyzhang
- Apple Corer
- Posts: 205
- Joined: Mon Sep 15, 2014 7:59 pm
Re: Problem with sheep_net networking on Ubuntu 14.04
I confirmed that the fix above works for System 7.5.5 under 3.15 kernel. I have sent pulled request to cebix in github.
There is an App for that!
https://github.com/rickyzhang82
https://github.com/rickyzhang82
Re: Problem with sheep_net networking on Ubuntu 14.04
sheep_net crashes the kernel when I use n2n.
n2n is a simple VPN that needs almost no configuration.
A supernode is launched on a server somewhere.
supernode -l 2929
Edge nodes connect to the supernode.
sudo edge -a 0 -c c -k k -l 10.9.2.9:2929
An edge node creates a tap device edge0 which can be used with sheep_net.
Except I see a kernel panic every time sheep_net calls dev_queue_xmit.
Calling skb_copy before dev_queue_xmit seems to fix it.
https://github.com/Masaq-/macemu/commit ... 29008fc40e
n2n is a simple VPN that needs almost no configuration.
A supernode is launched on a server somewhere.
supernode -l 2929
Edge nodes connect to the supernode.
sudo edge -a 0 -c c -k k -l 10.9.2.9:2929
An edge node creates a tap device edge0 which can be used with sheep_net.
Except I see a kernel panic every time sheep_net calls dev_queue_xmit.
Calling skb_copy before dev_queue_xmit seems to fix it.
https://github.com/Masaq-/macemu/commit ... 29008fc40e
Re: Problem with sheep_net networking on Ubuntu 14.04
by leaking memory. Sorry.Masaq' wrote:Calling skb_copy before dev_queue_xmit seems to fix it
After further digging into the Linux sources, I found the cause of the panic: tun_net_xmit invokes skb->destructor which is null. An empty destructor fixes the problem.
https://github.com/Masaq-/macemu/commit ... d7ae357007
Two other minor issues have been bugging me. First, sheep_net was not removable without rebooting Linux. Second, kmemleak reported 1040 bytes leaked each time sheep_net was closed. I just randomly commented out stuff until both of these issues mysteriously vanished. Apparently wmem_alloc serves no useful purpose anymore.
https://github.com/Masaq-/macemu/commit ... 90e3ddbe17
- adespoton
- Forum All-Star
- Posts: 4274
- Joined: Fri Nov 27, 2009 5:11 am
- Location: Emaculation.com
- Contact:
Re: Problem with sheep_net networking on Ubuntu 14.04
Thanks for hunting those down! Any chance you can commit those back to the trunk?
Re: Problem with sheep_net networking on Ubuntu 14.04
Pull request submitted.