summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Strachan <astrachan@google.com>2019-05-23 17:19:07 -0700
committerAlistair Strachan <astrachan@google.com>2019-05-28 13:37:20 -0700
commitd799900e7b137c9cdb4bac826228c9b817127535 (patch)
tree5116604d4b0e995537cee174d9174a650307691a
parentdbab6594bc99ab4026c051508af0bfe92487aef9 (diff)
downloadmtpd-d799900e7b137c9cdb4bac826228c9b817127535.tar.gz
Try OPNS/OLAC before PPTP/L2TP
When the PPTP/L2TP path was introduced, support for the features was determined simply by opening a socket with the appropriate upstream socket protocol types. However, it was later found that older kernels had bugs in their PPTP implementation which silently broke Android's use of the ppp tunnel, and must not be used. Unfortunately, some devices ship with CONFIG_PPTP or CONFIG_L2TP enabled *in addition* to the CONFIG_PPPOPNS or CONFIG_PPPOLAC Android extensions, but lacked the upstream fixes to PPTP/L2TP. This meant that mtpd would prefer the broken PPTP/L2TP features over the working OPNS/OLAC features. On newer kernels, which do not have broken PPTP/L2TP implementations, we have explicitly removed the Android OPNS/OLAC changes. This means even if we "prefer" the deprecated method, it will never be used, and PPTP/L2TP will always be used instead, which is what we want. This change maximizes compatibility with older broken kernels without sacrificing use of the modern path on kernels without the bugs. Bug: 116424816 Change-Id: Ic64426c76135b717a1da7013bc03501c03d19a6b
-rw-r--r--l2tp.c11
-rw-r--r--pptp.c11
2 files changed, 12 insertions, 10 deletions
diff --git a/l2tp.c b/l2tp.c
index 1d6171e..ae6088d 100644
--- a/l2tp.c
+++ b/l2tp.c
@@ -354,19 +354,20 @@ static int l2tp_connect(char **arguments)
}
/**
- * Check if upstream kernel implementation is enabled.
+ * Check if upstream kernel implementation of L2TP should be used.
*
- * @return true if upstream L2TP is enabled in kernel and false otherwise
+ * @return true If upstream L2TP should be used, which is the case if
+ * the obsolete OLAC feature is not available.
*/
static bool check_ol2tp(void)
{
- int fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OL2TP);
+ int fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OLAC);
if (fd < 0) {
- return false;
+ return true;
} else {
close(fd);
- return true;
+ return false;
}
}
diff --git a/pptp.c b/pptp.c
index 80eb24a..7a58a27 100644
--- a/pptp.c
+++ b/pptp.c
@@ -237,19 +237,20 @@ static int pptp_connect(char **arguments)
}
/**
- * Check if upstream kernel implementation is enabled.
+ * Check if upstream kernel implementation of PPTP should be used.
*
- * @return true if upstream PPTP is enabled in kernel and false otherwise
+ * @return true If upstream PPTP should be used, which is the case if
+ * the obsolete OPNS feature is not available.
*/
static bool check_pptp(void)
{
- int fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_PPTP);
+ int fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OPNS);
if (fd < 0) {
- return false;
+ return true;
} else {
close(fd);
- return true;
+ return false;
}
}