mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 05:41:26 +02:00
MINOR: connection: add names for transport and data layers
This makes debugging easier and avoids having to put ugly checks against certain well-known internal struct pointers.
This commit is contained in:
parent
2dc770c641
commit
8e0bb0ae16
@ -607,45 +607,16 @@ static inline const char *conn_get_ctrl_name(const struct connection *conn)
|
|||||||
|
|
||||||
static inline const char *conn_get_xprt_name(const struct connection *conn)
|
static inline const char *conn_get_xprt_name(const struct connection *conn)
|
||||||
{
|
{
|
||||||
static char ptr[19]; /* 0x... */
|
|
||||||
extern struct xprt_ops raw_sock; // should theorically not be exported
|
|
||||||
extern struct xprt_ops ssl_sock; // should theorically not be exported
|
|
||||||
|
|
||||||
if (!conn_xprt_ready(conn))
|
if (!conn_xprt_ready(conn))
|
||||||
return "NONE";
|
return "NONE";
|
||||||
|
return conn->xprt->name;
|
||||||
if (conn->xprt == &raw_sock)
|
|
||||||
return "RAW";
|
|
||||||
|
|
||||||
#ifdef USE_OPENSSL
|
|
||||||
if (conn->xprt == &ssl_sock)
|
|
||||||
return "SSL";
|
|
||||||
#endif
|
|
||||||
snprintf(ptr, sizeof(ptr), "%p", conn->xprt);
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char *conn_get_data_name(const struct connection *conn)
|
static inline const char *conn_get_data_name(const struct connection *conn)
|
||||||
{
|
{
|
||||||
static char ptr[19]; /* 0x... */
|
|
||||||
extern struct data_cb sess_conn_cb; // should theorically not be exported
|
|
||||||
extern struct data_cb si_conn_cb; // should theorically not be exported
|
|
||||||
extern struct data_cb check_conn_cb; // should theorically not be exported
|
|
||||||
|
|
||||||
if (!conn->data)
|
if (!conn->data)
|
||||||
return "NONE";
|
return "NONE";
|
||||||
|
return conn->data->name;
|
||||||
if (conn->data == &sess_conn_cb)
|
|
||||||
return "SESS";
|
|
||||||
|
|
||||||
if (conn->data == &si_conn_cb)
|
|
||||||
return "STRM";
|
|
||||||
|
|
||||||
if (conn->data == &check_conn_cb)
|
|
||||||
return "CHCK";
|
|
||||||
|
|
||||||
snprintf(ptr, sizeof(ptr), "%p", conn->data);
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,6 +213,7 @@ struct xprt_ops {
|
|||||||
void (*shutw)(struct connection *, int); /* shutw function */
|
void (*shutw)(struct connection *, int); /* shutw function */
|
||||||
void (*close)(struct connection *); /* close the transport layer */
|
void (*close)(struct connection *); /* close the transport layer */
|
||||||
int (*init)(struct connection *conn); /* initialize the transport layer */
|
int (*init)(struct connection *conn); /* initialize the transport layer */
|
||||||
|
char name[8]; /* transport layer name, zero-terminated */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* data_cb describes the data layer's recv and send callbacks which are called
|
/* data_cb describes the data layer's recv and send callbacks which are called
|
||||||
@ -230,6 +231,7 @@ struct data_cb {
|
|||||||
void (*send)(struct connection *conn); /* data-layer send callback */
|
void (*send)(struct connection *conn); /* data-layer send callback */
|
||||||
int (*wake)(struct connection *conn); /* data-layer callback to report activity */
|
int (*wake)(struct connection *conn); /* data-layer callback to report activity */
|
||||||
int (*init)(struct connection *conn); /* data-layer initialization */
|
int (*init)(struct connection *conn); /* data-layer initialization */
|
||||||
|
char name[8]; /* data layer name, zero-terminated */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct my_tcphdr {
|
struct my_tcphdr {
|
||||||
|
@ -1414,6 +1414,7 @@ struct data_cb check_conn_cb = {
|
|||||||
.recv = event_srv_chk_r,
|
.recv = event_srv_chk_r,
|
||||||
.send = event_srv_chk_w,
|
.send = event_srv_chk_w,
|
||||||
.wake = wake_srv_chk,
|
.wake = wake_srv_chk,
|
||||||
|
.name = "CHCK",
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -416,6 +416,7 @@ struct xprt_ops raw_sock = {
|
|||||||
.shutr = NULL,
|
.shutr = NULL,
|
||||||
.shutw = NULL,
|
.shutw = NULL,
|
||||||
.close = NULL,
|
.close = NULL,
|
||||||
|
.name = "RAW",
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -41,6 +41,7 @@ struct data_cb sess_conn_cb = {
|
|||||||
.send = NULL,
|
.send = NULL,
|
||||||
.wake = conn_update_session,
|
.wake = conn_update_session,
|
||||||
.init = conn_complete_session,
|
.init = conn_complete_session,
|
||||||
|
.name = "SESS",
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Create a a new session and assign it to frontend <fe>, listener <li>,
|
/* Create a a new session and assign it to frontend <fe>, listener <li>,
|
||||||
|
@ -6127,6 +6127,7 @@ struct xprt_ops ssl_sock = {
|
|||||||
.shutw = ssl_sock_shutw,
|
.shutw = ssl_sock_shutw,
|
||||||
.close = ssl_sock_close,
|
.close = ssl_sock_close,
|
||||||
.init = ssl_sock_init,
|
.init = ssl_sock_init,
|
||||||
|
.name = "SSL",
|
||||||
};
|
};
|
||||||
|
|
||||||
#if (OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined OPENSSL_NO_TLSEXT && !defined OPENSSL_IS_BORINGSSL && !defined LIBRESSL_VERSION_NUMBER)
|
#if (OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined OPENSSL_NO_TLSEXT && !defined OPENSSL_IS_BORINGSSL && !defined LIBRESSL_VERSION_NUMBER)
|
||||||
|
@ -86,12 +86,14 @@ struct data_cb si_conn_cb = {
|
|||||||
.recv = si_conn_recv_cb,
|
.recv = si_conn_recv_cb,
|
||||||
.send = si_conn_send_cb,
|
.send = si_conn_send_cb,
|
||||||
.wake = si_conn_wake_cb,
|
.wake = si_conn_wake_cb,
|
||||||
|
.name = "STRM",
|
||||||
};
|
};
|
||||||
|
|
||||||
struct data_cb si_idle_conn_cb = {
|
struct data_cb si_idle_conn_cb = {
|
||||||
.recv = si_idle_conn_null_cb,
|
.recv = si_idle_conn_null_cb,
|
||||||
.send = si_idle_conn_null_cb,
|
.send = si_idle_conn_null_cb,
|
||||||
.wake = si_idle_conn_wake_cb,
|
.wake = si_idle_conn_wake_cb,
|
||||||
|
.name = "IDLE",
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user