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