From: fendo Date: Sun, 28 Oct 2012 21:39:23 +0000 (+0100) Subject: MLPPP not working in cluster mode. X-Git-Tag: 2.2.1-2fdn3.1~12 X-Git-Url: http://git.sameswireless.fr/l2tpns.git/commitdiff_plain/refs/heads/fendo-mods?hp=76ae461853c7ac6e101704f6e6fd41dc520e9921 MLPPP not working in cluster mode. --- diff --git a/cluster.c b/cluster.c index 7b6b33e..b54ae0c 100644 --- a/cluster.c +++ b/cluster.c @@ -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)); diff --git a/cluster.h b/cluster.h index 02f7965..faeede4 100644 --- a/cluster.h +++ b/cluster.h @@ -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); diff --git a/debian/changelog b/debian/changelog index 6753f07..8163a9b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +l2tpns (2.2.1-2fdn1.5) unstable; urgency=low + + * MLPPP not working in cluster mode. + + -- Fernando Alves Wed, 09 May 2012 17:25:05 +0200 + l2tpns (2.2.1-2fdn1.4) unstable; urgency=low * Add a echo_timeout configuration option. diff --git a/l2tpns.c b/l2tpns.c index 8640c8b..7478560 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -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 0) + if ((s = read(tunfd, p, size_bufp)) > 0) { - processtun(buf, s); + processtun(p, s); tun_pkts++; } else diff --git a/l2tpns.h b/l2tpns.h index 8ac2583..6314ae7 100644 --- a/l2tpns.h +++ b/l2tpns.h @@ -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);