Willy Tarreau | dd81598 | 2007-10-16 12:25:14 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 2 | * Listener management functions. |
Willy Tarreau | dd81598 | 2007-10-16 12:25:14 +0200 | [diff] [blame] | 3 | * |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 4 | * Copyright 2000-2012 Willy Tarreau <w@1wt.eu> |
Willy Tarreau | dd81598 | 2007-10-16 12:25:14 +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 | |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 13 | #include <errno.h> |
Willy Tarreau | dd81598 | 2007-10-16 12:25:14 +0200 | [diff] [blame] | 14 | #include <stdio.h> |
| 15 | #include <string.h> |
| 16 | |
Willy Tarreau | 1bc4aab | 2012-10-08 20:11:03 +0200 | [diff] [blame] | 17 | #include <common/accept4.h> |
Willy Tarreau | dd81598 | 2007-10-16 12:25:14 +0200 | [diff] [blame] | 18 | #include <common/config.h> |
Willy Tarreau | dabf2e2 | 2007-10-28 21:59:24 +0100 | [diff] [blame] | 19 | #include <common/errors.h> |
Willy Tarreau | dd81598 | 2007-10-16 12:25:14 +0200 | [diff] [blame] | 20 | #include <common/mini-clist.h> |
| 21 | #include <common/standard.h> |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 22 | #include <common/time.h> |
| 23 | |
| 24 | #include <types/global.h> |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 25 | #include <types/protocol.h> |
Willy Tarreau | dd81598 | 2007-10-16 12:25:14 +0200 | [diff] [blame] | 26 | |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 27 | #include <proto/acl.h> |
Willy Tarreau | b648d63 | 2007-10-28 22:13:50 +0100 | [diff] [blame] | 28 | #include <proto/fd.h> |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 29 | #include <proto/freq_ctr.h> |
| 30 | #include <proto/log.h> |
| 31 | #include <proto/task.h> |
Willy Tarreau | b648d63 | 2007-10-28 22:13:50 +0100 | [diff] [blame] | 32 | |
Willy Tarreau | 2698266 | 2012-09-12 23:17:10 +0200 | [diff] [blame] | 33 | /* List head of all known bind keywords */ |
| 34 | static struct bind_kw_list bind_keywords = { |
| 35 | .list = LIST_HEAD_INIT(bind_keywords.list) |
| 36 | }; |
| 37 | |
Willy Tarreau | dabf2e2 | 2007-10-28 21:59:24 +0100 | [diff] [blame] | 38 | /* This function adds the specified listener's file descriptor to the polling |
| 39 | * lists if it is in the LI_LISTEN state. The listener enters LI_READY or |
| 40 | * LI_FULL state depending on its number of connections. |
| 41 | */ |
| 42 | void enable_listener(struct listener *listener) |
| 43 | { |
| 44 | if (listener->state == LI_LISTEN) { |
| 45 | if (listener->nbconn < listener->maxconn) { |
Willy Tarreau | 49b046d | 2012-08-09 12:11:58 +0200 | [diff] [blame] | 46 | fd_want_recv(listener->fd); |
Willy Tarreau | dabf2e2 | 2007-10-28 21:59:24 +0100 | [diff] [blame] | 47 | listener->state = LI_READY; |
| 48 | } else { |
| 49 | listener->state = LI_FULL; |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /* This function removes the specified listener's file descriptor from the |
| 55 | * polling lists if it is in the LI_READY or in the LI_FULL state. The listener |
| 56 | * enters LI_LISTEN. |
| 57 | */ |
| 58 | void disable_listener(struct listener *listener) |
| 59 | { |
| 60 | if (listener->state < LI_READY) |
| 61 | return; |
| 62 | if (listener->state == LI_READY) |
Willy Tarreau | 49b046d | 2012-08-09 12:11:58 +0200 | [diff] [blame] | 63 | fd_stop_recv(listener->fd); |
Willy Tarreau | e6ca1fc | 2011-07-24 22:03:52 +0200 | [diff] [blame] | 64 | if (listener->state == LI_LIMITED) |
| 65 | LIST_DEL(&listener->wait_queue); |
Willy Tarreau | dabf2e2 | 2007-10-28 21:59:24 +0100 | [diff] [blame] | 66 | listener->state = LI_LISTEN; |
| 67 | } |
| 68 | |
Willy Tarreau | be58c38 | 2011-07-24 18:28:10 +0200 | [diff] [blame] | 69 | /* This function tries to temporarily disable a listener, depending on the OS |
| 70 | * capabilities. Linux unbinds the listen socket after a SHUT_RD, and ignores |
| 71 | * SHUT_WR. Solaris refuses either shutdown(). OpenBSD ignores SHUT_RD but |
| 72 | * closes upon SHUT_WR and refuses to rebind. So a common validation path |
| 73 | * involves SHUT_WR && listen && SHUT_RD. In case of success, the FD's polling |
| 74 | * is disabled. It normally returns non-zero, unless an error is reported. |
| 75 | */ |
| 76 | int pause_listener(struct listener *l) |
| 77 | { |
| 78 | if (l->state <= LI_PAUSED) |
| 79 | return 1; |
| 80 | |
Willy Tarreau | b3fb60b | 2012-10-04 08:56:31 +0200 | [diff] [blame] | 81 | if (l->proto->sock_prot == IPPROTO_TCP) { |
| 82 | if (shutdown(l->fd, SHUT_WR) != 0) |
| 83 | return 0; /* Solaris dies here */ |
Willy Tarreau | be58c38 | 2011-07-24 18:28:10 +0200 | [diff] [blame] | 84 | |
Willy Tarreau | b3fb60b | 2012-10-04 08:56:31 +0200 | [diff] [blame] | 85 | if (listen(l->fd, l->backlog ? l->backlog : l->maxconn) != 0) |
| 86 | return 0; /* OpenBSD dies here */ |
Willy Tarreau | be58c38 | 2011-07-24 18:28:10 +0200 | [diff] [blame] | 87 | |
Willy Tarreau | b3fb60b | 2012-10-04 08:56:31 +0200 | [diff] [blame] | 88 | if (shutdown(l->fd, SHUT_RD) != 0) |
| 89 | return 0; /* should always be OK */ |
| 90 | } |
Willy Tarreau | be58c38 | 2011-07-24 18:28:10 +0200 | [diff] [blame] | 91 | |
Willy Tarreau | e6ca1fc | 2011-07-24 22:03:52 +0200 | [diff] [blame] | 92 | if (l->state == LI_LIMITED) |
| 93 | LIST_DEL(&l->wait_queue); |
| 94 | |
Willy Tarreau | 49b046d | 2012-08-09 12:11:58 +0200 | [diff] [blame] | 95 | fd_stop_recv(l->fd); |
Willy Tarreau | be58c38 | 2011-07-24 18:28:10 +0200 | [diff] [blame] | 96 | l->state = LI_PAUSED; |
| 97 | return 1; |
| 98 | } |
| 99 | |
Willy Tarreau | e6ca1fc | 2011-07-24 22:03:52 +0200 | [diff] [blame] | 100 | /* This function tries to resume a temporarily disabled listener. Paused, full, |
| 101 | * limited and disabled listeners are handled, which means that this function |
| 102 | * may replace enable_listener(). The resulting state will either be LI_READY |
| 103 | * or LI_FULL. 0 is returned in case of failure to resume (eg: dead socket). |
Willy Tarreau | be58c38 | 2011-07-24 18:28:10 +0200 | [diff] [blame] | 104 | */ |
| 105 | int resume_listener(struct listener *l) |
| 106 | { |
| 107 | if (l->state < LI_PAUSED) |
| 108 | return 0; |
| 109 | |
Willy Tarreau | b3fb60b | 2012-10-04 08:56:31 +0200 | [diff] [blame] | 110 | if (l->proto->sock_prot == IPPROTO_TCP && |
| 111 | l->state == LI_PAUSED && |
Willy Tarreau | be58c38 | 2011-07-24 18:28:10 +0200 | [diff] [blame] | 112 | listen(l->fd, l->backlog ? l->backlog : l->maxconn) != 0) |
| 113 | return 0; |
| 114 | |
| 115 | if (l->state == LI_READY) |
| 116 | return 1; |
| 117 | |
Willy Tarreau | e6ca1fc | 2011-07-24 22:03:52 +0200 | [diff] [blame] | 118 | if (l->state == LI_LIMITED) |
| 119 | LIST_DEL(&l->wait_queue); |
| 120 | |
Willy Tarreau | be58c38 | 2011-07-24 18:28:10 +0200 | [diff] [blame] | 121 | if (l->nbconn >= l->maxconn) { |
| 122 | l->state = LI_FULL; |
| 123 | return 1; |
| 124 | } |
| 125 | |
Willy Tarreau | 49b046d | 2012-08-09 12:11:58 +0200 | [diff] [blame] | 126 | fd_want_recv(l->fd); |
Willy Tarreau | be58c38 | 2011-07-24 18:28:10 +0200 | [diff] [blame] | 127 | l->state = LI_READY; |
| 128 | return 1; |
| 129 | } |
| 130 | |
Willy Tarreau | 6279371 | 2011-07-24 19:23:38 +0200 | [diff] [blame] | 131 | /* Marks a ready listener as full so that the session code tries to re-enable |
| 132 | * it upon next close() using resume_listener(). |
| 133 | */ |
| 134 | void listener_full(struct listener *l) |
| 135 | { |
| 136 | if (l->state >= LI_READY) { |
Willy Tarreau | e6ca1fc | 2011-07-24 22:03:52 +0200 | [diff] [blame] | 137 | if (l->state == LI_LIMITED) |
| 138 | LIST_DEL(&l->wait_queue); |
| 139 | |
Willy Tarreau | 49b046d | 2012-08-09 12:11:58 +0200 | [diff] [blame] | 140 | fd_stop_recv(l->fd); |
Willy Tarreau | 6279371 | 2011-07-24 19:23:38 +0200 | [diff] [blame] | 141 | l->state = LI_FULL; |
| 142 | } |
| 143 | } |
| 144 | |
Willy Tarreau | e6ca1fc | 2011-07-24 22:03:52 +0200 | [diff] [blame] | 145 | /* Marks a ready listener as limited so that we only try to re-enable it when |
| 146 | * resources are free again. It will be queued into the specified queue. |
| 147 | */ |
| 148 | void limit_listener(struct listener *l, struct list *list) |
| 149 | { |
| 150 | if (l->state == LI_READY) { |
| 151 | LIST_ADDQ(list, &l->wait_queue); |
Willy Tarreau | 49b046d | 2012-08-09 12:11:58 +0200 | [diff] [blame] | 152 | fd_stop_recv(l->fd); |
Willy Tarreau | e6ca1fc | 2011-07-24 22:03:52 +0200 | [diff] [blame] | 153 | l->state = LI_LIMITED; |
| 154 | } |
| 155 | } |
| 156 | |
Willy Tarreau | dabf2e2 | 2007-10-28 21:59:24 +0100 | [diff] [blame] | 157 | /* This function adds all of the protocol's listener's file descriptors to the |
| 158 | * polling lists when they are in the LI_LISTEN state. It is intended to be |
| 159 | * used as a protocol's generic enable_all() primitive, for use after the |
| 160 | * fork(). It puts the listeners into LI_READY or LI_FULL states depending on |
| 161 | * their number of connections. It always returns ERR_NONE. |
| 162 | */ |
| 163 | int enable_all_listeners(struct protocol *proto) |
| 164 | { |
| 165 | struct listener *listener; |
| 166 | |
| 167 | list_for_each_entry(listener, &proto->listeners, proto_list) |
| 168 | enable_listener(listener); |
| 169 | return ERR_NONE; |
| 170 | } |
| 171 | |
| 172 | /* This function removes all of the protocol's listener's file descriptors from |
| 173 | * the polling lists when they are in the LI_READY or LI_FULL states. It is |
| 174 | * intended to be used as a protocol's generic disable_all() primitive. It puts |
| 175 | * the listeners into LI_LISTEN, and always returns ERR_NONE. |
| 176 | */ |
| 177 | int disable_all_listeners(struct protocol *proto) |
| 178 | { |
| 179 | struct listener *listener; |
| 180 | |
| 181 | list_for_each_entry(listener, &proto->listeners, proto_list) |
| 182 | disable_listener(listener); |
| 183 | return ERR_NONE; |
| 184 | } |
| 185 | |
Willy Tarreau | e6ca1fc | 2011-07-24 22:03:52 +0200 | [diff] [blame] | 186 | /* Dequeues all of the listeners waiting for a resource in wait queue <queue>. */ |
| 187 | void dequeue_all_listeners(struct list *list) |
| 188 | { |
| 189 | struct listener *listener, *l_back; |
| 190 | |
| 191 | list_for_each_entry_safe(listener, l_back, list, wait_queue) { |
| 192 | /* This cannot fail because the listeners are by definition in |
| 193 | * the LI_LIMITED state. The function also removes the entry |
| 194 | * from the queue. |
| 195 | */ |
| 196 | resume_listener(listener); |
| 197 | } |
| 198 | } |
| 199 | |
Willy Tarreau | b648d63 | 2007-10-28 22:13:50 +0100 | [diff] [blame] | 200 | /* This function closes the listening socket for the specified listener, |
| 201 | * provided that it's already in a listening state. The listener enters the |
| 202 | * LI_ASSIGNED state. It always returns ERR_NONE. This function is intended |
| 203 | * to be used as a generic function for standard protocols. |
| 204 | */ |
| 205 | int unbind_listener(struct listener *listener) |
| 206 | { |
| 207 | if (listener->state == LI_READY) |
Willy Tarreau | 49b046d | 2012-08-09 12:11:58 +0200 | [diff] [blame] | 208 | fd_stop_recv(listener->fd); |
Willy Tarreau | b648d63 | 2007-10-28 22:13:50 +0100 | [diff] [blame] | 209 | |
Willy Tarreau | e6ca1fc | 2011-07-24 22:03:52 +0200 | [diff] [blame] | 210 | if (listener->state == LI_LIMITED) |
| 211 | LIST_DEL(&listener->wait_queue); |
| 212 | |
Willy Tarreau | be58c38 | 2011-07-24 18:28:10 +0200 | [diff] [blame] | 213 | if (listener->state >= LI_PAUSED) { |
Willy Tarreau | b648d63 | 2007-10-28 22:13:50 +0100 | [diff] [blame] | 214 | fd_delete(listener->fd); |
| 215 | listener->state = LI_ASSIGNED; |
| 216 | } |
| 217 | return ERR_NONE; |
| 218 | } |
| 219 | |
Willy Tarreau | 3acf8c3 | 2007-10-28 22:35:41 +0100 | [diff] [blame] | 220 | /* This function closes all listening sockets bound to the protocol <proto>, |
| 221 | * and the listeners end in LI_ASSIGNED state if they were higher. It does not |
| 222 | * detach them from the protocol. It always returns ERR_NONE. |
| 223 | */ |
| 224 | int unbind_all_listeners(struct protocol *proto) |
| 225 | { |
| 226 | struct listener *listener; |
| 227 | |
| 228 | list_for_each_entry(listener, &proto->listeners, proto_list) |
| 229 | unbind_listener(listener); |
| 230 | return ERR_NONE; |
| 231 | } |
| 232 | |
Willy Tarreau | 1a64d16 | 2007-10-28 22:26:05 +0100 | [diff] [blame] | 233 | /* Delete a listener from its protocol's list of listeners. The listener's |
| 234 | * state is automatically updated from LI_ASSIGNED to LI_INIT. The protocol's |
| 235 | * number of listeners is updated. Note that the listener must have previously |
| 236 | * been unbound. This is the generic function to use to remove a listener. |
| 237 | */ |
| 238 | void delete_listener(struct listener *listener) |
| 239 | { |
| 240 | if (listener->state != LI_ASSIGNED) |
| 241 | return; |
| 242 | listener->state = LI_INIT; |
| 243 | LIST_DEL(&listener->proto_list); |
| 244 | listener->proto->nb_listeners--; |
| 245 | } |
| 246 | |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 247 | /* This function is called on a read event from a listening socket, corresponding |
| 248 | * to an accept. It tries to accept as many connections as possible, and for each |
| 249 | * calls the listener's accept handler (generally the frontend's accept handler). |
| 250 | */ |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 251 | void listener_accept(int fd) |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 252 | { |
| 253 | struct listener *l = fdtab[fd].owner; |
| 254 | struct proxy *p = l->frontend; |
Willy Tarreau | 50de90a | 2012-11-23 20:11:45 +0100 | [diff] [blame] | 255 | int max_accept = l->maxaccept ? l->maxaccept : 1; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 256 | int cfd; |
| 257 | int ret; |
| 258 | |
| 259 | if (unlikely(l->nbconn >= l->maxconn)) { |
| 260 | listener_full(l); |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 261 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | if (global.cps_lim && !(l->options & LI_O_UNLIMITED)) { |
| 265 | int max = freq_ctr_remain(&global.conn_per_sec, global.cps_lim, 0); |
| 266 | |
| 267 | if (unlikely(!max)) { |
| 268 | /* frontend accept rate limit was reached */ |
| 269 | limit_listener(l, &global_listener_queue); |
| 270 | task_schedule(global_listener_queue_task, tick_add(now_ms, next_event_delay(&global.conn_per_sec, global.cps_lim, 0))); |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 271 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | if (max_accept > max) |
| 275 | max_accept = max; |
| 276 | } |
| 277 | |
| 278 | if (p && p->fe_sps_lim) { |
| 279 | int max = freq_ctr_remain(&p->fe_sess_per_sec, p->fe_sps_lim, 0); |
| 280 | |
| 281 | if (unlikely(!max)) { |
| 282 | /* frontend accept rate limit was reached */ |
| 283 | limit_listener(l, &p->listener_queue); |
| 284 | task_schedule(p->task, tick_add(now_ms, next_event_delay(&p->fe_sess_per_sec, p->fe_sps_lim, 0))); |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 285 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | if (max_accept > max) |
| 289 | max_accept = max; |
| 290 | } |
| 291 | |
| 292 | /* Note: if we fail to allocate a connection because of configured |
| 293 | * limits, we'll schedule a new attempt worst 1 second later in the |
| 294 | * worst case. If we fail due to system limits or temporary resource |
| 295 | * shortage, we try again 100ms later in the worst case. |
| 296 | */ |
| 297 | while (max_accept--) { |
| 298 | struct sockaddr_storage addr; |
| 299 | socklen_t laddr = sizeof(addr); |
| 300 | |
| 301 | if (unlikely(actconn >= global.maxconn) && !(l->options & LI_O_UNLIMITED)) { |
| 302 | limit_listener(l, &global_listener_queue); |
| 303 | task_schedule(global_listener_queue_task, tick_add(now_ms, 1000)); /* try again in 1 second */ |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 304 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | if (unlikely(p && p->feconn >= p->maxconn)) { |
| 308 | limit_listener(l, &p->listener_queue); |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 309 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 310 | } |
| 311 | |
Willy Tarreau | 1bc4aab | 2012-10-08 20:11:03 +0200 | [diff] [blame] | 312 | #ifdef USE_ACCEPT4 |
| 313 | cfd = accept4(fd, (struct sockaddr *)&addr, &laddr, SOCK_NONBLOCK); |
Willy Tarreau | 6b3b0d4 | 2012-10-22 19:32:55 +0200 | [diff] [blame] | 314 | if (unlikely(cfd == -1 && errno == EINVAL)) { |
| 315 | /* unsupported syscall, fallback to normal accept()+fcntl() */ |
| 316 | if ((cfd = accept(fd, (struct sockaddr *)&addr, &laddr)) != -1) |
| 317 | fcntl(cfd, F_SETFL, O_NONBLOCK); |
| 318 | } |
Willy Tarreau | 1bc4aab | 2012-10-08 20:11:03 +0200 | [diff] [blame] | 319 | #else |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 320 | cfd = accept(fd, (struct sockaddr *)&addr, &laddr); |
Willy Tarreau | 1bc4aab | 2012-10-08 20:11:03 +0200 | [diff] [blame] | 321 | #endif |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 322 | if (unlikely(cfd == -1)) { |
| 323 | switch (errno) { |
| 324 | case EAGAIN: |
| 325 | case EINTR: |
| 326 | case ECONNABORTED: |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 327 | fd_poll_recv(fd); |
| 328 | return; /* nothing more to accept */ |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 329 | case ENFILE: |
| 330 | if (p) |
| 331 | send_log(p, LOG_EMERG, |
| 332 | "Proxy %s reached system FD limit at %d. Please check system tunables.\n", |
| 333 | p->id, maxfd); |
| 334 | limit_listener(l, &global_listener_queue); |
| 335 | task_schedule(global_listener_queue_task, tick_add(now_ms, 100)); /* try again in 100 ms */ |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 336 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 337 | case EMFILE: |
| 338 | if (p) |
| 339 | send_log(p, LOG_EMERG, |
| 340 | "Proxy %s reached process FD limit at %d. Please check 'ulimit-n' and restart.\n", |
| 341 | p->id, maxfd); |
| 342 | limit_listener(l, &global_listener_queue); |
| 343 | task_schedule(global_listener_queue_task, tick_add(now_ms, 100)); /* try again in 100 ms */ |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 344 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 345 | case ENOBUFS: |
| 346 | case ENOMEM: |
| 347 | if (p) |
| 348 | send_log(p, LOG_EMERG, |
| 349 | "Proxy %s reached system memory limit at %d sockets. Please check system tunables.\n", |
| 350 | p->id, maxfd); |
| 351 | limit_listener(l, &global_listener_queue); |
| 352 | task_schedule(global_listener_queue_task, tick_add(now_ms, 100)); /* try again in 100 ms */ |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 353 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 354 | default: |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 355 | /* unexpected result, let's go back to poll */ |
| 356 | fd_poll_recv(fd); |
| 357 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 358 | } |
| 359 | } |
| 360 | |
| 361 | if (unlikely(cfd >= global.maxsock)) { |
| 362 | send_log(p, LOG_EMERG, |
| 363 | "Proxy %s reached the configured maximum connection limit. Please check the global 'maxconn' value.\n", |
| 364 | p->id); |
| 365 | close(cfd); |
| 366 | limit_listener(l, &global_listener_queue); |
| 367 | task_schedule(global_listener_queue_task, tick_add(now_ms, 1000)); /* try again in 1 second */ |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 368 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | /* increase the per-process number of cumulated connections */ |
| 372 | if (!(l->options & LI_O_UNLIMITED)) { |
| 373 | update_freq_ctr(&global.conn_per_sec, 1); |
| 374 | if (global.conn_per_sec.curr_ctr > global.cps_max) |
| 375 | global.cps_max = global.conn_per_sec.curr_ctr; |
| 376 | actconn++; |
| 377 | } |
| 378 | |
| 379 | jobs++; |
| 380 | totalconn++; |
| 381 | l->nbconn++; |
| 382 | |
| 383 | if (l->counters) { |
| 384 | if (l->nbconn > l->counters->conn_max) |
| 385 | l->counters->conn_max = l->nbconn; |
| 386 | } |
| 387 | |
| 388 | ret = l->accept(l, cfd, &addr); |
| 389 | if (unlikely(ret <= 0)) { |
| 390 | /* The connection was closed by session_accept(). Either |
| 391 | * we just have to ignore it (ret == 0) or it's a critical |
| 392 | * error due to a resource shortage, and we must stop the |
| 393 | * listener (ret < 0). |
| 394 | */ |
| 395 | if (!(l->options & LI_O_UNLIMITED)) |
| 396 | actconn--; |
| 397 | jobs--; |
| 398 | l->nbconn--; |
| 399 | if (ret == 0) /* successful termination */ |
| 400 | continue; |
| 401 | |
| 402 | limit_listener(l, &global_listener_queue); |
| 403 | task_schedule(global_listener_queue_task, tick_add(now_ms, 100)); /* try again in 100 ms */ |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 404 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | if (l->nbconn >= l->maxconn) { |
| 408 | listener_full(l); |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 409 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 410 | } |
| 411 | |
Willy Tarreau | aece46a | 2012-07-06 12:25:58 +0200 | [diff] [blame] | 412 | } /* end of while (max_accept--) */ |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 413 | |
Willy Tarreau | aece46a | 2012-07-06 12:25:58 +0200 | [diff] [blame] | 414 | /* we've exhausted max_accept, so there is no need to poll again */ |
Willy Tarreau | afad0e0 | 2012-08-09 14:45:22 +0200 | [diff] [blame] | 415 | return; |
Willy Tarreau | bbebbbf | 2012-05-07 21:22:09 +0200 | [diff] [blame] | 416 | } |
| 417 | |
Willy Tarreau | 2698266 | 2012-09-12 23:17:10 +0200 | [diff] [blame] | 418 | /* |
| 419 | * Registers the bind keyword list <kwl> as a list of valid keywords for next |
| 420 | * parsing sessions. |
| 421 | */ |
| 422 | void bind_register_keywords(struct bind_kw_list *kwl) |
| 423 | { |
| 424 | LIST_ADDQ(&bind_keywords.list, &kwl->list); |
| 425 | } |
| 426 | |
| 427 | /* Return a pointer to the bind keyword <kw>, or NULL if not found. If the |
| 428 | * keyword is found with a NULL ->parse() function, then an attempt is made to |
| 429 | * find one with a valid ->parse() function. This way it is possible to declare |
| 430 | * platform-dependant, known keywords as NULL, then only declare them as valid |
| 431 | * if some options are met. Note that if the requested keyword contains an |
| 432 | * opening parenthesis, everything from this point is ignored. |
| 433 | */ |
| 434 | struct bind_kw *bind_find_kw(const char *kw) |
| 435 | { |
| 436 | int index; |
| 437 | const char *kwend; |
| 438 | struct bind_kw_list *kwl; |
| 439 | struct bind_kw *ret = NULL; |
| 440 | |
| 441 | kwend = strchr(kw, '('); |
| 442 | if (!kwend) |
| 443 | kwend = kw + strlen(kw); |
| 444 | |
| 445 | list_for_each_entry(kwl, &bind_keywords.list, list) { |
| 446 | for (index = 0; kwl->kw[index].kw != NULL; index++) { |
| 447 | if ((strncmp(kwl->kw[index].kw, kw, kwend - kw) == 0) && |
| 448 | kwl->kw[index].kw[kwend-kw] == 0) { |
| 449 | if (kwl->kw[index].parse) |
| 450 | return &kwl->kw[index]; /* found it !*/ |
| 451 | else |
| 452 | ret = &kwl->kw[index]; /* may be OK */ |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | return ret; |
| 457 | } |
| 458 | |
Willy Tarreau | 8638f48 | 2012-09-18 18:01:17 +0200 | [diff] [blame] | 459 | /* Dumps all registered "bind" keywords to the <out> string pointer. The |
| 460 | * unsupported keywords are only dumped if their supported form was not |
| 461 | * found. |
| 462 | */ |
| 463 | void bind_dump_kws(char **out) |
| 464 | { |
| 465 | struct bind_kw_list *kwl; |
| 466 | int index; |
| 467 | |
| 468 | *out = NULL; |
| 469 | list_for_each_entry(kwl, &bind_keywords.list, list) { |
| 470 | for (index = 0; kwl->kw[index].kw != NULL; index++) { |
| 471 | if (kwl->kw[index].parse || |
| 472 | bind_find_kw(kwl->kw[index].kw) == &kwl->kw[index]) { |
Willy Tarreau | 51fb765 | 2012-09-18 18:24:39 +0200 | [diff] [blame] | 473 | memprintf(out, "%s[%4s] %s%s%s\n", *out ? *out : "", |
| 474 | kwl->scope, |
Willy Tarreau | 8638f48 | 2012-09-18 18:01:17 +0200 | [diff] [blame] | 475 | kwl->kw[index].kw, |
Willy Tarreau | 51fb765 | 2012-09-18 18:24:39 +0200 | [diff] [blame] | 476 | kwl->kw[index].skip ? " <arg>" : "", |
| 477 | kwl->kw[index].parse ? "" : " (not supported)"); |
Willy Tarreau | 8638f48 | 2012-09-18 18:01:17 +0200 | [diff] [blame] | 478 | } |
| 479 | } |
| 480 | } |
| 481 | } |
| 482 | |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 483 | /************************************************************************/ |
| 484 | /* All supported ACL keywords must be declared here. */ |
| 485 | /************************************************************************/ |
| 486 | |
Willy Tarreau | a5e3756 | 2011-12-16 17:06:15 +0100 | [diff] [blame] | 487 | /* set temp integer to the number of connexions to the same listening socket */ |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 488 | static int |
Willy Tarreau | 32a6f2e | 2012-04-25 10:13:36 +0200 | [diff] [blame] | 489 | acl_fetch_dconn(struct proxy *px, struct session *l4, void *l7, unsigned int opt, |
Willy Tarreau | 24e32d8 | 2012-04-23 23:55:44 +0200 | [diff] [blame] | 490 | const struct arg *args, struct sample *smp) |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 491 | { |
Willy Tarreau | f853c46 | 2012-04-23 18:53:56 +0200 | [diff] [blame] | 492 | smp->type = SMP_T_UINT; |
| 493 | smp->data.uint = l4->listener->nbconn; |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 494 | return 1; |
| 495 | } |
| 496 | |
Willy Tarreau | a5e3756 | 2011-12-16 17:06:15 +0100 | [diff] [blame] | 497 | /* set temp integer to the id of the socket (listener) */ |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 498 | static int |
Willy Tarreau | 32a6f2e | 2012-04-25 10:13:36 +0200 | [diff] [blame] | 499 | acl_fetch_so_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt, |
Willy Tarreau | 24e32d8 | 2012-04-23 23:55:44 +0200 | [diff] [blame] | 500 | const struct arg *args, struct sample *smp) |
Willy Tarreau | 3740635 | 2012-04-23 16:16:37 +0200 | [diff] [blame] | 501 | { |
Willy Tarreau | f853c46 | 2012-04-23 18:53:56 +0200 | [diff] [blame] | 502 | smp->type = SMP_T_UINT; |
| 503 | smp->data.uint = l4->listener->luid; |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 504 | return 1; |
| 505 | } |
| 506 | |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 507 | /* parse the "accept-proxy" bind keyword */ |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 508 | static int bind_parse_accept_proxy(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err) |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 509 | { |
| 510 | struct listener *l; |
| 511 | |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 512 | list_for_each_entry(l, &conf->listeners, by_bind) |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 513 | l->options |= LI_O_ACC_PROXY; |
| 514 | |
| 515 | return 0; |
| 516 | } |
| 517 | |
| 518 | /* parse the "backlog" bind keyword */ |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 519 | static int bind_parse_backlog(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err) |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 520 | { |
| 521 | struct listener *l; |
| 522 | int val; |
| 523 | |
| 524 | if (!*args[cur_arg + 1]) { |
Willy Tarreau | eb6cead | 2012-09-20 19:43:14 +0200 | [diff] [blame] | 525 | memprintf(err, "'%s' : missing value", args[cur_arg]); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 526 | return ERR_ALERT | ERR_FATAL; |
| 527 | } |
| 528 | |
| 529 | val = atol(args[cur_arg + 1]); |
| 530 | if (val <= 0) { |
Willy Tarreau | eb6cead | 2012-09-20 19:43:14 +0200 | [diff] [blame] | 531 | memprintf(err, "'%s' : invalid value %d, must be > 0", args[cur_arg], val); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 532 | return ERR_ALERT | ERR_FATAL; |
| 533 | } |
| 534 | |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 535 | list_for_each_entry(l, &conf->listeners, by_bind) |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 536 | l->backlog = val; |
| 537 | |
| 538 | return 0; |
| 539 | } |
| 540 | |
| 541 | /* parse the "id" bind keyword */ |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 542 | static int bind_parse_id(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err) |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 543 | { |
| 544 | struct eb32_node *node; |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 545 | struct listener *l, *new; |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 546 | |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 547 | if (conf->listeners.n != conf->listeners.p) { |
Willy Tarreau | eb6cead | 2012-09-20 19:43:14 +0200 | [diff] [blame] | 548 | memprintf(err, "'%s' can only be used with a single socket", args[cur_arg]); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 549 | return ERR_ALERT | ERR_FATAL; |
| 550 | } |
| 551 | |
| 552 | if (!*args[cur_arg + 1]) { |
Willy Tarreau | eb6cead | 2012-09-20 19:43:14 +0200 | [diff] [blame] | 553 | memprintf(err, "'%s' : expects an integer argument", args[cur_arg]); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 554 | return ERR_ALERT | ERR_FATAL; |
| 555 | } |
| 556 | |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 557 | new = LIST_NEXT(&conf->listeners, struct listener *, by_bind); |
| 558 | new->luid = atol(args[cur_arg + 1]); |
| 559 | new->conf.id.key = new->luid; |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 560 | |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 561 | if (new->luid <= 0) { |
Willy Tarreau | eb6cead | 2012-09-20 19:43:14 +0200 | [diff] [blame] | 562 | memprintf(err, "'%s' : custom id has to be > 0", args[cur_arg]); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 563 | return ERR_ALERT | ERR_FATAL; |
| 564 | } |
| 565 | |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 566 | node = eb32_lookup(&px->conf.used_listener_id, new->luid); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 567 | if (node) { |
| 568 | l = container_of(node, struct listener, conf.id); |
Willy Tarreau | eb6cead | 2012-09-20 19:43:14 +0200 | [diff] [blame] | 569 | memprintf(err, "'%s' : custom id %d already used at %s:%d ('bind %s')", |
| 570 | args[cur_arg], l->luid, l->bind_conf->file, l->bind_conf->line, |
| 571 | l->bind_conf->arg); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 572 | return ERR_ALERT | ERR_FATAL; |
| 573 | } |
| 574 | |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 575 | eb32_insert(&px->conf.used_listener_id, &new->conf.id); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 576 | return 0; |
| 577 | } |
| 578 | |
| 579 | /* parse the "maxconn" bind keyword */ |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 580 | static int bind_parse_maxconn(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err) |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 581 | { |
| 582 | struct listener *l; |
| 583 | int val; |
| 584 | |
| 585 | if (!*args[cur_arg + 1]) { |
Willy Tarreau | eb6cead | 2012-09-20 19:43:14 +0200 | [diff] [blame] | 586 | memprintf(err, "'%s' : missing value", args[cur_arg]); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 587 | return ERR_ALERT | ERR_FATAL; |
| 588 | } |
| 589 | |
| 590 | val = atol(args[cur_arg + 1]); |
| 591 | if (val <= 0) { |
Willy Tarreau | eb6cead | 2012-09-20 19:43:14 +0200 | [diff] [blame] | 592 | memprintf(err, "'%s' : invalid value %d, must be > 0", args[cur_arg], val); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 593 | return ERR_ALERT | ERR_FATAL; |
| 594 | } |
| 595 | |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 596 | list_for_each_entry(l, &conf->listeners, by_bind) |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 597 | l->maxconn = val; |
| 598 | |
| 599 | return 0; |
| 600 | } |
| 601 | |
| 602 | /* parse the "name" bind keyword */ |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 603 | static int bind_parse_name(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err) |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 604 | { |
| 605 | struct listener *l; |
| 606 | |
| 607 | if (!*args[cur_arg + 1]) { |
Willy Tarreau | eb6cead | 2012-09-20 19:43:14 +0200 | [diff] [blame] | 608 | memprintf(err, "'%s' : missing name", args[cur_arg]); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 609 | return ERR_ALERT | ERR_FATAL; |
| 610 | } |
| 611 | |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 612 | list_for_each_entry(l, &conf->listeners, by_bind) |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 613 | l->name = strdup(args[cur_arg + 1]); |
| 614 | |
| 615 | return 0; |
| 616 | } |
| 617 | |
| 618 | /* parse the "nice" bind keyword */ |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 619 | static int bind_parse_nice(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err) |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 620 | { |
| 621 | struct listener *l; |
| 622 | int val; |
| 623 | |
| 624 | if (!*args[cur_arg + 1]) { |
Willy Tarreau | eb6cead | 2012-09-20 19:43:14 +0200 | [diff] [blame] | 625 | memprintf(err, "'%s' : missing value", args[cur_arg]); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 626 | return ERR_ALERT | ERR_FATAL; |
| 627 | } |
| 628 | |
| 629 | val = atol(args[cur_arg + 1]); |
| 630 | if (val < -1024 || val > 1024) { |
Willy Tarreau | eb6cead | 2012-09-20 19:43:14 +0200 | [diff] [blame] | 631 | memprintf(err, "'%s' : invalid value %d, allowed range is -1024..1024", args[cur_arg], val); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 632 | return ERR_ALERT | ERR_FATAL; |
| 633 | } |
| 634 | |
Willy Tarreau | 4348fad | 2012-09-20 16:48:07 +0200 | [diff] [blame] | 635 | list_for_each_entry(l, &conf->listeners, by_bind) |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 636 | l->nice = val; |
| 637 | |
| 638 | return 0; |
| 639 | } |
| 640 | |
| 641 | |
Willy Tarreau | 61612d4 | 2012-04-19 18:42:05 +0200 | [diff] [blame] | 642 | /* Note: must not be declared <const> as its list will be overwritten. |
| 643 | * Please take care of keeping this list alphabetically sorted. |
| 644 | */ |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 645 | static struct acl_kw_list acl_kws = {{ },{ |
Willy Tarreau | 61612d4 | 2012-04-19 18:42:05 +0200 | [diff] [blame] | 646 | { "dst_conn", acl_parse_int, acl_fetch_dconn, acl_match_int, ACL_USE_NOTHING, 0 }, |
| 647 | { "so_id", acl_parse_int, acl_fetch_so_id, acl_match_int, ACL_USE_NOTHING, 0 }, |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 648 | { NULL, NULL, NULL, NULL }, |
| 649 | }}; |
| 650 | |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 651 | /* Note: must not be declared <const> as its list will be overwritten. |
| 652 | * Please take care of keeping this list alphabetically sorted, doing so helps |
| 653 | * all code contributors. |
| 654 | * Optional keywords are also declared with a NULL ->parse() function so that |
| 655 | * the config parser can report an appropriate error when a known keyword was |
| 656 | * not enabled. |
| 657 | */ |
Willy Tarreau | 51fb765 | 2012-09-18 18:24:39 +0200 | [diff] [blame] | 658 | static struct bind_kw_list bind_kws = { "ALL", { }, { |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 659 | { "accept-proxy", bind_parse_accept_proxy, 0 }, /* enable PROXY protocol */ |
| 660 | { "backlog", bind_parse_backlog, 1 }, /* set backlog of listening socket */ |
| 661 | { "id", bind_parse_id, 1 }, /* set id of listening socket */ |
| 662 | { "maxconn", bind_parse_maxconn, 1 }, /* set maxconn of listening socket */ |
| 663 | { "name", bind_parse_name, 1 }, /* set name of listening socket */ |
| 664 | { "nice", bind_parse_nice, 1 }, /* set nice of listening socket */ |
| 665 | { NULL, NULL, 0 }, |
| 666 | }}; |
| 667 | |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 668 | __attribute__((constructor)) |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 669 | static void __listener_init(void) |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 670 | { |
| 671 | acl_register_keywords(&acl_kws); |
Willy Tarreau | 3dcc341 | 2012-09-18 17:17:28 +0200 | [diff] [blame] | 672 | bind_register_keywords(&bind_kws); |
Willy Tarreau | 645513a | 2010-05-24 20:55:15 +0200 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | /* |
| 676 | * Local variables: |
| 677 | * c-indent-level: 8 |
| 678 | * c-basic-offset: 8 |
| 679 | * End: |
| 680 | */ |