]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: contrib/spoa_server: Set FIN flag on agent frames
authorDaniel Corbett <dcorbett@haproxy.com>
Tue, 11 Jun 2019 13:46:27 +0000 (09:46 -0400)
committerWilly Tarreau <w@1wt.eu>
Tue, 11 Jun 2019 17:27:41 +0000 (19:27 +0200)
When communicating over SPOP the AGENT-HELLO, AGENT-DISCONNECT,
and ACK frames must have the FIN flag set.

contrib/spoa_server/spoa.c
contrib/spoa_server/spoa.h

index a958f2226ee34890e3fb04523d4ea01e57b87a86..f36c3db903080b3d1bea402066373f9e1c203094 100644 (file)
@@ -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 */
index e9a7a46318575fb27c4edee8e9d1369f7ce4fc63..8f912e435fe2f09a0dab9ed8bf4669922ff17683 100644 (file)
@@ -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,