mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
MEDIUM: xprt: Add a "get_capability" method.
Add a new method to xprts, get_capability, that can be used to query if an xprt supports something or not. The first capability implemented is XPRT_CAN_SPLICE, to know if the xprt will be able to use splicing for the provided connection. The possible answers are XPRT_CONN_CAN_NOT_SPLICE, which indicates splicing will never be possible for that connection, XPRT_CONN_COULD_SPLICE, which indicates that splicing is not usable right now, but may be in the future, and XPRT_CONN_CAN_SPLICE, that means we can splice right away.
This commit is contained in:
parent
2623b7822e
commit
5731b8a19c
@ -433,6 +433,16 @@ union conn_handle {
|
|||||||
int fd; /* file descriptor, for regular sockets (CO_FL_FDLESS=0) */
|
int fd; /* file descriptor, for regular sockets (CO_FL_FDLESS=0) */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum xprt_capabilities {
|
||||||
|
XPRT_CAN_SPLICE,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum xprt_splice_cap {
|
||||||
|
XPRT_CONN_CAN_NOT_SPLICE, /* This connection can't, and won't ever be able to splice */
|
||||||
|
XPRT_CONN_COULD_SPLICE, /* This connection can't splice, but may later */
|
||||||
|
XPRT_CONN_CAN_SPLICE /* This connection can splice */
|
||||||
|
};
|
||||||
|
|
||||||
/* xprt_ops describes transport-layer operations for a connection. They
|
/* xprt_ops describes transport-layer operations for a connection. They
|
||||||
* generally run over a socket-based control layer, but not always. Some
|
* generally run over a socket-based control layer, but not always. Some
|
||||||
* of them are used for data transfer with the upper layer (rcv_*, snd_*)
|
* of them are used for data transfer with the upper layer (rcv_*, snd_*)
|
||||||
@ -464,6 +474,12 @@ struct xprt_ops {
|
|||||||
struct ssl_sock_ctx *(*get_ssl_sock_ctx)(struct connection *); /* retrieve the ssl_sock_ctx in use, or NULL if none */
|
struct ssl_sock_ctx *(*get_ssl_sock_ctx)(struct connection *); /* retrieve the ssl_sock_ctx in use, or NULL if none */
|
||||||
int (*show_fd)(struct buffer *, const struct connection *, const void *ctx); /* append some data about xprt for "show fd"; returns non-zero if suspicious */
|
int (*show_fd)(struct buffer *, const struct connection *, const void *ctx); /* append some data about xprt for "show fd"; returns non-zero if suspicious */
|
||||||
void (*dump_info)(struct buffer *, const struct connection *);
|
void (*dump_info)(struct buffer *, const struct connection *);
|
||||||
|
/*
|
||||||
|
* Returns the value for various capabilities.
|
||||||
|
* Returns 0 if the capability is known, iwth the actual value in arg,
|
||||||
|
* or -1 otherwise
|
||||||
|
*/
|
||||||
|
int (*get_capability)(struct connection *connection, void *xprt_ctx, enum xprt_capabilities, void *arg);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* mux_ops describes the mux operations, which are to be performed at the
|
/* mux_ops describes the mux operations, which are to be performed at the
|
||||||
|
@ -506,6 +506,19 @@ static int raw_sock_remove_xprt(struct connection *conn, void *xprt_ctx, void *t
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int raw_sock_get_capability(struct connection *conn, void *xprt_ctx, enum xprt_capabilities cap, void *arg)
|
||||||
|
{
|
||||||
|
int *ret;
|
||||||
|
|
||||||
|
switch (cap) {
|
||||||
|
case XPRT_CAN_SPLICE:
|
||||||
|
ret = arg;
|
||||||
|
*ret = XPRT_CONN_CAN_SPLICE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* transport-layer operations for RAW sockets */
|
/* transport-layer operations for RAW sockets */
|
||||||
static struct xprt_ops raw_sock = {
|
static struct xprt_ops raw_sock = {
|
||||||
.snd_buf = raw_sock_from_buf,
|
.snd_buf = raw_sock_from_buf,
|
||||||
@ -517,6 +530,7 @@ static struct xprt_ops raw_sock = {
|
|||||||
.rcv_pipe = raw_sock_to_pipe,
|
.rcv_pipe = raw_sock_to_pipe,
|
||||||
.snd_pipe = raw_sock_from_pipe,
|
.snd_pipe = raw_sock_from_pipe,
|
||||||
#endif
|
#endif
|
||||||
|
.get_capability = raw_sock_get_capability,
|
||||||
.shutr = NULL,
|
.shutr = NULL,
|
||||||
.shutw = NULL,
|
.shutw = NULL,
|
||||||
.close = raw_sock_close,
|
.close = raw_sock_close,
|
||||||
|
@ -6981,6 +6981,18 @@ yield:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int ssl_sock_get_capability(struct connection *conn, void *xprt_ctx, enum xprt_capabilities cap, void *arg)
|
||||||
|
{
|
||||||
|
int *ret;
|
||||||
|
|
||||||
|
switch (cap) {
|
||||||
|
case XPRT_CAN_SPLICE:
|
||||||
|
ret = arg;
|
||||||
|
*ret = XPRT_CONN_CAN_NOT_SPLICE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* register cli keywords */
|
/* register cli keywords */
|
||||||
static struct cli_kw_list cli_kws = {{ },{
|
static struct cli_kw_list cli_kws = {{ },{
|
||||||
@ -7011,6 +7023,7 @@ struct xprt_ops ssl_sock = {
|
|||||||
.close = ssl_sock_close,
|
.close = ssl_sock_close,
|
||||||
.init = ssl_sock_init,
|
.init = ssl_sock_init,
|
||||||
.start = ssl_sock_start,
|
.start = ssl_sock_start,
|
||||||
|
.get_capability = ssl_sock_get_capability,
|
||||||
.prepare_bind_conf = ssl_sock_prepare_bind_conf,
|
.prepare_bind_conf = ssl_sock_prepare_bind_conf,
|
||||||
.destroy_bind_conf = ssl_sock_destroy_bind_conf,
|
.destroy_bind_conf = ssl_sock_destroy_bind_conf,
|
||||||
.prepare_srv = ssl_sock_prepare_srv_ctx,
|
.prepare_srv = ssl_sock_prepare_srv_ctx,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user