svn commit: r337961 - head/usr.sbin/ppp
Nick Hibma
n_hibma at FreeBSD.org
Fri Aug 17 10:18:47 UTC 2018
Author: n_hibma
Date: Fri Aug 17 10:18:45 2018
New Revision: 337961
URL: https://svnweb.freebsd.org/changeset/base/337961
Log:
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.
Modified:
head/usr.sbin/ppp/command.c
head/usr.sbin/ppp/ip.c
head/usr.sbin/ppp/ncp.c
head/usr.sbin/ppp/ncp.h
head/usr.sbin/ppp/ppp.8
Modified: head/usr.sbin/ppp/command.c
==============================================================================
--- head/usr.sbin/ppp/command.c Fri Aug 17 07:27:15 2018 (r337960)
+++ head/usr.sbin/ppp/command.c Fri Aug 17 10:18:45 2018 (r337961)
@@ -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,
Modified: head/usr.sbin/ppp/ip.c
==============================================================================
--- head/usr.sbin/ppp/ip.c Fri Aug 17 07:27:15 2018 (r337960)
+++ head/usr.sbin/ppp/ip.c Fri Aug 17 10:18:45 2018 (r337961)
@@ -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;
Modified: head/usr.sbin/ppp/ncp.c
==============================================================================
--- head/usr.sbin/ppp/ncp.c Fri Aug 17 07:27:15 2018 (r337960)
+++ head/usr.sbin/ppp/ncp.c Fri Aug 17 10:18:45 2018 (r337961)
@@ -441,6 +441,21 @@ ncp_ClearUrgentPorts(struct port_range *range)
}
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)
{
struct ncp *ncp = &arg->bundle->ncp;
Modified: head/usr.sbin/ppp/ncp.h
==============================================================================
--- head/usr.sbin/ppp/ncp.h Fri Aug 17 07:27:15 2018 (r337960)
+++ head/usr.sbin/ppp/ncp.h Fri Aug 17 10:18:45 2018 (r337961)
@@ -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 *);
Modified: head/usr.sbin/ppp/ppp.8
==============================================================================
--- head/usr.sbin/ppp/ppp.8 Fri Aug 17 07:27:15 2018 (r337960)
+++ head/usr.sbin/ppp/ppp.8 Fri Aug 17 10:18:45 2018 (r337961)
@@ -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
More information about the svn-src-head
mailing list