summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_fw2.c
diff options
context:
space:
mode:
authorkbyanc <kbyanc@FreeBSD.org>2003-06-02 23:54:09 +0000
committerkbyanc <kbyanc@FreeBSD.org>2003-06-02 23:54:09 +0000
commit04929f21c1d192d3c77f8861204aebe408318d22 (patch)
tree63cbd9a60e1fb82e82f3d96e98cf1a2bf2fa5319 /sys/netinet/ip_fw2.c
parentb3ca652b31af4c3c53cbeb1ad4131a1b91fe2f92 (diff)
downloadFreeBSD-src-04929f21c1d192d3c77f8861204aebe408318d22.zip
FreeBSD-src-04929f21c1d192d3c77f8861204aebe408318d22.tar.gz
Account for packets processed at layer-2 (i.e. net.link.ether.ipfw=1).
MFC after: 2 weeks
Diffstat (limited to 'sys/netinet/ip_fw2.c')
-rw-r--r--sys/netinet/ip_fw2.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/netinet/ip_fw2.c b/sys/netinet/ip_fw2.c
index fbf3293..1b7b143 100644
--- a/sys/netinet/ip_fw2.c
+++ b/sys/netinet/ip_fw2.c
@@ -1340,6 +1340,7 @@ ipfw_chk(struct ip_fw_args *args)
u_int16_t src_port = 0, dst_port = 0; /* NOTE: host format */
struct in_addr src_ip, dst_ip; /* NOTE: network format */
u_int16_t ip_len=0;
+ int pktlen;
int dyn_dir = MATCH_UNKNOWN;
ipfw_dyn_rule *q = NULL;
@@ -1351,6 +1352,7 @@ ipfw_chk(struct ip_fw_args *args)
* MATCH_FORWARD or MATCH_REVERSE otherwise (q != NULL)
*/
+ pktlen = m->m_pkthdr.len;
if (args->eh == NULL || /* layer 3 packet */
( m->m_pkthdr.len >= sizeof(struct ip) &&
ntohs(args->eh->ether_type) == ETHERTYPE_IP))
@@ -1374,6 +1376,7 @@ ipfw_chk(struct ip_fw_args *args)
offset = ip->ip_off & IP_OFFMASK;
ip_len = ip->ip_len;
}
+ pktlen = ip_len < pktlen ? ip_len : pktlen;
#define PULLUP_TO(len) \
do { \
@@ -1874,7 +1877,7 @@ check_body:
* the parent rule.
*/
q->pcnt++;
- q->bcnt += ip_len;
+ q->bcnt += pktlen;
f = q->rule;
cmd = ACTION_PTR(f);
l = f->cmd_len - f->act_ofs;
@@ -1913,7 +1916,7 @@ check_body:
case O_COUNT:
case O_SKIPTO:
f->pcnt++; /* update stats */
- f->bcnt += ip_len;
+ f->bcnt += pktlen;
f->timestamp = time_second;
if (cmd->opcode == O_COUNT)
goto next_rule;
@@ -1978,7 +1981,7 @@ next_rule:; /* try next rule */
done:
/* Update statistics */
f->pcnt++;
- f->bcnt += ip_len;
+ f->bcnt += pktlen;
f->timestamp = time_second;
return retval;
OpenPOWER on IntegriCloud