guerrerolor / android-x86

Automatically exported from code.google.com/p/android-x86
2 stars 1 forks source link

VPN PPTP Failure #451

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add to kernel build (CONFIG_PPP, CONFIG_PPP_ASYNC, CONFIG_PPP_SYNC,
     CONFIG_PPP_DEFLATE, CONFIG_PPP_BSDCOMP, CONFIG_PPP_MPPE, CONFIG_PPPOLAC
     CONFIG_PPPOPNS, CONFIG_INET_AH, CONFIG_INET_ESP, CONFIG_INET_IPCOMP,
     CONFIG_INET_XFRM_MODE_TRANSPORT, CONFIG_INET_XFRM_MODE_TUNNEL,
     CONFIG_INET_XFRM_MODE_BEET)

2. Build Kernel / Android
3. Enable Ethernet
4. Test network connection. ping www.xyz.com. (make sure ethernet / dns / 
routes work)
5. make sure you can ping the vpn router
6. make a pptp vpn connection in (settings / wirless / vpn) in android gui
    or run from console
    (mtpd pptp xx.xx.xx.xx 1723 "linkname vpn name xxxxx password xxxx refuse_eap nodefaultroute usepeerdns idle 1800 mtu 1300 mru 1300" &) with out mppe
    (mtpd pptp xx.xx.xx.xx 1723 "linkname vpn name xxxxx password xxxx refuse_eap nodefaultroute usepeerdns idle 1800 mtu 1300 mru 1300 +mppe" &) with mppe

What is the expected output? What do you see instead?
should see a connection made
running logcat we see

I/mtpd    (2343): Using protocol pptp
I/mtpd    (2343): Connecting 192.168.220.238 port 1723
I/mtpd    (2343): Connection established (socket = 10)
D/mtpd    (2343): Sending SCCRQ
D/mtpd    (2343): Received SCCRP -> Sending OCRQ (local = 12339) -- Here we see 
that the SCCRP is received line 290 in pptp.c 
I/mtpd    (2343): Tunnel established
D/mtpd    (2343): Received OCRQ (remote = 10255)
I/mtpd    (2343): Session established
I/mtpd    (2343): Creating PPPoX socket -- mtpd.c calling pptp.c create_pppox 
line 237
F/mtpd    (2343): Connect() Invalid argument -- pptp.c line 252

mtpd dies

pptp.c -- create_pppox starting at line 251 

        if (connect(pppox, (struct sockaddr *)&address, sizeof(address)) != 0) {
            log_print(FATAL, "Connect() %s", strerror(errno));
        exit(SYSTEM_ERROR);
        }

sterror(errno) is returning Invalid argument
system exits with error and mtpd terminates
(sizeof(address)) is returning = 14

What version of the product are you using? On what operating system?
Andorid-x86 generic-x86 latest 2.4.7

Please provide any additional information below.

Added code to pptp.c in external/mtpd
to display sizeof(address)
size of address returned from connect(pppox,
is = 14.

code below

static int create_pppox()
{
    int pppox;
    log_print(INFO, "Creating PPPoX socket");
    pppox = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OPNS);

    if (pppox == -1) {
        log_print(FATAL, "Socket() %s", strerror(errno));
        exit(SYSTEM_ERROR);
    } else {
        struct sockaddr_pppopns address = {
            .sa_family = AF_PPPOX,
            .sa_protocol = PX_PROTO_OPNS,
            .tcp_socket = the_socket,
            .local = local,
            .remote = remote,
        };
        if (connect(pppox, (struct sockaddr *)&address, sizeof(address)) != 0) {
            log_print(FATAL, "Connect() %s", strerror(errno));
            log_print(FATAL, "CONNECT address size %d", sizeof(address);
            exit(SYSTEM_ERROR);
        }
    }
    return pppox;
}

Looks like a problem in connect(pppox,

VPN routers tried are MikroTik 5.4, MS Windows 2003, MS Windows 2008, DlinkWhat 

Original issue reported on code.google.com by markesse...@gmail.com on 2 Nov 2011 at 8:19

GoogleCodeExporter commented 9 years ago
TYPE Android 2.3.7 Nov 2, 2011 git

Original comment by markesse...@gmail.com on 2 Nov 2011 at 8:22

GoogleCodeExporter commented 9 years ago
I have found the answer to this problem. This goes all the way back to the 
master branch and was introduced by changes made in 2009 (FROYO)

PX_PROTO_OLAC and PX_PROTO_OPNS in the Bionic / libc /kernel / linux chain do 
not match those in the kernel / include chain!!!

Sloppy Coding and/or checking

Please forgive my Sloppy comment, but I have coded to the DOD-2167 standard 
from the start of time.

The Patch is

--------------------------------------------------------------------------------
----

diff --git a/libc/kernel/common/linux/if_pppolac.h 
b/libc/kernel/common/linux/if_pppolac.h
index bf6eba0..f3c8bb1 100644
--- a/libc/kernel/common/linux/if_pppolac.h
+++ b/libc/kernel/common/linux/if_pppolac.h
@@ -15,7 +15,8 @@
 #include <linux/socket.h>
 #include <linux/types.h>

-#define PX_PROTO_OLAC 2
+/* was 2 */
+#define PX_PROTO_OLAC 3

 struct sockaddr_pppolac {
  sa_family_t sa_family;
--------------------------------------------------------------------------------
----

diff --git a/libc/kernel/common/linux/if_pppopns.h 
b/libc/kernel/common/linux/if_pppopns.h
index ac75210..106b4d1 100644
--- a/libc/kernel/common/linux/if_pppopns.h
+++ b/libc/kernel/common/linux/if_pppopns.h
@@ -15,7 +15,8 @@
 #include <linux/socket.h>
 #include <linux/types.h>

-#define PX_PROTO_OPNS 3
+/* was 3 */
+#define PX_PROTO_OPNS 4

 struct sockaddr_pppopns {
  sa_family_t sa_family;

Original comment by markesse...@gmail.com on 4 Nov 2011 at 2:02