From 75fcf7f9d0c2f2c1b2e410f826585324446f0dcf Mon Sep 17 00:00:00 2001
From: Michael Tuexen <tuexen@fh-muenster.de>
Date: Mon, 20 Jun 2016 21:49:15 +0200
Subject: [PATCH] Improve arg checking for remote mode.

When using remote mode, eth0 only makes sense for Linux. So don't
use it on non-Linux platforms. Additionally, check for an interface
being specified and, when acting as a client, that a server address
is specified.

Sponsored by:	Netflix
---
 gtests/net/packetdrill/config.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/gtests/net/packetdrill/config.c b/gtests/net/packetdrill/config.c
index cc61bdea..6b335f0c 100644
--- a/gtests/net/packetdrill/config.c
+++ b/gtests/net/packetdrill/config.c
@@ -220,8 +220,10 @@ void set_default_config(struct config *config)
 	config->init_scripts = NULL;
 
 	config->wire_server_port	= 8081;
+#ifdef linux
 	config->wire_client_device	= "eth0";
 	config->wire_server_device	= "eth0";
+#endif
 }
 
 static void set_remote_ip_and_prefix(struct config *config)
@@ -320,6 +322,19 @@ void finalize_config(struct config *config)
 		break;
 		/* omitting default so compiler will catch missing cases */
 	}
+	if (config->is_wire_client) {
+		if (config->wire_client_device == NULL) {
+			die("wire_client_dev not specified\n");
+		}
+		if (config->wire_server_ip_string == NULL) {
+			die("wire_server_ip not specified\n");
+		}
+	}
+	if (config->is_wire_server) {
+		if (config->wire_server_device == NULL) {
+			die("%s: wire_server_dev not specified\n");
+		}
+	}
 }
 
 /* Expect that arg is comma-delimited, allowing for spaces. */
-- 
GitLab