summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/ip.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-09-04 00:00:21 +0000
committerbrian <brian@FreeBSD.org>1999-09-04 00:00:21 +0000
commitdcb79a71e6383c101218c59ed4feb6708a40b81a (patch)
tree8c060c30bd6bd3880f7c8ac84b8114e6b91f1603 /usr.sbin/ppp/ip.c
parenta14fe466b1bc7f6e0a024da706d5f849e07a3b40 (diff)
downloadFreeBSD-src-dcb79a71e6383c101218c59ed4feb6708a40b81a.zip
FreeBSD-src-dcb79a71e6383c101218c59ed4feb6708a40b81a.tar.gz
o Split the two IPCP queues into three - one for FSM data
(LCP/CCP/IPCP), one for urgent IP traffic and one for everything else. o Add the ``set urgent'' command for adjusting the list of urgent port numbers. The default urgent ports are 21, 22, 23, 513, 514, 543 and 544 (Ports 80 and 81 have been removed from the default priority list). o Increase the buffered packet threshold from 20 to 30. o Report the number of packets in the IP output queue and the list of urgent ports under ``show ipcp''.
Diffstat (limited to 'usr.sbin/ppp/ip.c')
-rw-r--r--usr.sbin/ppp/ip.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c
index 6606821..20440ec 100644
--- a/usr.sbin/ppp/ip.c
+++ b/usr.sbin/ppp/ip.c
@@ -68,13 +68,6 @@
#include "tun.h"
#include "ip.h"
-static const u_short interactive_ports[32] = {
- 544, 513, 514, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 80, 81, 0, 0, 0, 21, 22, 23, 0, 0, 0, 0, 0, 0, 0, 543,
-};
-
-#define INTERACTIVE(p) (interactive_ports[(p) & 0x1F] == (p))
-
static const char *TcpFlags[] = { "FIN", "SYN", "RST", "PSH", "ACK", "URG" };
static __inline int
@@ -319,7 +312,7 @@ PacketCheck(struct bundle *bundle, char *cp, int nb, struct filter *filter)
struct icmp *icmph;
char *ptop;
int mask, len, n;
- int pri = PRI_NORMAL;
+ int pri = 0;
int logit, loglen;
char logbuf[200];
@@ -394,11 +387,12 @@ PacketCheck(struct bundle *bundle, char *cp, int nb, struct filter *filter)
case IPPROTO_TCP:
th = (struct tcphdr *) ptop;
if (pip->ip_tos == IPTOS_LOWDELAY)
- pri = PRI_FAST;
- else if ((ntohs(pip->ip_off) & IP_OFFMASK) == 0) {
- if (INTERACTIVE(ntohs(th->th_sport)) || INTERACTIVE(ntohs(th->th_dport)))
- pri = PRI_FAST;
- }
+ pri++;
+ else if ((ntohs(pip->ip_off) & IP_OFFMASK) == 0 &&
+ ipcp_IsUrgentPort(&bundle->ncp.ipcp, ntohs(th->th_sport),
+ ntohs(th->th_dport)))
+ pri++;
+
if (logit && loglen < sizeof logbuf) {
len = ntohs(pip->ip_len) - (pip->ip_hl << 2) - (th->th_off << 2);
snprintf(logbuf + loglen, sizeof logbuf - loglen,
@@ -505,7 +499,7 @@ ip_Enqueue(struct ipcp *ipcp, int pri, char *ptr, int count)
{
struct mbuf *bp;
- if (pri < 0 || pri > sizeof ipcp->Queue / sizeof ipcp->Queue[0])
+ if (pri < 0 || pri >= IPCP_QUEUES(ipcp))
log_Printf(LogERROR, "Can't store in ip queue %d\n", pri);
else {
/*
@@ -518,7 +512,7 @@ ip_Enqueue(struct ipcp *ipcp, int pri, char *ptr, int count)
bp->offset += 4;
bp->cnt -= 6;
memcpy(MBUF_CTOP(bp), ptr, count);
- mbuf_Enqueue(&ipcp->Queue[pri], bp);
+ mbuf_Enqueue(ipcp->Queue + pri, bp);
}
}
@@ -527,7 +521,7 @@ ip_DeleteQueue(struct ipcp *ipcp)
{
struct mqueue *queue;
- for (queue = ipcp->Queue; queue < ipcp->Queue + PRI_MAX; queue++)
+ for (queue = ipcp->Queue; queue < ipcp->Queue + IPCP_QUEUES(ipcp); queue++)
while (queue->top)
mbuf_Free(mbuf_Dequeue(queue));
}
@@ -538,7 +532,7 @@ ip_QueueLen(struct ipcp *ipcp)
struct mqueue *queue;
int result = 0;
- for (queue = ipcp->Queue; queue < ipcp->Queue + PRI_MAX; queue++)
+ for (queue = ipcp->Queue; queue < ipcp->Queue + IPCP_QUEUES(ipcp); queue++)
result += queue->qlen;
return result;
@@ -556,17 +550,19 @@ ip_PushPacket(struct link *l, struct bundle *bundle)
if (ipcp->fsm.state != ST_OPENED)
return 0;
- for (queue = &ipcp->Queue[PRI_FAST]; queue >= ipcp->Queue; queue--)
+ queue = ipcp->Queue + IPCP_QUEUES(ipcp) - 1;
+ do {
if (queue->top) {
bp = mbuf_Contiguous(mbuf_Dequeue(queue));
cnt = mbuf_Length(bp);
pip = (struct ip *)MBUF_CTOP(bp);
if (!FilterCheck(pip, &bundle->filter.alive))
bundle_StartIdleTimer(bundle);
- link_PushPacket(l, bp, bundle, PRI_NORMAL, PROTO_IP);
+ link_PushPacket(l, bp, bundle, 0, PROTO_IP);
ipcp_AddOutOctets(ipcp, cnt);
return 1;
}
+ } while (queue-- != ipcp->Queue);
return 0;
}
OpenPOWER on IntegriCloud