From 72662a75668aceafc0eb70155c92fa74f829302a Mon Sep 17 00:00:00 2001 From: Luigi Rizzo Date: Mon, 15 Mar 2010 15:43:35 +0000 Subject: [PATCH] Implement "lookup dscp N" which does a lookup of the DSCP (top 6 bits of ip->ip_tos) in a table. This can be useful to direct traffic to different pipes/queues according to the DSCP of the packet, as follows: ipfw add 100 queue tablearg lookup dscp 3 // table 3 maps dscp->queue This change is a no-op (but harmless) until the two-line kernel side is committed, which will happen shortly. --- sbin/ipfw/ipfw2.c | 5 +++-- sbin/ipfw/ipfw2.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c index 27c6b0a80731..7940e544cf35 100644 --- a/sbin/ipfw/ipfw2.c +++ b/sbin/ipfw/ipfw2.c @@ -231,7 +231,7 @@ static struct _s_x rule_action_params[] = { */ static int lookup_key[] = { TOK_DSTIP, TOK_SRCIP, TOK_DSTPORT, TOK_SRCPORT, - TOK_UID, TOK_JAIL, -1 }; + TOK_UID, TOK_JAIL, TOK_DSCP, -1 }; static struct _s_x rule_options[] = { { "tagged", TOK_TAGGED }, @@ -258,6 +258,7 @@ static struct _s_x rule_options[] = { { "iplen", TOK_IPLEN }, { "ipid", TOK_IPID }, { "ipprecedence", TOK_IPPRECEDENCE }, + { "dscp", TOK_DSCP }, { "iptos", TOK_IPTOS }, { "ipttl", TOK_IPTTL }, { "ipversion", TOK_IPVER }, @@ -3519,7 +3520,7 @@ ipfw_add(char *av[]) char *p; int j; - if (av[0] && av[1]) + if (!av[0] || !av[1]) errx(EX_USAGE, "format: lookup argument tablenum"); cmd->opcode = O_IP_DST_LOOKUP; cmd->len |= F_INSN_SIZE(ipfw_insn) + 2; diff --git a/sbin/ipfw/ipfw2.h b/sbin/ipfw/ipfw2.h index 1dbb42b767b3..d1729841e97b 100644 --- a/sbin/ipfw/ipfw2.h +++ b/sbin/ipfw/ipfw2.h @@ -125,6 +125,7 @@ enum tokens { TOK_IPLEN, TOK_IPID, TOK_IPPRECEDENCE, + TOK_DSCP, TOK_IPTOS, TOK_IPTTL, TOK_IPVER,