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 | a73fcaf | 2011-03-20 10:15:22 +0100 | [diff] [blame] | 4 | * Copyright 2000-2011 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 | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 25 | #include <common/compat.h> |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 26 | #include <common/config.h> |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 27 | #include <common/debug.h> |
| 28 | #include <common/standard.h> |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 29 | #include <common/time.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 30 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 31 | #include <types/global.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 32 | |
Willy Tarreau | 8797c06 | 2007-05-07 00:55:35 +0200 | [diff] [blame] | 33 | #include <proto/acl.h> |
Willy Tarreau | 5446940 | 2006-07-29 16:59:06 +0200 | [diff] [blame] | 34 | #include <proto/buffers.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 35 | #include <proto/fd.h> |
Willy Tarreau | 03fa5df | 2010-05-24 21:02:37 +0200 | [diff] [blame] | 36 | #include <proto/frontend.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 37 | #include <proto/log.h> |
Willy Tarreau | e5f20dc | 2006-12-03 15:21:35 +0100 | [diff] [blame] | 38 | #include <proto/hdr_idx.h> |
Willy Tarreau | 9650f37 | 2009-08-16 14:02:45 +0200 | [diff] [blame] | 39 | #include <proto/proto_tcp.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 40 | #include <proto/proto_http.h> |
Willy Tarreau | 7f062c4 | 2009-03-05 18:43:00 +0100 | [diff] [blame] | 41 | #include <proto/proxy.h> |
Willy Tarreau | c6ca1a0 | 2007-05-13 19:43:47 +0200 | [diff] [blame] | 42 | #include <proto/session.h> |
Willy Tarreau | dded32d | 2008-11-30 19:48:07 +0100 | [diff] [blame] | 43 | #include <proto/stream_interface.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 44 | #include <proto/stream_sock.h> |
| 45 | #include <proto/task.h> |
| 46 | |
| 47 | |
Willy Tarreau | 14c8aac | 2007-05-08 19:46:30 +0200 | [diff] [blame] | 48 | /* Retrieves the original destination address used by the client, and sets the |
| 49 | * SN_FRT_ADDR_SET flag. |
| 50 | */ |
| 51 | void get_frt_addr(struct session *s) |
| 52 | { |
Willy Tarreau | 6471afb | 2011-09-23 10:54:59 +0200 | [diff] [blame] | 53 | socklen_t namelen = sizeof(s->si[0].addr.to); |
Willy Tarreau | 14c8aac | 2007-05-08 19:46:30 +0200 | [diff] [blame] | 54 | |
Willy Tarreau | 6471afb | 2011-09-23 10:54:59 +0200 | [diff] [blame] | 55 | if (get_original_dst(s->si[0].fd, (struct sockaddr_in *)&s->si[0].addr.to, &namelen) == -1) |
| 56 | getsockname(s->si[0].fd, (struct sockaddr *)&s->si[0].addr.to, &namelen); |
Willy Tarreau | 14c8aac | 2007-05-08 19:46:30 +0200 | [diff] [blame] | 57 | s->flags |= SN_FRT_ADDR_SET; |
| 58 | } |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 59 | |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 60 | /* Finish a session accept() for a proxy (TCP or HTTP). It returns a negative |
Willy Tarreau | abe8ea5 | 2010-11-11 10:56:04 +0100 | [diff] [blame] | 61 | * value in case of a critical failure which must cause the listener to be |
| 62 | * disabled, a positive value in case of success, or zero if it is a success |
| 63 | * but the session must be closed ASAP (eg: monitoring). |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 64 | */ |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 65 | int frontend_accept(struct session *s) |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 66 | { |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 67 | int cfd = s->si[0].fd; |
Emeric Brun | b982a3d | 2010-01-04 15:45:53 +0100 | [diff] [blame] | 68 | |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 69 | tv_zero(&s->logs.tv_request); |
| 70 | s->logs.t_queue = -1; |
| 71 | s->logs.t_connect = -1; |
| 72 | s->logs.t_data = -1; |
| 73 | s->logs.t_close = 0; |
| 74 | s->logs.bytes_in = s->logs.bytes_out = 0; |
| 75 | s->logs.prx_queue_size = 0; /* we get the number of pending conns before us */ |
| 76 | s->logs.srv_queue_size = 0; /* we will get this number soon */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 77 | |
Willy Tarreau | 35a0994 | 2010-06-01 17:12:40 +0200 | [diff] [blame] | 78 | /* FIXME: the logs are horribly complicated now, because they are |
| 79 | * defined in <p>, <p>, and later <be> and <be>. |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 80 | */ |
Willy Tarreau | 35a0994 | 2010-06-01 17:12:40 +0200 | [diff] [blame] | 81 | if (s->logs.logwait & LW_REQ) |
| 82 | s->do_log = http_sess_log; |
| 83 | else |
| 84 | s->do_log = tcp_sess_log; |
| 85 | |
| 86 | /* default error reporting function, may be changed by analysers */ |
| 87 | s->srv_error = default_srv_error; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 88 | |
Willy Tarreau | f67c978 | 2010-05-23 22:59:00 +0200 | [diff] [blame] | 89 | /* Adjust some socket options */ |
Willy Tarreau | 9c3bc22 | 2010-12-24 14:49:37 +0100 | [diff] [blame] | 90 | if (s->listener->addr.ss_family == AF_INET || s->listener->addr.ss_family == AF_INET6) { |
| 91 | if (setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, |
| 92 | (char *) &one, sizeof(one)) == -1) |
| 93 | goto out_return; |
Willy Tarreau | f67c978 | 2010-05-23 22:59:00 +0200 | [diff] [blame] | 94 | |
Willy Tarreau | 9c3bc22 | 2010-12-24 14:49:37 +0100 | [diff] [blame] | 95 | if (s->fe->options & PR_O_TCP_CLI_KA) |
| 96 | setsockopt(cfd, SOL_SOCKET, SO_KEEPALIVE, |
| 97 | (char *) &one, sizeof(one)); |
Willy Tarreau | f67c978 | 2010-05-23 22:59:00 +0200 | [diff] [blame] | 98 | |
Willy Tarreau | 9c3bc22 | 2010-12-24 14:49:37 +0100 | [diff] [blame] | 99 | if (s->fe->options & PR_O_TCP_NOLING) |
| 100 | setsockopt(cfd, SOL_SOCKET, SO_LINGER, |
| 101 | (struct linger *) &nolinger, sizeof(struct linger)); |
Willy Tarreau | 48a7e72 | 2010-12-24 15:26:39 +0100 | [diff] [blame] | 102 | #if defined(TCP_MAXSEG) |
| 103 | if (s->listener->maxseg < 0) { |
| 104 | /* we just want to reduce the current MSS by that value */ |
| 105 | int mss; |
Willy Tarreau | 7d286a0 | 2011-01-05 15:42:54 +0100 | [diff] [blame] | 106 | socklen_t mss_len = sizeof(mss); |
Willy Tarreau | 48a7e72 | 2010-12-24 15:26:39 +0100 | [diff] [blame] | 107 | if (getsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, &mss_len) == 0) { |
| 108 | mss += s->listener->maxseg; /* remember, it's < 0 */ |
| 109 | setsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, sizeof(mss)); |
| 110 | } |
| 111 | } |
| 112 | #endif |
Willy Tarreau | 9c3bc22 | 2010-12-24 14:49:37 +0100 | [diff] [blame] | 113 | } |
Willy Tarreau | f67c978 | 2010-05-23 22:59:00 +0200 | [diff] [blame] | 114 | |
| 115 | if (global.tune.client_sndbuf) |
| 116 | setsockopt(cfd, SOL_SOCKET, SO_SNDBUF, &global.tune.client_sndbuf, sizeof(global.tune.client_sndbuf)); |
| 117 | |
| 118 | if (global.tune.client_rcvbuf) |
| 119 | setsockopt(cfd, SOL_SOCKET, SO_RCVBUF, &global.tune.client_rcvbuf, sizeof(global.tune.client_rcvbuf)); |
| 120 | |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 121 | if (s->fe->mode == PR_MODE_HTTP) { |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 122 | /* the captures are only used in HTTP frontends */ |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 123 | if (unlikely(s->fe->nb_req_cap > 0 && |
| 124 | (s->txn.req.cap = pool_alloc2(s->fe->req_cap_pool)) == NULL)) |
Willy Tarreau | abe8ea5 | 2010-11-11 10:56:04 +0100 | [diff] [blame] | 125 | goto out_return; /* no memory */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 126 | |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 127 | if (unlikely(s->fe->nb_rsp_cap > 0 && |
| 128 | (s->txn.rsp.cap = pool_alloc2(s->fe->rsp_cap_pool)) == NULL)) |
Willy Tarreau | 35a0994 | 2010-06-01 17:12:40 +0200 | [diff] [blame] | 129 | goto out_free_reqcap; /* no memory */ |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 130 | } |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 131 | |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 132 | if (s->fe->acl_requires & ACL_USE_L7_ANY) { |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 133 | /* we have to allocate header indexes only if we know |
| 134 | * that we may make use of them. This of course includes |
| 135 | * (mode == PR_MODE_HTTP). |
Willy Tarreau | 042cc79 | 2007-03-19 16:20:06 +0100 | [diff] [blame] | 136 | */ |
Willy Tarreau | ac1932d | 2011-10-24 19:14:41 +0200 | [diff] [blame] | 137 | s->txn.hdr_idx.size = global.tune.max_http_hdr; |
Willy Tarreau | 45e73e3 | 2006-12-17 00:05:15 +0100 | [diff] [blame] | 138 | |
Willy Tarreau | 34eb671 | 2011-10-24 18:15:04 +0200 | [diff] [blame] | 139 | if (unlikely((s->txn.hdr_idx.v = pool_alloc2(pool2_hdr_idx)) == NULL)) |
Willy Tarreau | 35a0994 | 2010-06-01 17:12:40 +0200 | [diff] [blame] | 140 | goto out_free_rspcap; /* no memory */ |
Willy Tarreau | 45e73e3 | 2006-12-17 00:05:15 +0100 | [diff] [blame] | 141 | |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 142 | /* and now initialize the HTTP transaction state */ |
| 143 | http_init_txn(s); |
| 144 | } |
Willy Tarreau | e5f20dc | 2006-12-03 15:21:35 +0100 | [diff] [blame] | 145 | |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 146 | if ((s->fe->mode == PR_MODE_TCP || s->fe->mode == PR_MODE_HTTP) |
William Lallemand | 0f99e34 | 2011-10-12 17:50:54 +0200 | [diff] [blame] | 147 | && (!LIST_ISEMPTY(&s->fe->logsrvs))) { |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 148 | if (likely(s->fe->to_log)) { |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 149 | /* we have the client ip */ |
| 150 | if (s->logs.logwait & LW_CLIP) |
| 151 | if (!(s->logs.logwait &= ~LW_CLIP)) |
| 152 | s->do_log(s); |
Willy Tarreau | a3445fc | 2010-05-20 16:17:07 +0200 | [diff] [blame] | 153 | } |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 154 | else { |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 155 | char pn[INET6_ADDRSTRLEN], sn[INET6_ADDRSTRLEN]; |
Willy Tarreau | 14c8aac | 2007-05-08 19:46:30 +0200 | [diff] [blame] | 156 | |
| 157 | if (!(s->flags & SN_FRT_ADDR_SET)) |
| 158 | get_frt_addr(s); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 159 | |
Willy Tarreau | 6471afb | 2011-09-23 10:54:59 +0200 | [diff] [blame] | 160 | switch (addr_to_str(&s->req->prod->addr.from, pn, sizeof(pn))) { |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 161 | case AF_INET: |
| 162 | case AF_INET6: |
Willy Tarreau | 6471afb | 2011-09-23 10:54:59 +0200 | [diff] [blame] | 163 | addr_to_str(&s->req->prod->addr.to, sn, sizeof(sn)); |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 164 | send_log(s->fe, LOG_INFO, "Connect from %s:%d to %s:%d (%s/%s)\n", |
Willy Tarreau | 6471afb | 2011-09-23 10:54:59 +0200 | [diff] [blame] | 165 | pn, get_host_port(&s->req->prod->addr.from), |
| 166 | sn, get_host_port(&s->req->prod->addr.to), |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 167 | s->fe->id, (s->fe->mode == PR_MODE_HTTP) ? "HTTP" : "TCP"); |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 168 | break; |
| 169 | case AF_UNIX: |
| 170 | /* UNIX socket, only the destination is known */ |
| 171 | send_log(s->fe, LOG_INFO, "Connect to unix:%d (%s/%s)\n", |
| 172 | s->listener->luid, |
| 173 | s->fe->id, (s->fe->mode == PR_MODE_HTTP) ? "HTTP" : "TCP"); |
| 174 | break; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 175 | } |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 176 | } |
| 177 | } |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 178 | |
Willy Tarreau | 2281b7f | 2010-05-28 19:29:49 +0200 | [diff] [blame] | 179 | if (unlikely((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) { |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 180 | char pn[INET6_ADDRSTRLEN]; |
Willy Tarreau | b0f7532 | 2011-09-09 11:21:06 +0200 | [diff] [blame] | 181 | int len = 0; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 182 | |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 183 | if (!(s->flags & SN_FRT_ADDR_SET)) |
| 184 | get_frt_addr(s); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 185 | |
Willy Tarreau | 6471afb | 2011-09-23 10:54:59 +0200 | [diff] [blame] | 186 | switch (addr_to_str(&s->req->prod->addr.from, pn, sizeof(pn))) { |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 187 | case AF_INET: |
| 188 | case AF_INET6: |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 189 | len = sprintf(trash, "%08x:%s.accept(%04x)=%04x from [%s:%d]\n", |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 190 | s->uniq_id, s->fe->id, (unsigned short)s->listener->fd, (unsigned short)cfd, |
Willy Tarreau | 6471afb | 2011-09-23 10:54:59 +0200 | [diff] [blame] | 191 | pn, get_host_port(&s->req->prod->addr.from)); |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 192 | break; |
| 193 | case AF_UNIX: |
| 194 | /* UNIX socket, only the destination is known */ |
Emeric Brun | ab844ea | 2010-10-22 16:33:18 +0200 | [diff] [blame] | 195 | len = sprintf(trash, "%08x:%s.accept(%04x)=%04x from [unix:%d]\n", |
| 196 | s->uniq_id, s->fe->id, (unsigned short)s->listener->fd, (unsigned short)cfd, |
| 197 | s->listener->luid); |
Willy Tarreau | 631f01c | 2011-09-05 00:36:48 +0200 | [diff] [blame] | 198 | break; |
Emeric Brun | ab844ea | 2010-10-22 16:33:18 +0200 | [diff] [blame] | 199 | } |
Willy Tarreau | 9a2d154 | 2008-08-30 12:31:07 +0200 | [diff] [blame] | 200 | |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 201 | write(1, trash, len); |
| 202 | } |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 203 | |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 204 | if (s->fe->mode == PR_MODE_HTTP) |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 205 | s->req->flags |= BF_READ_DONTWAIT; /* one read is usually enough */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 206 | |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 207 | /* note: this should not happen anymore since there's always at least the switching rules */ |
| 208 | if (!s->req->analysers) { |
| 209 | buffer_auto_connect(s->req); /* don't wait to establish connection */ |
| 210 | buffer_auto_close(s->req); /* let the producer forward close requests */ |
| 211 | } |
Willy Tarreau | d797128 | 2006-07-29 18:36:34 +0200 | [diff] [blame] | 212 | |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 213 | s->req->rto = s->fe->timeout.client; |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 214 | s->rep->wto = s->fe->timeout.client; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 215 | |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 216 | fdtab[cfd].flags = FD_FL_TCP | FD_FL_TCP_NODELAY; |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 217 | if (s->fe->options & PR_O_TCP_NOLING) |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 218 | fdtab[cfd].flags |= FD_FL_TCP_NOLING; |
Willy Tarreau | 6e6fb2b | 2009-08-16 18:20:44 +0200 | [diff] [blame] | 219 | |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 220 | if (unlikely((s->fe->mode == PR_MODE_HTTP && (s->flags & SN_MONITOR)) || |
Willy Tarreau | 1620ec3 | 2011-08-06 17:05:02 +0200 | [diff] [blame] | 221 | (s->fe->mode == PR_MODE_HEALTH && ((s->fe->options2 & PR_O2_CHK_ANY) == PR_O2_HTTP_CHK)))) { |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 222 | /* Either we got a request from a monitoring system on an HTTP instance, |
| 223 | * or we're in health check mode with the 'httpchk' option enabled. In |
| 224 | * both cases, we return a fake "HTTP/1.0 200 OK" response and we exit. |
| 225 | */ |
| 226 | struct chunk msg; |
| 227 | chunk_initstr(&msg, "HTTP/1.0 200 OK\r\n\r\n"); |
| 228 | stream_int_retnclose(&s->si[0], &msg); /* forge a 200 response */ |
| 229 | s->req->analysers = 0; |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 230 | s->task->expire = s->rep->wex; |
Willy Tarreau | 35a0994 | 2010-06-01 17:12:40 +0200 | [diff] [blame] | 231 | EV_FD_CLR(cfd, DIR_RD); |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 232 | } |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 233 | else if (unlikely(s->fe->mode == PR_MODE_HEALTH)) { /* health check mode, no client reading */ |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 234 | struct chunk msg; |
| 235 | chunk_initstr(&msg, "OK\n"); |
| 236 | stream_int_retnclose(&s->si[0], &msg); /* forge an "OK" response */ |
| 237 | s->req->analysers = 0; |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 238 | s->task->expire = s->rep->wex; |
Willy Tarreau | 35a0994 | 2010-06-01 17:12:40 +0200 | [diff] [blame] | 239 | EV_FD_CLR(cfd, DIR_RD); |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 240 | } |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 241 | /* everything's OK, let's go on */ |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 242 | return 1; |
Willy Tarreau | 8ced9a4 | 2007-11-04 17:51:50 +0100 | [diff] [blame] | 243 | |
| 244 | /* Error unrolling */ |
Willy Tarreau | 35a0994 | 2010-06-01 17:12:40 +0200 | [diff] [blame] | 245 | out_free_rspcap: |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 246 | pool_free2(s->fe->rsp_cap_pool, s->txn.rsp.cap); |
Willy Tarreau | 35a0994 | 2010-06-01 17:12:40 +0200 | [diff] [blame] | 247 | out_free_reqcap: |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 248 | pool_free2(s->fe->req_cap_pool, s->txn.req.cap); |
Willy Tarreau | abe8ea5 | 2010-11-11 10:56:04 +0100 | [diff] [blame] | 249 | out_return: |
Willy Tarreau | eb47268 | 2010-05-28 18:46:57 +0200 | [diff] [blame] | 250 | return -1; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 251 | } |
| 252 | |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 253 | /* This analyser tries to fetch a line from the request buffer which looks like : |
| 254 | * |
| 255 | * "PROXY" <SP> PROTO <SP> SRC3 <SP> DST3 <SP> SRC4 <SP> <DST4> "\r\n" |
| 256 | * |
| 257 | * There must be exactly one space between each field. Fields are : |
Emeric Brun | 861ccff | 2010-10-29 12:03:03 +0200 | [diff] [blame] | 258 | * - PROTO : layer 4 protocol, which must be "TCP4" or "TCP6". |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 259 | * - SRC3 : layer 3 (eg: IP) source address in standard text form |
| 260 | * - DST3 : layer 3 (eg: IP) destination address in standard text form |
| 261 | * - SRC4 : layer 4 (eg: TCP port) source address in standard text form |
| 262 | * - DST4 : layer 4 (eg: TCP port) destination address in standard text form |
| 263 | * |
| 264 | * This line MUST be at the beginning of the buffer and MUST NOT wrap. |
| 265 | * |
| 266 | * Once the data is fetched, the values are set in the session's field and data |
| 267 | * are removed from the buffer. The function returns zero if it needs to wait |
| 268 | * for more data (max: timeout_client), or 1 if it has finished and removed itself. |
| 269 | */ |
| 270 | int frontend_decode_proxy_request(struct session *s, struct buffer *req, int an_bit) |
| 271 | { |
| 272 | char *line = req->data; |
| 273 | char *end = req->data + req->l; |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 274 | int len; |
| 275 | |
| 276 | DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bl=%d analysers=%02x\n", |
| 277 | now_ms, __FUNCTION__, |
| 278 | s, |
| 279 | req, |
| 280 | req->rex, req->wex, |
| 281 | req->flags, |
| 282 | req->l, |
| 283 | req->analysers); |
| 284 | |
| 285 | if (req->flags & (BF_READ_ERROR|BF_READ_TIMEOUT)) |
| 286 | goto fail; |
| 287 | |
Emeric Brun | f4711a3 | 2010-10-29 15:16:55 +0200 | [diff] [blame] | 288 | len = MIN(req->l, 6); |
| 289 | if (!len) |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 290 | goto missing; |
| 291 | |
Emeric Brun | f4711a3 | 2010-10-29 15:16:55 +0200 | [diff] [blame] | 292 | /* Decode a possible proxy request, fail early if it does not match */ |
| 293 | if (strncmp(line, "PROXY ", len) != 0) |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 294 | goto fail; |
Emeric Brun | f4711a3 | 2010-10-29 15:16:55 +0200 | [diff] [blame] | 295 | |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 296 | line += 6; |
Emeric Brun | f4711a3 | 2010-10-29 15:16:55 +0200 | [diff] [blame] | 297 | if (req->l < 18) /* shortest possible line */ |
| 298 | goto missing; |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 299 | |
Emeric Brun | 861ccff | 2010-10-29 12:03:03 +0200 | [diff] [blame] | 300 | if (!memcmp(line, "TCP4 ", 5) != 0) { |
| 301 | u32 src3, dst3, sport, dport; |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 302 | |
Emeric Brun | 861ccff | 2010-10-29 12:03:03 +0200 | [diff] [blame] | 303 | line += 5; |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 304 | |
Emeric Brun | 861ccff | 2010-10-29 12:03:03 +0200 | [diff] [blame] | 305 | src3 = inetaddr_host_lim_ret(line, end, &line); |
| 306 | if (line == end) |
| 307 | goto missing; |
| 308 | if (*line++ != ' ') |
| 309 | goto fail; |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 310 | |
Emeric Brun | 861ccff | 2010-10-29 12:03:03 +0200 | [diff] [blame] | 311 | dst3 = inetaddr_host_lim_ret(line, end, &line); |
| 312 | if (line == end) |
| 313 | goto missing; |
| 314 | if (*line++ != ' ') |
| 315 | goto fail; |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 316 | |
Emeric Brun | 861ccff | 2010-10-29 12:03:03 +0200 | [diff] [blame] | 317 | sport = read_uint((const char **)&line, end); |
| 318 | if (line == end) |
| 319 | goto missing; |
| 320 | if (*line++ != ' ') |
| 321 | goto fail; |
| 322 | |
| 323 | dport = read_uint((const char **)&line, end); |
| 324 | if (line > end - 2) |
| 325 | goto missing; |
| 326 | if (*line++ != '\r') |
| 327 | goto fail; |
| 328 | if (*line++ != '\n') |
| 329 | goto fail; |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 330 | |
Emeric Brun | 861ccff | 2010-10-29 12:03:03 +0200 | [diff] [blame] | 331 | /* update the session's addresses and mark them set */ |
Willy Tarreau | 6471afb | 2011-09-23 10:54:59 +0200 | [diff] [blame] | 332 | ((struct sockaddr_in *)&s->si[0].addr.from)->sin_family = AF_INET; |
| 333 | ((struct sockaddr_in *)&s->si[0].addr.from)->sin_addr.s_addr = htonl(src3); |
| 334 | ((struct sockaddr_in *)&s->si[0].addr.from)->sin_port = htons(sport); |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 335 | |
Willy Tarreau | 6471afb | 2011-09-23 10:54:59 +0200 | [diff] [blame] | 336 | ((struct sockaddr_in *)&s->si[0].addr.to)->sin_family = AF_INET; |
| 337 | ((struct sockaddr_in *)&s->si[0].addr.to)->sin_addr.s_addr = htonl(dst3); |
| 338 | ((struct sockaddr_in *)&s->si[0].addr.to)->sin_port = htons(dport); |
Emeric Brun | 861ccff | 2010-10-29 12:03:03 +0200 | [diff] [blame] | 339 | s->flags |= SN_FRT_ADDR_SET; |
| 340 | |
| 341 | } |
| 342 | else if (!memcmp(line, "TCP6 ", 5) != 0) { |
| 343 | u32 sport, dport; |
| 344 | char *src_s; |
| 345 | char *dst_s, *sport_s, *dport_s; |
| 346 | struct in6_addr src3, dst3; |
| 347 | |
| 348 | line+=5; |
| 349 | |
| 350 | src_s = line; |
| 351 | dst_s = sport_s = dport_s = NULL; |
| 352 | while (1) { |
| 353 | if (line > end - 2) { |
| 354 | goto missing; |
| 355 | } |
| 356 | else if (*line == '\r') { |
| 357 | *line = 0; |
| 358 | line++; |
| 359 | if (*line++ != '\n') |
| 360 | goto fail; |
| 361 | break; |
| 362 | } |
| 363 | |
| 364 | if (*line == ' ') { |
| 365 | *line = 0; |
| 366 | if (!dst_s) |
| 367 | dst_s = line+1; |
| 368 | else if (!sport_s) |
| 369 | sport_s = line+1; |
| 370 | else if (!dport_s) |
| 371 | dport_s = line+1; |
| 372 | } |
| 373 | line++; |
| 374 | } |
| 375 | |
| 376 | if (!dst_s || !sport_s || !dport_s) |
| 377 | goto fail; |
| 378 | |
| 379 | sport = read_uint((const char **)&sport_s,dport_s-1); |
| 380 | if ( *sport_s != 0 ) |
| 381 | goto fail; |
| 382 | |
| 383 | dport = read_uint((const char **)&dport_s,line-2); |
| 384 | if ( *dport_s != 0 ) |
| 385 | goto fail; |
| 386 | |
| 387 | if (inet_pton(AF_INET6, src_s, (void *)&src3) != 1) |
| 388 | goto fail; |
| 389 | |
| 390 | if (inet_pton(AF_INET6, dst_s, (void *)&dst3) != 1) |
| 391 | goto fail; |
| 392 | |
| 393 | /* update the session's addresses and mark them set */ |
Willy Tarreau | 6471afb | 2011-09-23 10:54:59 +0200 | [diff] [blame] | 394 | ((struct sockaddr_in6 *)&s->si[0].addr.from)->sin6_family = AF_INET6; |
| 395 | memcpy(&((struct sockaddr_in6 *)&s->si[0].addr.from)->sin6_addr, &src3, sizeof(struct in6_addr)); |
| 396 | ((struct sockaddr_in6 *)&s->si[0].addr.from)->sin6_port = htons(sport); |
Emeric Brun | 861ccff | 2010-10-29 12:03:03 +0200 | [diff] [blame] | 397 | |
Willy Tarreau | 6471afb | 2011-09-23 10:54:59 +0200 | [diff] [blame] | 398 | ((struct sockaddr_in6 *)&s->si[0].addr.to)->sin6_family = AF_INET6; |
| 399 | memcpy(&((struct sockaddr_in6 *)&s->si[0].addr.to)->sin6_addr, &dst3, sizeof(struct in6_addr)); |
| 400 | ((struct sockaddr_in6 *)&s->si[0].addr.to)->sin6_port = htons(dport); |
Emeric Brun | 861ccff | 2010-10-29 12:03:03 +0200 | [diff] [blame] | 401 | s->flags |= SN_FRT_ADDR_SET; |
| 402 | } |
| 403 | else { |
| 404 | goto fail; |
| 405 | } |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 406 | |
| 407 | /* remove the PROXY line from the request */ |
| 408 | len = line - req->data; |
| 409 | buffer_replace2(req, req->data, line, NULL, 0); |
| 410 | req->total -= len; /* don't count the header line */ |
| 411 | |
| 412 | req->analysers &= ~an_bit; |
| 413 | return 1; |
| 414 | |
| 415 | missing: |
| 416 | if (!(req->flags & (BF_SHUTR|BF_FULL))) { |
| 417 | buffer_dont_connect(s->req); |
| 418 | return 0; |
| 419 | } |
| 420 | /* missing data and buffer is either full or shutdown => fail */ |
| 421 | |
| 422 | fail: |
| 423 | buffer_abort(req); |
| 424 | buffer_abort(s->rep); |
| 425 | req->analysers = 0; |
| 426 | |
Willy Tarreau | 7d0aaf3 | 2011-03-10 23:25:56 +0100 | [diff] [blame] | 427 | s->fe->fe_counters.failed_req++; |
Willy Tarreau | 8b0cbf9 | 2010-10-15 23:23:19 +0200 | [diff] [blame] | 428 | if (s->listener->counters) |
| 429 | s->listener->counters->failed_req++; |
| 430 | |
| 431 | if (!(s->flags & SN_ERR_MASK)) |
| 432 | s->flags |= SN_ERR_PRXCOND; |
| 433 | if (!(s->flags & SN_FINST_MASK)) |
| 434 | s->flags |= SN_FINST_R; |
| 435 | return 0; |
| 436 | } |
| 437 | |
Willy Tarreau | a73fcaf | 2011-03-20 10:15:22 +0100 | [diff] [blame] | 438 | /* Makes a PROXY protocol line from the two addresses. The output is sent to |
| 439 | * buffer <buf> for a maximum size of <buf_len> (including the trailing zero). |
| 440 | * It returns the number of bytes composing this line (including the trailing |
| 441 | * LF), or zero in case of failure (eg: not enough space). It supports TCP4, |
| 442 | * TCP6 and "UNKNOWN" formats. |
| 443 | */ |
| 444 | int make_proxy_line(char *buf, int buf_len, struct sockaddr_storage *src, struct sockaddr_storage *dst) |
| 445 | { |
| 446 | int ret = 0; |
| 447 | |
| 448 | if (src->ss_family == dst->ss_family && src->ss_family == AF_INET) { |
| 449 | ret = snprintf(buf + ret, buf_len - ret, "PROXY TCP4 "); |
| 450 | if (ret >= buf_len) |
| 451 | return 0; |
| 452 | |
| 453 | /* IPv4 src */ |
| 454 | if (!inet_ntop(src->ss_family, &((struct sockaddr_in *)src)->sin_addr, buf + ret, buf_len - ret)) |
| 455 | return 0; |
| 456 | |
| 457 | ret += strlen(buf + ret); |
| 458 | if (ret >= buf_len) |
| 459 | return 0; |
| 460 | |
| 461 | buf[ret++] = ' '; |
| 462 | |
| 463 | /* IPv4 dst */ |
| 464 | if (!inet_ntop(dst->ss_family, &((struct sockaddr_in *)dst)->sin_addr, buf + ret, buf_len - ret)) |
| 465 | return 0; |
| 466 | |
| 467 | ret += strlen(buf + ret); |
| 468 | if (ret >= buf_len) |
| 469 | return 0; |
| 470 | |
| 471 | /* source and destination ports */ |
| 472 | ret += snprintf(buf + ret, buf_len - ret, " %u %u\r\n", |
| 473 | ntohs(((struct sockaddr_in *)src)->sin_port), |
| 474 | ntohs(((struct sockaddr_in *)dst)->sin_port)); |
| 475 | if (ret >= buf_len) |
| 476 | return 0; |
| 477 | } |
| 478 | else if (src->ss_family == dst->ss_family && src->ss_family == AF_INET6) { |
| 479 | ret = snprintf(buf + ret, buf_len - ret, "PROXY TCP6 "); |
| 480 | if (ret >= buf_len) |
| 481 | return 0; |
| 482 | |
| 483 | /* IPv6 src */ |
| 484 | if (!inet_ntop(src->ss_family, &((struct sockaddr_in6 *)src)->sin6_addr, buf + ret, buf_len - ret)) |
| 485 | return 0; |
| 486 | |
| 487 | ret += strlen(buf + ret); |
| 488 | if (ret >= buf_len) |
| 489 | return 0; |
| 490 | |
| 491 | buf[ret++] = ' '; |
| 492 | |
| 493 | /* IPv6 dst */ |
| 494 | if (!inet_ntop(dst->ss_family, &((struct sockaddr_in6 *)dst)->sin6_addr, buf + ret, buf_len - ret)) |
| 495 | return 0; |
| 496 | |
| 497 | ret += strlen(buf + ret); |
| 498 | if (ret >= buf_len) |
| 499 | return 0; |
| 500 | |
| 501 | /* source and destination ports */ |
| 502 | ret += snprintf(buf + ret, buf_len - ret, " %u %u\r\n", |
| 503 | ntohs(((struct sockaddr_in6 *)src)->sin6_port), |
| 504 | ntohs(((struct sockaddr_in6 *)dst)->sin6_port)); |
| 505 | if (ret >= buf_len) |
| 506 | return 0; |
| 507 | } |
| 508 | else { |
| 509 | /* unknown family combination */ |
| 510 | ret = snprintf(buf, buf_len, "PROXY UNKNOWN\r\n"); |
| 511 | if (ret >= buf_len) |
| 512 | return 0; |
| 513 | } |
| 514 | return ret; |
| 515 | } |
| 516 | |
Willy Tarreau | a5e3756 | 2011-12-16 17:06:15 +0100 | [diff] [blame] | 517 | /* set temp integer to the id of the frontend */ |
Willy Tarreau | d41f8d8 | 2007-06-10 10:06:18 +0200 | [diff] [blame] | 518 | static int |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 519 | acl_fetch_fe_id(struct proxy *px, struct session *l4, void *l7, int dir, |
| 520 | struct acl_expr *expr, struct acl_test *test) { |
Willy Tarreau | 662b2d8 | 2007-05-08 19:56:15 +0200 | [diff] [blame] | 521 | |
Willy Tarreau | 662b2d8 | 2007-05-08 19:56:15 +0200 | [diff] [blame] | 522 | test->flags = ACL_TEST_F_READ_ONLY; |
Willy Tarreau | a5e3756 | 2011-12-16 17:06:15 +0100 | [diff] [blame] | 523 | temp_pattern.data.integer = l4->fe->uuid; |
Emeric Brun | 5d16eda | 2010-01-04 15:47:45 +0100 | [diff] [blame] | 524 | return 1; |
| 525 | } |
| 526 | |
Willy Tarreau | a5e3756 | 2011-12-16 17:06:15 +0100 | [diff] [blame] | 527 | /* set temp integer to the number of connections per second reaching the frontend */ |
Willy Tarreau | d41f8d8 | 2007-06-10 10:06:18 +0200 | [diff] [blame] | 528 | static int |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 529 | acl_fetch_fe_sess_rate(struct proxy *px, struct session *l4, void *l7, int dir, |
| 530 | struct acl_expr *expr, struct acl_test *test) |
Willy Tarreau | 662b2d8 | 2007-05-08 19:56:15 +0200 | [diff] [blame] | 531 | { |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 532 | test->flags = ACL_TEST_F_VOL_TEST; |
| 533 | if (expr->arg_len) { |
| 534 | /* another proxy was designated, we must look for it */ |
| 535 | for (px = proxy; px; px = px->next) |
| 536 | if ((px->cap & PR_CAP_FE) && !strcmp(px->id, expr->arg.str)) |
| 537 | break; |
| 538 | } |
| 539 | if (!px) |
| 540 | return 0; |
Emeric Brun | 5d16eda | 2010-01-04 15:47:45 +0100 | [diff] [blame] | 541 | |
Willy Tarreau | a5e3756 | 2011-12-16 17:06:15 +0100 | [diff] [blame] | 542 | temp_pattern.data.integer = read_freq_ctr(&px->fe_sess_per_sec); |
Emeric Brun | 5d16eda | 2010-01-04 15:47:45 +0100 | [diff] [blame] | 543 | return 1; |
| 544 | } |
Alexandre Cassen | 5eb1a90 | 2007-11-29 15:43:32 +0100 | [diff] [blame] | 545 | |
Willy Tarreau | a5e3756 | 2011-12-16 17:06:15 +0100 | [diff] [blame] | 546 | /* set temp integer to the number of concurrent connections on the frontend */ |
Willy Tarreau | d41f8d8 | 2007-06-10 10:06:18 +0200 | [diff] [blame] | 547 | static int |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 548 | acl_fetch_fe_conn(struct proxy *px, struct session *l4, void *l7, int dir, |
| 549 | struct acl_expr *expr, struct acl_test *test) |
Willy Tarreau | 8797c06 | 2007-05-07 00:55:35 +0200 | [diff] [blame] | 550 | { |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 551 | test->flags = ACL_TEST_F_VOL_TEST; |
| 552 | if (expr->arg_len) { |
| 553 | /* another proxy was designated, we must look for it */ |
| 554 | for (px = proxy; px; px = px->next) |
| 555 | if ((px->cap & PR_CAP_FE) && !strcmp(px->id, expr->arg.str)) |
| 556 | break; |
| 557 | } |
| 558 | if (!px) |
| 559 | return 0; |
Krzysztof Piotr Oledzki | 346f76d | 2010-01-12 21:59:30 +0100 | [diff] [blame] | 560 | |
Willy Tarreau | a5e3756 | 2011-12-16 17:06:15 +0100 | [diff] [blame] | 561 | temp_pattern.data.integer = px->feconn; |
Krzysztof Piotr Oledzki | 346f76d | 2010-01-12 21:59:30 +0100 | [diff] [blame] | 562 | return 1; |
| 563 | } |
| 564 | |
Willy Tarreau | 8797c06 | 2007-05-07 00:55:35 +0200 | [diff] [blame] | 565 | |
| 566 | /* Note: must not be declared <const> as its list will be overwritten */ |
| 567 | static struct acl_kw_list acl_kws = {{ },{ |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 568 | { "fe_id", acl_parse_int, acl_fetch_fe_id, acl_match_int, ACL_USE_NOTHING }, |
| 569 | { "fe_sess_rate", acl_parse_int, acl_fetch_fe_sess_rate, acl_match_int, ACL_USE_NOTHING }, |
| 570 | { "fe_conn", acl_parse_int, acl_fetch_fe_conn, acl_match_int, ACL_USE_NOTHING }, |
Willy Tarreau | 8797c06 | 2007-05-07 00:55:35 +0200 | [diff] [blame] | 571 | { NULL, NULL, NULL, NULL }, |
| 572 | }}; |
| 573 | |
| 574 | |
| 575 | __attribute__((constructor)) |
Willy Tarreau | 03fa5df | 2010-05-24 21:02:37 +0200 | [diff] [blame] | 576 | static void __frontend_init(void) |
Willy Tarreau | 8797c06 | 2007-05-07 00:55:35 +0200 | [diff] [blame] | 577 | { |
| 578 | acl_register_keywords(&acl_kws); |
| 579 | } |
| 580 | |
| 581 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 582 | /* |
| 583 | * Local variables: |
| 584 | * c-indent-level: 8 |
| 585 | * c-basic-offset: 8 |
| 586 | * End: |
| 587 | */ |