Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r990 committed - Remove some unused code

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r990 committed - Remove some unused code


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r990 committed - Remove some unused code
  • Date: Mon, 10 Mar 2014 13:41:35 +0000

Revision: 990
Author:

Date: Mon Mar 10 13:40:31 2014 UTC
Log: Remove some unused code


http://code.google.com/p/ndt/source/detail?r=990

Modified:
/branches/aaron-tcp_stats_cleanup/src/test_mid_srv.c
/branches/aaron-tcp_stats_cleanup/src/test_sfw_srv.c
/branches/aaron-tcp_stats_cleanup/src/testoptions.h
/branches/aaron-tcp_stats_cleanup/src/web100-util.c
/branches/aaron-tcp_stats_cleanup/src/web100srv.c
/branches/aaron-tcp_stats_cleanup/src/web100srv.h

=======================================
--- /branches/aaron-tcp_stats_cleanup/src/test_mid_srv.c Mon Oct 14 13:20:21 2013 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/test_mid_srv.c Mon Mar 10 13:40:31 2014 UTC
@@ -109,14 +109,6 @@
// strcpy(listenmidport, "0");
strlcpy(listenmidport, "0", sizeof(listenmidport));
}
-
- /* RAC debug */
- /*
- if (KillHung() == 0)
- log_println(5, "KillHung() returned 0, should have tried to kill off some LastAck process");
- else
- log_println(5, "KillHung(): returned non-0 response, nothing to kill or kill failed");
- */

while (midsrv_addr == NULL) {
// attempt to bind to a new port and obtain address structure with
@@ -129,13 +121,6 @@
mrange_next(listenmidport, sizeof(listenmidport)) :
listenmidport,
conn_options, 0);
- if (midsrv_addr == NULL) {
- /*
- log_println(5, " Calling KillHung() because midsrv_address failed to bind");
- if (KillHung() == 0)
- continue;
- */
- }
if (strcmp(listenmidport, "0") == 0) {
log_println(0, "WARNING: ephemeral port number was bound");
break;
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/test_sfw_srv.c Mon Mar 10 13:39:30 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/test_sfw_srv.c Mon Mar 10 13:40:31 2014 UTC
@@ -108,7 +108,6 @@
/**
* Performs the server part of the Simple firewall test.
* @param ctlsockfd Client control socket descriptor
- * @param agent web100_agent
* @param options The test options
* @param conn_options The connection options
* @returns Integer with values:
@@ -120,7 +119,7 @@
* 5 - Unable to resolve client address
*/

-int test_sfw_srv(int ctlsockfd, tcp_stat_agent* agent, TestOptions* options,
+int test_sfw_srv(int ctlsockfd, TestOptions* options,
int conn_options) {
char buff[BUFFSIZE + 1];
I2Addr sfwsrv_addr = NULL;
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/testoptions.h Mon Oct 14 13:20:21 2013 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/testoptions.h Mon Mar 10 13:40:31 2014 UTC
@@ -59,8 +59,7 @@

void catch_s2c_alrm(int signo);

-int test_sfw_srv(int ctlsockfd, tcp_stat_agent* agent, TestOptions* options,
- int conn_options);
+int test_sfw_srv(int ctlsockfd, TestOptions* options, int conn_options);
int test_meta_srv(int ctlsockfd, tcp_stat_agent* agent, TestOptions* options,
int conn_options);

=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100-util.c Mon Mar 10 13:40:04 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100-util.c Mon Mar 10 13:40:31 2014 UTC
@@ -780,53 +780,6 @@
#endif
}

-#if USE_WEB100
-/**
- * Calculate Web100 based Round-Trip Time (RTT) value.
- *
- * "SumRTT" = sum of all sampled round trip times.
- * "CountRTT" = count of samples in SumRTT.
- * Thus, sumRTT/CountRTT = RTT
- * @param ctlsock integer socket file descriptor indicating data recipient
- * @param agent pointer to a web100_agent
- * @param cn pointer to web100_connection
- * @return positive integral round trip time in milliseconds on success,
- * negative integer error code if failure.
- * Error codes :
- * -10 if web100-connection is null.
- * -24 Cannot find CountRTT or SumRTT
web100_variable's var/group.
- * -25 cannot read the value of the countRTT or SumRTT web100_variable.
- *
- *
- */
-int web100_rtt(int sock, web100_agent* agent, web100_connection* cn) {
- web100_var* var;
- char buf[32];
- web100_group* group;
- double count, sum;
-
- if (cn == NULL)
- return (-10);
-
- if ((web100_agent_find_var_and_group(agent, "CountRTT", &group, &var))
- != WEB100_ERR_SUCCESS)
- return (-24);
- if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
- return (-25);
- }
- count = atoi(web100_value_to_text(web100_get_var_type(var), buf));
-
- if ((web100_agent_find_var_and_group(agent, "SumRTT", &group, &var))
- != WEB100_ERR_SUCCESS)
- return (-24);
- if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
- return (-25);
- }
- sum = atoi(web100_value_to_text(web100_get_var_type(var), buf));
- return (sum / count);
-}
-#endif
-
/**
* Check if the "Auto Tune Send Buffer" and "Auto Tune Receive Buffer" options
* are enabled and return status on each
@@ -892,98 +845,7 @@
#endif
}

-#if USE_WEB100
/**
- * Check if the "Auto Tune Send Buffer" and "Auto Tune Receive Buffer" options
- * are enabled. If not, scale the Send window or receive window sizes based on the
- * scaling factors negotiated. Scaling factor sndWinScale is used to set used to set "LimCwnd"
- * (maximum size, in bytes, of the congestion window that may be used)
- * and RcvWindowScale is used to set "LimRwin"( maximum receive window size, in bytes, that may be advertised).
- *
- * This function seems unused currently.
- *
- * @param sock integer socket file descriptor indicating data recipient
- * @param agent pointer to a web100_agent
- * @param cn pointer to web100_connection
- * @return Integer, 0 on success
- * If failure, error codes :
- * 10 - web100-connection is null.
- * 22 - Cannot find LimCwnd web100 variable's
var/group data.
- * 23 - Cannot find LimRwin web100 variable's
var/group data
- * 24 - cannot find SndWinScale web100
variable's var/group data.
- * 25 - cannot read the value of the
SndWinScale web100 variable.
- * 34 - cannot find RcvWinScale web100
variable's var/group data.
- * 35 - cannot read value of RcvWinScale
web100 variable.
- *
- */
-int tcp_stat_setbuff(int sock, tcp_stat_agent* agent, tcp_stat_connection cn,
- int autotune) {
- web100_var* var;
- char buf[32];
- web100_group* group;
- int buff;
- int sScale, rScale;
-
- if (cn == NULL)
- return (10);
-
- // get Window scale used by the sender to decode snd.wnd
- if ((web100_agent_find_var_and_group(agent, "SndWinScale", &group, &var))
- != WEB100_ERR_SUCCESS)
- return (24);
- if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
- return (25);
- }
- sScale = atoi(web100_value_to_text(web100_get_var_type(var), buf));
- if (sScale > 15) // define constant for 15
- sScale = 0;
-
- // get Window scale used by the sender to decode seg.wnd
- if ((web100_agent_find_var_and_group(agent, "RcvWinScale", &group, &var))
- != WEB100_ERR_SUCCESS)
- return (34);
- if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
- return (35);
- }
- rScale = atoi(web100_value_to_text(web100_get_var_type(var), buf));
- if (rScale > 15)
- rScale = 0;
-
- if ((sScale > 0) && (rScale > 0)) {
- // 64k( max TCP rcv window)
- buff = (MAX_TCP_WIN_BYTES * KILO_BITS) << sScale;
- if (autotune & 0x01) { // autotune send buffer is not enabled
- if ((web100_agent_find_var_and_group(agent, "LimCwnd", &group, &var))
- != WEB100_ERR_SUCCESS)
- return (22);
- // attempt writing variable value, log failure
- if ((web100_raw_write(var, cn, &buff)) != WEB100_ERR_SUCCESS) {
- log_println(4,
- "Web100_raw_write(LimCwnd) failed with errorno=%d",
- errno);
- return (23);
- }
- }
- buff = (MAX_TCP_WIN_BYTES * KILO_BITS) << rScale;
-
- if (autotune & 0x02) { // autotune receive buffer is not enabled
- if ((web100_agent_find_var_and_group(agent, "LimRwin", &group, &var))
- != WEB100_ERR_SUCCESS)
- return (22);
- if ((web100_raw_write(var, cn, &buff)) != WEB100_ERR_SUCCESS) {
- log_println(4,
- "Web100_raw_write(LimRwin) failed with errorno=%d",
- errno);
- return (23);
- }
- }
- }
-
- return (0);
-}
-#endif
-
-/**
* @param sock integer socket file descriptor indicating data recipient
* @param tcp_vars to local copies of tcp_stat variables
* @return integer 0
@@ -1176,193 +1038,3 @@
*inc_cnt, *dec_cnt, *same_cnt);
return (0);
}
-
-#if USE_WEB100
-/**
- * Generate TCP/IP checksum for our packet
- *
- * @param buff pointer to buffer
- * @param nwords integer length (in bytes) of the header
- * @return unsigned short checksum
- */
-unsigned short csum(unsigned short *buff, int nwords) {
- /* generate a TCP/IP checksum for our packet */
-
- register int sum = 0;
- u_short answer = 0;
- register u_short *w = buff;
- register int nleft = nwords;
-
- // make 16 bit words out of every couple of 8 bit words and
- // add up
- while (nleft > 1) {
- sum += *w++;
- nleft -= 2;
- }
-
- if (nleft == 1) {
- *(u_char *) (&answer) = *(u_char *) w;
- sum += answer;
- }
-
- // form 16 bit words, add and store
- sum = (sum >> 16) + (sum & 0xffff);
- // then add carries to the sume
- sum += (sum >> 16);
-
- // 1s complement of the above yields checksum
- answer = ~sum;
- return (answer);
-}
-
-/**
- * Try to close out connections in an unexpected or erroneous state.
- *
- * This function seems unused currently.
- *
- * @return integer, 0 if kill succeeded, and
- * -1 if kill failed or there was nothing to kill
- */
-int KillHung(void) {
- web100_agent *agent;
- web100_group *group;
- web100_var *state, *var;
- web100_connection *conn;
- int cid, one = 1, hung = 0;
- int sd;
- char *pkt, buff[64];
- struct in_addr src, dst;
- struct iphdr *ip = NULL;
- struct tcphdr *tcp;
- struct sockaddr_in sin;
- struct pseudo_hdr *phdr;
-
- if ((agent = web100_attach(WEB100_AGENT_TYPE_LOCAL, NULL)) == NULL) {
- web100_perror("web100_attach");
- return (-1);
- }
-
- group = web100_group_head(agent);
- conn = web100_connection_head(agent);
-
- while (conn) {
- cid = web100_get_connection_cid(conn);
- web100_agent_find_var_and_group(agent, "State", &group, &state);
- web100_raw_read(state, conn, buff);
- if (atoi(web100_value_to_text(web100_get_var_type(state), buff)) == 9) {
- /* Connection is in Last_Ack state, and probably stuck, so generate and
- send a FIN packet to the remote client. This should force the connection
- to close
- */
-
- log_println(3, "Connection %d was found in LastAck state", cid);
- sin.sin_family = AF_INET;
-
- pkt = malloc(sizeof(struct iphdr) + sizeof(struct tcphdr) + 24);
- memset(pkt, 0, (24 + sizeof(struct iphdr) + sizeof(struct tcphdr)));
- sd = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
- ip = (struct iphdr *) pkt;
- tcp = (struct tcphdr *) (pkt + sizeof(struct iphdr));
- phdr = (struct pseudo_hdr *) (pkt + sizeof(struct iphdr)
- - sizeof(struct pseudo_hdr));
-
- /* Build the TCP packet first, along with the pseudo header, the later
- * the IP header build process will overwrite the pseudo header fields
- */
-
- web100_agent_find_var_and_group(agent, "LocalAddress", &group,
- &var);
- web100_raw_read(var, conn, buff);
- log_println(3, "LocalAddress: '%s'",
- web100_value_to_text(web100_get_var_type(var), buff));
- dst.s_addr = inet_addr(
- web100_value_to_text(web100_get_var_type(var), buff));
- web100_agent_find_var_and_group(agent, "RemAddress", &group, &var);
- web100_raw_read(var, conn, buff);
- src.s_addr = inet_addr(
- web100_value_to_text(web100_get_var_type(var), buff));
- log_println(3, "RemAddress: '%s'",
- web100_value_to_text(web100_get_var_type(var), buff));
-
- phdr->protocol = IPPROTO_TCP;
- phdr->len = htons(sizeof(struct tcphdr) / 4);
- phdr->s_addr = src.s_addr;
- phdr->d_addr = dst.s_addr;
-
- web100_agent_find_var_and_group(agent, "LocalPort", &group, &var);
- web100_raw_read(var, conn, buff);
- tcp->dest = htons(
- atoi(web100_value_to_text(web100_get_var_type(var), buff)));
- log_println(3, "LocalPort: '%s'",
- web100_value_to_text(web100_get_var_type(var), buff));
- web100_agent_find_var_and_group(agent, "RemPort", &group, &var);
- web100_raw_read(var, conn, buff);
- tcp->source = htons(
- atoi(web100_value_to_text(web100_get_var_type(var), buff)));
- log_println(3, "RemPort: '%s'",
- web100_value_to_text(web100_get_var_type(var), buff));
- sin.sin_port = tcp->dest;
-
- web100_agent_find_var_and_group(agent, "RcvNxt", &group, &var);
- web100_raw_read(var, conn, buff);
- tcp->seq = htonl(
- atoll(
- web100_value_to_text(web100_get_var_type(var),
- buff)));
- log_println(3, "Seq No. (RcvNxt): '%s'",
- web100_value_to_text(web100_get_var_type(var), buff));
- web100_agent_find_var_and_group(agent, "SndUna", &group, &var);
- web100_raw_read(var, conn, buff);
- tcp->ack_seq = htonl(
- atoll(
- web100_value_to_text(web100_get_var_type(var),
- buff)));
- log_println(3, "Ack No. (SndNxt): '%s'",
- web100_value_to_text(web100_get_var_type(var), buff));
-
- tcp->window = 0x7fff;
- tcp->res1 = 0;
- tcp->doff = sizeof(struct tcphdr) / 4;
- /* tcp->syn = 1; */
- tcp->rst = 1;
- tcp->ack = 1;
- /* tcp->fin = 1; */
- tcp->urg_ptr = 0;
- tcp->check = csum((unsigned short *) phdr,
- sizeof(struct tcphdr) + sizeof(struct pseudo_hdr));
-
- bzero(pkt, sizeof(struct iphdr));
- ip->ihl = 5;
- ip->version = 4;
- ip->tos = 0;
- ip->tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
- ip->id = htons(31890);
- ip->frag_off = htons(IP_DF);
- ip->ttl = IPDEFTTL;
- ip->protocol = IPPROTO_TCP; /* TCP packet */
- ip->saddr = src.s_addr;
- ip->daddr = dst.s_addr;
- sin.sin_addr.s_addr = dst.s_addr;
-
- ip->check = csum((unsigned short *) pkt, sizeof(struct iphdr));
-
- if (setsockopt(sd, IPPROTO_IP, IP_HDRINCL, &one, sizeof(one)) < 0)
- return (-1);
-
- sendto(sd, (char *) pkt, 40, 0, (struct sockaddr *) &sin,
- sizeof(sin));
-
- hung = 1;
- }
- // returns the next connection in the sequence
- conn = web100_connection_next(conn);
- }
-
- // close and free allocated agent
- web100_detach(agent);
- /* free(pkt); */
- if (hung == 0)
- return (-1);
- return (0);
-}
-#endif
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100srv.c Fri Feb 21 16:32:03 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100srv.c Mon Mar 10 13:40:31 2014 UTC
@@ -1013,7 +1013,7 @@

/* alarm(20); */
log_println(6, "Starting simple firewall test");
- if ((ret = test_sfw_srv(ctlsockfd, agent, &*testopt, conn_options)) != 0) {
+ if ((ret = test_sfw_srv(ctlsockfd, &*testopt, conn_options)) != 0) {
if (ret < 0)
log_println(6, "SFW test failed with rc=%d", ret);
}
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100srv.h Mon Oct 14 13:20:21 2013 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100srv.h Mon Mar 10 13:40:31 2014 UTC
@@ -311,8 +311,6 @@
int tcp_stat_init(char *VarFileName);
void tcp_stat_middlebox(int sock, tcp_stat_agent* agent, tcp_stat_connection cn,
char *results, size_t results_strlen);
-int tcp_stat_setbuff(int sock, tcp_stat_agent* agent, tcp_stat_connection cn,
- int autotune);/* Not used so no web10g version */
void tcp_stat_get_data_recv(int sock, tcp_stat_agent* agent,
tcp_stat_connection cn, int count_vars);
int tcp_stat_get_data(tcp_stat_snap* snap, int testsock, int ctlsock,


  • [ndt-dev] [ndt] r990 committed - Remove some unused code, ndt, 03/10/2014

Archive powered by MHonArc 2.6.16.

Top of Page