From: fendo Date: Sun, 18 Nov 2012 15:04:06 +0000 (+0100) Subject: Fix the inverted "delete/add" of the routes, in cluster mode. X-Git-Tag: 2.2.1-2fdn3.1~10 X-Git-Url: http://git.sameswireless.fr/l2tpns.git/commitdiff_plain/7fd68b1daeab9a2a1a3ee8f0652c25fc37bf3549?ds=inline Fix the inverted "delete/add" of the routes, in cluster mode. --- diff --git a/cluster.c b/cluster.c index b54ae0c..67d8d5e 100644 --- a/cluster.c +++ b/cluster.c @@ -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) diff --git a/cluster.h b/cluster.h index faeede4..c1aa574 100644 --- a/cluster.h +++ b/cluster.h @@ -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); diff --git a/debian/changelog b/debian/changelog index 07cfce3..2a41d76 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Sun, 18 Nov 2012 15:59:44 +0100 + l2tpns (2.2.1-2fdn2) unstable; urgency=low * merge from branch fendo-mods, MLPPP developments diff --git a/l2tpns.c b/l2tpns.c index 7478560..ed85a91 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -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++)