Add the possibility to mark packets urgent based on their length.

This allows preferring small (e.g. ACK) packets, in upload heavy
environments.

It was already possible to mark packets urgent based on destination
port. This option piggy backs on that feature.
This commit is contained in:
Nick Hibma 2018-08-17 10:18:45 +00:00
parent 2502c66bbd
commit f80b39d182
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=337961
5 changed files with 38 additions and 4 deletions

View File

@ -139,7 +139,7 @@
#define VAR_CD 30
#define VAR_PARITY 31
#define VAR_CRTSCTS 32
#define VAR_URGENTPORTS 33
#define VAR_URGENT 33
#define VAR_LOGOUT 34
#define VAR_IFQUEUE 35
#define VAR_MPPE 36
@ -2267,7 +2267,7 @@ SetVariable(struct cmdargs const *arg)
}
break;
case VAR_URGENTPORTS:
case VAR_URGENT:
if (arg->argn == arg->argc) {
ncp_SetUrgentTOS(&arg->bundle->ncp);
ncp_ClearUrgentTcpPorts(&arg->bundle->ncp);
@ -2291,6 +2291,11 @@ SetVariable(struct cmdargs const *arg)
ncp_ClearUrgentTcpPorts(&arg->bundle->ncp);
ncp_ClearUrgentUdpPorts(&arg->bundle->ncp);
ncp_ClearUrgentTOS(&arg->bundle->ncp);
} else if (!strcasecmp(arg->argv[arg->argn], "length")) {
if (arg->argn == arg->argc - 1)
ncp_SetUrgentTcpLen(&arg->bundle->ncp, 0);
else
ncp_SetUrgentTcpLen(&arg->bundle->ncp, atoi(arg->argv[arg->argn + 1]));
} else {
ncp_SetUrgentTOS(&arg->bundle->ncp);
first = arg->argn;
@ -2469,8 +2474,8 @@ static struct cmdtab const SetCommands[] = {
"STOPPED timeouts", "set stopped [LCPseconds [CCPseconds]]", NULL},
{"timeout", NULL, SetVariable, LOCAL_AUTH, "Idle timeout",
"set timeout idletime", (const void *)VAR_IDLETIMEOUT},
{"urgent", NULL, SetVariable, LOCAL_AUTH, "urgent ports",
"set urgent [tcp|udp] [+|-]port...", (const void *)VAR_URGENTPORTS},
{"urgent", NULL, SetVariable, LOCAL_AUTH, "urgent traffic",
"set urgent [[tcp|udp] [+|-]port...]|[length len]", (const void *)VAR_URGENT},
{"vj", NULL, ipcp_vjset, LOCAL_AUTH,
"vj values", "set vj slots|slotcomp [value]", NULL},
{"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,

View File

@ -820,6 +820,8 @@ PacketCheck(struct bundle *bundle, u_int32_t family,
if (!frag && ncp_IsUrgentTcpPort(&bundle->ncp, ntohs(th->th_sport),
ntohs(th->th_dport)))
pri++;
else if (!frag && ncp_IsUrgentTcpLen(&bundle->ncp, datalen))
pri++;
if (logit && loglen < sizeof logbuf) {
len = datalen - (th->th_off << 2);
@ -851,6 +853,8 @@ PacketCheck(struct bundle *bundle, u_int32_t family,
loglen += strlen(logbuf + loglen);
}
}
snprintf(logbuf + loglen, sizeof logbuf - loglen, " pri:%d", pri);
loglen += strlen(logbuf + loglen);
}
break;

View File

@ -440,6 +440,21 @@ ncp_ClearUrgentPorts(struct port_range *range)
range->nports = 0;
}
int
ncp_IsUrgentTcpLen(struct ncp *ncp, int len)
{
if (len < ncp->cfg.urgent.len)
return 1;
else
return 0;
}
void
ncp_SetUrgentTcpLen(struct ncp *ncp, int len)
{
ncp->cfg.urgent.len = len;
}
int
ncp_Show(struct cmdargs const *arg)
{

View File

@ -42,6 +42,7 @@ struct ncp {
struct {
struct port_range tcp, udp; /* The range of urgent ports */
unsigned tos : 1; /* Urgent IPTOS_LOWDELAY packets ? */
int len; /* The size below which traffic is prioritised */
} urgent;
} cfg;
@ -68,6 +69,8 @@ extern size_t ncp_QueueLen(struct ncp *);
extern size_t ncp_FillPhysicalQueues(struct ncp *, struct bundle *);
extern int ncp_PushPacket(struct ncp *, int *, struct link *);
extern int ncp_IsUrgentPort(struct port_range *, u_short, u_short);
extern int ncp_IsUrgentTcpLen(struct ncp *, int);
extern void ncp_SetUrgentTcpLen(struct ncp *, int);
extern void ncp_AddUrgentPort(struct port_range *, u_short);
extern void ncp_RemoveUrgentPort(struct port_range *, u_short);
extern void ncp_ClearUrgentPorts(struct port_range *);

View File

@ -5823,6 +5823,13 @@ If
is specified, all priority port lists are disabled and even
.Dv IPTOS_LOWDELAY
packets are not prioritised.
.It set urgent length Ar length
This command tells ppp to prioritize small packets up to
.Ar length
bytes.
If
.Ar length
is not specified, or 0, this feature is disabled.
.It set vj slotcomp on|off
This command tells
.Nm