diff options
author | Maciej Żenczykowski <maze@google.com> | 2019-04-08 17:46:48 -0700 |
---|---|---|
committer | Maciej Żenczykowski <maze@google.com> | 2019-05-08 21:02:19 -0700 |
commit | 8addcc0f6360cc3762e9ef27437ded250e785da3 (patch) | |
tree | ac9a90d6280e22785aaca68db210bf5612ea1b13 /tun.c | |
parent | 3297c7d7bca85db2b178e8838138b71e9d2a86ad (diff) | |
download | platform_external_android-clat-android10-d4-s1-release.tar.gz platform_external_android-clat-android10-d4-s1-release.tar.bz2 platform_external_android-clat-android10-d4-s1-release.zip |
clatd: change to pass in tun filedescriptor via command lineandroid-mainline-10.0.0_r9android-mainline-10.0.0_r7android-mainline-10.0.0_r5android-mainline-10.0.0_r4android-mainline-10.0.0_r10android-10.0.0_r9android-10.0.0_r8android-10.0.0_r7android-10.0.0_r45android-10.0.0_r44android-10.0.0_r43android-10.0.0_r42android-10.0.0_r41android-10.0.0_r40android-10.0.0_r39android-10.0.0_r38android-10.0.0_r37android-10.0.0_r36android-10.0.0_r35android-10.0.0_r34android-10.0.0_r33android-10.0.0_r32android-10.0.0_r31android-10.0.0_r30android-10.0.0_r14android-10.0.0_r13android-10.0.0_r12android10-qpr3-s1-releaseandroid10-qpr3-releaseandroid10-qpr2-s4-releaseandroid10-qpr2-s3-releaseandroid10-qpr2-s2-releaseandroid10-qpr2-s1-releaseandroid10-qpr2-releaseandroid10-qpr1-mainline-releaseandroid10-mainline-media-releaseandroid10-devandroid10-d4-s1-releaseandroid10-d4-releaseandroid10-c2f2-s2-releaseandroid10-c2f2-s1-releaseandroid10-c2f2-release
Test: atest clatd_test, built and installed on aosp_blueline device
connected to ipv6-only wifi network: ping 8.8.8.8 still works
and it is via v4-wlan0 clat tun interface
Bug: 65674744
Bug: 131268436
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8c9e235e9a5bf1a1436e8dc3af8d0aa86f6dc1a5
Merged-In: I8c9e235e9a5bf1a1436e8dc3af8d0aa86f6dc1a5
(cherry picked from commit 716518d9b9ca52182498b1d7ed0f0ed8ab42cbe1)
Diffstat (limited to 'tun.c')
-rw-r--r-- | tun.c | 29 |
1 files changed, 3 insertions, 26 deletions
@@ -21,20 +21,19 @@ #include <linux/if_tun.h> #include <string.h> #include <sys/ioctl.h> -#include <sys/uio.h> #include <unistd.h> #include "common.h" /* function: tun_open - * tries to open the tunnel device + * tries to open the tunnel device in non-blocking mode */ int tun_open() { int fd; - fd = open("/dev/tun", O_RDWR | O_CLOEXEC); + fd = open("/dev/tun", O_RDWR | O_NONBLOCK | O_CLOEXEC); if (fd < 0) { - fd = open("/dev/net/tun", O_RDWR | O_CLOEXEC); + fd = open("/dev/net/tun", O_RDWR | O_NONBLOCK | O_CLOEXEC); } return fd; @@ -65,25 +64,3 @@ int tun_alloc(char *dev, int fd, size_t len) { strlcpy(dev, ifr.ifr_name, len); return 0; } - -/* function: set_nonblocking - * sets a filedescriptor to non-blocking mode - * fd - the filedescriptor - * returns: 0 on success, -1 on failure - */ -int set_nonblocking(int fd) { - int flags = fcntl(fd, F_GETFL); - if (flags == -1) { - return flags; - } - return fcntl(fd, F_SETFL, flags | O_NONBLOCK); -} - -/* function: send_tun - * sends a clat_packet to a tun interface - * fd - the tun filedescriptor - * out - the packet to send - * iov_len - the number of entries in the clat_packet - * returns: number of bytes read on success, -1 on failure - */ -int send_tun(int fd, clat_packet out, int iov_len) { return writev(fd, out, iov_len); } |