Differentiate ports for vsock_tunnel, native_vsock.

This prevents conflicts between vsock_tunnel and native_vsock.

socket_vsock_proxy no longer assumes that the vsock port and tcp port
should be the same in the guest. The flags have been changed to tcp_port
and vsock_port for clarity.

Right now socket_vsock_proxy is always a TCP server and vsock client on
the guest, and a vsock server and TCP client on the host. There's no
structural reason for it to always be like this; the ifdefs could be
replaced with another flag if required to reverse the client/server
relationships.

Test: Ran with -adb_mode=vsock_tunnel
Bug: 121166534
Change-Id: Iaa8bb331dd7cd4bb6a10841cf4588e69feb34c95
diff --git a/common/frontend/socket_vsock_proxy/main.cpp b/common/frontend/socket_vsock_proxy/main.cpp
index a47915b..7f7248a 100644
--- a/common/frontend/socket_vsock_proxy/main.cpp
+++ b/common/frontend/socket_vsock_proxy/main.cpp
@@ -28,12 +28,9 @@
 
 using vsoc::socket_forward::Packet;
 
-DEFINE_uint32(guest_port, 0,
-             "Port on which to forward TCP connections to the guest.");
-#ifdef CUTTLEFISH_HOST
-DEFINE_uint32(host_port, 0, "Ports on which to run a TCP server on the host.");
+DEFINE_uint32(tcp_port, 0, "TCP port (server on host, client on guest)");
+DEFINE_uint32(vsock_port, 0, "vsock port (client on host, server on guest");
 DEFINE_uint32(vsock_guest_cid, 0, "Guest identifier");
-#endif
 
 namespace {
 // Sends packets, Shutdown(SHUT_WR) on destruction
@@ -139,17 +136,17 @@
 
 #ifdef CUTTLEFISH_HOST
 [[noreturn]] void host() {
-  LOG(INFO) << "starting server on " << FLAGS_host_port << " for guest port "
-            << FLAGS_guest_port;
-  auto server = cvd::SharedFD::SocketLocalServer(FLAGS_host_port, SOCK_STREAM);
-  CHECK(server->IsOpen()) << "Could not start server on " << FLAGS_host_port;
+  LOG(INFO) << "starting server on " << FLAGS_tcp_port << " for vsock port "
+            << FLAGS_vsock_port;
+  auto server = cvd::SharedFD::SocketLocalServer(FLAGS_tcp_port, SOCK_STREAM);
+  CHECK(server->IsOpen()) << "Could not start server on " << FLAGS_tcp_port;
   while (true) {
     LOG(INFO) << "waiting for client connection";
     auto client_socket = cvd::SharedFD::Accept(*server);
     CHECK(client_socket->IsOpen()) << "error creating client socket";
     LOG(INFO) << "client socket accepted";
     cvd::SharedFD vsock_socket = cvd::SharedFD::VsockClient(
-        FLAGS_vsock_guest_cid, FLAGS_guest_port, SOCK_STREAM);
+        FLAGS_vsock_guest_cid, FLAGS_vsock_port, SOCK_STREAM);
     if (!vsock_socket->IsOpen()) {
       continue;
     }
@@ -162,11 +159,11 @@
 #else
 cvd::SharedFD OpenSocketConnection() {
   while (true) {
-    auto sock = cvd::SharedFD::SocketLocalClient(FLAGS_guest_port, SOCK_STREAM);
+    auto sock = cvd::SharedFD::SocketLocalClient(FLAGS_tcp_port, SOCK_STREAM);
     if (sock->IsOpen()) {
       return sock;
     }
-    LOG(WARNING) << "could not connect on port " << FLAGS_guest_port
+    LOG(WARNING) << "could not connect on port " << FLAGS_tcp_port
                  << ". sleeping for 1 second";
     sleep(1);
   }
@@ -185,16 +182,16 @@
 
 [[noreturn]] void guest() {
   LOG(INFO) << "Starting guest mainloop";
-  LOG(INFO) << "starting server on " << FLAGS_guest_port;
+  LOG(INFO) << "starting server on " << FLAGS_vsock_port;
   cvd::SharedFD vsock;
   do {
-    vsock = cvd::SharedFD::VsockServer(FLAGS_guest_port, SOCK_STREAM);
+    vsock = cvd::SharedFD::VsockServer(FLAGS_vsock_port, SOCK_STREAM);
     if (!vsock->IsOpen() && !socketErrorIsRecoverable(vsock->GetErrno())) {
       LOG(ERROR) << "Could not open vsock socket: " << vsock->StrError();
       SleepForever();
     }
   } while (!vsock->IsOpen());
-  CHECK(vsock->IsOpen()) << "Could not start server on " << FLAGS_guest_port;
+  CHECK(vsock->IsOpen()) << "Could not start server on " << FLAGS_vsock_port;
   while (true) {
     LOG(INFO) << "waiting for vsock connection";
     auto vsock_client = cvd::SharedFD::Accept(*vsock);
@@ -214,10 +211,10 @@
 int main(int argc, char* argv[]) {
   gflags::ParseCommandLineFlags(&argc, &argv, true);
 
-  CHECK(FLAGS_guest_port != 0) << "Must specify --guest_port flag";
+  CHECK(FLAGS_tcp_port != 0) << "Must specify -tcp_port flag";
+  CHECK(FLAGS_vsock_port != 0) << "Must specify -vsock_port flag";
 #ifdef CUTTLEFISH_HOST
-  CHECK(FLAGS_vsock_guest_cid != 0) << "Must specify --vsock_guest_cid flag";
-  CHECK(FLAGS_host_port != 0) << "Must specify --host_port flag";
+  CHECK(FLAGS_vsock_guest_cid != 0) << "Must specify -vsock_guest_cid flag";
   host();
 #else
   guest();
diff --git a/host/commands/launch/launch.cc b/host/commands/launch/launch.cc
index bada2f1..4bf3db9 100644
--- a/host/commands/launch/launch.cc
+++ b/host/commands/launch/launch.cc
@@ -214,9 +214,9 @@
                                  const vsoc::CuttlefishConfig& config) {
   if (AdbVsockTunnelEnabled(config)) {
     cvd::Command adb_tunnel(config.socket_vsock_proxy_binary());
-    adb_tunnel.AddParameter("--guest_port=5555");
+    adb_tunnel.AddParameter("--vsock_port=6520");
     adb_tunnel.AddParameter(
-        std::string{"--host_port="} + std::to_string(GetHostPort()));
+        std::string{"--tcp_port="} + std::to_string(GetHostPort()));
     adb_tunnel.AddParameter(std::string{"--vsock_guest_cid="} +
                             std::to_string(config.vsock_guest_cid()));
     process_monitor->StartSubprocess(std::move(adb_tunnel),