std.set_ip_tos() to support IPv6

parent 948661aa
......@@ -55,15 +55,26 @@ VCL_VOID v_matchproto_(td_std_set_ip_tos)
vmod_set_ip_tos(VRT_CTX, VCL_INT tos)
{
struct suckaddr *sa;
int itos = tos;
int fam, itos = tos;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AZ(SES_Get_local_addr(ctx->req->sp, &sa));
/* Silently ignore for non-IP addresses. */
if (VSA_Compare(sa, bogo_ip) == 0)
return;
VTCP_Assert(setsockopt(ctx->req->sp->fd,
IPPROTO_IP, IP_TOS, &itos, sizeof(itos)));
fam = VSA_Get_Proto(sa);
switch (fam) {
case PF_INET:
VTCP_Assert(setsockopt(ctx->req->sp->fd,
IPPROTO_IP, IP_TOS, &itos, sizeof(itos)));
break;
case PF_INET6:
VTCP_Assert(setsockopt(ctx->req->sp->fd,
IPPROTO_IPV6, IPV6_TCLASS, &itos, sizeof(itos)));
break;
default:
INCOMPL();
}
}
static const char *
......
......@@ -538,12 +538,14 @@ Example::
$Function VOID set_ip_tos(INT tos)
Sets the IP type-of-service (TOS) field for the current session to
*tos*. Silently ignored if the listen address is a Unix domain socket.
Please note that the TOS field is not removed by the end of the
request so probably want to set it on every request should you utilize
it.
Sets the Differentiated Services Codepoint (DSCP) / IPv4 Type of
Service (TOS) / IPv6 Traffic Class (TCLASS) byte for the current
session to *tos*. Silently ignored if the listen address is a Unix
domain socket.
Please note that setting the traffic class affects all requests on the
same http1.1 / http2 TCP connection and, in particular, is not removed
at the end of the request.
Example::
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment