]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
4 years agoMEDIUM: mux-h1: Return a 501-not-implemented for upgrade requests with a body
Christopher Faulet [Mon, 7 Dec 2020 17:17:33 +0000 (18:17 +0100)] 
MEDIUM: mux-h1: Return a 501-not-implemented for upgrade requests with a body

If an HTTP protocol upgrade request with a payload is received, a
501-not-implemented error is now returned to the client. It is valid from
the RFC point of view but will be incompatible with the way the H2
websockets will be handled by HAProxy. And it is probably a very uncommon
way to do perform protocol upgrades.

4 years agoMINOR: mux-h1: Be prepared to return 501-not-implemented error during parsing
Christopher Faulet [Mon, 7 Dec 2020 10:26:13 +0000 (11:26 +0100)] 
MINOR: mux-h1: Be prepared to return 501-not-implemented error during parsing

With this patch, the H1 mux is now able to return 501-not-implemented errors
to client during the request parsing. However, no such errors are returned
for now.

4 years agoMINOR: muxes: Add exit status for errors about not implemented features
Christopher Faulet [Mon, 7 Dec 2020 10:24:37 +0000 (11:24 +0100)] 
MINOR: muxes: Add exit status for errors about not implemented features

The MUX_ES_NOTIMPL_ERR exit status is added to allow the multiplexers to
report errors about not implemented features. This will be used by the H1
mux to return 501-not-implemented errors.

4 years agoMINOR: http: Add HTTP 501-not-implemented error message
Christopher Faulet [Mon, 7 Dec 2020 10:22:24 +0000 (11:22 +0100)] 
MINOR: http: Add HTTP 501-not-implemented error message

Add the support for the 501-not-implemented status code with the
corresponding default message. The documentation is updated accordingly
because it is now part of status codes HAProxy may emit via an errorfile or
a deny/return HTTP action.

4 years agoBUG/MEDIUM: mux-h2: Xfer rxbuf to the upper layer when creating a front stream
Christopher Faulet [Tue, 15 Dec 2020 15:56:50 +0000 (16:56 +0100)] 
BUG/MEDIUM: mux-h2: Xfer rxbuf to the upper layer when creating a front stream

Just like the H1 muliplexer, when a new frontend H2 stream is created, the
rxbuf is xferred to the stream at the upper layer.

Originally, it is not a bug fix, but just an api standardization. And in
fact, it fixes a crash when a h2 stream is aborted after the request parsing
but before the first call to process_stream(). It crashes since the commit
8bebd2fe5 ("MEDIUM: http-ana: Don't process partial or empty request
anymore"). It is now totally unexpected to have an HTTP stream without a
valid request. But here the stream is unable to get the request because the
client connection was aborted. Passing it during the stream creation fixes
the bug. But the true problem is that the stream-interfaces are still
relying on the connection state while only the muxes should do so.

This fix is specific for 2.4. No backport needed.

4 years agoBUG/MEDIUM: tcpcheck: Don't destroy connection in the wake callback context
Christopher Faulet [Mon, 18 Jan 2021 14:47:03 +0000 (15:47 +0100)] 
BUG/MEDIUM: tcpcheck: Don't destroy connection in the wake callback context

When a tcpcheck ruleset uses multiple connections, the existing one must be
closed and destroyed before openning the new one. This part is handled in
the tcpcheck_main() function, when called from the wake callback function
(wake_srv_chk). But it is indeed a problem, because this function may be
called from the mux layer. This means a mux may call the wake callback
function of the data layer, which may release the connection and the mux. It
is easy to see how it is hazardous. And actually, depending on the
scheduling, it leads to crashes.

Thus, we must avoid to release the connection in the wake callback context,
and move this part in the check's process function instead. To do so, we
rely on the CHK_ST_CLOSE_CONN flags. When a connection must be replaced by a
new one, this flag is set on the check, in tcpcheck_main() function, and the
check's task is woken up. Then, the connection is really closed in
process_chk_conn() function.

This patch must be backported as far as 2.2, with some adaptations however
because the code is not exactly the same.

4 years agoBUG/MINOR: mworker: define _GNU_SOURCE for strsignal()
Bertrand Jacquin [Thu, 21 Jan 2021 01:31:46 +0000 (01:31 +0000)] 
BUG/MINOR: mworker: define _GNU_SOURCE for strsignal()

glibc < 2.10 requires _GNU_SOURCE in order to make use of strsignal(),
otherwise leading to SEGV at runtime.

  $ make V=1 TARGET=linux-glibc-legacy USE_THREAD= USE_ACCEPT4=
  ..
  src/mworker.c: In function 'mworker_catch_sigchld':
  src/mworker.c:285: warning: implicit declaration of function 'strsignal'
  src/mworker.c:285: warning: pointer/integer type mismatch in conditional expression
  ..

  $ make V=1 reg-tests REGTESTS_TYPES=slow,default
  ..
  ###### Test case: reg-tests/mcli/mcli_start_progs.vtc ######
  ## test results in: "/tmp/haregtests-2021-01-19_15-18-07.n24989/vtc.29077.28f6153d"
  ---- h1    Bad exit status: 0x008b exit 0x0 signal 11 core 128
  ---- h1    Assert error in haproxy_wait(), src/vtc_haproxy.c line 792:  Condition(*(&h->fds[1]) >= 0) not true.  Errno=0 Success
  ..

  $ gdb ./haproxy /tmp/core.0.haproxy.30270
  ..
  Core was generated by `/root/haproxy/haproxy -d -W -S fd@8 -dM -f /tmp/haregtests-2021-01-19_15-18-07.'.
  Program terminated with signal 11, Segmentation fault.
  #0  0x00002aaaab387a10 in strlen () from /lib64/libc.so.6
  (gdb) bt
  #0  0x00002aaaab387a10 in strlen () from /lib64/libc.so.6
  #1  0x00002aaaab354b69 in vfprintf () from /lib64/libc.so.6
  #2  0x00002aaaab37788a in vsnprintf () from /lib64/libc.so.6
  #3  0x00000000004a76a3 in memvprintf (out=0x7fffedc680a0, format=0x5a5d58 "Current worker #%d (%d) exited with code %d (%s)\n", orig_args=0x7fffedc680d0)
      at src/tools.c:3868
  #4  0x00000000004bbd40 in print_message (label=0x58abed "ALERT", fmt=0x5a5d58 "Current worker #%d (%d) exited with code %d (%s)\n", argp=0x7fffedc680d0)
      at src/log.c:1066
  #5  0x00000000004bc07f in ha_alert (fmt=0x5a5d58 "Current worker #%d (%d) exited with code %d (%s)\n") at src/log.c:1109
  #6  0x0000000000534b7b in mworker_catch_sigchld (sh=<value optimized out>) at src/mworker.c:293
  #7  0x0000000000556af3 in __signal_process_queue () at src/signal.c:88
  #8  0x00000000004f6216 in signal_process_queue () at include/haproxy/signal.h:39
  #9  run_poll_loop () at src/haproxy.c:2859
  #10 0x00000000004f63b7 in run_thread_poll_loop (data=<value optimized out>) at src/haproxy.c:3028
  #11 0x00000000004faaac in main (argc=<value optimized out>, argv=0x7fffedc68498) at src/haproxy.c:904

See: https://man7.org/linux/man-pages/man3/strsignal.3.html

Must be backported as far as 2.0.

4 years agoMINOR: mux-h1/show_fd: report as suspicious an entry with too many calls
Willy Tarreau [Thu, 21 Jan 2021 08:13:35 +0000 (09:13 +0100)] 
MINOR: mux-h1/show_fd: report as suspicious an entry with too many calls

An FD entry that maps to an H1 connection whose stream was woken
up more than 1M times is now flagged as suspicious.

4 years agoMINOR: mux-h2/show_fd: report as suspicious an entry with too many calls
Willy Tarreau [Thu, 21 Jan 2021 08:13:35 +0000 (09:13 +0100)] 
MINOR: mux-h2/show_fd: report as suspicious an entry with too many calls

An FD entry that maps to an H2C connection whose last stream was woken
up more than 1M times is now flagged as suspicious.

4 years agoMINOR: ssl/show_fd: report some FDs as suspicious when possible
Willy Tarreau [Thu, 21 Jan 2021 07:53:50 +0000 (08:53 +0100)] 
MINOR: ssl/show_fd: report some FDs as suspicious when possible

If a subscriber's tasklet was called more than one million times, if
the ssl_ctx's connection doesn't match the current one, or if the
connection appears closed in one direction while the SSL stack is
still subscribed, the FD is reported as suspicious. The close cases
may occasionally trigger a false positive during very short and rare
windows. Similarly the 1M calls will trigger after 16GB are transferred
over a given connection. These are rare enough events to be reported as
suspicious.

4 years agoMINOR: cli/show_fd: report some easily detectable suspicious states
Willy Tarreau [Thu, 21 Jan 2021 08:07:29 +0000 (09:07 +0100)] 
MINOR: cli/show_fd: report some easily detectable suspicious states

A file descriptor which maps to a connection but has more than one
thread in its mask, or an FD handle that doesn't correspond to the FD,
or wiht no mux context, or an FD with no thread in its mask, or with
more than 1 million events is flagged as suspicious.

4 years agoMINOR: cli: give the show_fd helpers the ability to report a suspicious entry
Willy Tarreau [Thu, 21 Jan 2021 07:26:06 +0000 (08:26 +0100)] 
MINOR: cli: give the show_fd helpers the ability to report a suspicious entry

Now the show_fd helpers at the transport and mux levels return an integer
which indicates whether or not the inspected entry looks suspicious. When
an entry is reported as suspicious, "show fd" will suffix it with an
exclamation mark ('!') in the dump, that is supposed to help detecting
them.

For now, helpers were adjusted to adapt to the new API but none of them
reports any suspicious entry yet.

4 years agoCI: Pin VTest to a known good commit
Tim Duesterhus [Wed, 20 Jan 2021 18:13:29 +0000 (19:13 +0100)] 
CI: Pin VTest to a known good commit

As of January, 11th the macOS builds fail due to regression introduced in
VTest. This patch pins VTest to the newest good commit.

This patch should be reverted once VTest's 'master' is stable again.

see vtest/VTest#26

4 years agoMINOR: mux-fcgi: make the "show fd" helper also decode the fstrm subscriber when...
Willy Tarreau [Wed, 20 Jan 2021 16:10:46 +0000 (17:10 +0100)] 
MINOR: mux-fcgi: make the "show fd" helper also decode the fstrm subscriber when known

When dumping a live fcgi stream, also take the opportunity for reporting
the subscriber including the event, tasklet, handler and context.

4 years agoMINOR: mux-h1: make the "show fd" helper also decode the h1s subscriber when known
Willy Tarreau [Wed, 20 Jan 2021 16:05:58 +0000 (17:05 +0100)] 
MINOR: mux-h1: make the "show fd" helper also decode the h1s subscriber when known

When dumping a live h1 stream, also take the opportunity for reporting
the subscriber including the event, tasklet, handler and context. Example:

   3030 : st=0x21(R:rA W:Ra) ev=0x04(heOpi) [Lc] tmask=0x4 umask=0x0 owner=0x7f97805c1f70 iocb=0x65b847(sock_conn_iocb) back=1 cflg=0x00002300 sv=s1/recv mux=H1 ctx=0x7f97805c21b0 h1c.flg=0x80000200 .sub=1 .ibuf=0@(nil)+0/0 .obuf=0@(nil)+0/0 h1s=0x7f97805c2380 h1s.flg=0x4010 .req.state=MSG_DATA .res.state=MSG_RPBEFORE .meth=POST status=0 .cs.flg=0x00000000 .cs.data=0x7f97805c1720 .subs=0x7f97805c1748(ev=1 tl=0x7f97805c1990 tl.calls=2 tl.ctx=0x7f97805c1720 tl.fct=si_cs_io_cb) xprt=RAW

4 years agoMINOR: mux-h2: make the "show fd" helper also decode the h2s subscriber when known
Willy Tarreau [Wed, 20 Jan 2021 15:27:01 +0000 (16:27 +0100)] 
MINOR: mux-h2: make the "show fd" helper also decode the h2s subscriber when known

When dumping a valid h2 stream, also dump the subscriber, its events,
tasklet context and handler. Example:

    128 : st=0x21(R:rA W:Ra) ev=0x01(heopI) [lc] tmask=0x1 umask=0x0 owner=0x7f40380d7370 iocb=0x65b71b(sock_conn_iocb) back=0 cflg=0x00001300 fe=recv mux=H2 ctx=0x1ad23e0 h2c.st0=FRP .err=0 .maxid=3 .lastid=-1 .flg=0x10000 .nbst=2 .nbcs=2 .fctl_cnt=0 .send_cnt=0 .tree_cnt=2 .orph_cnt=0 .sub=1 .dsi=3 .dbuf=16366@0x1ea9380+16441/16448 .msi=-1 .mbuf=[1..1|32],h=[0@(nil)+0/0],t=[0@(nil)+0/0] last_h2s=0x20a8340 .id=3 .st=OPN .flg=0x4100 .rxbuf=0@(nil)+0/0 .cs=0x20a8440(.flg=0x00100000 .data=0x20a8738) .subs=0x20a8760(ev=1 tl=0x20a89b0 tl.calls=22 tl.ctx=0x20a8738 tl.fct=si_cs_io_cb) xprt=SSL xprt_ctx=0x1aaf4c0 xctx.st=0 .xprt=RAW .wait.ev=1 .subs=0x1ad28e0(ev=1 tl=0x1ab3c70 tl.calls=176 tl.ctx=0x1ad23e0 tl.fct=h2_io_cb) .sent_early=0 .early_in=0

4 years agoMINOR: xprt/mux: export all *_io_cb functions so that "show fd" resolves them
Willy Tarreau [Wed, 20 Jan 2021 13:55:01 +0000 (14:55 +0100)] 
MINOR: xprt/mux: export all *_io_cb functions so that "show fd" resolves them

In FD dumps it's often very important to figure what upper layer function
is going to be called. Let's export the few I/O callbacks that appear as
tasklet functions so that "show fd" can resolve them instead of printing
a pointer relative to main. For example:

   1028 : st=0x21(R:rA W:Ra) ev=0x01(heopI) [lc] tmask=0x2 umask=0x2 owner=0x7f00b889b200 iocb=0x65b638(sock_conn_iocb) back=0 cflg=0x00001300 fe=recv mux=H2 ctx=0x7f00c8824de0 h2c.st0=FRH .err=0 .maxid=795 .lastid=-1 .flg=0x0000 .nbst=0 .nbcs=0 .fctl_cnt=0 .send_cnt=0 .tree_cnt=0 .orph_cnt=0 .sub=1 .dsi=795 .dbuf=0@(nil)+0/0 .msi=-1 .mbuf=[1..1|32],h=[0@(nil)+0/0],t=[0@(nil)+0/0] xprt=SSL xprt_ctx=0x7f00c86d0750 xctx.st=0 .xprt=RAW .wait.ev=1 .subs=0x7f00c88252e0(ev=1 tl=0x7f00a07d1aa0 tl.calls=1047 tl.ctx=0x7f00c8824de0 tl.fct=h2_io_cb) .sent_early=0 .early_in=0

4 years agoMINOR: ssl: provide a "show fd" helper to report important SSL information
Willy Tarreau [Wed, 20 Jan 2021 13:41:29 +0000 (14:41 +0100)] 
MINOR: ssl: provide a "show fd" helper to report important SSL information

The SSL context contains a lot of important details that are currently
missing from debug outputs. Now that we detect ssl_sock, we can perform
some sanity checks, print the next xprt, the subscriber callback's context,
handler and number of calls. The process function is also resolved. This
now gives for example on an H2 connection:

   1029 : st=0x21(R:rA W:Ra) ev=0x01(heopI) [lc] tmask=0x2 umask=0x2 owner=0x7fc714881700 iocb=0x65b528(sock_conn_iocb) back=0 cflg=0x00001300 fe=recv mux=H2 ctx=0x7fc734545e50 h2c.st0=FRH .err=0 .maxid=217 .lastid=-1 .flg=0x0000 .nbst=0 .nbcs=0 .fctl_cnt=0 .send_cnt=0 .tree_cnt=0 .orph_cnt=0 .sub=1 .dsi=217 .dbuf=0@(nil)+0/0 .msi=-1 .mbuf=[1..1|32],h=[0@(nil)+0/0],t=[0@(nil)+0/0] xprt=SSL xprt_ctx=0x7fc73478f230 xctx.st=0 .xprt=RAW .wait.ev=1 .subs=0x7fc734546350(ev=1 tl=0x7fc7346702e0 tl.calls=278 tl.ctx=0x7fc734545e50 tl.fct=main-0x144efa) .sent_early=0 .early_in=0

4 years agoMINOR: xprt: add a new show_fd() helper to complete some "show fd" dumps.
Willy Tarreau [Wed, 20 Jan 2021 14:30:56 +0000 (15:30 +0100)] 
MINOR: xprt: add a new show_fd() helper to complete some "show fd" dumps.

Just like we did for the muxes, now the transport layers will have the
ability to provide helpers to report more detailed information about their
internal context. When the helper is not known, the pointer continues to
be dumped as-is if it's not NULL. This way a transport with no context nor
dump function will not add a useless "xprt_ctx=(nil)" but the pointer will
be emitted if valid or if a helper is defined.

4 years agoMINOR: cli: make "show fd" also report the xprt and xprt_ctx
Willy Tarreau [Wed, 20 Jan 2021 13:40:04 +0000 (14:40 +0100)] 
MINOR: cli: make "show fd" also report the xprt and xprt_ctx

These ones are definitely missing from some dumps, let's report them! We
print the xprt's name instead of its useless pointer, as well as its ctx
when xprt is not NULL.

4 years agoCLEANUP: cli: make "show fd" use a const connection to access other fields
Willy Tarreau [Wed, 20 Jan 2021 13:13:46 +0000 (14:13 +0100)] 
CLEANUP: cli: make "show fd" use a const connection to access other fields

Over time the code has uglified, casting fdt.owner as a struct connection
for about everything. Let's have a const struct connection* there and take
this opportunity for passing all fields as const as well.

Additionally a misplaced closing parenthesis on the output was fixed.

4 years agoCLEANUP: tools: make resolve_sym_name() take a const pointer
Willy Tarreau [Wed, 20 Jan 2021 13:37:59 +0000 (14:37 +0100)] 
CLEANUP: tools: make resolve_sym_name() take a const pointer

When 0c439d895 ("BUILD: tools: make resolve_sym_name() return a const")
was written, the pointer argument ought to have been turned to const for
more flexibility. Let's do it now.

4 years agoBUG/MINOR: mux_h2: missing space between "st" and ".flg" in the "show fd" helper
Willy Tarreau [Wed, 20 Jan 2021 14:50:03 +0000 (15:50 +0100)] 
BUG/MINOR: mux_h2: missing space between "st" and ".flg" in the "show fd" helper

That was causing confusing outputs like this one whenan H2S is known:

   1030 : ... last_h2s=0x2ed8390 .id=775 .st=HCR.flg=0x4001 .rxbuf=...
                                                ^^^^

This was introduced by commit ab2ec4540 in 2.1-dev2 so the fix can be
backported as far as 2.1.

4 years agoMINOR: contrib: Make the wireshark peers dissector compile for more distribs.
Frédéric Lécaille [Tue, 19 Jan 2021 13:33:24 +0000 (14:33 +0100)] 
MINOR: contrib: Make the wireshark peers dissector compile for more distribs.

With a 2.6.8 wireshark, this module could not compile because of ws_version.h
missing header. This patch offers the possibility to compile this plugin without
having to include this header. Furthermore with my wireshark version a
"plugin_release" object is required to make it be loaded by wireshark. This is
a string which seems to have to match a dotted string made of you wireshark
major and minor versions.

4 years agoBUG/MINOR: peers: Wrong "new_conn" value for "show peers" CLI command.
Frédéric Lécaille [Mon, 18 Jan 2021 14:14:39 +0000 (15:14 +0100)] 
BUG/MINOR: peers: Wrong "new_conn" value for "show peers" CLI command.

This counter could be hugely incremented by the peer task responsible of managing
peer synchronizations and reconnections, for instance when a peer is not reachable
there is a period where the appctx is not created. If we receive  stick-table
updates before the peer session (appctx) is instantiated, we reach the code
responsible of incrementing the "new_conn" counter.
With this patch we increment this counter only when we really instantiate a new
peer session thanks to peer_session_create().

May be backported as far as 2.0.

4 years agoCLEANUP: Rename accept_encoding_hash_cmp to accept_encoding_bitmap_cmp
Tim Duesterhus [Mon, 18 Jan 2021 12:41:17 +0000 (13:41 +0100)] 
CLEANUP: Rename accept_encoding_hash_cmp to accept_encoding_bitmap_cmp

For the `accept-encoding` header a bitmap and not a hash is stored.

4 years agoCLEANUP: cache: Use proper data types in secondary_key_cmp()
Tim Duesterhus [Mon, 18 Jan 2021 12:41:18 +0000 (13:41 +0100)] 
CLEANUP: cache: Use proper data types in secondary_key_cmp()

- hash_length is `unsigned int` and so should offset.
- idx is compared to a `size_t` and thus it should also be.

4 years agoMINOR: cache: Remove the `hash` part of the accept-encoding secondary key
Tim Duesterhus [Mon, 18 Jan 2021 12:41:16 +0000 (13:41 +0100)] 
MINOR: cache: Remove the `hash` part of the accept-encoding secondary key

As of commit 6ca89162dc881df8fecd7713ca1fe5dbaa66b315 this hash no longer is
required, because unknown encodings are not longer stored and known encodings
do not use the cache.

4 years agoMINOR: build: discard echoing in help target
Bertrand Jacquin [Sun, 17 Jan 2021 18:47:47 +0000 (18:47 +0000)] 
MINOR: build: discard echoing in help target

When V=1 is used in conjuction with help, the output becomes pretty
difficult to read properly.

  $ make TARGET=linux-glibc V=1 help
  ..
    DEBUG_USE_ABORT: use abort() for program termination, see include/haproxy/bug.h for details
  echo; \
     if [ -n "" ]; then \
       if [ -n "" ]; then \
          echo "Current TARGET: "; \
       else \
          echo "Current TARGET:  (custom target)"; \
       fi; \
     else \
       echo "TARGET not set, you may pass 'TARGET=xxx' to set one among :";\
       echo "  linux-glibc, linux-glibc-legacy, solaris, freebsd, dragonfly, netbsd,"; \
       echo "  osx, openbsd, aix51, aix52, aix72-gcc, cygwin, haiku, generic,"; \
       echo "  custom"; \
     fi

  TARGET not set, you may pass 'TARGET=xxx' to set one among :
    linux-glibc, linux-glibc-legacy, solaris, freebsd, dragonfly, netbsd,
    osx, openbsd, aix51, aix52, aix72-gcc, cygwin, haiku, generic,
    custom
  echo;echo "Enabled features for TARGET '' (disable with 'USE_xxx=') :"

  Enabled features for TARGET '' (disable with 'USE_xxx=') :
  set --        POLL                                  ; echo "  $*" | (fmt || cat) 2>/dev/null
    POLL
  echo;echo "Disabled features for TARGET '' (enable with 'USE_xxx=1') :"

  Disabled features for TARGET '' (enable with 'USE_xxx=1') :
  set -- EPOLL KQUEUE NETFILTER PCRE PCRE_JIT PCRE2 PCRE2_JIT  PRIVATE_CACHE THREAD PTHREAD_PSHARED BACKTRACE STATIC_PCRE STATIC_PCRE2 TPROXY LINUX_TPROXY LINUX_SPLICE LIBCRYPT CRYPT_H GETADDRINFO OPENSSL LUA FUTEX ACCEPT4 CLOSEFROM ZLIB SLZ CPU_AFFINITY TFO NS DL RT DEVICEATLAS 51DEGREES WURFL SYSTEMD OBSOLETE_LINKER PRCTL THREAD_DUMP EVPORTS OT QUIC; echo "  $*" | (fmt || cat) 2>/dev/null
    EPOLL KQUEUE NETFILTER PCRE PCRE_JIT PCRE2 PCRE2_JIT PRIVATE_CACHE

This commit ensure the help target always discard line echoing
regardless of V variable as done for reg-tests-help target.

4 years agoBUG/MINOR: peers: Possible appctx pointer dereference.
Frédéric Lécaille [Sun, 17 Jan 2021 12:08:39 +0000 (13:08 +0100)] 
BUG/MINOR: peers: Possible appctx pointer dereference.

This bug may occur when enabling peers traces. It is possible that
peer->appctx is NULL when entering peer_session_release().

4 years agoMINOR: cache: Do not store responses with an unknown encoding
Remi Tricot-Le Breton [Thu, 7 Jan 2021 13:50:51 +0000 (14:50 +0100)] 
MINOR: cache: Do not store responses with an unknown encoding

If a server varies on the accept-encoding header and it sends a response
with an encoding we do not know (see parse_encoding_value function), we
will not store it. This will prevent unexpected errors caused by
cache collisions that could happen in accept_encoding_hash_cmp.

4 years agoBUG/MEDIUM: stats: add missing INF_BUILD_INFO definition
Adis Nezirovic [Fri, 15 Jan 2021 12:12:33 +0000 (13:12 +0100)] 
BUG/MEDIUM: stats: add missing INF_BUILD_INFO definition

commit 5a982a71656ce885be4b1d4b90b8db31204788a1 ("MINOR:
contrib/prometheus-exporter: export build_info") is breaking lua
`core.get_info()`.

This patch makes sure build_info is correctly initialised in all cases.

Reviewed-by: William Dauchy <wdauchy@gmail.com>
4 years agoBUILD: peers: fix build warning about unused variable
Willy Tarreau [Fri, 15 Jan 2021 16:08:38 +0000 (17:08 +0100)] 
BUILD: peers: fix build warning about unused variable

Previous commit da2b0844f ("MINOR: peers: Add traces for peer control
messages.") introduced a build warning on some compiler versions after
the removal of variable "peers" in peer_send_msgs() because variable
"s" was used only to assign this one, and variable "si" to assign "s".
Let's remove both to fix the warning. No backport is needed.

4 years agoBUG/MINOR: dns: SRV records ignores duplicated AR records (v2)
Baptiste Assmann [Fri, 15 Jan 2021 16:01:24 +0000 (17:01 +0100)] 
BUG/MINOR: dns: SRV records ignores duplicated AR records (v2)

V2 of this fix which includes a missing pointer initialization which was
causing a segfault in v1 (949a7f64591458eb06c998acf409093ea991dc3a)

This bug happens when a service has multiple records on the same host
and the server provides the A/AAAA resolution in the response as AR
(Additional Records).

In such condition, the first occurence of the host will be taken from
the Additional section, while the second (and next ones) will be process
by an independent resolution task (like we used to do before 2.2).
This can lead to a situation where the "synchronisation" of the
resolution may diverge, like described in github issue #971.

Because of this behavior, HAProxy mixes various type of requests to
resolve the full list of servers: SRV+AR for all "first" occurences and
A/AAAA for all other occurences of an existing hostname.
IE: with the following type of response:

   ;; ANSWER SECTION:
   _http._tcp.be2.tld.     3600    IN      SRV     5 500 80 A2.tld.
   _http._tcp.be2.tld.     3600    IN      SRV     5 500 86 A3.tld.
   _http._tcp.be2.tld.     3600    IN      SRV     5 500 80 A1.tld.
   _http._tcp.be2.tld.     3600    IN      SRV     5 500 85 A3.tld.

   ;; ADDITIONAL SECTION:
   A2.tld.                 3600    IN      A       192.168.0.2
   A3.tld.                 3600    IN      A       192.168.0.3
   A1.tld.                 3600    IN      A       192.168.0.1
   A3.tld.                 3600    IN      A       192.168.0.3

the first A3 host is resolved using the Additional Section and the
second one through a dedicated A request.

When linking the SRV records to their respective Additional one, a
condition was missing (chek if said SRV record is already attached to an
Additional one), leading to stop processing SRV only when the target
SRV field matches the Additional record name. Hence only the first
occurence of a target was managed by an additional record.
This patch adds a condition in this loop to ensure the record being
parsed is not already linked to an Additional Record. If so, we can
carry on the parsing to find a possible next one with the same target
field value.

backport status: 2.2 and above

4 years agoMINOR: peers: Add traces for peer control messages.
Frédéric Lécaille [Fri, 15 Jan 2021 15:21:28 +0000 (16:21 +0100)] 
MINOR: peers: Add traces for peer control messages.

Display traces when sending/receiving peer control messages (synchronisation, heartbeat).
Add remaining traces when parsing malformed messages (acks, stick-table definitions)
or ignoring them.
Also add traces when releasing session or when reaching the PEER_SESS_ST_ERRPROTO
peer protocol state.

4 years agoMINOR: pattern: add the missing generation ID manipulation functions
Willy Tarreau [Fri, 15 Jan 2021 13:40:04 +0000 (14:40 +0100)] 
MINOR: pattern: add the missing generation ID manipulation functions

The functions needed to commit a pattern file generation number or
increase it were still missing. Better not have the caller play with
these.

4 years agoCLEANUP: pattern: rename pat_ref_commit() to pat_ref_commit_elt()
Willy Tarreau [Fri, 15 Jan 2021 13:11:59 +0000 (14:11 +0100)] 
CLEANUP: pattern: rename pat_ref_commit() to pat_ref_commit_elt()

It's about the third time I get confused by these functions, half of
which manipulate the reference as a whole and those manipulating only
an entry. For me "pat_ref_commit" means committing the pattern reference,
not just an element, so let's rename it. A number of other ones should
really be renamed before 2.4 gets released :-/

4 years agoBUG/MINOR: threads: Fixes the number of possible cpus report for Mac.
David CARLIER [Fri, 15 Jan 2021 08:09:56 +0000 (08:09 +0000)] 
BUG/MINOR: threads: Fixes the number of possible cpus report for Mac.

There is no low level api to achieve same as Linux/FreeBSD, we rely
on CPUs available. Without this, the number of threads is just 1 for
Mac while having 8 cores in my M1.

Backporting to 2.1 should be enough if that's possible.

Signed-off-by: David CARLIER <devnexen@gmail.com>
4 years agoMINOR: server: Forbid server definitions in frontend sections
Christopher Faulet [Wed, 13 Jan 2021 12:14:13 +0000 (13:14 +0100)] 
MINOR: server: Forbid server definitions in frontend sections

An fatal error is now reported if a server is defined in a frontend
section. til now, a warning was just emitted and the server was ignored. The
warning was added in the 1.3.4 when the frontend/backend keywords were
introduced to allow a smooth transition and to not break existing
configs. It is old enough now to emit an fatal error in this case.

This patch is related to the issue #1043. It may be backported at least as
far as 2.2, and possibly to older versions. It relies on the previous commit
("MINOR: config: Add failifnotcap() to emit an alert on proxy capabilities").

4 years agoMINOR: config: Add failifnotcap() to emit an alert on proxy capabilities
Christopher Faulet [Wed, 13 Jan 2021 11:10:00 +0000 (12:10 +0100)] 
MINOR: config: Add failifnotcap() to emit an alert on proxy capabilities

This function must be used to emit an alert if a proxy does not have at
least one of the requested capabilities. An additional message may be
appended to the alert.

4 years agoBUG/MINOR: init: Use a dynamic buffer to set HAPROXY_CFGFILES env variable
Christopher Faulet [Tue, 12 Jan 2021 17:57:38 +0000 (18:57 +0100)] 
BUG/MINOR: init: Use a dynamic buffer to set HAPROXY_CFGFILES env variable

The HAPROXY_CFGFILES env variable is built using a static trash chunk, via a
call to get_trash_chunk() function. This chunk is reserved during the whole
configuration parsing. It is far too large to guarantee it will not be
reused during the configuration parsing. And in fact, it happens in the lua
code since the commit f67442efd ("BUG/MINOR: lua: warn when registering
action, conv, sf, cli or applet multiple times"), when a lua script is
loaded.

To fix the bug, we now use a dynamic buffer instead. And we call memprintf()
function to handle both the allocation and the formatting. Allocation errors
at this stage are fatal.

This patch should fix the issue #1041. It must be backported as far as 2.0.

4 years agoMINOR: contrib/prometheus-exporter: use fill_info for process dump
William Dauchy [Mon, 11 Jan 2021 19:07:49 +0000 (20:07 +0100)] 
MINOR: contrib/prometheus-exporter: use fill_info for process dump

use `stats_fill_info` when possible to avoid duplicating code.

Signed-off-by: William Dauchy <wdauchy@gmail.com>
4 years agoMINOR: contrib/prometheus-exporter: avoid connection close header
William Dauchy [Mon, 11 Jan 2021 19:07:48 +0000 (20:07 +0100)] 
MINOR: contrib/prometheus-exporter: avoid connection close header

it does not seem to have a reason to close connections after each
request; reflect that in tests by doing all requests within the same
client.

Signed-off-by: William Dauchy <wdauchy@gmail.com>
4 years agoBUG/MINOR: init: enforce strict-limits when using master-worker
Jerome Magnin [Tue, 12 Jan 2021 19:19:38 +0000 (20:19 +0100)] 
BUG/MINOR: init: enforce strict-limits when using master-worker

The strict-limits global option was introduced with commit 0fec3ab7b
("MINOR: init: always fail when setrlimit fails"). When used in
conjuction with master-worker, haproxy will not fail when a setrlimit
fails. This happens because we only exit() if master-worker isn't used.

This patch removes all tests for master-worker mode for all cases covered
by strict-limits scope.

This should be backported from 2.1 onward.
This should fix issue #1042.

Reviewed by William Dauchy <wdauchy@gmail.com>

4 years agoBUG/MINOR: check: Don't perform any check on servers defined in a frontend
Christopher Faulet [Tue, 12 Jan 2021 16:29:45 +0000 (17:29 +0100)] 
BUG/MINOR: check: Don't perform any check on servers defined in a frontend

If a server is defined in a frontend, thus a proxy without the backend
capability, the 'check' and 'agent-check' keywords are ignored. This way, no
check is performed on an ignored server. This avoids a segfault because some
part of the tcpchecks are not fully initialized (or released for frontends
during the post-check).

In addition, an test on the server's proxy capabilities is performed when
checks or agent-checks are initialized and nothing is performed for servers
attached to a non-backend proxy.

This patch should fix the issue #1043. It must be backported as far as 2.2.

4 years agoBUG/MINOR: sample: Memory leak of sample_expr structure in case of error
Remi Tricot-Le Breton [Tue, 12 Jan 2021 13:55:12 +0000 (14:55 +0100)] 
BUG/MINOR: sample: Memory leak of sample_expr structure in case of error

If an errors occurs during the sample expression parsing, the alloced
sample_expr is not freed despite having its main pointer reset.

This fixes GitHub issue #1046.
It could be backported as far as 1.8.

4 years agoRevert "BUG/MINOR: dns: SRV records ignores duplicated AR records"
Christopher Faulet [Tue, 12 Jan 2021 09:27:26 +0000 (10:27 +0100)] 
Revert "BUG/MINOR: dns: SRV records ignores duplicated AR records"

This reverts commit 949a7f64591458eb06c998acf409093ea991dc3a.

The first part of the patch introduces a bug. When a dns answer item is
allocated, its <ar_item> is only initialized at the end of the parsing, when
the item is added in the answer list. Thus, we must not try to release it
during the parsing.

The second part is also probably buggy. It fixes the issue #971 but reverts
a fix for the issue #841 (see commit fb0884c8297 "BUG/MEDIUM: dns: Don't
store additional records in a linked-list"). So it must be at least
revalidated.

This revert fixes a segfault reported in a comment of the issue #971. It
must be backported as far as 2.2.

4 years agoMINOR: reg-tests: add base prometheus test
William Dauchy [Sun, 10 Jan 2021 20:13:06 +0000 (21:13 +0100)] 
MINOR: reg-tests: add base prometheus test

Add a base test to start with something, even though this is not
necessarily complete.
Also make use of the recent REQUIRE_SERVICE option to exclude it from
test list of it was not build with prometheus included.

note: I thought it was possible to send multiple requests within the
same client, but I'm getting "HTTP header is incomplete" from the second
request

Signed-off-by: William Dauchy <wdauchy@gmail.com>
4 years agoBUG/MINOR: reg-tests: fix service dependency script
William Dauchy [Sun, 10 Jan 2021 20:13:05 +0000 (21:13 +0100)] 
BUG/MINOR: reg-tests: fix service dependency script

I badly tested my previous patch forgetting to remove the "+" testing
present in options, and not in services; the list of services do not
have any "+" at the beginning of each service

this patch is fixing commit aabde7133242563109b4f36c42e732f083 ("MINOR:
reg-tests: add a way to add service dependency")

Signed-off-by: William Dauchy <wdauchy@gmail.com>
4 years agoBUG/MINOR: sample: check alloc_trash_chunk return value in concat()
William Dauchy [Mon, 11 Jan 2021 10:05:58 +0000 (11:05 +0100)] 
BUG/MINOR: sample: check alloc_trash_chunk return value in concat()

like it is done in other places, check the return value of
`alloc_trash_chunk` before using it. This was detected by coverity.

this patch fixes commit 591fc3a330005c289b4705fe4cb37c4eec9f9eed
("BUG/MINOR: sample: fix concat() converter's corruption with non-string
variables"
As a consequence, this patch should be backported as far as 2.0

this should fix github issue #1039

Signed-off-by: William Dauchy <wdauchy@gmail.com>
4 years agoMINOR: reg-tests: add a way to add service dependency
William Dauchy [Sat, 9 Jan 2021 16:26:20 +0000 (17:26 +0100)] 
MINOR: reg-tests: add a way to add service dependency

I was looking at writing a simple first test for prometheus but I
realised there is no proper way to exclude it if haproxy was not built
with prometheus plugin.

Today we have `REQUIRE_OPTIONS` in reg-tests which is based on `Feature
list` from `haproxy -vv`. Those options are coming from the Makefile
itself.

A plugin is build this way:
  EXTRA_OBJS="contrib/prometheus-exporter/service-prometheus.o"

It does register service actions through `service_keywords_register`.
Those are listed through `list_services` in `haproxy -vv`.
To facilitate parsing, I slightly changed the output to a single line
and integrate it in regtests shell script so that we can now specify a
dependency while writing a reg-test for prometheus, e.g:

  #REQUIRE_SERVICE=prometheus-exporter
  #REQUIRE_SERVICES=prometheus-exporter,foo

There might be other ways to handle this, but that's the cleanest I
found; I understand people might be concerned by this output change in
`haproxy -vv` which goes from:

  Available services :
          foo
          bar

to:

  Available services : foo bar

Signed-off-by: William Dauchy <wdauchy@gmail.com>
4 years agoCLEANUP: sample: remove uneeded check in json validation
William Dauchy [Fri, 8 Jan 2021 20:57:41 +0000 (21:57 +0100)] 
CLEANUP: sample: remove uneeded check in json validation

- check functions are never called with a NULL args list, it is always
  an array, so first check can be removed
- the expression parser guarantees that we can't have anything else,
  because we mentioned json converter takes a mandatory string argument.
  Thus test on `ARGT_STR` can be removed as well
- also add breaking line between enum and function declaration

In order to validate it, add a simple json test testing very simple
cases but can be improved in the future:

- default json converter without args
- json converter failing on error (utf8)
- json converter with error being removed (utf8s)

Signed-off-by: William Dauchy <wdauchy@gmail.com>
4 years agoBUG/MINOR: server: Memory leak of proxy.used_server_addr during deinit
Thayne McCombs [Fri, 8 Jan 2021 05:11:05 +0000 (22:11 -0700)] 
BUG/MINOR: server: Memory leak of proxy.used_server_addr during deinit

GitHub Issue #1037 Reported a memory leak in deinit() caused by an
allocation made in sa2str() that was stored in srv_set_addr_desc().

When destroying each server for a proxy in deinit, include freeing the
memory in the key of server->addr_node.

The leak was introduced in commit 92149f9a8 ("MEDIUM: stick-tables: Add
srvkey option to stick-table") which is not in any released version so
no backport is needed.

Cc: Tim Duesterhus <tim@bastelstu.be>
4 years agoBUG/MINOR: sample: fix concat() converter's corruption with non-string variables
Willy Tarreau [Fri, 8 Jan 2021 15:08:43 +0000 (16:08 +0100)] 
BUG/MINOR: sample: fix concat() converter's corruption with non-string variables

Patrick Hemmer reported that calling concat() with an integer variable
causes a %00 to appear at the beginning of the output. Looking at the
code, it's not surprising. The function uses get_trash_chunk() to get
one of the trashes, but can call casting functions which will also use
their trash in turn and will cycle back to ours, causing the trash to
be overwritten before being assigned to a sample.

By allocating the trash from a pool using alloc_trash_chunk(), we can
avoid this. However we must free it so the trash's contents must be
moved to a permanent trash buffer before returning. This is what's
achieved using smp_dup().

This should be backported as far as 2.0.

4 years agoDOC: Add maintainers for the Prometheus exporter
Christopher Faulet [Fri, 8 Jan 2021 13:39:04 +0000 (14:39 +0100)] 
DOC: Add maintainers for the Prometheus exporter

William Dauchy and Christopher Faulet are the official maintainers of the
Prometheus exporter. William better knows the Prometheus usages and is the
referent for the features while Christopher's role is more code-centric, he
takes care of bugs and the exporter integration into Haproxy.

4 years agoCI: github: add a few more words to the codespell ignore list
Thayne McCombs [Fri, 8 Jan 2021 04:42:56 +0000 (21:42 -0700)] 
CI: github: add a few more words to the codespell ignore list

This adds "referer,ot,uint,iif,fo,keep-alives" to the ignore list:
  - "referer" is the well-known HTTP header field name (with its
    spelling error)
  - "ot" appears a lot in the opentracing contrib.
  - "iff" often stands for "if and only if"
  - "fo" appears as a test string in tests/ist.c (could possibly be
     changed)
  - "keep-alives" appears as a noon in "...enable TCP keep-alives".

4 years agoSCRIPTS: announce-release: fix typo in help message
Thayne McCombs [Fri, 8 Jan 2021 04:36:27 +0000 (21:36 -0700)] 
SCRIPTS: announce-release: fix typo in help message

s/relase/release in -p help message.

4 years agoCLEANUP: Fix spelling errors in comments
Thayne McCombs [Fri, 8 Jan 2021 04:35:52 +0000 (21:35 -0700)] 
CLEANUP: Fix spelling errors in comments

This is from the output of codespell. It's done at once over a bunch
of files and only affects comments, so there is nothing user-visible.
No backport needed.

4 years agoDOC: fix some spelling issues over multiple files
Thayne McCombs [Fri, 8 Jan 2021 04:24:41 +0000 (21:24 -0700)] 
DOC: fix some spelling issues over multiple files

This is from the output of codespell and may be backported.

4 years agoMINOR: contrib/prometheus-exporter: export build_info
William Dauchy [Fri, 8 Jan 2021 12:18:06 +0000 (13:18 +0100)] 
MINOR: contrib/prometheus-exporter: export build_info

commit c55a626217a7e676e1cc ("MINOR: contrib/prometheus-exporter: Add
missing global and per-server metrics") is renaming two metrics between
v2.2 and v2.3:
  server_idle_connections_current
  server_idle_connections_limit

It is breaking some tools which are making use of those metrics while
supporting several haproxy versions. This build_info will permit tools
which make use of metrics to be able to match the haproxy version and
change the list of expected metrics. This was possible using the haproxy
stats socket but not with prometheus export.

This patch follows prometheus best pratices to export specific software
informations. It is adding a new field `build_info` so we can extend it
to other parameters if needed in the future.

example output:
  # HELP haproxy_process_build_info HAProxy build info.
  # TYPE haproxy_process_build_info gauge
  haproxy_process_build_info{version="2.4-dev5-2e1a3f-5"} 1

Even though it is not a bugfix, this patch will make more sense when
backported up to >= 2.0

Signed-off-by: William Dauchy <wdauchy@gmail.com>
4 years agoBUG/MINOR: hlua: Fix memory leak in hlua_alloc
Tim Duesterhus [Fri, 8 Jan 2021 09:35:33 +0000 (10:35 +0100)] 
BUG/MINOR: hlua: Fix memory leak in hlua_alloc

During a configuration check valgrind reports:

    ==14425== 0 bytes in 106 blocks are definitely lost in loss record 1 of 107
    ==14425==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==14425==    by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==14425==    by 0x443CFC: hlua_alloc (hlua.c:8662)
    ==14425==    by 0x5F72B11: luaM_realloc_ (in /usr/lib/x86_64-linux-gnu/liblua5.3.so.0.0.0)
    ==14425==    by 0x5F78089: luaH_free (in /usr/lib/x86_64-linux-gnu/liblua5.3.so.0.0.0)
    ==14425==    by 0x5F707D3: sweeplist (in /usr/lib/x86_64-linux-gnu/liblua5.3.so.0.0.0)
    ==14425==    by 0x5F710D0: luaC_freeallobjects (in /usr/lib/x86_64-linux-gnu/liblua5.3.so.0.0.0)
    ==14425==    by 0x5F7715D: close_state (in /usr/lib/x86_64-linux-gnu/liblua5.3.so.0.0.0)
    ==14425==    by 0x443D4C: hlua_deinit (hlua.c:9302)
    ==14425==    by 0x543F88: deinit (haproxy.c:2742)
    ==14425==    by 0x5448E7: deinit_and_exit (haproxy.c:2830)
    ==14425==    by 0x5455D9: init (haproxy.c:2044)

This is due to Lua calling `hlua_alloc()` with `ptr = NULL` and `nsize = 0`.
While `realloc` is supposed to be equivalent `free()` if the size is `0` this
is only required for a non-NULL pointer. Apparently my allocator (or valgrind)
actually allocates a zero size area if the pointer is NULL, possibly taking up
some memory for management structures.

Fix this leak by specifically handling the case where both the pointer and the
size are `0`.

This bug appears to have been introduced with the introduction of the
multi-threaded Lua, thus this fix is specific for 2.4. No backport needed.

4 years agoCLEANUP: cfgparse: replace "realloc" with "my_realloc2" to fix to memory leak on...
Ilya Shipitsin [Thu, 7 Jan 2021 17:45:13 +0000 (22:45 +0500)] 
CLEANUP: cfgparse: replace "realloc" with "my_realloc2" to fix to memory leak on error

my_realloc2 frees variable in case of allocation failure.

fixes #1030

realloc was introduced in 9e1758efbd68c8b1d27e17e2abe4444e110f3ebe

this might be backported to 2.2, 2.3

4 years agoBUILD: Makefile: exclude broken tests by default
William Dauchy [Thu, 7 Jan 2021 16:10:51 +0000 (17:10 +0100)] 
BUILD: Makefile: exclude broken tests by default

it could be sometimes a bit confusing to have tests which are known to
be broken executed in the default `make reg-tests` command, especially
for not frequent contributors which are not necessarily aware of all our
quirks.

without this patch, this test is failing on my side:
  #    top  TEST reg-tests/seamless-reload/abns_socket.vtc FAILED (2.228) exit=2
  1 tests failed, 0 tests skipped, 107 tests passed

Signed-off-by: William Dauchy <wdauchy@gmail.com>
4 years agoBUILD: ssl: guard openssl specific with SSL_READ_EARLY_DATA_SUCCESS
Ilya Shipitsin [Thu, 7 Jan 2021 06:59:58 +0000 (11:59 +0500)] 
BUILD: ssl: guard openssl specific with SSL_READ_EARLY_DATA_SUCCESS

let us switch to SSL_READ_EARLY_DATA_SUCCESS instead of openssl versions

4 years agoBUILD: ssl: guard EVP_PKEY_get_default_digest_nid with ASN1_PKEY_CTRL_DEFAULT_MD_NID
Ilya Shipitsin [Thu, 7 Jan 2021 06:57:42 +0000 (11:57 +0500)] 
BUILD: ssl: guard EVP_PKEY_get_default_digest_nid with ASN1_PKEY_CTRL_DEFAULT_MD_NID

let us switch to openssl specific macro instead of versions

4 years agoBUILD: SSL: guard TLS13 ciphersuites with HAVE_SSL_CTX_SET_CIPHERSUITES
Ilya Shipitsin [Thu, 7 Jan 2021 06:55:45 +0000 (11:55 +0500)] 
BUILD: SSL: guard TLS13 ciphersuites with HAVE_SSL_CTX_SET_CIPHERSUITES

accidently src/server.c still used earlier guarding

4 years agoMINOR: converter: adding support for url_enc
William Dauchy [Wed, 6 Jan 2021 22:39:50 +0000 (23:39 +0100)] 
MINOR: converter: adding support for url_enc

add base support for url encode following RFC3986, supporting `query`
type only.

- add test checking url_enc/url_dec/url_enc
- update documentation
- leave the door open for future changes

this should resolve github issue #941

Signed-off-by: William Dauchy <wdauchy@gmail.com>
4 years ago[RELEASE] Released version 2.4-dev5 v2.4-dev5
Willy Tarreau [Wed, 6 Jan 2021 16:41:32 +0000 (17:41 +0100)] 
[RELEASE] Released version 2.4-dev5

Released version 2.4-dev5 with the following main changes :
    - BUG/MEDIUM: mux_h2: Add missing braces in h2_snd_buf()around trace+wakeup
    - BUILD: hpack: hpack-tbl-t.h uses VAR_ARRAY but does not include compiler.h
    - MINOR: time: increase the minimum wakeup interval to 60s
    - MINOR: check: do not ignore a connection header for http-check send
    - REGTESTS: complete http-check test
    - CI: travis-ci: drop coverity scan builds
    - MINOR: atomic: don't use ; to separate instruction on aarch64.
    - IMPORT: xxhash: update to v0.8.0 that introduces stable XXH3 variant
    - MEDIUM: xxhash: use the XXH3 functions to generate 64-bit hashes
    - MEDIUM: xxhash: use the XXH_INLINE_ALL macro to inline all functions
    - CLEANUP: xxhash: remove the unused src/xxhash.c
    - MINOR: sample: add the xxh3 converter
    - REGTESTS: add tests for the xxh3 converter
    - MINOR: protocol: Create proto_quic QUIC protocol layer.
    - MINOR: connection: Attach a "quic_conn" struct to "connection" struct.
    - MINOR: quic: Redefine control layer callbacks which are QUIC specific.
    - MINOR: ssl_sock: Initialize BIO and SSL objects outside of ssl_sock_init()
    - MINOR: connection: Add a new xprt to connection.
    - MINOR: ssl: Export definitions required by QUIC.
    - MINOR: cfgparse: Do not modify the QUIC xprt when parsing "ssl".
    - MINOR: tools: Add support for QUIC addresses parsing.
    - MINOR: quic: Add definitions for QUIC protocol.
    - MINOR: quic: Import C source code files for QUIC protocol.
    - MINOR: listener: Add QUIC info to listeners and receivers.
    - MINOR: server: Add QUIC definitions to servers.
    - MINOR: ssl: SSL CTX initialization modifications for QUIC.
    - MINOR: ssl: QUIC transport parameters parsing.
    - MINOR: quic: QUIC socket management finalization.
    - MINOR: cfgparse: QUIC default server transport parameters init.
    - MINOR: quic: Enable the compilation of QUIC modules.
    - MAJOR: quic: Make usage of ebtrees to store QUIC ACK ranges.
    - MINOR: quic: Attempt to make trace more readable
    - MINOR: quic: Make usage of the congestion control window.
    - MINOR: quic: Flag RX packet as ack-eliciting from the generic parser.
    - MINOR: quic: Code reordering to help in reviewing/modifying.
    - MINOR: quic: Add traces to congestion avoidance NewReno callback.
    - MINOR: quic: Display the SSL alert in ->ssl_send_alert() callback.
    - MINOR: quic: Update the initial salt to that of draft-29.
    - MINOR: quic: Add traces for in flght ack-eliciting packet counter.
    - MINOR: quic: make a packet build fails when qc_build_frm() fails.
    - MINOR: quic: Add traces for quic_packet_encrypt().
    - MINOR: cache: Refactoring of secondary_key building functions
    - MINOR: cache: Avoid storing responses whose secondary key was not correctly calculated
    - BUG/MINOR: cache: Manage multiple headers in accept-encoding normalization
    - MINOR: cache: Add specific secondary key comparison mechanism
    - MINOR: http: Add helper functions to trim spaces and tabs
    - MEDIUM: cache: Manage a subset of encodings in accept-encoding normalizer
    - REGTESTS: cache: Simplify vary.vtc file
    - REGTESTS: cache: Add a specific test for the accept-encoding normalizer
    - MINOR: cache: Remove redundant test in http_action_req_cache_use
    - MINOR: cache: Replace the "process-vary" option's expected values
    - CI: GitHub Actions: enable daily Coverity scan
    - BUG/MEDIUM: cache: Fix hash collision in `accept-encoding` handling for `Vary`
    - MEDIUM: stick-tables: Add srvkey option to stick-table
    - REGTESTS: add test for stickiness using "srvkey addr"
    - BUILD: Makefile: disable -Warray-bounds until it's fixed in gcc 11
    - BUG/MINOR: sink: Return an allocation failure in __sink_new if strdup() fails
    - BUG/MINOR: lua: Fix memory leak error cases in hlua_config_prepend_path
    - MINOR: lua: Use consistent error message 'memory allocation failed'
    - CLEANUP: Compare the return value of `XXXcmp()` functions with zero
    - CLEANUP: Apply the coccinelle patch for `XXXcmp()` on include/
    - CLEANUP: Apply the coccinelle patch for `XXXcmp()` on contrib/
    - MINOR: qpack: Add static header table definitions for QPACK.
    - CLEANUP: qpack: Wrong comment about the draft for QPACK static header table.
    - CLEANUP: quic: Remove useless QUIC event trace definitions.
    - BUG/MINOR: quic: Possible CRYPTO frame building errors.
    - MINOR: quic: Pass quic_conn struct to frame parsers.
    - BUG/MINOR: quic: Wrong STREAM frames parsing.
    - MINOR: quic: Drop packets with STREAM frames with wrong direction.
    - CLEANUP: ssl: Remove useless loop in tlskeys_list_get_next()
    - CLEANUP: ssl: Remove useless local variable in tlskeys_list_get_next()
    - MINOR: ssl: make tlskeys_list_get_next() take a list element
    - Revert "BUILD: Makefile: disable -Warray-bounds until it's fixed in gcc 11"
    - BUG/MINOR: cfgparse: Fail if the strdup() for `rule->be.name` for `use_backend` fails
    - CLEANUP: mworker: remove duplicate pointer tests in cfg_parse_program()
    - CLEANUP: Reduce scope of `header_name` in http_action_store_cache()
    - CLEANUP: Reduce scope of `hdr_age` in http_action_store_cache()
    - CLEANUP: spoe: fix typo on `var_check_arg` comment
    - BUG/MINOR: tcpcheck: Report a L7OK if the last evaluated rule is a send rule
    - CI: github actions: build several popular "contrib" tools
    - DOC: Improve the message printed when running `make` w/o `TARGET`
    - BUG/MEDIUM: server: srv_set_addr_desc() crashes when a server has no address
    - REGTESTS: add unresolvable servers to srvkey-addr
    - BUG/MINOR: stats: Make stat_l variable used to dump a stat line thread local
    - BUG/MINOR: quic: NULL pointer dereferences when building post handshake frames.
    - SCRIPTS: improve announce-release to support different tag and versions
    - SCRIPTS: make announce release support preparing announces before tag exists
    - CLEANUP: assorted typo fixes in the code and comments
    - BUG/MINOR: srv: do not init address if backend is disabled
    - BUG/MINOR: srv: do not cleanup idle conns if pool max is null
    - CLEANUP: assorted typo fixes in the code and comments
    - CLEANUP: few extra typo and fixes over last one ("ot" -> "to")

4 years agoCLEANUP: few extra typo and fixes over last one ("ot" -> "to")
Willy Tarreau [Wed, 6 Jan 2021 16:35:12 +0000 (17:35 +0100)] 
CLEANUP: few extra typo and fixes over last one ("ot" -> "to")

As noticed by Tim there were a few incorrect fixes in the previous patch
("ot" -> "to" and not "or").

4 years agoCLEANUP: assorted typo fixes in the code and comments
Ilya Shipitsin [Wed, 6 Jan 2021 16:20:16 +0000 (21:20 +0500)] 
CLEANUP: assorted typo fixes in the code and comments

This is 15th iteration of typo fixes

4 years agoBUG/MINOR: srv: do not cleanup idle conns if pool max is null
Amaury Denoyelle [Wed, 6 Jan 2021 13:28:51 +0000 (14:28 +0100)] 
BUG/MINOR: srv: do not cleanup idle conns if pool max is null

If a server is configured to not have any idle conns, returns immediatly
from srv_cleanup_connections. This avoids a segfault when a server is
configured with pool-max-conn to 0.

This should be backported up to 2.2.

4 years agoBUG/MINOR: srv: do not init address if backend is disabled
Amaury Denoyelle [Wed, 6 Jan 2021 13:28:50 +0000 (14:28 +0100)] 
BUG/MINOR: srv: do not init address if backend is disabled

Do not proceed on init_addr if the backend of the server is marked as
disabled. When marked as disabled, the server is not fully initialized
and some operation must be avoided to prevent segfault. It is correct
because there is no way to activate a disabled backend.

This fixes the github issue #1031.
This should be backported to 2.2.

4 years agoCLEANUP: assorted typo fixes in the code and comments
Ilya Shipitsin [Tue, 5 Jan 2021 17:10:46 +0000 (22:10 +0500)] 
CLEANUP: assorted typo fixes in the code and comments

This is 14th iteration of typo fixes

4 years agoSCRIPTS: make announce release support preparing announces before tag exists
Willy Tarreau [Wed, 6 Jan 2021 14:46:33 +0000 (15:46 +0100)] 
SCRIPTS: make announce release support preparing announces before tag exists

It takes so much time to write an announce message that sometimes it's
annoying not being able to start the work while a fix is being finished.
With the new "-p" argument, announce-release will allow to prepare the
announce message for the current HEAD and with no tag yet. It will
restart from the last tag and automatically increment the version using
the same algorithm as create-release so that everything is accurate. It
should then be easier at the last moment to just include the final entry
by hand when the last fix finally arrives. For convenience, this argument
also allows to create an announce from another branch than master.

4 years agoSCRIPTS: improve announce-release to support different tag and versions
Willy Tarreau [Wed, 6 Jan 2021 14:16:46 +0000 (15:16 +0100)] 
SCRIPTS: improve announce-release to support different tag and versions

By having three variables it will be easier to preset the version and
the tag separately. One contains the announced version, another one the
associated tag and the last one the final commit ID (used as the ending
point before the release). This initially allows to check for the HEAD
matching the tag only when the version was not forced, hence re-announce
already tagged versions after some extra commits were added for example.

4 years agoBUG/MINOR: quic: NULL pointer dereferences when building post handshake frames.
Frédéric Lécaille [Wed, 6 Jan 2021 11:12:39 +0000 (12:12 +0100)] 
BUG/MINOR: quic: NULL pointer dereferences when building post handshake frames.

The second one was detected by cppcheck contrary to the first one.
Fixes issue #1032.
Thank you to Ilya for having reported this.

4 years agoBUG/MINOR: stats: Make stat_l variable used to dump a stat line thread local
Christopher Faulet [Wed, 6 Jan 2021 06:41:56 +0000 (07:41 +0100)] 
BUG/MINOR: stats: Make stat_l variable used to dump a stat line thread local

Since ee63d4bd6 ("MEDIUM: stats: integrate static proxies stats in new
stats"), all dumped stats for a given domain, the default ones and the
modules ones, are merged in a signle array to dump them in a generic way.
For this purpose, the stat_l global variable is allocated at startup to
store a line of stats before the dump, i.e. all stats of an entity
(frontend, backend, listener, server or dns nameserver). But this variable
is not thread safe.  If stats are retrieved concurrently by several clients
on different threads, the same variable is used. This leads to corrupted
stats output.

To fix the bug, the stat_l variable is now thread local.

This patch should probably solve issues #972 and #992. It must be backported
to 2.3.

4 years agoREGTESTS: add unresolvable servers to srvkey-addr
Willy Tarreau [Wed, 6 Jan 2021 08:20:22 +0000 (09:20 +0100)] 
REGTESTS: add unresolvable servers to srvkey-addr

This ensures that the previous fix remains operational, as without it
an unresolvable server causes a crash when it's been indexed.

4 years agoBUG/MEDIUM: server: srv_set_addr_desc() crashes when a server has no address
Thayne McCombs [Wed, 6 Jan 2021 06:10:09 +0000 (23:10 -0700)] 
BUG/MEDIUM: server: srv_set_addr_desc() crashes when a server has no address

GitHub Issue #1026 reported a crash during configuration check for the
following example config:

    backend 0
    server 0 0
    server 0 0

HAProxy crashed in srv_set_addr_desc() due to a NULL pointer dereference
caused by `sa2str` returning NULL for an `AF_UNSPEC` address (`0`).

Check to make sure the address key is non-null before using it for
comparison or inserting it into the tree.

The crash was introduced in commit 92149f9a8 ("MEDIUM: stick-tables: Add
srvkey option to stick-table") which not in any released version so no
backport is needed.

Cc: Tim Duesterhus <tim@bastelstu.be>
4 years agoDOC: Improve the message printed when running `make` w/o `TARGET`
Tim Duesterhus [Tue, 5 Jan 2021 17:10:41 +0000 (18:10 +0100)] 
DOC: Improve the message printed when running `make` w/o `TARGET`

Rephrase the message to no longer talk about something that "is no longer
supported", but about what actually *is* supported.

Adjustments include:

- Removal of rare targets to make it easier to find the proper one.
- Reformatting to be easier to read (more newlines)
- Explanation of common non-default feature flags.

4 years agoCI: github actions: build several popular "contrib" tools
Ilya Shipitsin [Wed, 30 Dec 2020 10:25:25 +0000 (15:25 +0500)] 
CI: github actions: build several popular "contrib" tools

this adds "halog", "flags" and "poll" builds. builds are done in
separate steps for better failure identification

4 years agoBUG/MINOR: tcpcheck: Report a L7OK if the last evaluated rule is a send rule
Christopher Faulet [Tue, 5 Jan 2021 15:56:07 +0000 (16:56 +0100)] 
BUG/MINOR: tcpcheck: Report a L7OK if the last evaluated rule is a send rule

When all rules of a tcpcheck ruleset are successfully evaluated, the right
check status must always be reported. It is true if the last evaluated rule
is an expect or a connect rule. But not if it is a send rule. In this
situation, nothing more is done until the check timeout expiration and a
L7TOUT is reported instead of a L7OK.

Now, by default, when all rules were successfully evaluated, a L7OK is
reported. When the last evaluated rule is an expect or a connect, the
behavior remains unchanged.

This patch should fix the issue #1027. It must be backported as far as 2.2.

4 years agoCLEANUP: spoe: fix typo on `var_check_arg` comment
William Dauchy [Tue, 5 Jan 2021 10:14:58 +0000 (11:14 +0100)] 
CLEANUP: spoe: fix typo on `var_check_arg` comment

there was an extra `s` added to the `var_check_arg` function

Signed-off-by: William Dauchy <wdauchy@gmail.com>
4 years agoCLEANUP: Reduce scope of `hdr_age` in http_action_store_cache()
Tim Duesterhus [Sat, 2 Jan 2021 21:47:17 +0000 (22:47 +0100)] 
CLEANUP: Reduce scope of `hdr_age` in http_action_store_cache()

This is only required to process the `age` header.

4 years agoCLEANUP: Reduce scope of `header_name` in http_action_store_cache()
Tim Duesterhus [Sat, 2 Jan 2021 21:47:16 +0000 (22:47 +0100)] 
CLEANUP: Reduce scope of `header_name` in http_action_store_cache()

This variable is only needed deeply nested in a single location and clang's
static analyzer complains about a dead initialization. Reduce the scope to
satisfy clang and the human that reads the function.

4 years agoCLEANUP: mworker: remove duplicate pointer tests in cfg_parse_program()
Willy Tarreau [Tue, 5 Jan 2021 14:58:37 +0000 (15:58 +0100)] 
CLEANUP: mworker: remove duplicate pointer tests in cfg_parse_program()

As reported in issue #1017, there are two harmless duplicate tests in
cfg_parse_program(), one made of a "if" using the same condition as the
loop it's in, and the other one being a null test before a free. This
just removes them. No backport is needed.

4 years agoBUG/MINOR: cfgparse: Fail if the strdup() for `rule->be.name` for `use_backend` fails
Tim Duesterhus [Sun, 3 Jan 2021 21:54:43 +0000 (22:54 +0100)] 
BUG/MINOR: cfgparse: Fail if the strdup() for `rule->be.name` for `use_backend` fails

This patch fixes GitHub issue #1024.

I could track the `strdup` back to commit
3a1f5fda109fc56ae127d03eaf34ce027c9542e1 which is 1.9-dev8. It's probably not
worth the effort to backport it across this refactoring.

This patch should be backported to 1.9+.

4 years agoRevert "BUILD: Makefile: disable -Warray-bounds until it's fixed in gcc 11"
Willy Tarreau [Tue, 5 Jan 2021 10:11:38 +0000 (11:11 +0100)] 
Revert "BUILD: Makefile: disable -Warray-bounds until it's fixed in gcc 11"

This reverts commit 5e8c35da1b93b64ec4892192aec3d61d73b3bbce.

While the issue is being discussed with gcc folks, a reasonable workaround
could be found for the tls_keys_ref list usage which doesn't significantly
complicate the code. Since it was the only place triggering the warning and
I don't feel very comfortable leaving this one disabled for too long, let's
re-enable it right now. This definitely closes issue #1010.

4 years agoMINOR: ssl: make tlskeys_list_get_next() take a list element
Willy Tarreau [Tue, 5 Jan 2021 09:44:30 +0000 (10:44 +0100)] 
MINOR: ssl: make tlskeys_list_get_next() take a list element

As reported in issue #1010, gcc-11 as of 2021-01-05 is overzealous in
its -Warray-bounds check as it considers that a cast of a global struct
accesses the entire struct even if only one specific element is accessed.
This instantly breaks all lists making use of container_of() to build
their iterators as soon as the starting point is known if the next
element is retrieved from the list head in a way that is visible to the
compiler's optimizer, because it decides that accessing the list's next
element dereferences the list as a larger struct (which it does not).

The temporary workaround consisted in disabling -Warray-bounds, but this
warning is traditionally quite effective at spotting real bugs, and we
actually have is a single occurrence of this issue in the whole code.

By changing the tlskeys_list_get_next() function to take a list element
as the starting point instead of the current element, we can avoid
the starting point issue but this requires to change all call places
to write hideous casts made of &((struct blah*)ref)->list. At the
moment we only have two such call places, the first one being used to
initialize the list (which is the one causing the warning) and which
is thus easy to simplify, and the second one for which we already have
an aliased pointer to the reference that is still valid at the call
place, and given the original pointer also remained unchanged, we can
safely use this alias, and this is safer than leaving a cast there.

Let's make this change now while it's still easy.

The generated code only changed in function cli_io_handler_tlskeys_files()
due to register allocation and the change of variable scope between the
old one and the new one.

4 years agoCLEANUP: ssl: Remove useless local variable in tlskeys_list_get_next()
Tim Duesterhus [Sun, 3 Jan 2021 00:29:56 +0000 (01:29 +0100)] 
CLEANUP: ssl: Remove useless local variable in tlskeys_list_get_next()

`getnext` was only used to fill `ref` at the beginning of the function. Both
have the same type. Replace the parameter name by `ref` to remove the useless
local variable.

4 years agoCLEANUP: ssl: Remove useless loop in tlskeys_list_get_next()
Tim Duesterhus [Sun, 3 Jan 2021 00:29:55 +0000 (01:29 +0100)] 
CLEANUP: ssl: Remove useless loop in tlskeys_list_get_next()

This loop was always exited in the first iteration by `return`.

4 years agoMINOR: quic: Drop packets with STREAM frames with wrong direction.
Frédéric Lécaille [Thu, 31 Dec 2020 11:45:38 +0000 (12:45 +0100)] 
MINOR: quic: Drop packets with STREAM frames with wrong direction.

A server initiates streams with odd-numbered stream IDs.
Also add useful traces when parsing STREAM frames.

4 years agoBUG/MINOR: quic: Wrong STREAM frames parsing.
Frédéric Lécaille [Thu, 31 Dec 2020 09:57:04 +0000 (10:57 +0100)] 
BUG/MINOR: quic: Wrong STREAM frames parsing.

After having re-read the RFC, we noticed there are two bugs in the STREAM
frame parser. When the OFF bit (0x04) in the frame type is not set
we must set the offset to 0 (it was not set at all). When the LEN bit (0x02)
is not set we must extend the length of the data field to the end of the packet
(it was not set at all).

4 years agoMINOR: quic: Pass quic_conn struct to frame parsers.
Frédéric Lécaille [Tue, 29 Dec 2020 10:42:08 +0000 (11:42 +0100)] 
MINOR: quic: Pass quic_conn struct to frame parsers.

This is only for debugging purposes.

4 years agoBUG/MINOR: quic: Possible CRYPTO frame building errors.
Frédéric Lécaille [Thu, 24 Dec 2020 12:01:37 +0000 (13:01 +0100)] 
BUG/MINOR: quic: Possible CRYPTO frame building errors.

This is issue is due to the fact that when we call the function
responsible of building CRYPTO frames to fill a buffer, the Length
field of this packet did not take into an account the trailing 16 bytes for
the AEAD tag. Furthermore, the remaining <room> available in this buffer
was not decremented by the CRYPTO frame length, but only by the CRYPTO data length
of this frame.

4 years agoCLEANUP: quic: Remove useless QUIC event trace definitions.
Frédéric Lécaille [Wed, 23 Dec 2020 16:17:37 +0000 (17:17 +0100)] 
CLEANUP: quic: Remove useless QUIC event trace definitions.

Remove QUIC_EV_CONN_E* event trace macros which were defined for  errors.
Replace QUIC_EV_CONN_ECHPKT by QUIC_EV_CONN_BCFRMS used in qc_build_cfrms()

4 years agoCLEANUP: qpack: Wrong comment about the draft for QPACK static header table.
Frédéric Lécaille [Tue, 22 Dec 2020 15:08:51 +0000 (16:08 +0100)] 
CLEANUP: qpack: Wrong comment about the draft for QPACK static header table.

This came with a "copy and paste" from the definition for HPACK.

4 years agoMINOR: qpack: Add static header table definitions for QPACK.
Frédéric Lécaille [Tue, 22 Dec 2020 15:01:57 +0000 (16:01 +0100)] 
MINOR: qpack: Add static header table definitions for QPACK.

As HPACK, QPACK makes usage of a static header table.

4 years agoCLEANUP: Apply the coccinelle patch for `XXXcmp()` on contrib/
Tim Duesterhus [Sat, 2 Jan 2021 21:31:55 +0000 (22:31 +0100)] 
CLEANUP: Apply the coccinelle patch for `XXXcmp()` on contrib/

Compare the various `cmp()` functions against zero.

4 years agoCLEANUP: Apply the coccinelle patch for `XXXcmp()` on include/
Tim Duesterhus [Sat, 2 Jan 2021 21:31:54 +0000 (22:31 +0100)] 
CLEANUP: Apply the coccinelle patch for `XXXcmp()` on include/

Compare the various `XXXcmp()` functions against zero.