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

raj at netperf.org raj at netperf.org
Thu Aug 25 17:26:39 PDT 2011


Author: raj
Date: 2011-08-25 17:26:39 -0700 (Thu, 25 Aug 2011)
New Revision: 486

Modified:
   trunk/Release_Notes
   trunk/src/netsh.c
   trunk/src/netsh.h
   trunk/src/nettest_bsd.c
   trunk/src/nettest_bsd.h
   trunk/src/nettest_omni.c
Log:
enable setting of IP_TOS

Modified: trunk/Release_Notes
===================================================================
--- trunk/Release_Notes	2011-08-25 22:39:07 UTC (rev 485)
+++ trunk/Release_Notes	2011-08-26 00:26:39 UTC (rev 486)
@@ -1,9 +1,18 @@
 These are the Release Notes for post Revision 2.5.0 top-of-trunk netperf:
 
+*) The global -Y option can be used to set IP_TOS on those platforms
+   which support it.  Since this is specific to IP (v4 or v6) it may
+   move to a test-specific otion in the future.  It is presently
+   global for foolish consistency with the -y option to set
+   SO_PRIORITY.
+
+*) The global -y option can be used to set SO_PRIORITY on those
+   platforms which support it.  Based on patches from Amir Vidai.
+
 *) The control message size has been increased from 256 bytes to 512
-    bytes. THIS WILL BREAK COMPATABILITY WITH PREVIOUS VERSIONS OF
-    NETPERF. However, we need more room on the pinhead on which the
-    angels dance.
+   bytes. THIS WILL BREAK COMPATABILITY WITH PREVIOUS VERSIONS OF
+   NETPERF. However, we need more room on the pinhead on which the
+   angels dance.
 
 *) Make the "sum" field of the histogram structure a 64 bit int to
    avoid having it wrap-around on tests where the sum of all the

Modified: trunk/src/netsh.c
===================================================================
--- trunk/src/netsh.c	2011-08-25 22:39:07 UTC (rev 485)
+++ trunk/src/netsh.c	2011-08-26 00:26:39 UTC (rev 486)
@@ -102,7 +102,7 @@
    getopt to parse the command line, we will tell getopt that they do
    not take parms, and then look for them ourselves */
 
-#define GLOBAL_CMD_LINE_ARGS "A:a:b:B:CcdDf:F:H:hi:I:jk:K:l:L:n:NO:o:P:p:rSs:t:T:v:VW:w:y:46"
+#define GLOBAL_CMD_LINE_ARGS "A:a:b:B:CcdDf:F:H:hi:I:jk:K:l:L:n:NO:o:P:p:rSs:t:T:v:VW:w:y:Y:46"
 
 /************************************************************************/
 /*									*/
@@ -239,6 +239,10 @@
 int local_socket_prio = -1;
 int remote_socket_prio = -1;
 
+/* and IP_TOS */
+int local_socket_tos = -1;
+int remote_socket_tos = -1;
+
 /* did someone request processor affinity? */
 int cpu_binding_requested = 0;
 
@@ -303,7 +307,8 @@
     -W send,recv      Set the number of send,recv buffers\n\
     -v level          Set the verbosity level (default 1, min 0)\n\
     -V                Display the netperf version and exit\n\
-    -y local,remote   Set the socket priority\n";
+    -y local,remote   Set the socket priority\n\
+    -Y local,remote   Set the IP_TOS. Use hexadecimal.\n";
 
 char netperf_usage2[] = "\n\
 For those options taking two parms, at least one must be specified;\n\
@@ -959,6 +964,22 @@
       if (arg2[0])
 	remote_socket_prio = convert(arg2);
       break;
+    case 'Y':
+      break_args(optarg, arg1, arg2);
+#if defined(IP_TOS)
+      if (arg1[0])
+	local_socket_tos = strtol(arg1,NULL,0);
+#else
+      if (debug) {
+	fprintf(where,
+		"Setting IP_TOS is not supported on this platform, request to set IP_TOS locally ignored.\n");
+	fflush(where);
+      }
+      local_socket_tos = -1;
+#endif
+      if (arg2[0])
+	remote_socket_tos = strtol(arg2,NULL,0);
+      break;
     case 'l':
       /* determine test end conditions */
       /* assume a timed test */
@@ -1192,6 +1213,7 @@
      of what else may have been set on the command line */
   if (no_control) {
     remote_socket_prio = -1;
+    remote_socket_tos = -1;
     remote_recv_align = -1;
     remote_send_align = -1;
     remote_send_offset = -1;
@@ -1345,6 +1367,8 @@
   printf("Remote recv alignment: %d\n",remote_recv_align);
   printf("Local socket priority: %d\n", local_socket_prio);
   printf("Remote socket priority: %d\n", remote_socket_prio);
+  printf("Local socket TOS: %x\n", local_socket_tos);
+  printf("Remote socket TOS: %x\n", remote_socket_tos);
   printf("Report local CPU %d\n",local_cpu_usage);
   printf("Report remote CPU %d\n",remote_cpu_usage);
   printf("Verbosity: %d\n",verbosity);

Modified: trunk/src/netsh.h
===================================================================
--- trunk/src/netsh.h	2011-08-25 22:39:07 UTC (rev 485)
+++ trunk/src/netsh.h	2011-08-26 00:26:39 UTC (rev 486)
@@ -172,6 +172,9 @@
 extern int local_socket_prio;
 extern int remote_socket_prio;
 
+extern int local_socket_tos;
+extern int remote_socket_tos;
+
 /* address family */
 extern int	af;
 

Modified: trunk/src/nettest_bsd.c
===================================================================
--- trunk/src/nettest_bsd.c	2011-08-25 22:39:07 UTC (rev 485)
+++ trunk/src/nettest_bsd.c	2011-08-26 00:26:39 UTC (rev 486)
@@ -1434,7 +1434,7 @@
 #endif
 
 #if defined(SO_PRIORITY)
-  if (local_socket_prio > 0) {
+  if (local_socket_prio >= 0) {
     if (setsockopt(temp_socket,
                   SOL_SOCKET,
                   SO_PRIORITY,
@@ -1459,6 +1459,34 @@
   local_socket_prio = -3;
 #endif
 
+#if defined(IP_TOS)
+  if (local_socket_tos >= 0) {
+    unsigned char my_tos = (unsigned char) (local_socket_tos & 0xFF);
+    if (setsockopt(temp_socket,
+		   (res->ai_family == AF_INET6) ? IPPROTO_IPV6 : IPPROTO_IP,
+		   IP_TOS,
+		   &my_tos,
+		   sizeof(my_tos)) == SOCKET_ERROR) {
+      fprintf(where,
+             "netperf: create_data_socket: ip_tos: errno %d\n",
+             errno);
+      fflush(where);
+      local_socket_tos = -2;
+    }
+    else {
+      sock_opt_len = 1;
+      /* I wonder if some error checking might be indicated */
+      getsockopt(temp_socket,
+		 (res->ai_family == AF_INET6) ? IPPROTO_IPV6 : IPPROTO_IP,
+		 IP_TOS,
+		 &my_tos,
+		 &sock_opt_len);	       
+      local_socket_tos = my_tos;
+    }
+  }
+#else
+  local_socket_tos = -3;
+#endif
   return(temp_socket);
 
 }

Modified: trunk/src/nettest_bsd.h
===================================================================
--- trunk/src/nettest_bsd.h	2011-08-25 22:39:07 UTC (rev 485)
+++ trunk/src/nettest_bsd.h	2011-08-26 00:26:39 UTC (rev 486)
@@ -83,6 +83,7 @@
   uint32_t   netperf_ip[4]; /* when netserver needs netperf's data IP */
   uint32_t   netserver_ip[4]; /* when netperf tells netserver his IP */
   int32_t    socket_prio; /* what netserver should use for socket prio */
+  int32_t    socket_tos;  /* what netserver should use for socket tos */
 };
 
 struct  omni_response_struct {
@@ -113,8 +114,10 @@
   uint32_t   cpu_frequency;  /* this should be megahertz */
   uint32_t   security_info;
   int32_t    socket_prio;
-  /* there are 17 ints above here */
-#define OMNI_RESPONSE_CONV_CUTOFF 17
+  int32_t    socket_tos;
+  /* there are 18 ints above here, add another and you need to adjust
+     the define below */
+#define OMNI_RESPONSE_CONV_CUTOFF 18
   char       system_model[33];
   char       cpu_model[80];  /* seems like an awful lot doesn't
 				it. some clever person at Intel

Modified: trunk/src/nettest_omni.c
===================================================================
--- trunk/src/nettest_omni.c	2011-08-25 22:39:07 UTC (rev 485)
+++ trunk/src/nettest_omni.c	2011-08-26 00:26:39 UTC (rev 486)
@@ -673,6 +673,8 @@
   STDDEV_LATENCY,
   LOCAL_SOCKET_PRIO,
   REMOTE_SOCKET_PRIO,
+  LOCAL_SOCKET_TOS,
+  REMOTE_SOCKET_TOS,
   COMMAND_LINE,    /* COMMAND_LINE should always be "last" */
   OUTPUT_END,
   NETPERF_OUTPUT_MAX
@@ -1279,6 +1281,10 @@
     return "LOCAL_SOCKET_PRIO";
   case REMOTE_SOCKET_PRIO:
     return "REMOTE_SOCKET_PRIO";
+  case LOCAL_SOCKET_TOS:
+    return "LOCAL_SOCKET_TOS";
+  case REMOTE_SOCKET_TOS:
+    return "REMOTE_SOCKET_TOS";
   case OUTPUT_END:
     return "OUTPUT_END";
   default:
@@ -3755,6 +3761,26 @@
   netperf_output_source[i].max_line_len =  NETPERF_LINE_MAX(i);
   netperf_output_source[i].tot_line_len =  NETPERF_LINE_TOT(i);
 
+  i = LOCAL_SOCKET_TOS;
+  netperf_output_source[i].output_name = LOCAL_SOCKET_TOS;
+  netperf_output_source[i].line[0] = "Local";
+  netperf_output_source[i].line[1] = "Socket";
+  netperf_output_source[i].line[2] = "TOS";
+  netperf_output_source[i].format = "0x%.2x";
+  netperf_output_source[i].display_value = &local_socket_tos;
+  netperf_output_source[i].max_line_len = NETPERF_LINE_MAX(i);
+  netperf_output_source[i].tot_line_len = NETPERF_LINE_TOT(i);
+
+  i = REMOTE_SOCKET_TOS;
+  netperf_output_source[i].output_name = REMOTE_SOCKET_TOS;
+  netperf_output_source[i].line[0] = "Remote";
+  netperf_output_source[i].line[1] = "Socket";
+  netperf_output_source[i].line[2] = "TOS";
+  netperf_output_source[i].format = "0x%.2x";
+  netperf_output_source[i].display_value = &remote_socket_tos;
+  netperf_output_source[i].max_line_len =  NETPERF_LINE_MAX(i);
+  netperf_output_source[i].tot_line_len =  NETPERF_LINE_TOT(i);
+
   netperf_output_source[OUTPUT_END].output_name = OUTPUT_END;
   netperf_output_source[OUTPUT_END].line[0] = "This";
   netperf_output_source[OUTPUT_END].line[1] = "Is";
@@ -4945,6 +4971,7 @@
       omni_request->recv_width             = recv_width;
       omni_request->response_size	   = rsp_size;
       omni_request->socket_prio            = remote_socket_prio;
+      omni_request->socket_tos             = remote_socket_tos;
 
       /* we have no else clauses here because we previously set flags
 	 to zero above raj 20090803 */
@@ -5048,6 +5075,7 @@
 	remote_send_width   = omni_response->send_width;
 	remote_recv_width   = omni_response->recv_width;
 	remote_socket_prio  = omni_response->socket_prio;
+	remote_socket_tos   = omni_response->socket_tos;
 
 	/* make sure that port numbers are in network order because
 	   recv_response will have put everything into host order */
@@ -6059,6 +6087,7 @@
   routing_allowed = (omni_request->flags) & OMNI_ROUTING_ALLOWED;
   want_keepalive  = (omni_request->flags) & OMNI_WANT_KEEPALIVE;
   local_socket_prio = omni_request->socket_prio;
+  local_socket_tos  = omni_request->socket_tos;
 
 #ifdef WANT_INTERVALS
   interval_usecs = omni_request->interval_usecs;
@@ -6124,6 +6153,7 @@
   omni_response->send_size = omni_request->send_size;
   omni_response->send_width = omni_request->send_width;
   omni_response->socket_prio = local_socket_prio;
+  omni_response->socket_tos = local_socket_tos;
 
   if (omni_request->direction & NETPERF_XMIT) {
 #ifdef fo



More information about the netperf-dev mailing list