From owner-freebsd-bugs@FreeBSD.ORG Wed Apr 25 22:20:19 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 36DB516A404 for ; Wed, 25 Apr 2007 22:20:19 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 17B3413C45B for ; Wed, 25 Apr 2007 22:20:19 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l3PMKI1t063968 for ; Wed, 25 Apr 2007 22:20:18 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l3PMKIBO063966; Wed, 25 Apr 2007 22:20:18 GMT (envelope-from gnats) Resent-Date: Wed, 25 Apr 2007 22:20:18 GMT Resent-Message-Id: <200704252220.l3PMKIBO063966@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Joćo Rocha Braga Filho Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7665D16A402 for ; Wed, 25 Apr 2007 22:15:49 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.freebsd.org (Postfix) with ESMTP id 59C6113C484 for ; Wed, 25 Apr 2007 22:15:49 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l3PMFnsT096002 for ; Wed, 25 Apr 2007 22:15:49 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id l3PMAlF6095213; Wed, 25 Apr 2007 22:10:47 GMT (envelope-from nobody) Message-Id: <200704252210.l3PMAlF6095213@www.freebsd.org> Date: Wed, 25 Apr 2007 22:10:47 GMT From: Joćo Rocha Braga Filho To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: kern/112148: Sometimes useless code is executed in ip_dummynet, function find_queue X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2007 22:20:19 -0000 >Number: 112148 >Category: kern >Synopsis: Sometimes useless code is executed in ip_dummynet, function find_queue >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Apr 25 22:20:18 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Joćo Rocha Braga Filho >Release: >Organization: Paratyinfo >Environment: FreeBSD staff.paratyinfo.com.br 6.2-STABLE FreeBSD 6.2-STABLE #2: Sat Apr 14 10:16:36 BRT 2007 root@goffredo.paratyinfo.com.br:/usr/obj/usr/src/sys/GOFFREDO amd64 >Description: In function find_queue there is some code to IPv6, but anyone can compile FreeBSD without IPv6, but this code will be there, even compiled without IPv6 support in kernel. The package will be tested if it is IPv6, even if the compiled kernel don't suport IPv6. I know, the time lost is few, but I make this PR, and send a code to fix. Thanks, Joćo Rocha. >How-To-Repeat: >Fix: /* If kernel supports IPv6 */ #ifdef INET6 /* Here is the function with IPv6 support. */ #else /* New function version, without IPv6 suport. */ static struct dn_flow_queue * find_queue(struct dn_flow_set *fs, struct ipfw_flow_id *id) { int i = 0 ; /* we need i and q for new allocations */ struct dn_flow_queue *q, *prev; if ( !(fs->flags_fs & DN_HAVE_FLOW_MASK) ) q = fs->rq[0] ; else { /* first, do the masking, then hash */ id->dst_port &= fs->flow_mask.dst_port ; id->src_port &= fs->flow_mask.src_port ; id->proto &= fs->flow_mask.proto ; id->flags = 0 ; /* we don't care about this one */ id->dst_ip &= fs->flow_mask.dst_ip ; id->src_ip &= fs->flow_mask.src_ip ; i = ( ( (id->dst_ip) & 0xffff ) ^ ( (id->dst_ip >> 15) & 0xffff ) ^ ( (id->src_ip << 1) & 0xffff ) ^ ( (id->src_ip >> 16 ) & 0xffff ) ^ (id->dst_port << 1) ^ (id->src_port) ^ (id->proto ) ) % fs->rq_size ; /* finally, scan the current list for a match */ searches++ ; for (prev=NULL, q = fs->rq[i] ; q ; ) { search_steps++; if ( id->dst_ip == q->id.dst_ip && id->src_ip == q->id.src_ip && id->dst_port == q->id.dst_port && id->src_port == q->id.src_port && id->proto == q->id.proto && id->flags == q->id.flags) break ; /* found */ /* No match. Check if we can expire the entry */ if (pipe_expire && q->head == NULL && q->S == q->F+1 ) { /* entry is idle and not in any heap, expire it */ struct dn_flow_queue *old_q = q ; if (prev != NULL) prev->next = q = q->next ; else fs->rq[i] = q = q->next ; fs->rq_elements-- ; free(old_q, M_DUMMYNET); continue ; } prev = q ; q = q->next ; } if (q && prev != NULL) { /* found and not in front */ prev->next = q->next ; q->next = fs->rq[i] ; fs->rq[i] = q ; } } if (q == NULL) { /* no match, need to allocate a new entry */ q = create_queue(fs, i); if (q != NULL) q->id = *id ; } return q ; } #endif >Release-Note: >Audit-Trail: >Unformatted: