MEAM-Ware / android-wifi-tether

Automatically exported from code.google.com/p/android-wifi-tether
0 stars 0 forks source link

Packets get routed to wrong interface #367

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Which device (manufacturer, type)?
HTC Magic 32A

Which firmware is installed?
Stock HTC SenseUI firmware for Australia (Hutchison/Three) with engineering 
SPL. I rooted it by booting a recovery image with fastboot and using it to 
copy /system/bin/sh to /system/bin/su and setting owner to root/setting the 
suid bit.
I also checked /proc/config.gz and it has all the required kernel options 
statically built into the kernel.

It's android 1.5 (that's cupcake, yes?).
Baseband version 63.18.55.06JU_6.35.08.29
Kernel 2.6.27-5b476e83 htc-kernel@and18-2 #989
Build 3.05.861.2 CL#97012 release-keys

What version of wireless tether are you using?
I tried a whole bunch of them, what I have at the moment is 2.0.1

The computer is Win7 x86_64 with an Intel 5100. I know there was an issue 
with this card so I updated the driver to 13.1.1.1 but the problem 
persisted.

What steps will reproduce the problem?
What is the expected output? What do you see instead?

So, this is the result of trying to start tethering via adb shell

$su
#cd /data/data/android.tether/bin

Curiously,

#./ifconfig tiwlan0
tiwlan0: No such device

But OK, let's keep going...

#./tether start 1
about to run: [/system/bin/wlan_loader -f /system/etc/wifi/Fw1251r1c.bin -e 
/proc/calibration -i /data/data/android.teth
er/conf/tiwlan.ini]
about to run: [/data/data/android.tether/bin/ifconfig tiwlan0 192.168.2.254 
netmask 255.255.255.0]
about to run: [/data/data/android.tether/bin/ifconfig tiwlan0 up]
about to run: [/data/data/android.tether/bin/iptables -N wireless-tether]
about to run: [/data/data/android.tether/bin/iptables -F wireless-tether]
about to run: [/data/data/android.tether/bin/iptables -t nat -F PREROUTING]
about to run: [/data/data/android.tether/bin/iptables -t nat -F 
POSTROUTING]
about to run: [/data/data/android.tether/bin/iptables -t nat -F]
about to run: [/data/data/android.tether/bin/iptables -A wireless-tether -m 
state --state ESTABLISHED,RELATED -j ACCEPT]

about to run: [/data/data/android.tether/bin/iptables -A wireless-tether -s 
192.168.2.0/24 -j ACCEPT]
about to run: [/data/data/android.tether/bin/iptables -A wireless-tether -j 
DROP]
about to run: [/data/data/android.tether/bin/iptables -A FORWARD -j 
wireless-tether]
about to run: [/data/data/android.tether/bin/iptables -t nat -I POSTROUTING 
-s 192.168.2.0/24 -j MASQUERADE]
about to run: [/data/data/android.tether/bin/dnsmasq -i tiwlan0 --resolv-
file=/data/data/android.tether/conf/resolv.conf
 --conf-file=/data/data/android.tether/conf/dnsmasq.conf]
script result was []

This looks better

#./ifconfig tiwlan0
tiwlan0: ip 192.168.2.254 mask 255.255.255.0 flags [up broadcast multicast]

But this is odd

#./iwconfig tiwlan0
tiwlan0   no wireless extensions.

I don't know iptables, so i can't make sense of this

# ./iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
wireless-tether  0    --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain wireless-tether (1 references)
target     prot opt source               destination
ACCEPT     0    --  anywhere             anywhere            state 
RELATED,ESTABLISHED
FIX ME! implement getnetbyaddr() bionic/libc/bionic/stubs.c:366
ACCEPT     0    --  192.168.2.0/24       anywhere
DROP       0    --  anywhere             anywhere

Now, at this point, I can see the "AndroidTether" ad-hoc network in 
windows. So, I associate with it and try and get an IP

PS C:\Users\KJ> ipconfig /renew "Wireless Network Connection"

Windows IP Configuration

An error occurred while renewing interface Wireless Network Connection : 
unable to contact your DHCP server. Request has
 timed out.

dnsmasq is running...

#ps
<lots of stuff>
root     504   1     784   360   c00bf368 afe0c584 S 
/data/data/android.tether/bin/dnsmasq

So, I try setting a static IP on the laptop: 192.168.2.1, subnet mask 
255.255.255.0, gateway 192.168.2.254, DNS server as 8.8.8.8 (google public 
dns). Yet the problems persist

PS C:\Users\KJ> ping 192.168.2.254

Pinging 192.168.2.254 with 32 bytes of data:
Request timed out. (x4)

And from the phone,

# ping -c 4 192.168.2.1
PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data.

--- 192.168.2.1 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3034ms

Yet curiously,

# ping -I tiwlan0 -c 4 192.168.2.1
PING 192.168.2.1 (192.168.2.1) from 10.238.199.137 tiwlan0: 56(84) bytes of 
data.
64 bytes from 192.168.2.1: icmp_seq=1 ttl=128 time=6.31 ms
64 bytes from 192.168.2.1: icmp_seq=2 ttl=128 time=3.75 ms
64 bytes from 192.168.2.1: icmp_seq=3 ttl=128 time=3.78 ms
64 bytes from 192.168.2.1: icmp_seq=4 ttl=128 time=3.96 ms

--- 192.168.2.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3034ms
rtt min/avg/max/mdev = 3.754/4.455/6.317/1.079 ms

This also happend in issue 122, but nobody ever resolved it. It does seem 
to indicate that packets for the tethering client are going through the 
wrong interface, like was said there, but this looks right

# ip route
10.238.199.136/30 dev rmnet0  proto kernel  scope link  src 10.238.199.137
192.168.2.0/24 dev tiwlan0  proto kernel  scope link  src 192.168.2.254
default via 10.238.199.138 dev rmnet0

And watch this!
If I run these three commands in quick succession...

#cat /proc/net/dev
Inter-|   Receive                                                |  
Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    
packets errs drop fifo colls carrier compress
ed
    lo:       0       0    0    0    0     0          0         0        0       
0    0    0    0     0       0
 0
dummy0:       0       0    0    0    0     0          0         0        0      

0    0    0    0     0       0
 0
rmnet0:  330791     759    0    0    0     0          0         0   158023    
1331    0    0    0     0       0
 0
rmnet1:       0       0    0    0    0     0          0         0        0      

0    0    0    0     0       0
 0
rmnet2:       0       0    0    0    0     0          0         0        0      

0    0    0    0     0       0
 0
  usb0:       0       0    8    0    0     0          0         0        0       
0    0    0    0     0       0
 0
tiwlan0:  108556    1500    0    0    0     0          0         0     2882     

56    0    0    0     0       0
  0

PS C:\Users\KJ> ping 192.168.2.254 -n 1

Pinging 192.168.2.254 with 32 bytes of data:
Request timed out.

Ping statistics for 192.168.2.254:
    Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),

#cat /proc/net/dev
Inter-|   Receive                                                |  
Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    
packets errs drop fifo colls carrier compress
ed
    lo:       0       0    0    0    0     0          0         0        0       
0    0    0    0     0       0
 0
dummy0:       0       0    0    0    0     0          0         0        0      

0    0    0    0     0       0
 0
rmnet0:  330791     759    0    0    0     0          0         0   158097    
1332    0    0    0     0       0
 0
rmnet1:       0       0    0    0    0     0          0         0        0      

0    0    0    0     0       0
 0
rmnet2:       0       0    0    0    0     0          0         0        0      

0    0    0    0     0       0
 0
  usb0:       0       0    8    0    0     0          0         0        0       
0    0    0    0     0       0
 0
tiwlan0:  108616    1501    0    0    0     0          0         0     2882     

56    0    0    0     0       0
  0

Whilst this isn't conclusive as the packet counts can be changed by other 
things, it would seem that since 1331+1 = 1332 and 1500+1 = 1501 that the 
phone is recieving ping packets on tiwlan0 and sending the replies on 
rmnet0! (this is the 3g connection, right?) I'm going to change the title 
of this to something a bit more descriptive now :P

As a side note, I tried using bluetooth but it didn't come up in the list 
of PAN networks to connect to on windows. The wlan stuff looks a bit more 
fundamental though.

Any ideas anyone?
Many thanks,
KJ

Original issue reported on code.google.com by greeklegend@gmail.com on 6 Jun 2010 at 3:08

GoogleCodeExporter commented 9 years ago
Gah, can't find the edit button. Well, I refer to comment 91 in issue 122, not 
122 
itself.

Original comment by greeklegend@gmail.com on 6 Jun 2010 at 3:11

GoogleCodeExporter commented 9 years ago
This issue tracker really needs an edit button. After reading the entirety of 
issue 
122, it seems that what I describe here might be the problem there (based on 
the output 
of cat /proc/net/dev) but most people were for some reason able to get IP 
addresses. 
However the solution turned out to be to install a custom ROM, which i'd rather 
not do 
(the stock one i'm running is really good :) )

Original comment by greeklegend@gmail.com on 6 Jun 2010 at 3:30