Sheep_net.ko on Debian 8 PPC

About BasiliskII, a 68k Mac emulator for Windows, MacOSX, and Linux that can run System 7.x through MacOS 8.1.

Moderators: Cat_7, Ronald P. Regensburg

galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by galgot »

Hi rickyzhang,

Building your last sheep-net-bug-fix-debug branch fails :

Makefile:190: recipe for target 'obj/newcpu.o' failed
make: *** [obj/newcpu.o] Error 1
./../SDL/video_sdl.cpp: In function ‘void update_display_static(driver_base*)’:
./../SDL/video_sdl.cpp:1868:26: warning: comparison between ‘const enum video_depth’ and ‘enum<anonymous>’ [-Wenum-compare]
if (VIDEO_MODE_DEPTH < VIDEO_DEPTH_8BIT) {

So I can't test with it :/

But, I've managed to sniff packets with Wireshark.
this is the saved capt of ping to 8.8.8.8 from 192.168.0.64 :
http://galgot.com/transit/wireshark/Pin ... 8.8.pcapng
then this is saved capt of ping to www.nytimes.com :
http://galgot.com/transit/wireshark/Pin ... com.pcapng
and this is capt of icab trying to reach http://74.125232.241, I had to stop it cause it would "turn " forever :
http://galgot.com/transit/wireshark/iCa ... 241.pcapng

Hope this can help...
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

1. Do you have sdl 1.2 library in host PC? My build script require SDL 1.2 and GTK2

2. I have python script to capture and dump BasiliskII ether_unix.cpp receive and send packet from sheep_net. These packets are more relevant than capturing by wireshark in host.

Please try to compile it again and upload hex dump. Basically, the python script will parse Basilisk II output log from ether_unix.cpp and convert it to wireshark hex dump format.

I found several interesting things from that hex dump in wireshark. (Note that there are differences between packets captured by wireshark in host PC and packets from Basilisk II output log.)

1. modern firewall in host pc may mess up sheep_net. It kept on sent to router saying that guest IP is not reachable. So disable firewall in host PC or if have time, figure it out make a specific rule for guest IP in iptables.

2. When receiving packets from outsides in guest IP, I found duplicate packets with different source ethernet address but same source IP. One from my router and one from my host PC. I believe that may be the main reason why it mess up connection from time to time. But I need to figure it out why.
There is an App for that!
https://github.com/rickyzhang82
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

Update after reading your packets capture.

1. ICMP to 8.8.8.8 looks good
2. DNS works
3. http to IP address got stuck. It is the similar situation it got stuck in TCP 3 way handshake between guest IP and remote IP. I saw first and second step. But guest OS never response in 3rd step.

From 1 and 2, you don't have the issues as I did. Have you disabled your firewall yet?

Please disable your firewall and run python script to generate hex dump. TBH, sheep_net magically work on my box again.
There is an App for that!
https://github.com/rickyzhang82
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

I found reason why there is duplicate packet. It is because Fedora enable IP forwarding by default. After disable it, I don't see duplicate any more.

Code: Select all

echo 0 > /proc/sys/net/ipv4//ip_foward
In any case, sheep_net module works again at least for now. But I need to at least
1. Disable firewall so that disable ICMP host unreachable error message.
2. Disable IPv4 forwarding.

Please make sure we have the same setting.
There is an App for that!
https://github.com/rickyzhang82
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by galgot »

Ok ,
disabled ip fowarding :
# sysctl -w net.ipv4.ip_forward=0
net.ipv4.ip_forward = 0

disabled firewall :
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

Still not working.

Yes I have sdl 1.2 lib , tried again but still can't build your sheep-net-bug-fix-debug branch.
Tried with :
NO_CONFIGURE=1 ./autogen.sh
./configure --enable-sdl-video --enable-sdl-audio --disable-vosf --enable-jit-compiler
make

here result :
In file included from compemu.cpp:7:0:
./../uae_cpu/compiler/compemu.h:36:2: error: #error "Unsupported JIT compiler for this architecture"
#error "Unsupported JIT compiler for this architecture"
^
Makefile:266: recipe for target 'obj/compemu1.o' failed
make: *** [obj/compemu1.o] Error 1

or if I try without specifying jit compiler :
./configure --enable-sdl-video --enable-sdl-audio --disable-vosf
make

I get :
/home/galgot/macemu-sheep-net-bug-fix-debug/BasiliskII/src/Unix/main_unix.cpp:929: undefined reference to `UseJIT'
/home/galgot/macemu-sheep-net-bug-fix-debug/BasiliskII/src/Unix/main_unix.cpp:929: undefined reference to `UseJIT'
/home/galgot/macemu-sheep-net-bug-fix-debug/BasiliskII/src/Unix/main_unix.cpp:930: undefined reference to `flush_icache_range(unsigned char*, unsigned int)'
collect2: error: ld returned 1 exit status
Makefile:111: recipe for target 'BasiliskII' failed
make: *** [BasiliskII] Error 1


...
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

You may need to run the whole thing again to remove JIT:
NO_CONFIGURE=1 ./autogen.sh
./configure --enable-sdl-video --enable-sdl-audio --disable-vosf
make
There is an App for that!
https://github.com/rickyzhang82
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by galgot »

both

NO_CONFIGURE=1 ./autogen.sh
./configure --enable-sdl-video --enable-sdl-audio --disable-vosf
make


and

NO_CONFIGURE=1 ./autogen.sh
./configure --enable-sdl-video --enable-sdl-audio --disable-vosf --disable-jit-compiler
make


fails :

obj/main_unix.o: In function `FlushCodeCache(void*, unsigned int)':
/home/galgot/macemu-sheep-net-bug-fix-debug/BasiliskII/src/Unix/main_unix.cpp:929: undefined reference to `UseJIT'
/home/galgot/macemu-sheep-net-bug-fix-debug/BasiliskII/src/Unix/main_unix.cpp:929: undefined reference to `UseJIT'
/home/galgot/macemu-sheep-net-bug-fix-debug/BasiliskII/src/Unix/main_unix.cpp:930: undefined reference to `flush_icache_range(unsigned char*, unsigned int)'
collect2: error: ld returned 1 exit status
Makefile:111: recipe for target 'BasiliskII' failed
make: *** [BasiliskII] Error 1


even with a reboot between the two tries...
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

make clean
to remove *.o

You are using the old object! I'd suggest to modify build.sh. Remove JIT in configure. I don't like typing too much.
There is an App for that!
https://github.com/rickyzhang82
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by galgot »

OK...
Finally managed to build it , thks for your patience.

Here is the hexbump.log after saved from Wireshark :
http://galgot.com/transit/wireshark/hex ... g_1.pcapng

And here are the packets sniffed while pinging with your latest BII build :
http://galgot.com/transit/wireshark/Pin ... mit.pcapng
there a ping to 8.8.8.8 and a icab connection atempt to nytimes in there.
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

Which one is python script converted from BII output log?

Could you do the following test:
1. Bring up wireshark on host
2. Bring up guest OS with redirect output to the log
3. Ping 8.8.8.8
3. Ping www.google.com
4. http www.google.com

Especially for hex dump from 2. It is essentially one that BII communicate with sheep_net. You can run python script or I can do it for you.
Last edited by rickyzhang on Wed Aug 17, 2016 4:58 pm, edited 1 time in total.
There is an App for that!
https://github.com/rickyzhang82
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by galgot »

first one
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

I found the issue in hex dump log(HDL). BII didn't receive DNS response from sheep_net module, while your host wireshark capture (HWC) suggest that DNS did send response.

Since you have filter HWC, do you see anything fishy around that without filtering?

One more thing, you can add in test I updated above, when http
1. Open local web server, http with IP address
2. http with IP address like nytimes IP 170.149.161.130

-----
PS: Your test is quite messy. I believe at some point time you change DNS from 8.8.8.8 to 212.27.40.240. Could you have a control test setting that we both agree? That would be more helpful.
There is an App for that!
https://github.com/rickyzhang82
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by galgot »

rickyzhang wrote:Which one is python script converted from BII output log?

Could you do the following test:
1. Bring up wireshark on host
2. Bring up guest OS with redirect output to the log
3. Ping 8.8.8.8
3. Ping http://www.google.com
4. http http://www.google.com

Especially for hex dump from 2. It is essentially one that BII communicate with sheep_net. You can run python script or I can do it for you.
Here,
Packets from Wireshark while Ping fron guest to 8.8.8.8, http://www.google.com and http to google:
http://galgot.com/transit/wireshark/Pin ... t-2.pcapng

and the hex dumps of the same session from python script, raw one from /temp :
http://galgot.com/transit/wireshark/hexdump.log
and the same imported into Wireshark and saved :
http://galgot.com/transit/wireshark/hex ... g_2.pcapng

Mmmh... what is HWC please ? You know, I don't really know what I'm doing, just trying to do what you tell me :)

Edit: yes my guest have dns 8.8.8.8 and 212.27.40.240/241 , these last two are my provider's one. should I remove it ?

Re-edit : done...
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

Just use one. 8.8.8.8
HWC means host PC wireshark capture packets.
There is an App for that!
https://github.com/rickyzhang82
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

From HWC, I saw DNS did response to request. But in HDL, BII didn't receive it.

Can you unfilter HWC, see if anything different color around DNS protocol that from 192.168.0.64 ==> 8.8.8.8?

Please use only *one* DNS 8.8.8.8 for testing. I guess guest OS switch different one if it can't get response. It make our lives harder. But you guest OS is able to connect to 8.8.8.8. It seems something fish there between BII and sheep_net.

We are close!
There is an App for that!
https://github.com/rickyzhang82
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by galgot »

Ok,
but how should I unfilter the host (HWC) please ?
If I uncheck "eth0 192.168.0.4" the start button is greyed, so can't snif anything...
Shall I use "Loopback: lo 127.0.0.1 ethernet" ?
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

First of all, you should stop sniffing and shutdown guest OS when you are done with test. Otherwise, HWC will be jammed with noise. Not fun!
Secondly, filter with ip.addr == 192.168.0.64.
Then, find the one with DNS request to 8.8.8.8, click it.
In then end, clear filter. eye ball any suspicious color after 8.8.8.8 send reply to 192.168.0.64.

By using this method, I found that Fedora enable IP forwarding to mess with guest OS connection and ICMP error due to the firewall. Debian may have something to prevent BII get DNS response from sheep_net.

--
Edit
1. sniffing and filter is different thing. You can sniff first, which sniff all packet. Then do whatever filter later.
2. you should sniff your host PC interface. Not 127.0.0.1. run ifconfig, find the name of interface binding to the host IP.
There is an App for that!
https://github.com/rickyzhang82
User avatar
adespoton
Forum All-Star
Posts: 4227
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Sheep_net.ko on Debian 8 PPC

Post by adespoton »

To explain what's going on a bit more: wireshark sets your ethernet packet capture to promiscuous mode, which means it captures all packets on the wire. It then saves all packets that go to/from the ethernet adapter in a pcap file. Wireshark then has a number of filtering and visualization features that let you filter out data you aren't interested in. You can set inclusive or exclusive filters so that only specific subsets of packets are displayed.

Ricky wants you to filter out everything that doesn't reference IP address 192.168.0.4 to make it easy to find the DNS request, and then remove the filter to see if there's any related activity surrounding the DNS request that doesn't reference that IP. It's possible that the firewall is inserting itself between the hardware device and the virtual device, causing some types of packets to get dropped.

If this is the problem, it should be fixable by adding a rule to the firewall that allows for all traffic between the two interfaces with no filtering. Make it the last rule to run, and it should prevent the kind of blocking you're seeing... IF this is the actual cause of the problem.
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by galgot »

Ok, thks for explanations Adespoton.
Now I understand I can filter the snifed packets to 192.168.0.64 only , then only save the wireshark file...
Anyway, was doing another test while you posted. so didn't do the filtering...
this time shuting down host and stoping capture after each test, then saving python hexdump.log and the wireshark capture for each. only with 8.8.8.8 DNS.
here :
http://galgot.com/transit/wireshark/Pin ... 8-2.pcapng
http://galgot.com/transit/wireshark/hex ... to_8.8.8.8

http://galgot.com/transit/wireshark/Pin ... Com.pcapng
http://galgot.com/transit/wireshark/hex ... wGoogleCom

http://galgot.com/transit/wireshark/htt ... Com.pcapng
http://galgot.com/transit/wireshark/hex ... wGoogleCom

Hope this can help

Will continue tomorrow, good night.
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

@adespoton Thanks for your explanation.
@galgot, I didn't explain it well what I want.

After guest OS send DNS query on what "www.google.com"'s IP is to 8.8.8.8 (google DNS server), it (google DNS server) responses correctly to host OS. This has been confirmed from HWC.

However from HDL sheep_net module didn't relay this module to guest OS. Thus, it got stuck.

What I want you was: (assuming you can do analysis by yourself) eyeball unfiltered HWC and see if any suspicious packet around DNS response. If you do, tell me what packets are.

But since you may not be able to do that, what I want from you now is to post the whole unfiltered HWC for a very short time period. Because it sniff all packet from your host, if you have any privacy concerns, you don't have to do that. But we will end the whole analysis. I will have to wait for the moment I can replicate the issues.

Good night!
There is an App for that!
https://github.com/rickyzhang82
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

I fix a couple issue in sheep_net.

I believe the culprit may be here: https://github.com/rickyzhang82/macemu/ ... 37e520L749

It use transport layer to get destination address, instead of network layer. I tested it with/without my fix and also use dmesg to printk. You can do that as well and see how sheep_net keep and drop IP packet.

Please get the fix from https://github.com/rickyzhang82/macemu/ ... -fix-debug

Make sure commit is 61b04a892815273911f448601e45fbbfed1e5da8

It is US eastern time 10PM. I haven't eaten anything yet. Hope this resolve the intermittent problem.
There is an App for that!
https://github.com/rickyzhang82
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by galgot »

Hi Rickyzhang,

Tried your latest, (not sure shat you mean by "Make sure commit is 61b04a892815273911f448601e45fbbfed1e5da8" btw, I just downloaded it from the page...).
Doesn't work, sorry :/

Tried what you asked, sniffed the all trafic for a while , host and guest, to see anything suspicious , found this strange :

Image

checked my LAN, there are no other machine using 192.168.0.64... so don't know why "duplicate use..."

anyway, I send you by PM the saved .pcapng from Wireshark so you can see. Two sessions.
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

You haven't used my latest branch! My fix on ARP should address the ARP duplicate problem.

In your local repo, run git log to check if commit hash. Another way to check is to see if file BasiliskII/src/Unix/Linux/NetDriver/README.md exists or not.

If it does, you are on the right track and commit. Rebuild the sheep_net module by runing

Code: Select all

sh build.sh [your account]
-- Edit
You ** must ** rebuild and reload sheep_net module. One way to check it is to run dmesg after you ping from guest OS.

Code: Select all

dmesg | grep sheep_net
Show what IP packet is dropped/kept by sheep_net module.

BTW, I also arp duplicate issues last night. It is because sheep_net broadcast its ARP back to host. It should be eliminated, otherwise it spoof ARP.

Code: Select all

https://github.com/rickyzhang82/macemu/commit/3bc95ecfd48d0765eaf97a119542214e685fc01e#diff-1f71d2ec5a6fd33f4701d42a7e37e520L503
There is an App for that!
https://github.com/rickyzhang82
galgot
Granny Smith
Posts: 119
Joined: Thu Feb 13, 2014 3:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by galgot »

README.md file is there. So I have the latest.
Rebuilded sheep_net twice, and reload.
Still no joy :/ sorry

Many thanks for your patience and work Rickyzhang, but if this takes too much of your time, just leave it. No prob.
User avatar
rickyzhang
Apple Corer
Posts: 205
Joined: Mon Sep 15, 2014 7:59 pm

Re: Sheep_net.ko on Debian 8 PPC

Post by rickyzhang »

No problem. Be patient! ;-)

I really want to fix this and send pull request.

Do you see anything dmesg | grep sheep_net? If it doesn't show drop and keep, you still use the old sheep_net.

You need to close BII to reload it.

--edit
Here is dmesg that show iCab http to www.google.com (IP 74.125.141.147) with my guest OS IP 192.168.2.111

Code: Select all

[  325.172791] sheep_net: got incoming unicast IP packet 74.125.141.147
[  325.201229] sheep_net: got incoming unicast IP packet 74.125.141.147
[  325.201496] sheep_net: got incoming unicast IP packet 74.125.141.147
[  325.201808] sheep_net: got incoming unicast IP packet 74.125.141.147
[  325.202475] sheep_net: got incoming unicast IP packet 74.125.141.147
[  325.228236] sheep_net: got incoming unicast IP packet 74.125.141.147
[  325.228510] sheep_net: got incoming unicast IP packet 74.125.141.147
[  325.236382] sheep_net: got incoming unicast IP packet 74.125.141.147
[  326.211811] sheep_net: filter out incoming IP packet 162.125.18.133 for keep filter 192.168.2.111
[  326.241937] sheep_net: filter out incoming IP packet 162.125.18.133 for keep filter 192.168.2.111
If you still want to debug it, copy dmesg | grep sheep_net to the post
There is an App for that!
https://github.com/rickyzhang82
Post Reply