Distinguish the bye packet interpretation

In openconnect client the BYE packet indicates an explicit
user disconnect by sending 0x0b as payload. In anyconnect clients it
may indicate an intention to reconnect (e.g., because network was changed).
We introduce a check for 0x0b to identify the user disconnect and
add debugging output for other disconnect reasons.

Relates: #281

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
This commit is contained in:
Nikos Mavrogiannopoulos
2020-04-06 14:21:34 +02:00
committed by Nikos Mavrogiannopoulos
parent 2c93618c90
commit fca41e2fa2
3 changed files with 18 additions and 1 deletions

View File

@@ -170,6 +170,8 @@ const char *discon_reason_to_str(unsigned reason)
return "unspecified";
case REASON_USER_DISCONNECT:
return "user disconnected";
case REASON_TEMP_DISCONNECT:
return "anyconnect client disconnected";
case REASON_SERVER_DISCONNECT:
return "server disconnected";
case REASON_IDLE_TIMEOUT:

View File

@@ -37,6 +37,7 @@
#define REASON_DPD_TIMEOUT 5
#define REASON_ERROR 6
#define REASON_SESSION_TIMEOUT 7
#define REASON_TEMP_DISCONNECT 8
/* Timeout (secs) for communication between main and sec-mod */
#define MAIN_SEC_MOD_TIMEOUT 120

View File

@@ -2514,7 +2514,21 @@ static int parse_data(struct worker_st *ws, uint8_t *buf, size_t buf_size,
break;
case AC_PKT_DISCONN:
oclog(ws, LOG_INFO, "received BYE packet; exiting");
exit_worker_reason(ws, REASON_USER_DISCONNECT);
/* In openconnect the BYE packet indicates an explicit
* user disconnect. In anyconnect clients it may indicate
* an intention to reconnect (e.g., because network was
* changed). We separate the error codes to ensure we do
* do not interpret the intention incorrectly (see #281). */
if (plain_size > 0 && plain[0] == 0xb0) {
exit_worker_reason(ws, REASON_USER_DISCONNECT);
} else {
if (plain_size > 0) {
oclog(ws, LOG_DEBUG, "bye packet with payload: %u/%.2x", (unsigned)plain_size, plain[0]);
return -1;
}
exit_worker_reason(ws, REASON_TEMP_DISCONNECT);
}
break;
case AC_PKT_COMPRESSED:
/* decompress */