Coverage Report

Created: 2023-03-26 06:06

/src/haproxy/include/haproxy/check.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * include/haproxy/check.h
3
 * Functions prototypes for the checks.
4
 *
5
 * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation, version 2.1
10
 * exclusively.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
 */
21
22
#ifndef _HAPROXY_CHECKS_H
23
#define _HAPROXY_CHECKS_H
24
25
#include <haproxy/check-t.h>
26
#include <haproxy/proxy-t.h>
27
#include <haproxy/server-t.h>
28
#include <haproxy/trace-t.h>
29
30
extern struct trace_source trace_check;
31
32
/* Details about these events are defined in <src/check.c> */
33
#define CHK_EV_TASK_WAKE       (1ULL <<  0)
34
#define CHK_EV_HCHK_START      (1ULL <<  1)
35
#define CHK_EV_HCHK_WAKE       (1ULL <<  2)
36
#define CHK_EV_HCHK_RUN        (1ULL <<  3)
37
#define CHK_EV_HCHK_END        (1ULL <<  4)
38
#define CHK_EV_HCHK_SUCC       (1ULL <<  5)
39
#define CHK_EV_HCHK_ERR        (1ULL <<  6)
40
#define CHK_EV_HCHK            (CHK_EV_HCHK_START|CHK_EV_HCHK_WAKE|CHK_EV_HCHK_RUN|\
41
        CHK_EV_HCHK_END|CHK_EV_HCHK_SUCC|CHK_EV_HCHK_ERR)
42
43
0
#define CHK_EV_TCPCHK_EVAL     (1ULL <<  7)
44
0
#define CHK_EV_TCPCHK_ERR      (1ULL <<  8)
45
0
#define CHK_EV_TCPCHK_CONN     (1ULL <<  9)
46
0
#define CHK_EV_TCPCHK_SND      (1ULL << 10)
47
0
#define CHK_EV_TCPCHK_EXP      (1ULL << 11)
48
0
#define CHK_EV_TCPCHK_ACT      (1ULL << 12)
49
0
#define CHK_EV_TCPCHK          (CHK_EV_TCPCHK_EVAL|CHK_EV_TCPCHK_ERR|CHK_EV_TCPCHK_CONN|\
50
0
        CHK_EV_TCPCHK_SND|CHK_EV_TCPCHK_EXP|CHK_EV_TCPCHK_ACT)
51
52
0
#define CHK_EV_RX_DATA         (1ULL << 13)
53
0
#define CHK_EV_RX_BLK          (1ULL << 14)
54
0
#define CHK_EV_RX_ERR          (1ULL << 15)
55
0
#define CHK_EV_RX              (CHK_EV_RX_DATA|CHK_EV_RX_BLK|CHK_EV_RX_ERR)
56
57
0
#define CHK_EV_TX_DATA         (1ULL << 16)
58
0
#define CHK_EV_TX_BLK          (1ULL << 17)
59
0
#define CHK_EV_TX_ERR          (1ULL << 18)
60
0
#define CHK_EV_TX              (CHK_EV_TX_DATA|CHK_EV_TX_BLK|CHK_EV_TX_ERR)
61
62
extern struct data_cb check_conn_cb;
63
extern struct proxy checks_fe;
64
65
short get_check_status_result(short check_status);
66
const char *get_check_status_description(short check_status);
67
const char *get_check_status_info(short check_status);
68
int httpchk_build_status_header(struct server *s, struct buffer *buf);
69
void __health_adjust(struct server *s, short status);
70
void set_server_check_status(struct check *check, short status, const char *desc);
71
void chk_report_conn_err(struct check *check, int errno_bck, int expired);
72
void check_notify_failure(struct check *check);
73
void check_notify_stopping(struct check *check);
74
void check_notify_success(struct check *check);
75
struct task *process_chk(struct task *t, void *context, unsigned int state);
76
77
struct task *srv_chk_io_cb(struct task *t, void *ctx, unsigned int state);
78
79
int check_buf_available(void *target);
80
struct buffer *check_get_buf(struct check *check, struct buffer *bptr);
81
void check_release_buf(struct check *check, struct buffer *bptr);
82
const char *init_check(struct check *check, int type);
83
void free_check(struct check *check);
84
void check_purge(struct check *check);
85
int wake_srv_chk(struct stconn *sc);
86
87
int init_srv_check(struct server *srv);
88
int init_srv_agent_check(struct server *srv);
89
int start_check_task(struct check *check, int mininter, int nbcheck, int srvpos);
90
91
/* Declared here, but the definitions are in flt_spoe.c */
92
int spoe_prepare_healthcheck_request(char **req, int *len);
93
int spoe_handle_healthcheck_response(char *frame, size_t size, char *err, int errlen);
94
95
int set_srv_agent_send(struct server *srv, const char *send);
96
97
/* set agent addr and appropriate flag */
98
static inline void set_srv_agent_addr(struct server *srv, struct sockaddr_storage *sk)
99
0
{
100
0
  srv->agent.addr = *sk;
101
0
  srv->flags |= SRV_F_AGENTADDR;
102
0
}
Unexecuted instantiation: cfgparse.c:set_srv_agent_addr
Unexecuted instantiation: cli.c:set_srv_agent_addr
Unexecuted instantiation: http_ana.c:set_srv_agent_addr
Unexecuted instantiation: mailers.c:set_srv_agent_addr
Unexecuted instantiation: resolvers.c:set_srv_agent_addr
Unexecuted instantiation: server.c:set_srv_agent_addr
Unexecuted instantiation: stats.c:set_srv_agent_addr
Unexecuted instantiation: stconn.c:set_srv_agent_addr
Unexecuted instantiation: stream.c:set_srv_agent_addr
Unexecuted instantiation: tcpcheck.c:set_srv_agent_addr
Unexecuted instantiation: vars.c:set_srv_agent_addr
Unexecuted instantiation: backend.c:set_srv_agent_addr
Unexecuted instantiation: cfgparse-listen.c:set_srv_agent_addr
Unexecuted instantiation: check.c:set_srv_agent_addr
Unexecuted instantiation: dns.c:set_srv_agent_addr
Unexecuted instantiation: extcheck.c:set_srv_agent_addr
Unexecuted instantiation: flt_spoe.c:set_srv_agent_addr
103
104
/* set agent port and appropriate flag */
105
static inline void set_srv_agent_port(struct server *srv, int port)
106
0
{
107
0
  srv->agent.port = port;
108
0
  srv->flags |= SRV_F_AGENTPORT;
109
0
}
Unexecuted instantiation: cfgparse.c:set_srv_agent_port
Unexecuted instantiation: cli.c:set_srv_agent_port
Unexecuted instantiation: http_ana.c:set_srv_agent_port
Unexecuted instantiation: mailers.c:set_srv_agent_port
Unexecuted instantiation: resolvers.c:set_srv_agent_port
Unexecuted instantiation: server.c:set_srv_agent_port
Unexecuted instantiation: stats.c:set_srv_agent_port
Unexecuted instantiation: stconn.c:set_srv_agent_port
Unexecuted instantiation: stream.c:set_srv_agent_port
Unexecuted instantiation: tcpcheck.c:set_srv_agent_port
Unexecuted instantiation: vars.c:set_srv_agent_port
Unexecuted instantiation: backend.c:set_srv_agent_port
Unexecuted instantiation: cfgparse-listen.c:set_srv_agent_port
Unexecuted instantiation: check.c:set_srv_agent_port
Unexecuted instantiation: dns.c:set_srv_agent_port
Unexecuted instantiation: extcheck.c:set_srv_agent_port
Unexecuted instantiation: flt_spoe.c:set_srv_agent_port
110
111
/* Use this one only. This inline version only ensures that we don't
112
 * call the function when the observe mode is disabled.
113
 */
114
static inline void health_adjust(struct server *s, short status)
115
0
{
116
  /* return now if observing nor health check is not enabled */
117
0
  if (!s->observe || !s->check.task)
118
0
    return;
119
120
0
  __health_adjust(s, status);
121
0
}
Unexecuted instantiation: cfgparse.c:health_adjust
Unexecuted instantiation: cli.c:health_adjust
Unexecuted instantiation: http_ana.c:health_adjust
Unexecuted instantiation: mailers.c:health_adjust
Unexecuted instantiation: resolvers.c:health_adjust
Unexecuted instantiation: server.c:health_adjust
Unexecuted instantiation: stats.c:health_adjust
Unexecuted instantiation: stconn.c:health_adjust
Unexecuted instantiation: stream.c:health_adjust
Unexecuted instantiation: tcpcheck.c:health_adjust
Unexecuted instantiation: vars.c:health_adjust
Unexecuted instantiation: backend.c:health_adjust
Unexecuted instantiation: cfgparse-listen.c:health_adjust
Unexecuted instantiation: check.c:health_adjust
Unexecuted instantiation: dns.c:health_adjust
Unexecuted instantiation: extcheck.c:health_adjust
Unexecuted instantiation: flt_spoe.c:health_adjust
122
123
#endif /* _HAPROXY_CHECKS_H */
124
125
/*
126
 * Local variables:
127
 *  c-indent-level: 8
128
 *  c-basic-offset: 8
129
 * End:
130
 */