mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-16 12:07:03 +02:00
Another way to say it: "Safely unlink requester from a requester callbacks".
Requester callbacks must never try to unlink a requester from a resolution, for
the current requester or another one. First, these callback functions are called
in a loop on a request list, not necessarily safe. Thus unlink resolution at
this place, may be unsafe. And it is useless to try to make these loops safe
because, all this stuff is placed in a loop on a resolution list. Unlink a
requester may lead to release a resolution if it is the last requester.
However, the unkink is necessary because we cannot reset the server state
(hostname and IP) with some pending DNS resolution on it. So, to workaround
this issue, we introduce the "safe" unlink. It is only performed from a
requester callback. In this case, the unlink function never releases the
resolution, it only reset it if necessary. And when a resolution is found
with an empty requester list, it is released.
This patch depends on the following commits :
* MINOR: resolvers: Purge answer items when a SRV resolution triggers an error
* MINOR: resolvers: Use a function to remove answers attached to a resolution
* MINOR: resolvers: Directly call srvrq_update_srv_state() when possible
* MINOR: resolvers: Add function to change the srv status based on SRV resolution
All the series must be backported as far as 2.2. It fixes a regression
introduced by the commit b4badf720
("BUG/MINOR: resolvers: new callback to
properly handle SRV record errors").
don't release resolution from requester cb
61 lines
2.8 KiB
C
61 lines
2.8 KiB
C
/*
|
|
* include/haproxy/dns.h
|
|
* This file provides functions related to DNS protocol
|
|
*
|
|
* Copyright (C) 2014 Baptiste Assmann <bedis9@gmail.com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
* exclusively.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _HAPROXY_RESOLVERS_H
|
|
#define _HAPROXY_RESOLVERS_H
|
|
|
|
#include <haproxy/action-t.h>
|
|
#include <haproxy/resolvers-t.h>
|
|
|
|
extern struct list sec_resolvers;
|
|
extern unsigned int resolv_failed_resolutions;
|
|
|
|
struct resolvers *find_resolvers_by_id(const char *id);
|
|
struct resolv_srvrq *find_srvrq_by_name(const char *name, struct proxy *px);
|
|
struct resolv_srvrq *new_resolv_srvrq(struct server *srv, char *fqdn);
|
|
struct resolv_answer_item *find_srvrq_answer_record(const struct resolv_requester *requester);
|
|
|
|
int resolv_str_to_dn_label(const char *str, int str_len, char *dn, int dn_len);
|
|
int resolv_dn_label_to_str(const char *dn, int dn_len, char *str, int str_len);
|
|
|
|
int resolv_hostname_validation(const char *string, char **err);
|
|
int resolv_get_ip_from_response(struct resolv_response *r_res,
|
|
struct resolv_options *resolv_opts, void *currentip,
|
|
short currentip_sin_family,
|
|
void **newip, short *newip_sin_family,
|
|
void *owner);
|
|
|
|
void resolv_purge_resolution_answer_records(struct resolv_resolution *resolution);
|
|
int resolv_link_resolution(void *requester, int requester_type, int requester_locked);
|
|
void resolv_unlink_resolution(struct resolv_requester *requester, int safe);
|
|
void resolv_trigger_resolution(struct resolv_requester *requester);
|
|
enum act_parse_ret resolv_parse_do_resolve(const char **args, int *orig_arg, struct proxy *px, struct act_rule *rule, char **err);
|
|
int check_action_do_resolve(struct act_rule *rule, struct proxy *px, char **err);
|
|
|
|
int stats_dump_resolvers(struct stream_interface *si,
|
|
struct field *stats, size_t stats_count,
|
|
struct list *stat_modules);
|
|
void resolv_stats_clear_counters(int clrall, struct list *stat_modules);
|
|
int resolv_allocate_counters(struct list *stat_modules);
|
|
int dns_dgram_init(struct dns_nameserver *ns, struct sockaddr_storage *sk);
|
|
|
|
#endif // _HAPROXY_RESOLVER_H
|