Commit be2490f1 authored by Jonathon Duerig's avatar Jonathon Duerig

Fixed a bug when use-magent was set to 2 (Use magent but use iperfd as the...

Fixed a bug when use-magent was set to 2 (Use magent but use iperfd as the peer server). peerserverport was set to 0 in this case which made the magent unable to connect to other magents. Now there is a seperate --nopeerserver option.
parent ebfbd429
......@@ -94,15 +94,15 @@ void KernelTcp::connect(PlanetOrder & planet)
logWrite(ERROR, "Could not create a datagram socket in KernelTcp::connect");
}
int flags = fcntl(peersock, F_GETFL, 0);
int flags = fcntl(peersock, F_GETFL, 0);
flags = flags | O_NONBLOCK;
flags = flags | O_NONBLOCK;
if( fcntl(peersock, F_SETFL, flags) < 0 )
{
logWrite(ERROR,"Could not set UDP socket to non-blocking");
if( fcntl(peersock, F_SETFL, flags) < 0 )
{
logWrite(ERROR,"Could not set UDP socket to non-blocking");
}
}
udpLocalAddr.sin_family = AF_INET;
udpLocalAddr.sin_addr.s_addr = htonl(INADDR_ANY);
......@@ -398,14 +398,14 @@ int KernelTcp::writeUdpMessage(int size, WriteResult & result)
return -1;
}
int flags = fcntl(peersock, F_GETFL, 0);
int flags = fcntl(peersock, F_GETFL, 0);
flags = flags | O_NONBLOCK;
flags = flags | O_NONBLOCK;
if( fcntl(peersock, F_SETFL, flags) < 0 )
{
logWrite(ERROR,"Could not set UDP socket to non-blocking");
}
if( fcntl(peersock, F_SETFL, flags) < 0 )
{
logWrite(ERROR,"Could not set UDP socket to non-blocking");
}
}
// result.planet.ip and result.planet.remotePort denote the destination.
// result.planet.ip is in host order
......@@ -437,15 +437,15 @@ int KernelTcp::writeUdpMessage(int size, WriteResult & result)
if(bytesWritten < 0)
{
if(errno == EWOULDBLOCK)
{
logWrite(EXCEPTION,"UDP sendto returned EWOULDBLOCK");
}
else
{
logWrite(EXCEPTION, "Error writing to UDP socket in KernelTcp, errno = %d",errno);
return -1;
}
if(errno == EWOULDBLOCK)
{
logWrite(EXCEPTION,"UDP sendto returned EWOULDBLOCK");
}
else
{
logWrite(EXCEPTION, "Error writing to UDP socket in KernelTcp, errno = %d",errno);
return -1;
}
}
udpCurSeqNum++;
......@@ -481,7 +481,7 @@ namespace
void KernelTcp::init(void)
{
// Set up the peerAccept socket
if (global::peerServerPort != 0) {
if (global::isPeerServer) {
global::peerAccept = createServer(global::peerServerPort,
"Peer accept socket (No incoming peer "
"connections will be accepted)");
......@@ -931,14 +931,14 @@ namespace
static int counter = 0;
pcap_stats(KernelTcp::pcapDescriptor, &pcapStats);
if(counter%2000 == 0)
{
if(counter%2000 == 0)
{
if(pcapStats.ps_drop > currentPcapLoss)
{
currentPcapLoss = pcapStats.ps_drop;
logWrite(SENSOR,"\nSTAT::Number of packets lost in libpcap = %d\n",currentPcapLoss);
}
}
}
counter++;
// We want to distinguish between packets that are outgoing and
......
......@@ -22,7 +22,7 @@ TARGETS=$MAGENT
#
if [ ${MAGENT_NORECV:-0} -ne 0 ]; then
port=`echo $ARGS | sed -e 's/.*--peerserverport=\([0-9][0-9]*\).*/\1/'`
ARGS=`echo $ARGS | sed -e "s/--peerserverport=$port/--peerserverport=0/"`
ARGS=$ARGS --nopeerserver
echo "${IPERFD_DIR}/$IPERFD -p $port"
${IPERFD_DIR}/$IPERFD -p $port &
TARGETS="$TARGETS $IPERFD"
......
......@@ -23,6 +23,7 @@ namespace global
int connectionModelArg = 0;
unsigned short peerUdpServerPort = 0;
unsigned short peerServerPort = 0;
bool isPeerServer = true;
unsigned short monitorServerPort = 0;
bool doDaemonize = false;
int replayArg = NO_REPLAY;
......
......@@ -350,6 +350,7 @@ namespace global
extern int connectionModelArg;
extern unsigned short peerUdpServerPort;
extern unsigned short peerServerPort;
extern bool isPeerServer;
extern unsigned short monitorServerPort;
extern bool doDaemonize;
extern int replayArg;
......
......@@ -66,6 +66,7 @@ void usageMessage(char *progname)
cerr << "Usage: " << progname << " [options]" << endl;
cerr << " --connectionmodel=<null|kerneltcp> " << endl;
cerr << " --peerserverport=<int> " << endl;
cerr << " --nopeerserver " << endl;
cerr << " --peerudpserverport=<int> " << endl;
cerr << " --monitorserverport=<int> " << endl;
cerr << " --interface=<iface> " << endl;
......@@ -82,6 +83,7 @@ void processArgs(int argc, char * argv[])
// Defaults, in case the user does not pass us explicit values
global::connectionModelArg = CONNECTION_MODEL_KERNEL;
global::peerServerPort = 3491;
global::isPeerServer = true;
global::peerUdpServerPort = 3492;
global::monitorServerPort = 4200;
global::interface = "vnet";
......@@ -94,6 +96,7 @@ void processArgs(int argc, char * argv[])
// too.
{"connectionmodel", required_argument, NULL, 'c'},
{"peerserverport", required_argument, NULL, 'p'},
{"nopeerserver", no_argument, NULL, 'x'},
{"peerudpserverport", required_argument, NULL, 'u'},
{"monitorserverport", required_argument, NULL, 'm'},
{"interface", required_argument, NULL, 'i'},
......@@ -160,6 +163,9 @@ void processArgs(int argc, char * argv[])
global::peerServerPort = argIntVal;
}
break;
case 'x':
global::isPeerServer = false;
break;
case 'u':
if (sscanf(optarg,"%i",&argIntVal) != 1)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment