[PATCH] Get things working under Darwin

90 views
Skip to first unread message

Lars Eggert

unread,
Jun 10, 2014, 10:53:54 AM6/10/14
to packe...@googlegroups.com, Lars Eggert
Get things working under Darwin. Since the tuntap driver [1]
only provides a point-to-point interface, we need to pass around local and
remote IP addresses to configure it correctly.

[1] http://tuntaposx.sourceforge.net
---
gtests/net/packetdrill/Makefile.Darwin | 3 +
gtests/net/packetdrill/Makefile.common | 4 +-
gtests/net/packetdrill/link_layer.c | 4 +-
gtests/net/packetdrill/net_utils.c | 62 +++---
gtests/net/packetdrill/net_utils.h | 6 +-
gtests/net/packetdrill/netdev.c | 33 ++-
gtests/net/packetdrill/packet_socket_pcap.c | 6 +-
gtests/net/packetdrill/platforms.h | 16 ++
gtests/net/packetdrill/run.c | 4 +-
gtests/net/packetdrill/run_system_call.c | 26 ++-
gtests/net/packetdrill/symbols_darwin.c | 310 ++++++++++++++++++++++++++++
gtests/net/packetdrill/wire_client_netdev.c | 1 +
gtests/net/packetdrill/wire_server_netdev.c | 1 +
13 files changed, 431 insertions(+), 45 deletions(-)
create mode 100644 gtests/net/packetdrill/Makefile.Darwin
create mode 100644 gtests/net/packetdrill/symbols_darwin.c

diff --git a/gtests/net/packetdrill/Makefile.Darwin b/gtests/net/packetdrill/Makefile.Darwin
new file mode 100644
index 0000000..d6ca711
--- /dev/null
+++ b/gtests/net/packetdrill/Makefile.Darwin
@@ -0,0 +1,3 @@
+packetdrill-ext-libs := -lpthread -lpcap
+LDFLAGS :=
+include Makefile.common
diff --git a/gtests/net/packetdrill/Makefile.common b/gtests/net/packetdrill/Makefile.common
index 0ec741f..9b4a675 100644
--- a/gtests/net/packetdrill/Makefile.common
+++ b/gtests/net/packetdrill/Makefile.common
@@ -1,6 +1,7 @@
all: binaries

CFLAGS = -g -Wall -Werror
+LDFLAGS ?= -static

parser.o: parser.y
bison --output=parser.c --defines=parser.h --report=state parser.y
@@ -19,6 +20,7 @@ packetdrill-lib := \
symbols_freebsd.o \
symbols_openbsd.o \
symbols_netbsd.o \
+ symbols_darwin.o \
gre_packet.o icmp_packet.o ip_packet.o tcp_packet.o udp_packet.o \
mpls_packet.o \
run.o run_command.o run_packet.o run_system_call.o \
@@ -33,7 +35,7 @@ packetdrill-lib := \
packetdrill-objs := packetdrill.o $(packetdrill-lib)

packetdrill: $(packetdrill-objs)
- $(CC) -o packetdrill -g -static $(packetdrill-objs) $(packetdrill-ext-libs)
+ $(CC) -o packetdrill -g $(LDFLAGS) $(packetdrill-objs) $(packetdrill-ext-libs)

test-bins := checksum_test packet_parser_test packet_to_string_test
tests: $(test-bins)
diff --git a/gtests/net/packetdrill/link_layer.c b/gtests/net/packetdrill/link_layer.c
index 45f5b66..e8445a2 100644
--- a/gtests/net/packetdrill/link_layer.c
+++ b/gtests/net/packetdrill/link_layer.c
@@ -66,13 +66,13 @@ void get_hw_address(const char *name, struct ether_addr *hw_address)

#else

-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__)
#include <net/if_types.h>
#include <net/if_dl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ifaddrs.h>
-#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) */
+#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__) */

void get_hw_address(const char *name, struct ether_addr *hw_address)
{
diff --git a/gtests/net/packetdrill/net_utils.c b/gtests/net/packetdrill/net_utils.c
index 1b59d64..2582aac 100644
--- a/gtests/net/packetdrill/net_utils.c
+++ b/gtests/net/packetdrill/net_utils.c
@@ -43,22 +43,28 @@ static void verbose_system(const char *command)

/* Configure a local IPv4 address and netmask for the device */
static void net_add_ipv4_address(const char *dev_name,
- const struct ip_address *ip,
+ const struct ip_address *local,
+ const struct ip_address *remote,
int prefix_len)
{
char *command = NULL;
- char ip_string[ADDR_STR_LEN];
+ char local_string[ADDR_STR_LEN], remote_string[ADDR_STR_LEN];

- ip_to_string(ip, ip_string);
+ ip_to_string(local, local_string);
+ ip_to_string(remote, remote_string);

#ifdef linux
asprintf(&command, "ip addr add %s/%d dev %s > /dev/null 2>&1",
- ip_string, prefix_len, dev_name);
+ local_string, prefix_len, dev_name);
#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
asprintf(&command, "/sbin/ifconfig %s %s/%d alias",
- dev_name, ip_string, prefix_len);
-#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) */
+ dev_name, local_string, prefix_len);
+#elif defined(__MACH__)
+ /* tuntap is a point-to-point interface on Darwin */
+ asprintf(&command, "/sbin/ifconfig %s %s/%d %s alias",
+ dev_name, local_string, prefix_len, remote_string);
+#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__) */

verbose_system(command);
free(command);
@@ -66,24 +72,28 @@ static void net_add_ipv4_address(const char *dev_name,

/* Configure a local IPv6 address and prefix length for the device */
static void net_add_ipv6_address(const char *dev_name,
- const struct ip_address *ip,
+ const struct ip_address *local,
+ const struct ip_address *remote,
int prefix_len)
{
char *command = NULL;
- char ip_string[ADDR_STR_LEN];
+ char local_string[ADDR_STR_LEN], remote_string[ADDR_STR_LEN];

- ip_to_string(ip, ip_string);
+ ip_to_string(local, local_string);
+ ip_to_string(remote, remote_string);

#ifdef linux
-
asprintf(&command, "ip addr add %s/%d dev %s > /dev/null 2>&1",
- ip_string, prefix_len, dev_name);
+ local_string, prefix_len, dev_name);
#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
-
asprintf(&command, "/sbin/ifconfig %s inet6 %s/%d",
- dev_name, ip_string, prefix_len);
-#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) */
+ dev_name, local_string, prefix_len);
+#elif defined(__MACH__)
+ /* tuntap is a point-to-point interface on Darwin */
+ asprintf(&command, "/sbin/ifconfig %s inet6 %s/%d %s alias",
+ dev_name, local_string, prefix_len, remote_string);
+#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__) */

verbose_system(command);
free(command);
@@ -97,21 +107,22 @@ static void net_add_ipv6_address(const char *dev_name,
if (!strstr(dev_name, "tun"))
sleep(2);
#endif
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__)
sleep(3);
#endif
}

void net_add_dev_address(const char *dev_name,
- const struct ip_address *ip,
+ const struct ip_address *local,
+ const struct ip_address *remote,
int prefix_len)
{
- switch (ip->address_family) {
+ switch (local->address_family) {
case AF_INET:
- net_add_ipv4_address(dev_name, ip, prefix_len);
+ net_add_ipv4_address(dev_name, local, remote, prefix_len);
break;
case AF_INET6:
- net_add_ipv6_address(dev_name, ip, prefix_len);
+ net_add_ipv6_address(dev_name, local, remote, prefix_len);
break;
default:
assert(!"bad family");
@@ -132,12 +143,12 @@ void net_del_dev_address(const char *dev_name,
asprintf(&command, "ip addr del %s/%d dev %s > /dev/null 2>&1",
ip_string, prefix_len, dev_name);
#endif
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__)
asprintf(&command, "/sbin/ifconfig %s %s %s/%d -alias",
dev_name,
ip->address_family == AF_INET6 ? "inet6" : "",
ip_string, prefix_len);
-#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) */
+#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__) */

verbose_system(command);
free(command);
@@ -152,12 +163,13 @@ void net_del_dev_address(const char *dev_name,
* and add it on the newly-requested device.
*/
void net_setup_dev_address(const char *dev_name,
- const struct ip_address *ip,
+ const struct ip_address *local,
+ const struct ip_address *remote,
int prefix_len)
{
char cur_dev_name[IFNAMSIZ];

- bool found = get_ip_device(ip, cur_dev_name);
+ bool found = get_ip_device(local, cur_dev_name);

DEBUGP("net_setup_dev_address: found: %d\n", found);

@@ -167,6 +179,6 @@ void net_setup_dev_address(const char *dev_name,
}

if (found)
- net_del_dev_address(cur_dev_name, ip, prefix_len);
- net_add_dev_address(dev_name, ip, prefix_len);
+ net_del_dev_address(cur_dev_name, local, prefix_len);
+ net_add_dev_address(dev_name, local, remote, prefix_len);
}
diff --git a/gtests/net/packetdrill/net_utils.h b/gtests/net/packetdrill/net_utils.h
index bdc1009..bf300b0 100644
--- a/gtests/net/packetdrill/net_utils.h
+++ b/gtests/net/packetdrill/net_utils.h
@@ -34,7 +34,8 @@
* to the given device.
*/
extern void net_add_dev_address(const char *dev_name,
- const struct ip_address *ip,
+ const struct ip_address *local,
+ const struct ip_address *remote,
int prefix_len);

/* Delete the given IP address, with the given subnet/prefix length,
@@ -50,7 +51,8 @@ extern void net_del_dev_address(const char *dev_name,
* add it to the given network device.
*/
extern void net_setup_dev_address(const char *dev_name,
- const struct ip_address *ip,
+ const struct ip_address *local,
+ const struct ip_address *remote,
int prefix_len);

#endif /* __NET_UTILS_H__ */
diff --git a/gtests/net/packetdrill/netdev.c b/gtests/net/packetdrill/netdev.c
index aeca2da..0e33be8 100644
--- a/gtests/net/packetdrill/netdev.c
+++ b/gtests/net/packetdrill/netdev.c
@@ -55,6 +55,12 @@
#include "tcp.h"
#include "tun.h"

+#ifdef __MACH__
+/* See http://sourceforge.net/p/tuntaposx/code/ci/master/tree/tuntap/ */
+#define TUNSIFHEAD _IOW('t', 96, int)
+#define TUNGIFHEAD _IOR('t', 97, int)
+#endif
+
/* Internal private state for the netdev for purely local tests. */
struct local_netdev {
struct netdev netdev; /* "inherit" from netdev */
@@ -141,15 +147,19 @@ static void create_device(struct config *config, struct local_netdev *netdev)
netdev->name = strdup(TUN_DEV);
#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) */

-#if defined(__FreeBSD__) || defined(__NetBSD__)
- /* On FreeBSD and NetBSD we need to explicitly ask to be able
+#ifdef __MACH__
+ netdev->name = strdup(TUN_DEV);
+#endif
+
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__MACH__)
+ /* On FreeBSD, NetBSD and Darwin we need to explicitly ask to be able
* to prepend the address family when injecting tun packets.
* OpenBSD presumes we are doing this, even without the ioctl.
*/
const int header = 1;
if (ioctl(netdev->tun_fd, TUNSIFHEAD, &header, sizeof(header)) < 0)
die_perror("TUNSIFHEAD");
-#endif /* defined(__FreeBSD__) || defined(__NetBSD__) */
+#endif /* defined(__FreeBSD__) || defined(__NetBSD__) || defined(__MACH__) */

DEBUGP("tun name: '%s'\n", netdev->name);

@@ -235,7 +245,7 @@ static void route_traffic_to_device(struct config *config,
netdev->name,
config->live_gateway_ip_string);
#endif
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__)
if (config->wire_protocol == AF_INET) {
asprintf(&route_command,
"route delete %s > /dev/null 2>&1 ; "
@@ -248,7 +258,7 @@ static void route_traffic_to_device(struct config *config,
"route delete -inet6 %s > /dev/null 2>&1 ; "
#if defined(__FreeBSD__)
"route add -inet6 %s -interface tun0 %s > /dev/null",
-#elif defined(__OpenBSD__) || defined(__NetBSD__)
+#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__)
"route add -inet6 %s %s > /dev/null",
#endif
config->live_remote_prefix_string,
@@ -257,7 +267,7 @@ static void route_traffic_to_device(struct config *config,
} else {
assert(!"bad wire protocol");
}
-#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) */
+#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__) */
int result = system(route_command);
if ((result == -1) || (WEXITSTATUS(result) != 0)) {
die("error executing route command '%s'\n",
@@ -281,6 +291,7 @@ struct netdev *local_netdev_new(struct config *config)

net_setup_dev_address(netdev->name,
&config->live_local_ip,
+ &config->live_remote_ip,
config->live_prefix_len);

route_traffic_to_device(config, netdev);
@@ -307,7 +318,7 @@ static void local_netdev_free(struct netdev *a_netdev)
free(netdev);
}

-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__)
/* According to `man 4 tun` on OpenBSD: "Each packet read or written
* is prefixed with a tunnel header consisting of a 4-byte network
* byte order integer containing the address family in the case of
@@ -328,7 +339,7 @@ static void bsd_tun_write(struct local_netdev *netdev,
if (writev(netdev->tun_fd, vector, ARRAY_SIZE(vector)) < 0)
die_perror("BSD tun write()");
}
-#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) */
+#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__) */

#ifdef linux
static void linux_tun_write(struct local_netdev *netdev,
@@ -342,7 +353,9 @@ static void linux_tun_write(struct local_netdev *netdev,
static int local_netdev_send(struct netdev *a_netdev,
struct packet *packet)
{
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__)
struct local_netdev *netdev = to_local_netdev(a_netdev);
+#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__) */

assert(packet->ip_bytes > 0);
/* We do IPv4 and IPv6 */
@@ -352,9 +365,9 @@ static int local_netdev_send(struct netdev *a_netdev,

DEBUGP("local_netdev_send\n");

-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__)
bsd_tun_write(netdev, packet);
-#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) */
+#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__) */

#ifdef linux
linux_tun_write(netdev, packet);
diff --git a/gtests/net/packetdrill/packet_socket_pcap.c b/gtests/net/packetdrill/packet_socket_pcap.c
index 9b22101..ae620d4 100644
--- a/gtests/net/packetdrill/packet_socket_pcap.c
+++ b/gtests/net/packetdrill/packet_socket_pcap.c
@@ -39,6 +39,10 @@
#include <pcap/pcap.h>
#elif defined(__OpenBSD__) || defined(__NetBSD__)
#include <pcap.h>
+#elif defined(__MACH__)
+#define PCAP_DONT_INCLUDE_PCAP_BPF_H
+#include <net/bpf.h>
+#include <pcap.h>
#endif

#include "ethernet.h"
@@ -252,7 +256,7 @@ int packet_socket_receive(struct packet_socket *psock,
(u32)pkt_header->ts.tv_sec,
(u32)pkt_header->ts.tv_usec);

-#if defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__MACH__)
packet->time_usecs = timeval_to_usecs(&pkt_header->ts);
#elif defined(__OpenBSD__)
packet->time_usecs = bpf_timeval_to_usecs(&pkt_header->ts);
diff --git a/gtests/net/packetdrill/platforms.h b/gtests/net/packetdrill/platforms.h
index 5fdda2c..33a384d 100644
--- a/gtests/net/packetdrill/platforms.h
+++ b/gtests/net/packetdrill/platforms.h
@@ -92,5 +92,21 @@

#endif /* __NetBSD__ */

+/* ------------------------- MacOS X --------------------- */
+
+#if defined(__MACH__)
+
+#define SOL_TCP IPPROTO_TCP
+
+#define USE_LIBPCAP 1
+#define TUN_PATH "/dev/tun0"
+#define TUN_DEV "tun0"
+
+#include "fmemopen.h"
+#include "open_memstream.h"
+
+#define __always_inline __attribute__((__always_inline__))
+
+#endif /* __MACH__ */

#endif /* __PLATFORMS_H__ */
diff --git a/gtests/net/packetdrill/run.c b/gtests/net/packetdrill/run.c
index a326019..f1d002b 100644
--- a/gtests/net/packetdrill/run.c
+++ b/gtests/net/packetdrill/run.c
@@ -407,7 +407,7 @@ void set_scheduling_priority(void)
if (num_cpus <= 1)
return;

-#if !defined(__OpenBSD__)
+#if !defined(__OpenBSD__) && !defined(__MACH__)
/* Chose a real-time policy, but use SCHED_RR instead of
* SCHED_FIFO, so that we round-robin among real-time threads
* of the same priority. In practice this shouldn't matter,
@@ -434,8 +434,10 @@ void set_scheduling_priority(void)
*/
void lock_memory(void)
{
+#ifndef __MACH__
if (mlockall(MCL_CURRENT | MCL_FUTURE))
die_perror("lockall(MCL_CURRENT | MCL_FUTURE)");
+#endif
}

/* Wait for and return the wall time at which we should start the
diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c
index 8a88598..202582d 100644
--- a/gtests/net/packetdrill/run_system_call.c
+++ b/gtests/net/packetdrill/run_system_call.c
@@ -48,16 +48,36 @@
static int to_live_fd(struct state *state, int script_fd, int *live_fd,
char **error);

+#ifdef __MACH__
+#include <mach/clock.h>
+#include <mach/mach.h>
+
+#define CLOCK_REALTIME CALENDAR_CLOCK
+
+int clock_gettime(__int32_t clock_id, struct timespec *tp)
+{
+ clock_serv_t cclock;
+ mach_timespec_t mts;
+
+ host_get_clock_service(mach_host_self(), clock_id, &cclock);
+ clock_get_time(cclock, &mts);
+ mach_port_deallocate(mach_task_self(), cclock);
+ tp->tv_sec = mts.tv_sec;
+ tp->tv_nsec = mts.tv_nsec;
+ return 0;
+}
+#endif
+
/* Provide a wrapper for the Linux gettid() system call (glibc does not). */
static pid_t gettid(void)
{
#ifdef linux
return syscall(__NR_gettid);
#endif
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__)
/* TODO(ncardwell): Implement me. XXX */
return 0;
-#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)*/
+#endif /* defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__MACH__) */
}

/* Read a whole file into the given buffer of the given length. */
@@ -1795,7 +1815,7 @@ static int yield(void)
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
pthread_yield();
return 0;
-#elif defined(__NetBSD__)
+#elif defined(__NetBSD__) || defined(__MACH__)
return sched_yield();
#endif /* defined(__NetBSD__) */
}
diff --git a/gtests/net/packetdrill/symbols_darwin.c b/gtests/net/packetdrill/symbols_darwin.c
new file mode 100644
index 0000000..5de0a57
--- /dev/null
+++ b/gtests/net/packetdrill/symbols_darwin.c
@@ -0,0 +1,310 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+/*
+ * Author: ncar...@google.com (Neal Cardwell)
+ *
+ * Definitions of strace-style symbols for FreeBSD.
+ * Allows us to map from symbolic strings to integers for system call inputs.
+ */
+
+#if defined(__MACH__)
+
+#include "symbols.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <netinet/in.h>
+#include <netinet/udp.h>
+#include <poll.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/unistd.h>
+
+#include "tcp.h"
+
+/* A table of platform-specific string->int mappings. */
+struct int_symbol platform_symbols_table[] = {
+
+ /* /usr/include/sys/socket.h */
+ { SO_DEBUG, "SO_DEBUG" },
+ { SO_ACCEPTCONN, "SO_ACCEPTCONN" },
+ { SO_REUSEADDR, "SO_REUSEADDR" },
+ { SO_KEEPALIVE, "SO_KEEPALIVE" },
+ { SO_DONTROUTE, "SO_DONTROUTE" },
+ { SO_BROADCAST, "SO_BROADCAST" },
+ { SO_USELOOPBACK, "SO_USELOOPBACK" },
+ { SO_LINGER, "SO_LINGER" },
+ { SO_OOBINLINE, "SO_OOBINLINE" },
+ { SO_REUSEPORT, "SO_REUSEPORT" },
+ { SO_TIMESTAMP, "SO_TIMESTAMP" },
+ { SO_NOSIGPIPE, "SO_NOSIGPIPE" },
+ { SO_DONTTRUNC, "SO_DONTTRUNC" },
+ // { SO_BINTIME, "SO_BINTIME" },
+ // { SO_NO_OFFLOAD, "SO_NO_OFFLOAD" },
+ // { SO_NO_DDP, "SO_NO_DDP" },
+ { SO_SNDBUF, "SO_SNDBUF" },
+ { SO_RCVBUF, "SO_RCVBUF" },
+ { SO_SNDLOWAT, "SO_SNDLOWAT" },
+ { SO_RCVLOWAT, "SO_RCVLOWAT" },
+ { SO_SNDTIMEO, "SO_SNDTIMEO" },
+ { SO_RCVTIMEO, "SO_RCVTIMEO" },
+ { SO_ERROR, "SO_ERROR" },
+ { SO_TYPE, "SO_TYPE" },
+ { SO_LABEL, "SO_LABEL" },
+ { SO_PEERLABEL, "SO_PEERLABEL" },
+ // { SO_LISTENQLIMIT, "SO_LISTENQLIMIT" },
+ // { SO_LISTENQLEN, "SO_LISTENQLEN" },
+ // { SO_LISTENINCQLEN, "SO_LISTENINCQLEN" },
+ // { SO_SETFIB, "SO_SETFIB" },
+ // { SO_USER_COOKIE, "SO_USER_COOKIE" },
+
+ /* /usr/include/netinet/tcp.h */
+ { TCP_NODELAY, "TCP_NODELAY" },
+ { TCP_MAXSEG, "TCP_MAXSEG" },
+ { TCP_NOPUSH, "TCP_NOPUSH" },
+ { TCP_NOOPT, "TCP_NOOPT" },
+ // { TCP_MD5SIG, "TCP_MD5SIG" },
+ // { TCP_INFO, "TCP_INFO" },
+ // { TCP_CONGESTION, "TCP_CONGESTION" },
+
+ /* /usr/include/sys/fcntl.h */
+ { O_RDONLY, "O_RDONLY" },
+ { O_WRONLY, "O_WRONLY" },
+ { O_RDWR, "O_RDWR" },
+ { O_ACCMODE, "O_ACCMODE" },
+ { FREAD, "FREAD" },
+ { FWRITE, "FWRITE" },
+ { O_NONBLOCK, "O_NONBLOCK" },
+ { O_APPEND, "O_APPEND" },
+ { O_SHLOCK, "O_SHLOCK" },
+ { O_EXLOCK, "O_EXLOCK" },
+ { O_ASYNC, "O_ASYNC" },
+ { O_FSYNC, "O_FSYNC" },
+ { O_SYNC, "O_SYNC" },
+ { O_NOFOLLOW, "O_NOFOLLOW" },
+ { O_CREAT, "O_CREAT" },
+ { O_TRUNC, "O_TRUNC" },
+ { O_EXCL, "O_EXCL" },
+ { O_NOCTTY, "O_NOCTTY" },
+ // { O_DIRECT, "O_DIRECT" },
+ { O_DIRECTORY, "O_DIRECTORY" },
+ // { O_EXEC, "O_EXEC" },
+ // { O_TTY_INIT, "O_TTY_INIT" },
+ { O_CLOEXEC, "O_CLOEXEC" },
+ { FAPPEND, "FAPPEND" },
+ { FASYNC, "FASYNC" },
+ { FFSYNC, "FFSYNC" },
+ { FNONBLOCK, "FNONBLOCK" },
+ { FNDELAY, "FNDELAY" },
+ { O_NDELAY, "O_NDELAY" },
+ // { FRDAHEAD, "FRDAHEAD" },
+ // { AT_FDCWD, "AT_FDCWD" },
+ // { AT_EACCESS, "AT_EACCESS" },
+ // { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" },
+ // { AT_SYMLINK_FOLLOW, "AT_SYMLINK_FOLLOW" },
+ // { AT_REMOVEDIR, "AT_REMOVEDIR" },
+ { F_DUPFD, "F_DUPFD" },
+ { F_GETFD, "F_GETFD" },
+ { F_SETFD, "F_SETFD" },
+ { F_GETFL, "F_GETFL" },
+ { F_SETFL, "F_SETFL" },
+ { F_GETOWN, "F_GETOWN" },
+ { F_SETOWN, "F_SETOWN" },
+ // { F_OGETLK, "F_OGETLK" },
+ // { F_OSETLK, "F_OSETLK" },
+ // { F_OSETLKW, "F_OSETLKW" },
+ // { F_DUP2FD, "F_DUP2FD" },
+ { F_GETLK, "F_GETLK" },
+ { F_SETLK, "F_SETLK" },
+ { F_SETLKW, "F_SETLKW" },
+ // { F_SETLK_REMOTE, "F_SETLK_REMOTE" },
+ // { F_READAHEAD, "F_READAHEAD" },
+ { F_RDAHEAD, "F_RDAHEAD" },
+ { FD_CLOEXEC, "FD_CLOEXEC" },
+ { F_RDLCK, "F_RDLCK" },
+ { F_UNLCK, "F_UNLCK" },
+ { F_WRLCK, "F_WRLCK" },
+ // { F_UNLCKSYS, "F_UNLCKSYS" },
+ // { F_CANCEL, "F_CANCEL" },
+ { LOCK_SH, "LOCK_SH" },
+ { LOCK_EX, "LOCK_EX" },
+ { LOCK_NB, "LOCK_NB" },
+ { LOCK_UN, "LOCK_UN" },
+
+ /* /usr/include/sys/unistd.h */
+ { SEEK_SET, "SEEK_SET" },
+ { SEEK_CUR, "SEEK_CUR" },
+ { SEEK_END, "SEEK_END" },
+
+ /* /usr/include/sys/socket.h */
+ { MSG_OOB, "MSG_OOB" },
+ { MSG_PEEK, "MSG_PEEK" },
+ { MSG_DONTROUTE, "MSG_DONTROUTE" },
+ { MSG_EOR, "MSG_EOR" },
+ { MSG_TRUNC, "MSG_TRUNC" },
+ { MSG_CTRUNC, "MSG_CTRUNC" },
+ { MSG_WAITALL, "MSG_WAITALL" },
+ // { MSG_NOTIFICATION, "MSG_NOTIFICATION" },
+ { MSG_DONTWAIT, "MSG_DONTWAIT" },
+ { MSG_EOF, "MSG_EOF" },
+ // { MSG_NBIO, "MSG_NBIO" },
+ // { MSG_COMPAT, "MSG_COMPAT" },
+ // { MSG_NOSIGNAL, "MSG_NOSIGNAL" },
+
+ /* /usr/include/sys/filio.h */
+ { FIOCLEX, "FIOCLEX" },
+ { FIONCLEX, "FIONCLEX" },
+ { FIONREAD, "FIONREAD" },
+ { FIONBIO, "FIONBIO" },
+ { FIOASYNC, "FIOASYNC" },
+ { FIOSETOWN, "FIOSETOWN" },
+ { FIOGETOWN, "FIOGETOWN" },
+ { FIODTYPE, "FIODTYPE" },
+ // { FIOGETLBA, "FIOGETLBA" },
+ // { FIODGNAME, "FIODGNAME" },
+ // { FIONWRITE, "FIONWRITE" },
+ // { FIONSPACE, "FIONSPACE" },
+ // { FIOSEEKDATA, "FIOSEEKDATA" },
+ // { FIOSEEKHOLE, "FIOSEEKHOLE" },
+
+ /* /usr/include/sys/poll.h */
+ { POLLIN, "POLLIN" },
+ { POLLPRI, "POLLPRI" },
+ { POLLOUT, "POLLOUT" },
+ { POLLRDNORM, "POLLRDNORM" },
+ { POLLWRNORM, "POLLWRNORM" },
+ { POLLRDBAND, "POLLRDBAND" },
+ { POLLWRBAND, "POLLWRBAND" },
+ // { POLLINIGNEOF, "POLLINIGNEOF" },
+ { POLLERR, "POLLERR" },
+ { POLLHUP, "POLLHUP" },
+ { POLLNVAL, "POLLNVAL" },
+
+ /* /usr/include/sys/errno.h */
+ { EPERM, "EPERM" },
+ { ENOENT, "ENOENT" },
+ { ESRCH, "ESRCH" },
+ { EINTR, "EINTR" },
+ { EIO, "EIO" },
+ { ENXIO, "ENXIO" },
+ { E2BIG, "E2BIG" },
+ { ENOEXEC, "ENOEXEC" },
+ { EBADF, "EBADF" },
+ { ECHILD, "ECHILD" },
+ { EDEADLK, "EDEADLK" },
+ { ENOMEM, "ENOMEM" },
+ { EACCES, "EACCES" },
+ { EFAULT, "EFAULT" },
+ { ENOTBLK, "ENOTBLK" },
+ { EBUSY, "EBUSY" },
+ { EEXIST, "EEXIST" },
+ { EXDEV, "EXDEV" },
+ { ENODEV, "ENODEV" },
+ { ENOTDIR, "ENOTDIR" },
+ { EISDIR, "EISDIR" },
+ { EINVAL, "EINVAL" },
+ { ENFILE, "ENFILE" },
+ { EMFILE, "EMFILE" },
+ { ENOTTY, "ENOTTY" },
+ { ETXTBSY, "ETXTBSY" },
+ { EFBIG, "EFBIG" },
+ { ENOSPC, "ENOSPC" },
+ { ESPIPE, "ESPIPE" },
+ { EROFS, "EROFS" },
+ { EMLINK, "EMLINK" },
+ { EPIPE, "EPIPE" },
+ { EDOM, "EDOM" },
+ { ERANGE, "ERANGE" },
+ { EAGAIN, "EAGAIN" },
+ { EWOULDBLOCK, "EWOULDBLOCK" },
+ { EINPROGRESS, "EINPROGRESS" },
+ { EALREADY, "EALREADY" },
+ { ENOTSOCK, "ENOTSOCK" },
+ { EDESTADDRREQ, "EDESTADDRREQ" },
+ { EMSGSIZE, "EMSGSIZE" },
+ { EPROTOTYPE, "EPROTOTYPE" },
+ { ENOPROTOOPT, "ENOPROTOOPT" },
+ { EPROTONOSUPPORT, "EPROTONOSUPPORT" },
+ { ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT" },
+ { EOPNOTSUPP, "EOPNOTSUPP" },
+ { ENOTSUP, "ENOTSUP" },
+ { EPFNOSUPPORT, "EPFNOSUPPORT" },
+ { EAFNOSUPPORT, "EAFNOSUPPORT" },
+ { EADDRINUSE, "EADDRINUSE" },
+ { EADDRNOTAVAIL, "EADDRNOTAVAIL" },
+ { ENETDOWN, "ENETDOWN" },
+ { ENETUNREACH, "ENETUNREACH" },
+ { ENETRESET, "ENETRESET" },
+ { ECONNABORTED, "ECONNABORTED" },
+ { ECONNRESET, "ECONNRESET" },
+ { ENOBUFS, "ENOBUFS" },
+ { EISCONN, "EISCONN" },
+ { ENOTCONN, "ENOTCONN" },
+ { ESHUTDOWN, "ESHUTDOWN" },
+ { ETOOMANYREFS, "ETOOMANYREFS" },
+ { ETIMEDOUT, "ETIMEDOUT" },
+ { ECONNREFUSED, "ECONNREFUSED" },
+ { ELOOP, "ELOOP" },
+ { ENAMETOOLONG, "ENAMETOOLONG" },
+ { EHOSTDOWN, "EHOSTDOWN" },
+ { EHOSTUNREACH, "EHOSTUNREACH" },
+ { ENOTEMPTY, "ENOTEMPTY" },
+ { EPROCLIM, "EPROCLIM" },
+ { EUSERS, "EUSERS" },
+ { EDQUOT, "EDQUOT" },
+ { ESTALE, "ESTALE" },
+ { EREMOTE, "EREMOTE" },
+ { EBADRPC, "EBADRPC" },
+ { ERPCMISMATCH, "ERPCMISMATCH" },
+ { EPROGUNAVAIL, "EPROGUNAVAIL" },
+ { EPROGMISMATCH, "EPROGMISMATCH" },
+ { EPROCUNAVAIL, "EPROCUNAVAIL" },
+ { ENOLCK, "ENOLCK" },
+ { ENOSYS, "ENOSYS" },
+ { EFTYPE, "EFTYPE" },
+ { EAUTH, "EAUTH" },
+ { ENEEDAUTH, "ENEEDAUTH" },
+ { EIDRM, "EIDRM" },
+ { ENOMSG, "ENOMSG" },
+ { EOVERFLOW, "EOVERFLOW" },
+ { ECANCELED, "ECANCELED" },
+ { EILSEQ, "EILSEQ" },
+ { ENOATTR, "ENOATTR" },
+ // { EDOOFUS, "EDOOFUS" },
+ { EBADMSG, "EBADMSG" },
+ { EMULTIHOP, "EMULTIHOP" },
+ { ENOLINK, "ENOLINK" },
+ { EPROTO, "EPROTO" },
+ // { ENOTCAPABLE, "ENOTCAPABLE" },
+ // { ECAPMODE, "ECAPMODE" },
+
+ /* Sentinel marking the end of the table. */
+ { 0, NULL },
+};
+
+struct int_symbol *platform_symbols(void)
+{
+ return platform_symbols_table;
+}
+
+#endif /* __MACH__ */
diff --git a/gtests/net/packetdrill/wire_client_netdev.c b/gtests/net/packetdrill/wire_client_netdev.c
index ce4ebef..cb4a83e 100644
--- a/gtests/net/packetdrill/wire_client_netdev.c
+++ b/gtests/net/packetdrill/wire_client_netdev.c
@@ -121,6 +121,7 @@ struct netdev *wire_client_netdev_new(struct config *config)
/* Add the client live local IP to our NIC, so we can send/receive */
net_setup_dev_address(netdev->name,
&config->live_local_ip,
+ &config->live_remote_ip,
config->live_prefix_len);

route_traffic_to_wire_server(config, netdev);
diff --git a/gtests/net/packetdrill/wire_server_netdev.c b/gtests/net/packetdrill/wire_server_netdev.c
index cee64e7..2b9f9da 100644
--- a/gtests/net/packetdrill/wire_server_netdev.c
+++ b/gtests/net/packetdrill/wire_server_netdev.c
@@ -126,6 +126,7 @@ struct netdev *wire_server_netdev_new(
*/
net_setup_dev_address(netdev->name,
&config->live_gateway_ip,
+ &config->live_remote_ip,
config->live_prefix_len);

netdev->psock = packet_socket_new(netdev->name);
--
2.0.0

Reply all
Reply to author
Forward
0 new messages