Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | 03fa5df | 2010-05-24 21:02:37 +0200 | [diff] [blame] | 2 | * Frontend variables and functions. |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 3 | * |
Willy Tarreau | d6896bc | 2013-01-07 22:48:29 +0100 | [diff] [blame] | 4 | * Copyright 2000-2013 Willy Tarreau <w@1wt.eu> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <errno.h> |
| 14 | #include <fcntl.h> |
| 15 | #include <stdio.h> |
| 16 | #include <stdlib.h> |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 17 | #include <string.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 18 | |
| 19 | #include <sys/socket.h> |
| 20 | #include <sys/stat.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Willy Tarreau | 48a7e72 | 2010-12-24 15:26:39 +0100 | [diff] [blame] | 23 | #include <netinet/tcp.h> |
| 24 | |
Willy Tarreau | c7e4238 | 2012-08-24 19:22:53 +0200 | [diff] [blame] | 25 | #include <common/chunk.h> |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 26 | #include <common/compat.h> |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 27 | #include <common/config.h> |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 28 | #include <common/debug.h> |
Willy Tarreau | 0108d90 | 2018-11-25 19:14:37 +0100 | [diff] [blame] | 29 | #include <common/initcall.h> |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 30 | #include <common/standard.h> |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 31 | #include <common/time.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 32 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 33 | #include <types/global.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 34 | |
Willy Tarreau | 8797c06 | 2007-05-07 00:55:35 +0200 | [diff] [blame] | 35 | #include <proto/acl.h> |
Willy Tarreau | 61612d4 | 2012-04-19 18:42:05 +0200 | [diff] [blame] | 36 | #include <proto/arg.h> |
Willy Tarreau | c7e4238 | 2012-08-24 19:22:53 +0200 | [diff] [blame] | 37 | #include <proto/channel.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 38 | #include <proto/fd.h> |
Willy Tarreau | 03fa5df | 2010-05-24 21:02:37 +0200 | [diff] [blame] | 39 | #include <proto/frontend.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 40 | #include <proto/log.h> |
Willy Tarreau | 9650f37 | 2009-08-16 14:02:45 +0200 | [diff] [blame] | 41 | #include <proto/proto_tcp.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 42 | #include <proto/proto_http.h> |
Willy Tarreau | 7f062c4 | 2009-03-05 18:43:00 +0100 | [diff] [blame] | 43 | #include <proto/proxy.h> |
Willy Tarreau | d6896bc | 2013-01-07 22:48:29 +0100 | [diff] [blame] | 44 | #include <proto/sample.h> |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 45 | #include <proto/stream.h> |
Willy Tarreau | dded32d | 2008-11-30 19:48:07 +0100 | [diff] [blame] | 46 | #include <proto/stream_interface.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 47 | #include <proto/task.h> |
| 48 | |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 49 | /* Finish a stream accept() for a proxy (TCP or HTTP). It returns a negative |
Willy Tarreau | abe8ea5 | 2010-11-11 10:56:04 +0100 | [diff] [blame] | 50 | * value in case of a critical failure which must cause the listener to be |
Willy Tarreau | e0232f1 | 2015-04-05 18:01:06 +0200 | [diff] [blame] | 51 | * disabled, a positive or null value in case of success. |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 52 | */ |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 53 | int frontend_accept(struct stream *s) |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 54 | { |
Willy Tarreau | e36cbcb | 2015-04-03 15:40:56 +0200 | [diff] [blame] | 55 | struct session *sess = s->sess; |
Willy Tarreau | e0232f1 | 2015-04-05 18:01:06 +0200 | [diff] [blame] | 56 | struct connection *conn = objt_conn(sess->origin); |
Willy Tarreau | e36cbcb | 2015-04-03 15:40:56 +0200 | [diff] [blame] | 57 | struct listener *l = sess->listener; |
| 58 | struct proxy *fe = sess->fe; |
Willy Tarreau | fb0afa7 | 2015-04-03 14:46:27 +0200 | [diff] [blame] | 59 | |
Willy Tarreau | e36cbcb | 2015-04-03 15:40:56 +0200 | [diff] [blame] | 60 | if ((fe->mode == PR_MODE_TCP || fe->mode == PR_MODE_HTTP) |
| 61 | && (!LIST_ISEMPTY(&fe->logsrvs))) { |
| 62 | if (likely(!LIST_ISEMPTY(&fe->logformat))) { |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 63 | /* we have the client ip */ |
| 64 | if (s->logs.logwait & LW_CLIP) |
Willy Tarreau | d79a3b2 | 2012-12-28 09:40:16 +0100 | [diff] [blame] | 65 | if (!(s->logs.logwait &= ~(LW_CLIP|LW_INIT))) |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 66 | s->do_log(s); |
Willy Tarreau | a3445fc | 2010-05-20 16:17:07 +0200 | [diff] [blame] | 67 | } |
Willy Tarreau | e0232f1 | 2015-04-05 18:01:06 +0200 | [diff] [blame] | 68 | else if (conn) { |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 69 | char pn[INET6_ADDRSTRLEN], sn[INET6_ADDRSTRLEN]; |
Willy Tarreau | 14c8aac | 2007-05-08 19:46:30 +0200 | [diff] [blame] | 70 | |
Willy Tarreau | b363a1f | 2013-10-01 10:45:07 +0200 | [diff] [blame] | 71 | conn_get_from_addr(conn); |
| 72 | conn_get_to_addr(conn); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 73 | |
Willy Tarreau | b363a1f | 2013-10-01 10:45:07 +0200 | [diff] [blame] | 74 | switch (addr_to_str(&conn->addr.from, pn, sizeof(pn))) { |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 75 | case AF_INET: |
| 76 | case AF_INET6: |
Willy Tarreau | b363a1f | 2013-10-01 10:45:07 +0200 | [diff] [blame] | 77 | addr_to_str(&conn->addr.to, sn, sizeof(sn)); |
Willy Tarreau | e36cbcb | 2015-04-03 15:40:56 +0200 | [diff] [blame] | 78 | send_log(fe, LOG_INFO, "Connect from %s:%d to %s:%d (%s/%s)\n", |
Willy Tarreau | b363a1f | 2013-10-01 10:45:07 +0200 | [diff] [blame] | 79 | pn, get_host_port(&conn->addr.from), |
| 80 | sn, get_host_port(&conn->addr.to), |
Willy Tarreau | e36cbcb | 2015-04-03 15:40:56 +0200 | [diff] [blame] | 81 | fe->id, (fe->mode == PR_MODE_HTTP) ? "HTTP" : "TCP"); |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 82 | break; |
| 83 | case AF_UNIX: |
| 84 | /* UNIX socket, only the destination is known */ |
Willy Tarreau | e36cbcb | 2015-04-03 15:40:56 +0200 | [diff] [blame] | 85 | send_log(fe, LOG_INFO, "Connect to unix:%d (%s/%s)\n", |
Willy Tarreau | fb0afa7 | 2015-04-03 14:46:27 +0200 | [diff] [blame] | 86 | l->luid, |
Willy Tarreau | e36cbcb | 2015-04-03 15:40:56 +0200 | [diff] [blame] | 87 | fe->id, (fe->mode == PR_MODE_HTTP) ? "HTTP" : "TCP"); |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 88 | break; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 89 | } |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 90 | } |
| 91 | } |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 92 | |
Willy Tarreau | e0232f1 | 2015-04-05 18:01:06 +0200 | [diff] [blame] | 93 | if (unlikely((global.mode & MODE_DEBUG) && conn && |
| 94 | (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) { |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 95 | char pn[INET6_ADDRSTRLEN]; |
Willy Tarreau | 9c26680 | 2016-12-04 19:05:24 +0100 | [diff] [blame] | 96 | char alpn[16] = "<none>"; |
Willy Tarreau | 20814ff | 2017-09-15 11:43:32 +0200 | [diff] [blame] | 97 | const char *alpn_str = NULL; |
| 98 | int alpn_len; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 99 | |
Willy Tarreau | b363a1f | 2013-10-01 10:45:07 +0200 | [diff] [blame] | 100 | conn_get_from_addr(conn); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 101 | |
Willy Tarreau | 20814ff | 2017-09-15 11:43:32 +0200 | [diff] [blame] | 102 | /* try to report the ALPN value when available (also works for NPN) */ |
| 103 | |
Olivier Houchard | 9aaf778 | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 104 | if (conn && conn == cs_conn(objt_cs(s->si[0].end))) { |
Willy Tarreau | 20814ff | 2017-09-15 11:43:32 +0200 | [diff] [blame] | 105 | if (conn_get_alpn(conn, &alpn_str, &alpn_len) && alpn_str) { |
| 106 | int len = MIN(alpn_len, sizeof(alpn) - 1); |
| 107 | memcpy(alpn, alpn_str, len); |
| 108 | alpn[len] = 0; |
| 109 | } |
Willy Tarreau | 9c26680 | 2016-12-04 19:05:24 +0100 | [diff] [blame] | 110 | } |
| 111 | |
Willy Tarreau | b363a1f | 2013-10-01 10:45:07 +0200 | [diff] [blame] | 112 | switch (addr_to_str(&conn->addr.from, pn, sizeof(pn))) { |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 113 | case AF_INET: |
| 114 | case AF_INET6: |
Willy Tarreau | 9c26680 | 2016-12-04 19:05:24 +0100 | [diff] [blame] | 115 | chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [%s:%d] ALPN=%s\n", |
Willy Tarreau | 585744b | 2017-08-24 14:31:19 +0200 | [diff] [blame] | 116 | s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)conn->handle.fd, |
Willy Tarreau | 9c26680 | 2016-12-04 19:05:24 +0100 | [diff] [blame] | 117 | pn, get_host_port(&conn->addr.from), alpn); |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 118 | break; |
| 119 | case AF_UNIX: |
| 120 | /* UNIX socket, only the destination is known */ |
Willy Tarreau | 9c26680 | 2016-12-04 19:05:24 +0100 | [diff] [blame] | 121 | chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [unix:%d] ALPN=%s\n", |
Willy Tarreau | 585744b | 2017-08-24 14:31:19 +0200 | [diff] [blame] | 122 | s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)conn->handle.fd, |
Willy Tarreau | 9c26680 | 2016-12-04 19:05:24 +0100 | [diff] [blame] | 123 | l->luid, alpn); |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 124 | break; |
Emeric Brun | ab844ea | 2010-10-22 16:33:18 +0200 | [diff] [blame] | 125 | } |
Willy Tarreau | 9a2d154 | 2008-08-30 12:31:07 +0200 | [diff] [blame] | 126 | |
Willy Tarreau | 843b7cb | 2018-07-13 10:54:26 +0200 | [diff] [blame] | 127 | shut_your_big_mouth_gcc(write(1, trash.area, trash.data)); |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 128 | } |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 129 | |
Willy Tarreau | e36cbcb | 2015-04-03 15:40:56 +0200 | [diff] [blame] | 130 | if (fe->mode == PR_MODE_HTTP) |
Willy Tarreau | 22ec1ea | 2014-11-27 20:45:39 +0100 | [diff] [blame] | 131 | s->req.flags |= CF_READ_DONTWAIT; /* one read is usually enough */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 132 | |
Willy Tarreau | 0a6bed2 | 2016-12-04 18:39:22 +0100 | [diff] [blame] | 133 | if (unlikely(fe->nb_req_cap > 0)) { |
Willy Tarreau | bafbe01 | 2017-11-24 17:34:44 +0100 | [diff] [blame] | 134 | if ((s->req_cap = pool_alloc(fe->req_cap_pool)) == NULL) |
Willy Tarreau | 0a6bed2 | 2016-12-04 18:39:22 +0100 | [diff] [blame] | 135 | goto out_return; /* no memory */ |
| 136 | memset(s->req_cap, 0, fe->nb_req_cap * sizeof(void *)); |
| 137 | } |
| 138 | |
| 139 | if (unlikely(fe->nb_rsp_cap > 0)) { |
Willy Tarreau | bafbe01 | 2017-11-24 17:34:44 +0100 | [diff] [blame] | 140 | if ((s->res_cap = pool_alloc(fe->rsp_cap_pool)) == NULL) |
Willy Tarreau | 0a6bed2 | 2016-12-04 18:39:22 +0100 | [diff] [blame] | 141 | goto out_free_reqcap; /* no memory */ |
| 142 | memset(s->res_cap, 0, fe->nb_rsp_cap * sizeof(void *)); |
| 143 | } |
| 144 | |
| 145 | if (fe->http_needed) { |
| 146 | /* we have to allocate header indexes only if we know |
| 147 | * that we may make use of them. This of course includes |
| 148 | * (mode == PR_MODE_HTTP). |
| 149 | */ |
| 150 | if (unlikely(!http_alloc_txn(s))) |
| 151 | goto out_free_rspcap; /* no memory */ |
| 152 | |
| 153 | /* and now initialize the HTTP transaction state */ |
| 154 | http_init_txn(s); |
| 155 | } |
| 156 | |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 157 | /* everything's OK, let's go on */ |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 158 | return 1; |
Willy Tarreau | 8ced9a4 | 2007-11-04 17:51:50 +0100 | [diff] [blame] | 159 | |
| 160 | /* Error unrolling */ |
Willy Tarreau | 35a0994 | 2010-06-01 17:12:40 +0200 | [diff] [blame] | 161 | out_free_rspcap: |
Willy Tarreau | bafbe01 | 2017-11-24 17:34:44 +0100 | [diff] [blame] | 162 | pool_free(fe->rsp_cap_pool, s->res_cap); |
Willy Tarreau | 35a0994 | 2010-06-01 17:12:40 +0200 | [diff] [blame] | 163 | out_free_reqcap: |
Willy Tarreau | bafbe01 | 2017-11-24 17:34:44 +0100 | [diff] [blame] | 164 | pool_free(fe->req_cap_pool, s->req_cap); |
Willy Tarreau | abe8ea5 | 2010-11-11 10:56:04 +0100 | [diff] [blame] | 165 | out_return: |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 166 | return -1; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 167 | } |
| 168 | |
Willy Tarreau | d6896bc | 2013-01-07 22:48:29 +0100 | [diff] [blame] | 169 | /************************************************************************/ |
| 170 | /* All supported sample and ACL keywords must be declared here. */ |
| 171 | /************************************************************************/ |
| 172 | |
Willy Tarreau | a5e3756 | 2011-12-16 17:06:15 +0100 | [diff] [blame] | 173 | /* set temp integer to the id of the frontend */ |
Willy Tarreau | d41f8d8 | 2007-06-10 10:06:18 +0200 | [diff] [blame] | 174 | static int |
Thierry FOURNIER | 0786d05 | 2015-05-11 15:42:45 +0200 | [diff] [blame] | 175 | smp_fetch_fe_id(const struct arg *args, struct sample *smp, const char *kw, void *private) |
Willy Tarreau | 3740635 | 2012-04-23 16:16:37 +0200 | [diff] [blame] | 176 | { |
Willy Tarreau | f853c46 | 2012-04-23 18:53:56 +0200 | [diff] [blame] | 177 | smp->flags = SMP_F_VOL_SESS; |
Thierry FOURNIER | 8c542ca | 2015-08-19 09:00:18 +0200 | [diff] [blame] | 178 | smp->data.type = SMP_T_SINT; |
Thierry FOURNIER | 136f9d3 | 2015-08-19 09:07:19 +0200 | [diff] [blame] | 179 | smp->data.u.sint = smp->sess->fe->uuid; |
Emeric Brun | 5d16eda | 2010-01-04 15:47:45 +0100 | [diff] [blame] | 180 | return 1; |
| 181 | } |
| 182 | |
Marcin Deranek | d2471c2 | 2016-12-12 14:08:05 +0100 | [diff] [blame] | 183 | /* set string to the name of the frontend */ |
| 184 | static int |
| 185 | smp_fetch_fe_name(const struct arg *args, struct sample *smp, const char *kw, void *private) |
| 186 | { |
Willy Tarreau | 843b7cb | 2018-07-13 10:54:26 +0200 | [diff] [blame] | 187 | smp->data.u.str.area = (char *)smp->sess->fe->id; |
| 188 | if (!smp->data.u.str.area) |
Marcin Deranek | d2471c2 | 2016-12-12 14:08:05 +0100 | [diff] [blame] | 189 | return 0; |
| 190 | |
| 191 | smp->data.type = SMP_T_STR; |
| 192 | smp->flags = SMP_F_CONST; |
Willy Tarreau | 843b7cb | 2018-07-13 10:54:26 +0200 | [diff] [blame] | 193 | smp->data.u.str.data = strlen(smp->data.u.str.area); |
Marcin Deranek | d2471c2 | 2016-12-12 14:08:05 +0100 | [diff] [blame] | 194 | return 1; |
| 195 | } |
| 196 | |
Marcin Deranek | 9a66dfb | 2018-04-13 14:37:50 +0200 | [diff] [blame] | 197 | /* set string to the name of the default backend */ |
| 198 | static int |
| 199 | smp_fetch_fe_defbe(const struct arg *args, struct sample *smp, const char *kw, void *private) |
| 200 | { |
| 201 | if (!smp->sess->fe->defbe.be) |
| 202 | return 0; |
Willy Tarreau | 843b7cb | 2018-07-13 10:54:26 +0200 | [diff] [blame] | 203 | smp->data.u.str.area = (char *)smp->sess->fe->defbe.be->id; |
| 204 | if (!smp->data.u.str.area) |
Marcin Deranek | 9a66dfb | 2018-04-13 14:37:50 +0200 | [diff] [blame] | 205 | return 0; |
| 206 | |
| 207 | smp->data.type = SMP_T_STR; |
| 208 | smp->flags = SMP_F_CONST; |
Willy Tarreau | 843b7cb | 2018-07-13 10:54:26 +0200 | [diff] [blame] | 209 | smp->data.u.str.data = strlen(smp->data.u.str.area); |
Marcin Deranek | 9a66dfb | 2018-04-13 14:37:50 +0200 | [diff] [blame] | 210 | return 1; |
| 211 | } |
| 212 | |
Nenad Merdanovic | ad9a7e9 | 2016-10-03 04:57:37 +0200 | [diff] [blame] | 213 | /* set temp integer to the number of HTTP requests per second reaching the frontend. |
| 214 | * Accepts exactly 1 argument. Argument is a frontend, other types will cause |
| 215 | * an undefined behaviour. |
| 216 | */ |
| 217 | static int |
| 218 | smp_fetch_fe_req_rate(const struct arg *args, struct sample *smp, const char *kw, void *private) |
| 219 | { |
| 220 | smp->flags = SMP_F_VOL_TEST; |
| 221 | smp->data.type = SMP_T_SINT; |
| 222 | smp->data.u.sint = read_freq_ctr(&args->data.prx->fe_req_per_sec); |
| 223 | return 1; |
| 224 | } |
| 225 | |
Willy Tarreau | 34db108 | 2012-04-19 17:16:54 +0200 | [diff] [blame] | 226 | /* set temp integer to the number of connections per second reaching the frontend. |
Willy Tarreau | 0146c2e | 2012-04-20 11:37:56 +0200 | [diff] [blame] | 227 | * Accepts exactly 1 argument. Argument is a frontend, other types will cause |
Willy Tarreau | 34db108 | 2012-04-19 17:16:54 +0200 | [diff] [blame] | 228 | * an undefined behaviour. |
| 229 | */ |
Willy Tarreau | d41f8d8 | 2007-06-10 10:06:18 +0200 | [diff] [blame] | 230 | static int |
Thierry FOURNIER | 0786d05 | 2015-05-11 15:42:45 +0200 | [diff] [blame] | 231 | smp_fetch_fe_sess_rate(const struct arg *args, struct sample *smp, const char *kw, void *private) |
Willy Tarreau | 662b2d8 | 2007-05-08 19:56:15 +0200 | [diff] [blame] | 232 | { |
Willy Tarreau | 3740635 | 2012-04-23 16:16:37 +0200 | [diff] [blame] | 233 | smp->flags = SMP_F_VOL_TEST; |
Thierry FOURNIER | 8c542ca | 2015-08-19 09:00:18 +0200 | [diff] [blame] | 234 | smp->data.type = SMP_T_SINT; |
Thierry FOURNIER | 136f9d3 | 2015-08-19 09:07:19 +0200 | [diff] [blame] | 235 | smp->data.u.sint = read_freq_ctr(&args->data.prx->fe_sess_per_sec); |
Emeric Brun | 5d16eda | 2010-01-04 15:47:45 +0100 | [diff] [blame] | 236 | return 1; |
| 237 | } |
Alexandre Cassen | 5eb1a90 | 2007-11-29 15:43:32 +0100 | [diff] [blame] | 238 | |
Willy Tarreau | 34db108 | 2012-04-19 17:16:54 +0200 | [diff] [blame] | 239 | /* set temp integer to the number of concurrent connections on the frontend |
Willy Tarreau | 0146c2e | 2012-04-20 11:37:56 +0200 | [diff] [blame] | 240 | * Accepts exactly 1 argument. Argument is a frontend, other types will cause |
Willy Tarreau | 34db108 | 2012-04-19 17:16:54 +0200 | [diff] [blame] | 241 | * an undefined behaviour. |
| 242 | */ |
Willy Tarreau | d41f8d8 | 2007-06-10 10:06:18 +0200 | [diff] [blame] | 243 | static int |
Thierry FOURNIER | 0786d05 | 2015-05-11 15:42:45 +0200 | [diff] [blame] | 244 | smp_fetch_fe_conn(const struct arg *args, struct sample *smp, const char *kw, void *private) |
Willy Tarreau | 8797c06 | 2007-05-07 00:55:35 +0200 | [diff] [blame] | 245 | { |
Willy Tarreau | 3740635 | 2012-04-23 16:16:37 +0200 | [diff] [blame] | 246 | smp->flags = SMP_F_VOL_TEST; |
Thierry FOURNIER | 8c542ca | 2015-08-19 09:00:18 +0200 | [diff] [blame] | 247 | smp->data.type = SMP_T_SINT; |
Thierry FOURNIER | 136f9d3 | 2015-08-19 09:07:19 +0200 | [diff] [blame] | 248 | smp->data.u.sint = args->data.prx->feconn; |
Krzysztof Piotr Oledzki | 346f76d | 2010-01-12 21:59:30 +0100 | [diff] [blame] | 249 | return 1; |
| 250 | } |
| 251 | |
Willy Tarreau | 8797c06 | 2007-05-07 00:55:35 +0200 | [diff] [blame] | 252 | |
Willy Tarreau | 61612d4 | 2012-04-19 18:42:05 +0200 | [diff] [blame] | 253 | /* Note: must not be declared <const> as its list will be overwritten. |
| 254 | * Please take care of keeping this list alphabetically sorted. |
| 255 | */ |
Willy Tarreau | dc13c11 | 2013-06-21 23:16:39 +0200 | [diff] [blame] | 256 | static struct sample_fetch_kw_list smp_kws = {ILH, { |
Thierry FOURNIER | 07ee64e | 2015-07-06 23:43:03 +0200 | [diff] [blame] | 257 | { "fe_conn", smp_fetch_fe_conn, ARG1(1,FE), NULL, SMP_T_SINT, SMP_USE_INTRN, }, |
Marcin Deranek | 9a66dfb | 2018-04-13 14:37:50 +0200 | [diff] [blame] | 258 | { "fe_defbe", smp_fetch_fe_defbe, 0, NULL, SMP_T_STR, SMP_USE_FTEND, }, |
Thierry FOURNIER | 07ee64e | 2015-07-06 23:43:03 +0200 | [diff] [blame] | 259 | { "fe_id", smp_fetch_fe_id, 0, NULL, SMP_T_SINT, SMP_USE_FTEND, }, |
Marcin Deranek | d2471c2 | 2016-12-12 14:08:05 +0100 | [diff] [blame] | 260 | { "fe_name", smp_fetch_fe_name, 0, NULL, SMP_T_STR, SMP_USE_FTEND, }, |
Nenad Merdanovic | ad9a7e9 | 2016-10-03 04:57:37 +0200 | [diff] [blame] | 261 | { "fe_req_rate", smp_fetch_fe_req_rate, ARG1(1,FE), NULL, SMP_T_SINT, SMP_USE_INTRN, }, |
Thierry FOURNIER | 07ee64e | 2015-07-06 23:43:03 +0200 | [diff] [blame] | 262 | { "fe_sess_rate", smp_fetch_fe_sess_rate, ARG1(1,FE), NULL, SMP_T_SINT, SMP_USE_INTRN, }, |
Willy Tarreau | d6896bc | 2013-01-07 22:48:29 +0100 | [diff] [blame] | 263 | { /* END */ }, |
| 264 | }}; |
| 265 | |
Willy Tarreau | 0108d90 | 2018-11-25 19:14:37 +0100 | [diff] [blame] | 266 | INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws); |
Willy Tarreau | d6896bc | 2013-01-07 22:48:29 +0100 | [diff] [blame] | 267 | |
| 268 | /* Note: must not be declared <const> as its list will be overwritten. |
| 269 | * Please take care of keeping this list alphabetically sorted. |
| 270 | */ |
Willy Tarreau | dc13c11 | 2013-06-21 23:16:39 +0200 | [diff] [blame] | 271 | static struct acl_kw_list acl_kws = {ILH, { |
Willy Tarreau | d6896bc | 2013-01-07 22:48:29 +0100 | [diff] [blame] | 272 | { /* END */ }, |
Willy Tarreau | 8797c06 | 2007-05-07 00:55:35 +0200 | [diff] [blame] | 273 | }}; |
| 274 | |
Willy Tarreau | 0108d90 | 2018-11-25 19:14:37 +0100 | [diff] [blame] | 275 | INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws); |
Willy Tarreau | 8797c06 | 2007-05-07 00:55:35 +0200 | [diff] [blame] | 276 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 277 | /* |
| 278 | * Local variables: |
| 279 | * c-indent-level: 8 |
| 280 | * c-basic-offset: 8 |
| 281 | * End: |
| 282 | */ |