From: Daniel Corbett Date: Tue, 11 Jun 2019 13:46:27 +0000 (-0400) Subject: BUG/MEDIUM: contrib/spoa_server: Set FIN flag on agent frames X-Git-Tag: v2.0-dev7~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e0fa55dcd5c1fd7ac113cce866759b1010ddf2d;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: contrib/spoa_server: Set FIN flag on agent frames When communicating over SPOP the AGENT-HELLO, AGENT-DISCONNECT, and ACK frames must have the FIN flag set. --- diff --git a/contrib/spoa_server/spoa.c b/contrib/spoa_server/spoa.c index a958f2226e..f36c3db903 100644 --- a/contrib/spoa_server/spoa.c +++ b/contrib/spoa_server/spoa.c @@ -679,13 +679,16 @@ error: * the number of written bytes otherwise. */ static void prepare_agentack(struct worker *w) { + unsigned int flags = 0; + w->ack_len = 0; /* Frame type */ w->ack[w->ack_len++] = SPOE_FRM_T_AGENT_ACK; - /* No flags for now */ - memset(w->ack + w->ack_len, 0, 4); /* No flags */ + /* Set flags */ + flags |= htonl(SPOE_FRM_FL_FIN); + memcpy(w->ack + w->ack_len, &flags, 4); w->ack_len += 4; /* Set stream-id and frame-id for ACK frames */ @@ -940,12 +943,14 @@ static int prepare_agenthello(struct worker *w) { int idx = 0; + unsigned int flags = 0; /* Frame Type */ w->buf[idx++] = SPOE_FRM_T_AGENT_HELLO; - /* No flags for now */ - memset(w->buf+idx, 0, 4); /* No flags */ + /* Set flags */ + flags |= htonl(SPOE_FRM_FL_FIN); + memcpy(w->buf+idx, &flags, 4); idx += 4; /* No stream-id and frame-id for HELLO frames */ @@ -978,6 +983,7 @@ prepare_agentdicon(struct worker *w) { const char *reason; int rlen, idx = 0; + unsigned int flags = 0; if (w->status_code >= SPOE_FRM_ERRS) w->status_code = SPOE_FRM_ERR_UNKNOWN; @@ -987,8 +993,9 @@ prepare_agentdicon(struct worker *w) /* Frame type */ w->buf[idx++] = SPOE_FRM_T_AGENT_DISCON; - /* No flags for now */ - memset(w->buf+idx, 0, 4); + /* Set flags */ + flags |= htonl(SPOE_FRM_FL_FIN); + memcpy(w->buf+idx, &flags, 4); idx += 4; /* No stream-id and frame-id for DISCONNECT frames */ diff --git a/contrib/spoa_server/spoa.h b/contrib/spoa_server/spoa.h index e9a7a46318..8f912e435f 100644 --- a/contrib/spoa_server/spoa.h +++ b/contrib/spoa_server/spoa.h @@ -21,6 +21,9 @@ #define SPOP_VERSION "2.0" #define SPOA_CAPABILITIES "" +/* Flags set on the SPOE frame */ +#define SPOE_FRM_FL_FIN 0x00000001 + /* All supported data types */ enum spoe_data_type { SPOE_DATA_T_NULL = 0,