mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 15:47:01 +02:00
MINOR: tcp: add support for defer-accept on FreeBSD.
FreeBSD has a kernel feature (accf) and a sockopt flag similar to the Linux's TCP_DEFER_ACCEPT to filter incoming data upon ACK. The main difference is the filter needs to be placed when the socket actually listens.
This commit is contained in:
parent
9a4bbfe151
commit
1eb595b8b4
@ -61,7 +61,7 @@ static int bind_parse_transparent(char **args, int cur_arg, struct proxy *px, st
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TCP_DEFER_ACCEPT
|
||||
#if defined(TCP_DEFER_ACCEPT) || defined(SO_ACCEPTFILTER)
|
||||
/* parse the "defer-accept" bind keyword */
|
||||
static int bind_parse_defer_accept(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
|
||||
{
|
||||
@ -243,7 +243,7 @@ static int srv_parse_tcp_ut(char **args, int *cur_arg, struct proxy *px, struct
|
||||
* not enabled.
|
||||
*/
|
||||
static struct bind_kw_list bind_kws = { "TCP", { }, {
|
||||
#ifdef TCP_DEFER_ACCEPT
|
||||
#if defined(TCP_DEFER_ACCEPT) || defined(SO_ACCEPTFILTER)
|
||||
{ "defer-accept", bind_parse_defer_accept, 0 }, /* wait for some data for 1 second max before doing accept */
|
||||
#endif
|
||||
#ifdef SO_BINDTODEVICE
|
||||
|
@ -708,6 +708,18 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
goto tcp_close_return;
|
||||
}
|
||||
|
||||
#if !defined(TCP_DEFER_ACCEPT) && defined(SO_ACCEPTFILTER)
|
||||
/* the socket needs to listen first */
|
||||
if (listener->options & LI_O_DEF_ACCEPT) {
|
||||
struct accept_filter_arg accept;
|
||||
memset(&accept, 0, sizeof(accept));
|
||||
strcpy(accept.af_name, "dataready");
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_ACCEPTFILTER, &accept, sizeof(accept)) == -1) {
|
||||
msg = "cannot enable ACCEPT_FILTER";
|
||||
err |= ERR_WARN;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(TCP_QUICKACK)
|
||||
if (listener->options & LI_O_NOQUICKACK)
|
||||
setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &zero, sizeof(zero));
|
||||
|
Loading…
Reference in New Issue
Block a user