Fix the inverted "delete/add" of the routes, in cluster mode.

This commit is contained in:
fendo 2012-11-18 16:04:06 +01:00
parent e1412c5ca0
commit 7fd68b1dae
4 changed files with 58 additions and 21 deletions

View file

@ -1002,6 +1002,36 @@ static int type_changed(int type, int id)
return 1;
}
// The deleted session, must be before the new session
int cluster_listinvert_session(int sidnew, int sidtodel)
{
int i, inew = 0;
for (i = 0 ; i < config->cluster_num_changes ; ++i)
{
if ( cluster_changes[i].id == sidtodel && cluster_changes[i].type == C_CSESSION)
return 0; // Deleted session already before the new session.
if ( cluster_changes[i].id == sidnew && cluster_changes[i].type == C_CSESSION)
{
inew = i;
break;
}
}
for ( ; i < config->cluster_num_changes ; ++i)
{
if ( cluster_changes[i].id == sidtodel && cluster_changes[i].type == C_CSESSION)
{
// Reverse position
cluster_changes[i].id = sidnew;
cluster_changes[inew].id = sidtodel;
return 1;
}
}
return 0;
}
// A particular session has been changed!
int cluster_send_session(int sid)

View file

@ -78,6 +78,7 @@ typedef struct {
int cluster_init(void);
int processcluster(uint8_t *buf, int size, in_addr_t addr);
int cluster_listinvert_session(int sidnew, int sidtodel);
int cluster_send_session(int sid);
int cluster_send_bundle(int bid);
int cluster_send_tunnel(int tid);

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
l2tpns (2.2.1-2fdn2.1) unstable; urgency=low
* Fix the inverted "delete/add" of the routes, in cluster mode.
-- Fernando Alves <fernando.alves@sameswireless.fr> Sun, 18 Nov 2012 15:59:44 +0100
l2tpns (2.2.1-2fdn2) unstable; urgency=low
* merge from branch fendo-mods, MLPPP developments

View file

@ -5227,18 +5227,18 @@ int sessionsetup(sessionidt s, tunnelidt t)
LOG(3, s, t, "Doing session setup for session\n");
// Join a bundle if the MRRU option is accepted
if(session[s].mrru > 0 && session[s].bundle == 0)
{
LOG(3, s, t, "This session can be part of multilink bundle\n");
if (join_bundle(s) > 0)
cluster_send_bundle(session[s].bundle);
if(session[s].mrru > 0 && session[s].bundle == 0)
{
LOG(3, s, t, "This session can be part of multilink bundle\n");
if (join_bundle(s) > 0)
cluster_send_bundle(session[s].bundle);
else
{
LOG(0, s, t, "MPPP: Mismaching mssf option with other sessions in bundle\n");
sessionshutdown(s, "Mismaching mssf option.", CDN_NONE, TERM_SERVICE_UNAVAILABLE);
return 0;
}
}
}
if (!session[s].ip)
{
@ -5253,7 +5253,6 @@ int sessionsetup(sessionidt s, tunnelidt t)
fmtaddr(htonl(session[s].ip), 0));
}
// Make sure this is right
session[s].tunnel = t;
@ -5266,13 +5265,14 @@ int sessionsetup(sessionidt s, tunnelidt t)
for (i = 1; i <= config->cluster_highest_sessionid; i++)
{
if (i == s) continue;
if (!session[s].opened) continue;
if (!session[s].opened) break;
// Allow duplicate sessions for multilink ones of the same bundle.
if (session[s].bundle && session[i].bundle && session[s].bundle == session[i].bundle)
continue;
if (session[s].bundle && session[i].bundle && session[s].bundle == session[i].bundle) continue;
if (ip == session[i].ip)
{
sessionkill(i, "Duplicate IP address");
cluster_listinvert_session(s, i);
continue;
}
@ -5280,16 +5280,16 @@ int sessionsetup(sessionidt s, tunnelidt t)
if (session[s].walled_garden || session[i].walled_garden) continue;
// Guest change
int found = 0;
int gu;
for (gu = 0; gu < guest_accounts_num; gu++)
{
if (!strcasecmp(user, guest_users[gu]))
{
found = 1;
break;
}
}
if (found) continue;
int gu;
for (gu = 0; gu < guest_accounts_num; gu++)
{
if (!strcasecmp(user, guest_users[gu]))
{
found = 1;
break;
}
}
if (found) continue;
// Drop the new session in case of duplicate sessionss, not the old one.
if (!strcasecmp(user, session[i].user))
@ -5300,7 +5300,7 @@ int sessionsetup(sessionidt s, tunnelidt t)
// no need to set a route for the same IP address of the bundle
if (!session[s].bundle || (bundle[session[s].bundle].num_of_links == 1))
{
int routed = 0;
int routed = 0;
// Add the route for this session.
for (r = 0; r < MAXROUTE && session[s].route[r].ip; r++)