From: bodea Date: Sun, 11 Jul 2004 07:57:33 +0000 (+0000) Subject: - TerminateAck fix from Yuri X-Git-Tag: release_2_0_1~5 X-Git-Url: http://git.sameswireless.fr/l2tpns.git/commitdiff_plain/3ef237977d8e9596f8a22fabed7384b39a7aead5?hp=570d0d53855b9121b29c94bd20206e2158130997 - TerminateAck fix from Yuri - Adject cli_loop args for libcli 1.8.0 - Allow for backward compatabity in C_PING packets - Don't send RADIUS stop messages from sessionshutdown when called from sessionkill. --- diff --git a/cli.c b/cli.c index 2728f84..8e768c0 100644 --- a/cli.c +++ b/cli.c @@ -2,7 +2,7 @@ // vim: sw=4 ts=8 char const *cvs_name = "$Name: $"; -char const *cvs_id_cli = "$Id: cli.c,v 1.9 2004/07/08 16:54:35 bodea Exp $"; +char const *cvs_id_cli = "$Id: cli.c,v 1.10 2004/07/11 07:57:33 bodea Exp $"; #include #include @@ -314,11 +314,7 @@ void cli_do(int sockfd) memset(&debug_flags, 0, sizeof(debug_flags)); debug_flags.critical = 1; - { - char prompt[1005]; - snprintf(prompt, 1005, "l2tpns> "); - cli_loop(cli, sockfd, prompt); - } + cli_loop(cli, sockfd); close(sockfd); log(3, 0, 0, 0, "Closed CLI connection\n"); diff --git a/cluster.c b/cluster.c index 39a0db2..14b994a 100644 --- a/cluster.c +++ b/cluster.c @@ -1,6 +1,6 @@ // L2TPNS Clustering Stuff -char const *cvs_id_cluster = "$Id: cluster.c,v 1.8 2004/07/08 16:54:35 bodea Exp $"; +char const *cvs_id_cluster = "$Id: cluster.c,v 1.9 2004/07/11 07:57:35 bodea Exp $"; #include #include @@ -911,12 +911,25 @@ int cluster_catchup_slave(int seq, u32 slave) // We've heard from another peer! Add it to the list // that we select from at election time. // -int cluster_add_peer(u32 peer, time_t basetime, pingt *p) +int cluster_add_peer(u32 peer, time_t basetime, pingt *pp, int size) { int i; u32 clusterid; + pingt p; + - clusterid = p->addr; + // Allow for backward compatability. + // Just the ping packet into a new structure to allow + // for the possibility that we might have received + // more or fewer elements than we were expecting. + if (size > sizeof(p)) + size = sizeof(p); + + memset( (void*) &p, 0, sizeof(p) ); + memcpy( (void*) &p, (void*) pp, size); + + + clusterid = p.addr; if (clusterid != config->bind_address) { // Is this for us? @@ -932,7 +945,7 @@ int cluster_add_peer(u32 peer, time_t basetime, pingt *p) // This peer already exists. Just update the timestamp. peers[i].basetime = basetime; peers[i].timestamp = TIME; - peers[i].uptodate = !p->undef; + peers[i].uptodate = !p.undef; break; } @@ -969,7 +982,7 @@ int cluster_add_peer(u32 peer, time_t basetime, pingt *p) peers[i].peer = peer; peers[i].basetime = basetime; peers[i].timestamp = TIME; - peers[i].uptodate = !p->undef; + peers[i].uptodate = !p.undef; if (i == num_peers) ++num_peers; @@ -1297,7 +1310,7 @@ int processcluster(char * data, int size, u32 addr) switch (type) { case C_PING: // Update the peers table. - return cluster_add_peer(addr, more, (pingt*)p); + return cluster_add_peer(addr, more, (pingt*)p, s); case C_LASTSEEN: // Catch up a slave (slave missed a packet). return cluster_catchup_slave(more, addr); diff --git a/l2tpns.c b/l2tpns.c index cd550f7..c3443bd 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -4,7 +4,7 @@ // Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced // vim: sw=8 ts=8 -char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.12 2004/07/08 16:54:35 bodea Exp $"; +char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.13 2004/07/11 07:57:35 bodea Exp $"; #include #include @@ -1015,7 +1015,7 @@ void sessionshutdown(sessionidt s, char *reason) return; // not a live session } - if (!session[s].die) + if (!dead) log(2, 0, s, session[s].tunnel, "Shutting down session %d: %s\n", s, reason); session[s].die = now() + 150; // Clean up in 15 seconds @@ -1122,9 +1122,10 @@ void sessionkill(sessionidt s, char *reason) CSTAT(call_sessionkill); + session[s].die = now(); sessionshutdown(s, reason); // close radius/routes, etc. if (session[s].radius) - radiusclear(session[s].radius, 0); // cant send clean accounting data, session is killed + radiusclear(session[s].radius, s); // cant send clean accounting data, session is killed log(2, 0, s, session[s].tunnel, "Kill session %d (%s): %s\n", s, session[s].user, reason); @@ -1304,9 +1305,9 @@ void processudp(u8 * buf, int len, struct sockaddr_in *addr) // Is this a duplicate of the first packet? (SCCRQ) // for ( i = 1; i <= config->cluster_highest_tunnelid ; ++i) { - if (tunnel[t].state != TUNNELOPENING || - tunnel[t].ip != ntohl(*(ipt *) & addr->sin_addr) || - tunnel[t].port != ntohs(addr->sin_port) ) + if (tunnel[i].state != TUNNELOPENING || + tunnel[i].ip != ntohl(*(ipt *) & addr->sin_addr) || + tunnel[i].port != ntohs(addr->sin_port) ) continue; t = i; break; diff --git a/ppp.c b/ppp.c index a88add9..202f650 100644 --- a/ppp.c +++ b/ppp.c @@ -1,6 +1,6 @@ // L2TPNS PPP Stuff -char const *cvs_id_ppp = "$Id: ppp.c,v 1.7 2004/07/08 16:54:35 bodea Exp $"; +char const *cvs_id_ppp = "$Id: ppp.c,v 1.8 2004/07/11 07:57:35 bodea Exp $"; #include #include @@ -420,9 +420,9 @@ void processlcp(tunnelidt t, sessionidt s, u8 * p, u16 l) sessionshutdown(s, "Remote end closed connection."); tunnelsend(b, l + (q - b), t); // send it } - else if (*p == TerminateReq) + else if (*p == TerminateAck) { - sessionshutdown(s, "Remote end closed connection."); + sessionshutdown(s, "Connection closed."); } else if (*p == EchoReq) { diff --git a/radius.c b/radius.c index 1739c80..0f60298 100644 --- a/radius.c +++ b/radius.c @@ -1,6 +1,6 @@ // L2TPNS Radius Stuff -char const *cvs_id_radius = "$Id: radius.c,v 1.7 2004/07/07 09:09:53 bodea Exp $"; +char const *cvs_id_radius = "$Id: radius.c,v 1.8 2004/07/11 07:57:35 bodea Exp $"; #include #include @@ -664,6 +664,6 @@ void radius_clean() || !session[radius[i].session].opened || session[radius[i].session].die || session[radius[i].session].tunnel == 0) - radiusclear(i, 0); + radiusclear(i, radius[i].session); } }