MLPPP not working in cluster mode.

This commit is contained in:
fendo 2012-10-28 22:39:23 +01:00
parent 76ae461853
commit ce928583b4
5 changed files with 64 additions and 11 deletions

View file

@ -363,6 +363,28 @@ int master_garden_packet(sessionidt s, uint8_t *data, int size)
}
//
// Forward a MPPP packet to the master for handling.
//
// (Note that this must be called with the tun header
// as the start of the data).
// (i.e. this routine writes to data[-8]).
int master_forward_mppp_packet(sessionidt s, uint8_t *data, int size)
{
uint8_t *p = data - (2 * sizeof(uint32_t));
uint8_t *psave = p;
if (!config->cluster_master_address) // No election has been held yet. Just skip it.
return -1;
LOG(4, 0, 0, "Forward MPPP packet to master (size %d)\n", size);
add_type(&p, C_MPPP_FORWARD, s, NULL, 0);
return peer_send_data(config->cluster_master_address, psave, size + (2 * sizeof(uint32_t)));
}
//
// Send a chunk of data as a heartbeat..
// We save it in the history buffer as we do so.
@ -945,7 +967,7 @@ void cluster_heartbeat()
exit(1);
}
LOG(3, 0, 0, "Sending v%d heartbeat #%d, change #%" PRIu64 " with %d changes "
LOG(4, 0, 0, "Sending v%d heartbeat #%d, change #%" PRIu64 " with %d changes "
"(%d x-sess, %d x-bundles, %d x-tunnels, %d highsess, %d highbund, %d hightun, size %d)\n",
HB_VERSION, h.seq, h.table_version, config->cluster_num_changes,
count, bcount, tcount, config->cluster_highest_sessionid, config->cluster_highest_bundleid,
@ -1802,6 +1824,16 @@ int processcluster(uint8_t *data, int size, in_addr_t addr)
return 0;
}
case C_MPPP_FORWARD:
// Receive a MPPP packet from a slave.
if (!config->cluster_iam_master) {
LOG(0, 0, 0, "I'm not the master, but I got a C_MPPP_FORWARD from %s?\n", fmtaddr(addr, 0));
return -1;
}
processipout(p, s);
return 0;
case C_THROTTLE: { // Receive a forwarded packet from a slave.
if (!config->cluster_iam_master) {
LOG(0, 0, 0, "I'm not the master, but I got a C_THROTTLE from %s?\n", fmtaddr(addr, 0));

View file

@ -23,6 +23,7 @@
#define C_FORWARD_DAE 16 // A DAE packet for the master to handle
#define C_BUNDLE 17 // Bundle structure.
#define C_CBUNDLE 18 // Compressed bundle structure.
#define C_MPPP_FORWARD 19 // MPPP Forwarded packet..
#define HB_VERSION 6 // Protocol version number..
#define HB_MAX_SEQ (1<<30) // Maximum sequence number. (MUST BE A POWER OF 2!)
@ -84,6 +85,7 @@ int master_forward_packet(uint8_t *data, int size, in_addr_t addr, int port);
int master_forward_dae_packet(uint8_t *data, int size, in_addr_t addr, int port);
int master_throttle_packet(int tid, uint8_t *data, int size);
int master_garden_packet(sessionidt s, uint8_t *data, int size);
int master_forward_mppp_packet(sessionidt s, uint8_t *data, int size);
void master_update_counts(void);
void cluster_send_ping(time_t basetime);
void cluster_heartbeat(void);

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
l2tpns (2.2.1-2fdn1.5) unstable; urgency=low
* MLPPP not working in cluster mode.
-- Fernando Alves <fernando.alves@sameswireless.fr> Wed, 09 May 2012 17:25:05 +0200
l2tpns (2.2.1-2fdn1.4) unstable; urgency=low
* Add a echo_timeout configuration option.

View file

@ -1330,7 +1330,8 @@ static void update_session_out_stat(sessionidt s, sessiont *sp, int len)
// process outgoing (to tunnel) IP
//
static void processipout(uint8_t *buf, int len)
// (i.e. this routine writes to data[-8]).
void processipout(uint8_t *buf, int len)
{
sessionidt s;
sessiont *sp;
@ -1469,6 +1470,14 @@ static void processipout(uint8_t *buf, int len)
if(session[s].bundle != 0 && bundle[session[s].bundle].num_of_links > 1)
{
if (!config->cluster_iam_master)
{
// The MPPP packets must be managed by the Master.
master_forward_mppp_packet(s, data, size);
return;
}
// Add on L2TP header
sessionidt members[MAXBUNDLESES];
bundleidt bid = session[s].bundle;
@ -1490,7 +1499,7 @@ static void processipout(uint8_t *buf, int len)
if (nb_opened < 1)
{
LOG(2, s, t, "MPPP: PROCESSIPOUT ERROR, no session opened in bundle:%d\n", bid);
LOG(3, s, t, "MPPP: PROCESSIPOUT ERROR, no session opened in bundle:%d\n", bid);
return;
}
@ -2035,11 +2044,11 @@ void sessionshutdown(sessionidt s, char const *reason, int cdn_result, int cdn_e
{
uint8_t ml;
for(ml = 0; ml<bundle[b].num_of_links; ml++)
if(bundle[b].members[ml] == s)
{
mem_num = ml;
break;
}
if(bundle[b].members[ml] == s)
{
mem_num = ml;
break;
}
bundle[b].members[mem_num] = bundle[b].members[bundle[b].num_of_links];
LOG(3, s, session[s].tunnel, "MPPP: Adjusted member links array\n");
@ -2615,7 +2624,7 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr)
case 0: // message type
message = ntohs(*(uint16_t *) b);
mandatory = flags & 0x80;
LOG(4, s, t, " Message type = %u (%s)\n", *b, l2tp_code(message));
LOG(4, s, t, " Message type = %u (%s)\n", message, l2tp_code(message));
break;
case 1: // result code
{
@ -3210,6 +3219,7 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr)
}
// read and process packet on tun
// (i.e. this routine writes to buf[-8]).
static void processtun(uint8_t * buf, int len)
{
LOG_HEX(5, "Receive TUN Data", buf, len);
@ -3774,6 +3784,8 @@ static void mainloop(void)
{
int i;
uint8_t buf[65536];
uint8_t *p = buf + 8; // for the hearder of the forwarded MPPP packet (see C_MPPP_FORWARD)
int size_bufp = sizeof(buf) - 8;
clockt next_cluster_ping = 0; // send initial ping immediately
struct epoll_event events[BASE_FDS + RADIUS_FDS + EXTRA_FDS];
int maxevent = sizeof(events)/sizeof(*events);
@ -4018,9 +4030,9 @@ static void mainloop(void)
// incoming IP
if (tun_ready)
{
if ((s = read(tunfd, buf, sizeof(buf))) > 0)
if ((s = read(tunfd, p, size_bufp)) > 0)
{
processtun(buf, s);
processtun(p, s);
tun_pkts++;
}
else

View file

@ -897,6 +897,7 @@ void adjust_tcp_mss(sessionidt s, tunnelidt t, uint8_t *buf, int len, uint8_t *t
void sendipcp(sessionidt s, tunnelidt t);
void sendipv6cp(sessionidt s, tunnelidt t);
void processudp(uint8_t *buf, int len, struct sockaddr_in *addr);
void processipout(uint8_t *buf, int len);
void snoop_send_packet(uint8_t *packet, uint16_t size, in_addr_t destination, uint16_t port);
int find_filter(char const *name, size_t len);
int ip_filter(uint8_t *buf, int len, uint8_t filter);