Commit 1feb2b93 authored by Benoit Steiner's avatar Benoit Steiner

Bug fixes :

* VLAN_ROUTE_OK renvoye au lieu de VLAN_MOVE OK en cas de succes.
* Gestion du cas VLANsrc = VLANdst (qui cradait les tables ARP).

Improvements :
Messages d'erreurs temporaires en partie reecrits proprement.

Kludge :
Desactivation de la verification du bon deroulement du changement de VLAN
pour pouvoir tester sur des machines dont une seule carte reseau est
effectivement branchee.

Benny
parent d4b93345
......@@ -12,7 +12,7 @@ BEGIN Performer # Config du performer
VLANcount = 16 # Nombre de VLANs
VLANdefault = 2 # VLAN par defaut
VLAN2 = eth0 # Mapping VLAN / If
# VLAN3 = eth1
VLAN3 = eth1
# VLAN15 = eth2
# VLAN16 = eth3
END
......
......@@ -229,9 +229,13 @@ int RecvMsg(int iSockFd, char* strBuff)
{
int iPos = 0;
int iRc = 0;
struct sockaddr_in saPeerName;
int iNameLen = sizeof(saPeerName);
ASSERT(strBuff);
iRc = getpeername(iSockFd, &saPeerName, &iNameLen);
while (iRc >= 0)
{
iRc = recv(iSockFd, strBuff+iPos, 1, 0);
......@@ -240,7 +244,7 @@ int RecvMsg(int iSockFd, char* strBuff)
if (iRc <= 0)
{
Log(LOG_WARN, MOD_NAME, "Unable to receive data from %s: %s",
"tutu", strerror(iRc));
inet_ntoa(saPeerName.sin_addr), strerror(iRc));
break;
}
......@@ -256,7 +260,7 @@ int RecvMsg(int iSockFd, char* strBuff)
else if (iPos >= VLAN_MSG_LEN-1)
{
Log(LOG_WARN, MOD_NAME, "Message from %s too long: aborting",
"tutu");
inet_ntoa(saPeerName.sin_addr));
iRc = 1;
break;
......
......@@ -197,7 +197,7 @@ int Receive(struct s_Listener* share)
if (iConnectionOK <= 0)
{
/* Connection lost: register error and exit the for loop */
//Log(LOG_ERROR, MOD_NAME, "Read error: %s\n", strerror(errno));
Log(LOG_ERROR, MOD_NAME, "Read error: %s", strerror(errno));
iRc = errno;
break;
}
......@@ -270,7 +270,7 @@ void *ListenerThread(void *arg)
/* Handle connection losts if needed */
if (iRc)
{
Log (LOG_WARN, MOD_NAME, "Connection with VLANserver lost: %s", strerror(iRc));
Log (LOG_WARN, MOD_NAME, "Connection with VLANserver lost");
/* Enter exclusive execution zone */
iRc = pthread_mutex_lock(&ConnectionLock);
......
......@@ -78,7 +78,8 @@ int StartTask (struct s_Manager* psmManager, struct s_Request* psrRequest)
if (psrHostStatus->iThread != 0)
{
iRc = BUSY;
Log(LOG_NOTE, MOD_NAME, "Aborting request for host %s: VLANbridge is already dealing with it", inet_ntoa(psrRequest->saClientIP.sin_addr));
Log(LOG_NOTE, MOD_NAME, "Aborting request for host %s: VLANbridge is already dealing with it",
inet_ntoa(psrRequest->saClientIP.sin_addr));
}
else
{
......@@ -90,8 +91,14 @@ int StartTask (struct s_Manager* psmManager, struct s_Request* psrRequest)
/* Compare the request with the data in the stack and modify it if needed */
if (psrRequest->iVLANsrc != psrHostStatus->iCurrentVLAN)
Log(LOG_WARN, MOD_NAME, "%s is on VLAN %d in our database, in VLAN %d for VLANserver", inet_ntoa(psrRequest->saClientIP.sin_addr), psrHostStatus->iCurrentVLAN, psrRequest->iVLANsrc);
// if (psrRequest->saClientMAC != psrHostStatus->saClientMAC)
{
Log(LOG_WARN, MOD_NAME, "%s is on VLAN %d in our database, in VLAN %d for VLANserver",
inet_ntoa(psrRequest->saClientIP.sin_addr), psrHostStatus->iCurrentVLAN,
psrRequest->iVLANsrc);
psrRequest->iVLANsrc = psrHostStatus->iCurrentVLAN;
}
// if (memcmp(&psrRequest->saClientMAC, &psrHostStatus->saClientMAC,
// sizeof(psrRequest->saClientMAC))
// {
// psrHostStatus->saClientMAC = psrRequest->saClientMAC;
// Log(LOG_WARN, MOD_NAME, "MAC error, problems will arise\n");
......@@ -249,7 +256,8 @@ void* ManagerThread (void *arg)
iRc = StartTask(psmConfig, psrTask);
if (iRc)
{
Log(LOG_ERROR, MOD_NAME, "Unable to process VLANserver request for host tutu");
Log(LOG_ERROR, MOD_NAME, "Unable to process VLANserver request for host %s",
inet_ntoa(psrTask->saClientIP.sin_addr));
/* Warn bridge */
psrTask->iStatus = VLAN_ERROR;
iRc = WarnSender(&sender, psrTask);
......@@ -261,7 +269,8 @@ void* ManagerThread (void *arg)
{
iRc = FinishTask(psmConfig, psrTask);
if (iRc)
Log(LOG_ERROR, MOD_NAME, "Unable to finish task for host tutu");
Log(LOG_ERROR, MOD_NAME, "Unable to finish task for host %s",
inet_ntoa(psrTask->saClientIP.sin_addr) );
break;
}
......
......@@ -290,7 +290,8 @@ int UpdateTables (struct s_Request* psrJob)
ASSERT(psrJob);
#ifdef DEBUG
Log (LOG_NOTE, MOD_NAME, "Updating bridge config for host %s", "titi");
Log (LOG_NOTE, MOD_NAME, "Updating bridge config for host %s",
inet_ntoa(psrJob->saClientIP.sin_addr));
#endif
/* Open a socket */
......@@ -420,18 +421,28 @@ void* PerformerThread (void* pvArg)
//sleep(20);
#endif
/* Check that VLANsrc and VLANdst are not equal (to avoid problems
in the ARP table) */
if (psrJob->iVLANsrc == psrJob->iVLANdst)
{
Log (LOG_NOTE, MOD_NAME, "VLANsrc = VLANdst: nothing to do for host %s",
inet_ntoa(psrJob->saClientIP.sin_addr));
}
/* Init the pinger */
if ((iRc = Pinger_Init(&psrJob->saClientIP, &spPingerCfg)))
else if ((iRc = Pinger_Init(&psrJob->saClientIP, &spPingerCfg)))
{
psrJob->iStatus = VLAN_ERROR;
Log (LOG_ERROR, MOD_NAME, "Could not init pinger for tutu: aborting");
Log (LOG_ERROR, MOD_NAME, "Could not init pinger for %s: aborting",
inet_ntoa(psrJob->saClientIP.sin_addr));
}
/* Synchronise with the VLAN change */
else if ((iRc = Pinger_DetectMove (&spPingerCfg, &iHasMoved)))
{
psrJob->iStatus = VLAN_ERROR;
Log (LOG_ERROR, MOD_NAME, "Could not ping tutu: aborting");
Log (LOG_ERROR, MOD_NAME, "Could not ping %s: aborting",
inet_ntoa(psrJob->saClientIP.sin_addr));
}
/* Check the client has moved before updating the bridge config */
......@@ -450,8 +461,9 @@ void* PerformerThread (void* pvArg)
if (iRc)
{
psrJob->iStatus = VLAN_ROUTE_KO;
Log (LOG_WARN, MOD_NAME, "Tables modif failed for client tutu");
psrJob->iStatus = VLAN_ERROR;
Log (LOG_WARN, MOD_NAME, "Tables modif failed for client %s",
inet_ntoa(psrJob->saClientIP.sin_addr));
}
else
{
......@@ -460,7 +472,8 @@ void* PerformerThread (void* pvArg)
{
/* This is not really important if we can ping the client, so just
log the error */
Log (LOG_WARN, MOD_NAME, "Could not warn other computers of tutu's move");
Log (LOG_WARN, MOD_NAME, "Could not warn other computers of %s's move",
inet_ntoa(psrJob->saClientIP.sin_addr));
}
/* Check everything is ok with the client */
......@@ -468,17 +481,20 @@ void* PerformerThread (void* pvArg)
{
iRc = iRc | -1;
psrJob->iStatus = VLAN_ERROR;
Log (LOG_WARN, MOD_NAME, "Could not ping tutu: Don't know if move was OK");
Log (LOG_WARN, MOD_NAME, "Could not ping %s: Don't know if move was OK",
inet_ntoa(psrJob->saClientIP.sin_addr));
}
else if (iHasMoved == 1)
{
psrJob->iStatus = VLAN_MOVE_OK;
Log (LOG_NOTE, MOD_NAME, "Request from tutu successfully processed");
psrJob->iStatus = VLAN_ROUTE_OK;
Log (LOG_NOTE, MOD_NAME, "Request from %s successfully processed",
inet_ntoa(psrJob->saClientIP.sin_addr));
}
else
{
psrJob->iStatus = VLAN_MOVE_KO;
Log (LOG_WARN, MOD_NAME, "Host tutu lost");
psrJob->iStatus = VLAN_ROUTE_KO;
Log (LOG_WARN, MOD_NAME, "Host %s lost",
inet_ntoa(psrJob->saClientIP.sin_addr));
}
}
}
......
......@@ -219,6 +219,8 @@ int Pinger_DetectMove(const struct s_Pinger* pspConfig, int* piHasMoved)
}
}
//Kludge
*piHasMoved = 1;
return iRc;
};
......@@ -282,6 +284,8 @@ int Pinger_CheckMove (const struct s_Pinger* pspConfig, int* piMoveOk)
}
}
//Kludge
*piMoveOk = 1;
return iRc;
}
......@@ -226,7 +226,7 @@ int Answer(struct s_Sender *share)
if (iConnectionOK <= 0)
{ /* Connection lost : can't do anything else as waiting for a new connexion */
iRc = errno;
Log (LOG_WARN, MOD_NAME, "Connection to VLANserver lost");
Log (LOG_WARN, MOD_NAME, "Send error: %s", strerror(errno));
break;
}
}
......@@ -258,19 +258,15 @@ void* SenderThread (void* arg)
/* Get the sockfd on which one must send */
iRc = WaitSocket(sender);
//printf ("socket get\n");
/* Send the bridge answers to VLANserver */
if (!iRc)
{
iRc = Answer(sender);
//printf ("sending\n");
/* Handle connection losts if needed */
if (iRc)
{
Log (LOG_WARN, MOD_NAME, "Connection with VLANserver lost: %s", strerror(iRc));
Log (LOG_WARN, MOD_NAME, "Connection with VLANserver lost");
/* Enter exclusive execution zone */
iRc = pthread_mutex_lock(&ConnectionLock);
......
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