]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: spoe: Add "send-frag-payload" option in spoe-agent section
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 24 Feb 2017 21:11:21 +0000 (22:11 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 9 Mar 2017 14:32:55 +0000 (15:32 +0100)
This option can be used to enable or to disable (prefixing the option line with
the "no" keyword) the sending of fragmented payload to agents. By default, this
option is enabled.

include/types/spoe.h
src/flt_spoe.c

index e8ef7a185177afb52466ab122b0338900cdd8858..edbb459048936792b30e0a2b37cf6fbee29f9421 100644 (file)
@@ -36,6 +36,8 @@
 #define SPOE_FL_CONT_ON_ERR       0x00000001 /* Do not stop events processing when an error occurred */
 #define SPOE_FL_PIPELINING        0x00000002 /* Set when SPOE agent supports pipelining (set by default) */
 #define SPOE_FL_ASYNC             0x00000004 /* Set when SPOE agent supports async (set by default) */
+#define SPOE_FL_SND_FRAGMENTATION 0x00000008 /* Set when SPOE agent supports sending fragmented payload */
+#define SPOE_FL_RCV_FRAGMENTATION 0x00000010 /* Set when SPOE agent supports receiving fragmented payload */
 
 /* Flags set on the SPOE context */
 #define SPOE_CTX_FL_CLI_CONNECTED 0x00000001 /* Set after that on-client-session event was processed */
index 3014fa8ff31601a444ee45127330ff35bcfeee3c..7b332221f969b01bae2dbc92b140d0bd335e010e 100644 (file)
@@ -407,6 +407,11 @@ spoe_prepare_hahello_frame(struct appctx *appctx, char *frame, size_t size)
                memcpy(chk->str+chk->len, "async", 5);
                chk->len += 5;
        }
+       if (agent != NULL && (agent->flags & SPOE_FL_RCV_FRAGMENTATION)) {
+               if (chk->len) chk->str[chk->len++] = ',';
+               memcpy(chk->str+chk->len, "fragmentation", 13);
+               chk->len += 5;
+       }
        if (spoe_encode_buffer(chk->str, chk->len, &p, end) == -1)
                goto too_big;
 
@@ -2170,9 +2175,10 @@ spoe_encode_messages(struct stream *s, struct spoe_context *ctx,
        return 1;
 
   too_big:
-       // FIXME: if fragmentation not supported =>
-       //  ctx->status_code = SPOE_CTX_ERR_TOO_BIG;
-       //  return -1;
+       if (!(agent->flags & SPOE_FL_SND_FRAGMENTATION)) {
+               ctx->status_code = SPOE_CTX_ERR_TOO_BIG;
+               return -1;
+       }
 
        SPOE_PRINTF(stderr, "%d.%06d [SPOE/%-15s] %s: stream=%p"
                    " - encode fragmented messages - spoe_appctx=%p"
@@ -3017,7 +3023,7 @@ cfg_parse_spoe_agent(const char *file, int linenum, char **args, int kwm)
                curagent->engine_id      = NULL;
                curagent->var_pfx        = NULL;
                curagent->var_on_error   = NULL;
-               curagent->flags          = (SPOE_FL_PIPELINING | SPOE_FL_ASYNC);
+               curagent->flags          = (SPOE_FL_PIPELINING | SPOE_FL_ASYNC | SPOE_FL_SND_FRAGMENTATION);
                curagent->cps_max        = 0;
                curagent->eps_max        = 0;
                curagent->max_frame_size = MAX_FRAME_SIZE;
@@ -3138,6 +3144,15 @@ cfg_parse_spoe_agent(const char *file, int linenum, char **args, int kwm)
                                curagent->flags |= SPOE_FL_ASYNC;
                        goto out;
                }
+               else if (!strcmp(args[1], "send-frag-payload")) {
+                       if (alertif_too_many_args(1, file, linenum, args, &err_code))
+                               goto out;
+                       if (kwm == 1)
+                               curagent->flags &= ~SPOE_FL_SND_FRAGMENTATION;
+                       else
+                               curagent->flags |= SPOE_FL_SND_FRAGMENTATION;
+                       goto out;
+               }
 
                /* Following options does not support negation */
                if (kwm == 1) {