From owner-svn-src-head@freebsd.org Fri Aug 17 10:18:47 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 05B241055364; Fri, 17 Aug 2018 10:18:47 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A64EE75FD8; Fri, 17 Aug 2018 10:18:46 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7D2EA26FEC; Fri, 17 Aug 2018 10:18:46 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7HAIkX2030059; Fri, 17 Aug 2018 10:18:46 GMT (envelope-from n_hibma@FreeBSD.org) Received: (from n_hibma@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7HAIjMk030054; Fri, 17 Aug 2018 10:18:45 GMT (envelope-from n_hibma@FreeBSD.org) Message-Id: <201808171018.w7HAIjMk030054@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: n_hibma set sender to n_hibma@FreeBSD.org using -f From: Nick Hibma Date: Fri, 17 Aug 2018 10:18:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337961 - head/usr.sbin/ppp X-SVN-Group: head X-SVN-Commit-Author: n_hibma X-SVN-Commit-Paths: head/usr.sbin/ppp X-SVN-Commit-Revision: 337961 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2018 10:18:47 -0000 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