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