Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Protocol registration functions. |
| 3 | * |
| 4 | * Copyright 2000-2012 Willy Tarreau <w@1wt.eu> |
| 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 | a6e3be7 | 2016-08-10 18:24:48 +0200 | [diff] [blame] | 13 | #include <sys/types.h> |
Willy Tarreau | b550d00 | 2015-02-20 16:53:25 +0100 | [diff] [blame] | 14 | #include <sys/socket.h> |
| 15 | |
Willy Tarreau | 4c7e4b7 | 2020-05-27 12:58:42 +0200 | [diff] [blame] | 16 | #include <haproxy/api.h> |
Willy Tarreau | 8d36697 | 2020-05-27 16:10:29 +0200 | [diff] [blame] | 17 | #include <haproxy/errors.h> |
Frédéric Lécaille | 12a0317 | 2023-01-12 15:23:54 +0100 | [diff] [blame] | 18 | #include <haproxy/global.h> |
Willy Tarreau | 853b297 | 2020-05-27 18:01:47 +0200 | [diff] [blame] | 19 | #include <haproxy/list.h> |
Willy Tarreau | 9432085 | 2020-09-01 18:48:35 +0200 | [diff] [blame] | 20 | #include <haproxy/listener.h> |
Frédéric Lécaille | 12a0317 | 2023-01-12 15:23:54 +0100 | [diff] [blame] | 21 | #include <haproxy/proto_quic.h> |
Willy Tarreau | b255105 | 2020-06-09 09:07:15 +0200 | [diff] [blame] | 22 | #include <haproxy/protocol.h> |
Willy Tarreau | e91bff2 | 2020-09-02 11:11:43 +0200 | [diff] [blame] | 23 | #include <haproxy/proxy.h> |
Willy Tarreau | f1003ea | 2023-04-22 18:26:56 +0200 | [diff] [blame] | 24 | #include <haproxy/sock.h> |
Willy Tarreau | 48fbcae | 2020-06-03 18:09:46 +0200 | [diff] [blame] | 25 | #include <haproxy/tools.h> |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 26 | |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 27 | |
| 28 | /* List head of all registered protocols */ |
| 29 | static struct list protocols = LIST_HEAD_INIT(protocols); |
Willy Tarreau | e3b4518 | 2021-10-27 17:28:55 +0200 | [diff] [blame] | 30 | struct protocol *__protocol_by_family[AF_CUST_MAX][PROTO_NUM_TYPES][2] __read_mostly = { }; |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 31 | |
Willy Tarreau | daacf36 | 2019-07-24 16:45:02 +0200 | [diff] [blame] | 32 | /* This is the global spinlock we may need to register/unregister listeners or |
| 33 | * protocols. Its main purpose is in fact to serialize the rare stop/deinit() |
| 34 | * phases. |
| 35 | */ |
| 36 | __decl_spinlock(proto_lock); |
| 37 | |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 38 | /* Registers the protocol <proto> */ |
| 39 | void protocol_register(struct protocol *proto) |
| 40 | { |
Willy Tarreau | bdcee7f | 2021-10-27 15:06:35 +0200 | [diff] [blame] | 41 | int sock_domain = proto->fam->sock_domain; |
| 42 | |
| 43 | BUG_ON(sock_domain < 0 || sock_domain >= AF_CUST_MAX); |
Willy Tarreau | e3b4518 | 2021-10-27 17:28:55 +0200 | [diff] [blame] | 44 | BUG_ON(proto->proto_type >= PROTO_NUM_TYPES); |
Willy Tarreau | bdcee7f | 2021-10-27 15:06:35 +0200 | [diff] [blame] | 45 | |
Willy Tarreau | daacf36 | 2019-07-24 16:45:02 +0200 | [diff] [blame] | 46 | HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 47 | LIST_APPEND(&protocols, &proto->list); |
Willy Tarreau | bdcee7f | 2021-10-27 15:06:35 +0200 | [diff] [blame] | 48 | __protocol_by_family[sock_domain] |
Willy Tarreau | e3b4518 | 2021-10-27 17:28:55 +0200 | [diff] [blame] | 49 | [proto->proto_type] |
Willy Tarreau | 91b4726 | 2022-05-20 16:36:46 +0200 | [diff] [blame] | 50 | [proto->xprt_type == PROTO_TYPE_DGRAM] = proto; |
Willy Tarreau | daacf36 | 2019-07-24 16:45:02 +0200 | [diff] [blame] | 51 | HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | /* Unregisters the protocol <proto>. Note that all listeners must have |
| 55 | * previously been unbound. |
| 56 | */ |
| 57 | void protocol_unregister(struct protocol *proto) |
| 58 | { |
Willy Tarreau | daacf36 | 2019-07-24 16:45:02 +0200 | [diff] [blame] | 59 | HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 60 | LIST_DELETE(&proto->list); |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 61 | LIST_INIT(&proto->list); |
Willy Tarreau | daacf36 | 2019-07-24 16:45:02 +0200 | [diff] [blame] | 62 | HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 63 | } |
| 64 | |
Willy Tarreau | 65df7e0 | 2023-04-22 15:02:35 +0200 | [diff] [blame] | 65 | /* clears flag <flag> on all protocols. */ |
| 66 | void protocol_clrf_all(uint flag) |
| 67 | { |
| 68 | struct protocol *proto; |
| 69 | |
| 70 | HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); |
| 71 | list_for_each_entry(proto, &protocols, list) |
| 72 | proto->flags &= ~flag; |
| 73 | HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); |
| 74 | } |
| 75 | |
| 76 | /* sets flag <flag> on all protocols. */ |
| 77 | void protocol_setf_all(uint flag) |
| 78 | { |
| 79 | struct protocol *proto; |
| 80 | |
| 81 | HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); |
| 82 | list_for_each_entry(proto, &protocols, list) |
| 83 | proto->flags |= flag; |
| 84 | HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); |
| 85 | } |
| 86 | |
Willy Tarreau | 8a5e6f4 | 2023-04-22 17:39:30 +0200 | [diff] [blame] | 87 | /* Checks if protocol <proto> supports PROTO_F flag <flag>. Returns zero if not, |
| 88 | * non-zero if supported. It may return a cached value from a previous test, |
| 89 | * and may run live tests then update the proto's flags to cache a result. It's |
| 90 | * better to call it only if needed so that it doesn't result in modules being |
| 91 | * loaded in case of a live test. It is only supposed to be used during boot. |
| 92 | */ |
| 93 | int protocol_supports_flag(struct protocol *proto, uint flag) |
| 94 | { |
| 95 | if (flag == PROTO_F_REUSEPORT_SUPPORTED) { |
Willy Tarreau | f1003ea | 2023-04-22 18:26:56 +0200 | [diff] [blame] | 96 | int ret = 0; |
| 97 | |
Willy Tarreau | 8a5e6f4 | 2023-04-22 17:39:30 +0200 | [diff] [blame] | 98 | /* check if the protocol supports SO_REUSEPORT */ |
| 99 | if (!(_HA_ATOMIC_LOAD(&proto->flags) & PROTO_F_REUSEPORT_SUPPORTED)) |
| 100 | return 0; |
| 101 | |
Willy Tarreau | f1003ea | 2023-04-22 18:26:56 +0200 | [diff] [blame] | 102 | /* at least nobody said it was not supported */ |
| 103 | if (_HA_ATOMIC_LOAD(&proto->flags) & PROTO_F_REUSEPORT_TESTED) |
| 104 | return 1; |
| 105 | |
| 106 | /* run a live check */ |
| 107 | ret = _sock_supports_reuseport(proto->fam, proto->sock_type, proto->sock_prot); |
| 108 | if (!ret) |
| 109 | _HA_ATOMIC_AND(&proto->flags, ~PROTO_F_REUSEPORT_SUPPORTED); |
| 110 | |
| 111 | _HA_ATOMIC_OR(&proto->flags, PROTO_F_REUSEPORT_TESTED); |
| 112 | return ret; |
Willy Tarreau | 8a5e6f4 | 2023-04-22 17:39:30 +0200 | [diff] [blame] | 113 | } |
| 114 | return 0; |
| 115 | } |
| 116 | |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 117 | /* binds all listeners of all registered protocols. Returns a composition |
| 118 | * of ERR_NONE, ERR_RETRYABLE, ERR_FATAL. |
| 119 | */ |
Willy Tarreau | e91bff2 | 2020-09-02 11:11:43 +0200 | [diff] [blame] | 120 | int protocol_bind_all(int verbose) |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 121 | { |
| 122 | struct protocol *proto; |
Willy Tarreau | 9432085 | 2020-09-01 18:48:35 +0200 | [diff] [blame] | 123 | struct listener *listener; |
Willy Tarreau | fc97488 | 2020-09-02 18:22:11 +0200 | [diff] [blame] | 124 | struct receiver *receiver; |
Bjoern Jacke | ed17485 | 2021-01-12 19:24:43 +0100 | [diff] [blame] | 125 | char msg[1000]; |
Willy Tarreau | fc97488 | 2020-09-02 18:22:11 +0200 | [diff] [blame] | 126 | char *errmsg; |
Willy Tarreau | e91bff2 | 2020-09-02 11:11:43 +0200 | [diff] [blame] | 127 | int err, lerr; |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 128 | |
| 129 | err = 0; |
Willy Tarreau | daacf36 | 2019-07-24 16:45:02 +0200 | [diff] [blame] | 130 | HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 131 | list_for_each_entry(proto, &protocols, list) { |
Willy Tarreau | d7f331c | 2020-09-25 17:01:43 +0200 | [diff] [blame] | 132 | list_for_each_entry(receiver, &proto->receivers, proto_list) { |
Frédéric Lécaille | 12a0317 | 2023-01-12 15:23:54 +0100 | [diff] [blame] | 133 | #ifdef USE_QUIC |
| 134 | if ((global.tune.options & GTUNE_NO_QUIC) && |
| 135 | (proto == &proto_quic4 || proto == &proto_quic6)) |
| 136 | continue; |
| 137 | #endif |
Willy Tarreau | fc97488 | 2020-09-02 18:22:11 +0200 | [diff] [blame] | 138 | listener = LIST_ELEM(receiver, struct listener *, rx); |
| 139 | |
Willy Tarreau | 233ad28 | 2020-10-15 21:45:15 +0200 | [diff] [blame] | 140 | lerr = proto->fam->bind(receiver, &errmsg); |
Willy Tarreau | fc97488 | 2020-09-02 18:22:11 +0200 | [diff] [blame] | 141 | err |= lerr; |
Willy Tarreau | e91bff2 | 2020-09-02 11:11:43 +0200 | [diff] [blame] | 142 | |
| 143 | /* errors are reported if <verbose> is set or if they are fatal */ |
| 144 | if (verbose || (lerr & (ERR_FATAL | ERR_ABORT))) { |
| 145 | struct proxy *px = listener->bind_conf->frontend; |
| 146 | |
| 147 | if (lerr & ERR_ALERT) |
Willy Tarreau | 37de553 | 2021-10-14 11:55:48 +0200 | [diff] [blame] | 148 | ha_alert("Binding [%s:%d] for %s %s: %s\n", |
| 149 | listener->bind_conf->file, listener->bind_conf->line, |
Willy Tarreau | fc97488 | 2020-09-02 18:22:11 +0200 | [diff] [blame] | 150 | proxy_type_str(px), px->id, errmsg); |
Willy Tarreau | e91bff2 | 2020-09-02 11:11:43 +0200 | [diff] [blame] | 151 | else if (lerr & ERR_WARN) |
Willy Tarreau | 37de553 | 2021-10-14 11:55:48 +0200 | [diff] [blame] | 152 | ha_warning("Binding [%s:%d] for %s %s: %s\n", |
| 153 | listener->bind_conf->file, listener->bind_conf->line, |
Willy Tarreau | fc97488 | 2020-09-02 18:22:11 +0200 | [diff] [blame] | 154 | proxy_type_str(px), px->id, errmsg); |
Willy Tarreau | e91bff2 | 2020-09-02 11:11:43 +0200 | [diff] [blame] | 155 | } |
Aurelien DARRAGON | 8429627 | 2023-02-07 15:51:58 +0100 | [diff] [blame] | 156 | if (lerr != ERR_NONE) |
| 157 | ha_free(&errmsg); |
| 158 | |
Willy Tarreau | fc97488 | 2020-09-02 18:22:11 +0200 | [diff] [blame] | 159 | if (lerr & ERR_ABORT) |
| 160 | break; |
Willy Tarreau | e91bff2 | 2020-09-02 11:11:43 +0200 | [diff] [blame] | 161 | |
Willy Tarreau | fc97488 | 2020-09-02 18:22:11 +0200 | [diff] [blame] | 162 | if (lerr & ~ERR_WARN) |
| 163 | continue; |
| 164 | |
| 165 | /* for now there's still always a listening function */ |
| 166 | BUG_ON(!proto->listen); |
| 167 | lerr = proto->listen(listener, msg, sizeof(msg)); |
Willy Tarreau | e91bff2 | 2020-09-02 11:11:43 +0200 | [diff] [blame] | 168 | err |= lerr; |
Willy Tarreau | fc97488 | 2020-09-02 18:22:11 +0200 | [diff] [blame] | 169 | |
| 170 | if (verbose || (lerr & (ERR_FATAL | ERR_ABORT))) { |
| 171 | struct proxy *px = listener->bind_conf->frontend; |
| 172 | |
| 173 | if (lerr & ERR_ALERT) |
Willy Tarreau | 37de553 | 2021-10-14 11:55:48 +0200 | [diff] [blame] | 174 | ha_alert("Starting [%s:%d] for %s %s: %s\n", |
| 175 | listener->bind_conf->file, listener->bind_conf->line, |
Willy Tarreau | fc97488 | 2020-09-02 18:22:11 +0200 | [diff] [blame] | 176 | proxy_type_str(px), px->id, msg); |
| 177 | else if (lerr & ERR_WARN) |
Willy Tarreau | 37de553 | 2021-10-14 11:55:48 +0200 | [diff] [blame] | 178 | ha_warning("Starting [%s:%d] for %s %s: %s\n", |
| 179 | listener->bind_conf->file, listener->bind_conf->line, |
Willy Tarreau | fc97488 | 2020-09-02 18:22:11 +0200 | [diff] [blame] | 180 | proxy_type_str(px), px->id, msg); |
| 181 | } |
Willy Tarreau | e91bff2 | 2020-09-02 11:11:43 +0200 | [diff] [blame] | 182 | if (lerr & ERR_ABORT) |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 183 | break; |
| 184 | } |
Willy Tarreau | e91bff2 | 2020-09-02 11:11:43 +0200 | [diff] [blame] | 185 | if (err & ERR_ABORT) |
| 186 | break; |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 187 | } |
Willy Tarreau | daacf36 | 2019-07-24 16:45:02 +0200 | [diff] [blame] | 188 | HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 189 | return err; |
| 190 | } |
| 191 | |
| 192 | /* unbinds all listeners of all registered protocols. They are also closed. |
| 193 | * This must be performed before calling exit() in order to get a chance to |
| 194 | * remove file-system based sockets and pipes. |
| 195 | * Returns a composition of ERR_NONE, ERR_RETRYABLE, ERR_FATAL, ERR_ABORT. |
| 196 | */ |
| 197 | int protocol_unbind_all(void) |
| 198 | { |
| 199 | struct protocol *proto; |
Willy Tarreau | ca21262 | 2020-09-02 10:31:31 +0200 | [diff] [blame] | 200 | struct listener *listener; |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 201 | int err; |
| 202 | |
| 203 | err = 0; |
Willy Tarreau | daacf36 | 2019-07-24 16:45:02 +0200 | [diff] [blame] | 204 | HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 205 | list_for_each_entry(proto, &protocols, list) { |
Willy Tarreau | d7f331c | 2020-09-25 17:01:43 +0200 | [diff] [blame] | 206 | list_for_each_entry(listener, &proto->receivers, rx.proto_list) |
Willy Tarreau | ca21262 | 2020-09-02 10:31:31 +0200 | [diff] [blame] | 207 | unbind_listener(listener); |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 208 | } |
Willy Tarreau | daacf36 | 2019-07-24 16:45:02 +0200 | [diff] [blame] | 209 | HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 210 | return err; |
| 211 | } |
| 212 | |
Willy Tarreau | eb77824 | 2021-06-11 16:27:10 +0200 | [diff] [blame] | 213 | /* stops all listeners of all registered protocols. This will normally catch |
| 214 | * every single listener, all protocols included. This is to be used during |
| 215 | * soft_stop() only. It does not return any error. |
Willy Tarreau | 02e8557 | 2020-10-07 16:50:49 +0200 | [diff] [blame] | 216 | */ |
| 217 | void protocol_stop_now(void) |
| 218 | { |
| 219 | struct protocol *proto; |
| 220 | struct listener *listener, *lback; |
| 221 | |
| 222 | HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); |
| 223 | list_for_each_entry(proto, &protocols, list) { |
| 224 | list_for_each_entry_safe(listener, lback, &proto->receivers, rx.proto_list) |
Aurelien DARRAGON | 4059e09 | 2023-02-06 17:06:03 +0100 | [diff] [blame] | 225 | stop_listener(listener, 0, 1, 0); |
Willy Tarreau | 02e8557 | 2020-10-07 16:50:49 +0200 | [diff] [blame] | 226 | } |
| 227 | HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); |
| 228 | } |
| 229 | |
Aurelien DARRAGON | d3ffba4 | 2023-02-13 17:45:08 +0100 | [diff] [blame] | 230 | /* suspends all listeners of all registered protocols. This is typically |
Willy Tarreau | 09819d1 | 2020-09-24 16:26:50 +0200 | [diff] [blame] | 231 | * used on SIG_TTOU to release all listening sockets for the time needed to |
Aurelien DARRAGON | d3ffba4 | 2023-02-13 17:45:08 +0100 | [diff] [blame] | 232 | * try to bind a new process. The listeners enter LI_PAUSED or LI_ASSIGNED. |
| 233 | * It returns ERR_NONE, with ERR_FATAL on failure. |
Willy Tarreau | 09819d1 | 2020-09-24 16:26:50 +0200 | [diff] [blame] | 234 | */ |
| 235 | int protocol_pause_all(void) |
| 236 | { |
| 237 | struct protocol *proto; |
| 238 | struct listener *listener; |
| 239 | int err; |
| 240 | |
| 241 | err = 0; |
| 242 | HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); |
| 243 | list_for_each_entry(proto, &protocols, list) { |
Willy Tarreau | d7f331c | 2020-09-25 17:01:43 +0200 | [diff] [blame] | 244 | list_for_each_entry(listener, &proto->receivers, rx.proto_list) |
Aurelien DARRAGON | d3ffba4 | 2023-02-13 17:45:08 +0100 | [diff] [blame] | 245 | if (!suspend_listener(listener, 0, 0)) |
Willy Tarreau | 09819d1 | 2020-09-24 16:26:50 +0200 | [diff] [blame] | 246 | err |= ERR_FATAL; |
| 247 | } |
| 248 | HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); |
| 249 | return err; |
| 250 | } |
| 251 | |
| 252 | /* resumes all listeners of all registered protocols. This is typically used on |
| 253 | * SIG_TTIN to re-enable listening sockets after a new process failed to bind. |
| 254 | * The listeners switch to LI_READY/LI_FULL. It returns ERR_NONE, with ERR_FATAL |
| 255 | * on failure. |
| 256 | */ |
| 257 | int protocol_resume_all(void) |
| 258 | { |
| 259 | struct protocol *proto; |
| 260 | struct listener *listener; |
| 261 | int err; |
| 262 | |
| 263 | err = 0; |
| 264 | HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); |
| 265 | list_for_each_entry(proto, &protocols, list) { |
Willy Tarreau | d7f331c | 2020-09-25 17:01:43 +0200 | [diff] [blame] | 266 | list_for_each_entry(listener, &proto->receivers, rx.proto_list) |
Aurelien DARRAGON | 4059e09 | 2023-02-06 17:06:03 +0100 | [diff] [blame] | 267 | if (!resume_listener(listener, 0, 0)) |
Willy Tarreau | 09819d1 | 2020-09-24 16:26:50 +0200 | [diff] [blame] | 268 | err |= ERR_FATAL; |
| 269 | } |
| 270 | HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); |
| 271 | return err; |
| 272 | } |
| 273 | |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 274 | /* enables all listeners of all registered protocols. This is intended to be |
Willy Tarreau | 5b95ae6 | 2020-09-25 16:41:05 +0200 | [diff] [blame] | 275 | * used after a fork() to enable reading on all file descriptors. Returns |
| 276 | * composition of ERR_NONE. |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 277 | */ |
| 278 | int protocol_enable_all(void) |
| 279 | { |
| 280 | struct protocol *proto; |
Willy Tarreau | 5b95ae6 | 2020-09-25 16:41:05 +0200 | [diff] [blame] | 281 | struct listener *listener; |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 282 | |
Willy Tarreau | daacf36 | 2019-07-24 16:45:02 +0200 | [diff] [blame] | 283 | HA_SPIN_LOCK(PROTO_LOCK, &proto_lock); |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 284 | list_for_each_entry(proto, &protocols, list) { |
Willy Tarreau | d7f331c | 2020-09-25 17:01:43 +0200 | [diff] [blame] | 285 | list_for_each_entry(listener, &proto->receivers, rx.proto_list) |
Willy Tarreau | 5b95ae6 | 2020-09-25 16:41:05 +0200 | [diff] [blame] | 286 | enable_listener(listener); |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 287 | } |
Willy Tarreau | daacf36 | 2019-07-24 16:45:02 +0200 | [diff] [blame] | 288 | HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock); |
Willy Tarreau | 5b95ae6 | 2020-09-25 16:41:05 +0200 | [diff] [blame] | 289 | return ERR_NONE; |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 290 | } |
| 291 | |
Willy Tarreau | d1d5454 | 2012-09-12 22:58:11 +0200 | [diff] [blame] | 292 | /* |
| 293 | * Local variables: |
| 294 | * c-indent-level: 8 |
| 295 | * c-basic-offset: 8 |
| 296 | * End: |
| 297 | */ |