From owner-svn-src-all@FreeBSD.ORG Mon Feb 2 04:59:02 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0CA221065694; Mon, 2 Feb 2009 04:59:02 +0000 (UTC) (envelope-from keramida@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 426368FC27; Mon, 2 Feb 2009 04:59:01 +0000 (UTC) (envelope-from keramida@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n124x06i081632; Mon, 2 Feb 2009 04:59:00 GMT (envelope-from keramida@svn.freebsd.org) Received: (from keramida@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n124x0v2081631; Mon, 2 Feb 2009 04:59:00 GMT (envelope-from keramida@svn.freebsd.org) Message-Id: <200902020459.n124x0v2081631@svn.freebsd.org> From: Giorgos Keramidas Date: Mon, 2 Feb 2009 04:59:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188000 - stable/6/share/man/man4 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Feb 2009 04:59:05 -0000 Author: keramida (doc committer) Date: Mon Feb 2 04:59:00 2009 New Revision: 188000 URL: http://svn.freebsd.org/changeset/base/188000 Log: MFC 187935 from /head Sometimes, depending on the bpf filter rules used in $PATTERN, the example script of the manpage feeds awk(1) with values larger than UINT32_MAX. Then awk prints a negative value, and this messes up $BPFPROG. Trying to load the resulting bpf byte codes with ngctl then fails. For example, the output for PATTERN="udp and dst net 255.255.0.0/16" should be (all in one line): bpf_prog_len=10 bpf_prog=[ { code=40 jt=0 jf=0 k=12 } { code=21 jt=7 jf=0 k=34525 } { code=21 jt=0 jf=6 k=2048 } { code=48 jt=0 jf=0 k=23 } { code=21 jt=0 jf=4 k=17 } { code=32 jt=0 jf=0 k=30 } { code=84 jt=0 jf=0 k=4294901760 } { code=21 jt=0 jf=1 k=4294901760 } { code=6 jt=0 jf=0 k=8192 } { code=6 jt=0 jf=0 k=0 } ] The two k=4294901760 values are displayed as k=-2147483648 by awk. Replace the awk script of the manpage example with a slower but safer version, that doesn't really attempt to convert the byte code printed by tcpdump from string to number and back. PR: docs/123255 Submitted by: Eugenio Maffione, eugenio.maffione at telecomitalia.it Modified: stable/6/share/man/man4/ (props changed) stable/6/share/man/man4/ng_bpf.4 stable/6/share/man/man4/xl.4 (props changed) Modified: stable/6/share/man/man4/ng_bpf.4 ============================================================================== --- stable/6/share/man/man4/ng_bpf.4 Mon Feb 2 04:57:36 2009 (r187999) +++ stable/6/share/man/man4/ng_bpf.4 Mon Feb 2 04:59:00 2009 (r188000) @@ -156,21 +156,14 @@ INHOOK="hook1" MATCHHOOK="hook2" NOTMATCHHOOK="hook3" -cat > /tmp/bpf.awk << xxENDxx -{ - if (!init) { - printf "bpf_prog_len=%d bpf_prog=[", \\$1; - init=1; - } else { - printf " { code=%d jt=%d jf=%d k=%d }", \\$1, \\$2, \\$3, \\$4; - } -} -END { - print " ]" -} -xxENDxx - -BPFPROG=`tcpdump -s 8192 -ddd ${PATTERN} | awk -f /tmp/bpf.awk` +BPFPROG=$( tcpdump -s 8192 -ddd ${PATTERN} | \\ + ( read len ; \\ + echo -n "bpf_prog_len=$len" ; \\ + echo -n "bpf_prog=[" ; \\ + while read code jt jf k ; do \\ + echo -n " { code=$code jt=$jt jf=$jf k=$k }" ; \\ + done ; \\ + echo " ]" ) ) ngctl msg ${NODEPATH} setprogram { thisHook=\\"${INHOOK}\\" \\ ifMatch=\\"${MATCHHOOK}\\" \\