[netperf-dev] netperf2 commit notice r80 - in trunk: . src

raj at netperf.org raj at netperf.org
Mon Oct 9 17:32:46 PDT 2006


Author: raj
Date: 2006-10-09 17:32:44 -0700 (Mon, 09 Oct 2006)
New Revision: 80

Modified:
   trunk/Release_Notes
   trunk/src/nettest_bsd.c
Log:
Make the checks that getaddrinfo returned the protocol/sockettype we request
regardless of the protocol/sockettype when we make a specific request.


Modified: trunk/Release_Notes
===================================================================
--- trunk/Release_Notes	2006-09-14 22:38:14 UTC (rev 79)
+++ trunk/Release_Notes	2006-10-10 00:32:44 UTC (rev 80)
@@ -2,6 +2,15 @@
 
 Things changed in this release:
 
+*) The check to make sure that getaddrinfo returned ai_protocol and/or
+   ai_socktype's matching that which we requested is done for all socket
+   and/or protocol types and a warning is emitted if it returns any which
+   do not match.
+
+*) The linux CPU affinity code has been made capable of binding to
+   CPU's >=32 on a 32-bit compilation and >=64 on a 64-bit
+   compilation.
+
 *) More complete closing/redirecting of stdin/stdout/stderr/where in
    netserver to make it easier to launch netserver at the far-end of a
    remote shell.  Courtesy of Hans Blom.

Modified: trunk/src/nettest_bsd.c
===================================================================
--- trunk/src/nettest_bsd.c	2006-09-14 22:38:14 UTC (rev 79)
+++ trunk/src/nettest_bsd.c	2006-10-10 00:32:44 UTC (rev 80)
@@ -507,11 +507,15 @@
 {
   struct addrinfo hints;
   struct addrinfo *res;
+  struct addrinfo *temp_res;
+
+#define CHANGED_SOCK_TYPE  0x1
+#define CHANGED_PROTOCOL   0x2
+  int    change_info = 0;
+  static int change_warning_displayed = 0;
+
   int count = 0;
   int error = 0;
-#define CHANGE_SOCK_TYPE  0x1
-#define CHANGE_PROTOCOL   0x2
-  int change_info = 0;
 
   char *hostname;
 
@@ -535,35 +539,10 @@
 
   memset(&hints, 0, sizeof(hints));
   hints.ai_family = family;
-  switch (type) {
-      case 0:
-      case SOCK_STREAM:
-      case SOCK_DGRAM:
-	  /* Right now most implementations only support these socket
-	   * types.
-	   */
-	  hints.ai_socktype = type;
-	  break;
-      default:
-	  /* we'll default to STREAM and will change the type if successfull */
-	  hints.ai_socktype = SOCK_STREAM;
-	  change_info |= CHANGE_SOCK_TYPE;
-	  break;
-  }
-  switch (protocol) {
-    case 0:
-    case IPPROTO_TCP:
-    case IPPROTO_UDP:
-	/* This is supported on all implementations */
-	hints.ai_protocol = protocol;
-	break;
-    default:
-	hints.ai_protocol = 0;
-	change_info |= CHANGE_PROTOCOL;
-	break;
-  }
+  hints.ai_socktype = type;
+  hints.ai_protocol = protocol;
+  hints.ai_flags = flags|AI_CANONNAME;
 
-  hints.ai_flags = flags|AI_CANONNAME;
   count = 0;
   do {
     error = getaddrinfo((char *)hostname,
@@ -594,30 +573,74 @@
     exit(-1);
   }
 
-  if (change_info) {
-    struct addrinfo *temp = res;
+  /* there exists at least one platform - Solaris 10 - that does not
+     seem to completely honor the ai_protocol and/or ai_socktype one
+     sets in the hints parm to the getaddrinfo call.  so, we need to
+     walk the list of entries returned and if either of those do not
+     match what we asked for, we need to go ahead and set them
+     "correctly" this is based in part on some earlier SCTP-only code
+     from previous revisions.  raj 2006-10-09 */
 
+  temp_res = res;
+
+  while (temp_res) {
+
+    if ((type)  &&
+	(temp_res->ai_socktype != type)) {
+      change_info |= CHANGED_SOCK_TYPE;
+      if (debug) {
+	fprintf(where,
+		"WARNING! Changed bogus getaddrinfo socket type %d to %d\n",
+		temp_res->ai_socktype,
+		type);
+	fflush(where);
+      }
+      temp_res->ai_socktype = type;
+    }
+
+    if ((protocol) &&
+	(temp_res->ai_protocol != protocol)) {
+      change_info |= CHANGED_PROTOCOL;
+      if (debug) {
+	fprintf(where,
+		"WARNING! Changed bogus getaddrinfo protocol %d to %d\n",
+		temp_res->ai_protocol,
+		protocol);
+	fflush(where);
+      }
+      temp_res->ai_protocol = protocol;
+    }
+    temp_res = temp_res->ai_next;
+  }
+	
+  if ((change_info & CHANGED_SOCK_TYPE) &&
+      !(change_warning_displayed & CHANGED_SOCK_TYPE)) {
+    change_warning_displayed |= CHANGED_SOCK_TYPE;
     fprintf(where,
-		"Warning! getaddrinfo returned a result which did not match\n");
+	    "WARNING! getaddrinfo returned a socket type which did not\n");
     fprintf(where,
-		"requested protocol. Kludging. Please contact your vendor for a fix.\n");
+	    "match the requested type.  Please contact your vendor for\n");
+    fprintf(where,
+	    "a fix to this bug in getaddrinfo()\n");
     fflush(where);
-    while (temp) {
-      if (change_info & CHANGE_SOCK_TYPE)
-	  temp->ai_socktype = type;
+  }
 
-      if (change_info & CHANGE_PROTOCOL)
-	  temp->ai_protocol = protocol;
-
-      temp = temp->ai_next;
-    }
+  if ((change_info & CHANGED_PROTOCOL) &&
+      !(change_warning_displayed & CHANGED_PROTOCOL)) {
+    change_warning_displayed |= CHANGED_PROTOCOL;
+    fprintf(where,
+	    "WARNING! getaddrinfo returned a protocol other than the\n");
+    fprintf(where,
+	    "requested protocol.  Please contact your vendor for\n");
+    fprintf(where,
+	    "a fix to this bug in getaddrinfo()\n");
+    fflush(where);
   }
 
   if (debug) {
     dump_addrinfo(where, res, hostname, port, family);
   }
 
-
   return(res);
 }
 



More information about the netperf-dev mailing list