From owner-p4-projects@FreeBSD.ORG Sat Nov 10 15:44:03 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C678F16A481; Sat, 10 Nov 2007 15:44:03 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A8FA16A473 for ; Sat, 10 Nov 2007 15:44:03 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 7173113C4BD for ; Sat, 10 Nov 2007 15:44:03 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id lAAFi3Qh065218 for ; Sat, 10 Nov 2007 15:44:03 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id lAAFi31E065208 for perforce@freebsd.org; Sat, 10 Nov 2007 15:44:03 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sat, 10 Nov 2007 15:44:03 GMT Message-Id: <200711101544.lAAFi31E065208@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 128899 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Nov 2007 15:44:04 -0000 http://perforce.freebsd.org/chv.cgi?CH=128899 Change 128899 by rwatson@rwatson_cinnamon on 2007/11/10 15:43:12 Allow bpfnull to build on systems without zero-copy definitions, but then necessarily without zero-copy support. Affected files ... .. //depot/projects/zcopybpf/utils/bpfnull/bpfnull.c#19 edit Differences ... ==== //depot/projects/zcopybpf/utils/bpfnull/bpfnull.c#19 (text+ko) ==== @@ -75,6 +75,20 @@ static u_char *bufa, *bufb; static unsigned long packet_count; +#ifndef BPF_BUFMODE_ZBUF +/* + * bpfnull uses certain constructs that depend on zero-copy definitions being + * present in bpf.h even when running in normal buffer mode. If the system + * doesn't have these constructs, define them locally. + */ +struct bpf_zbuf { + void *bz_bufa; + void *bz_bufb; + size_t bz_buflen; +}; +#warning "BPF_BUFMODE_ZBUF not present, building without zero-copy support" +#endif + static int handle_int(int sig __unused) { @@ -189,7 +203,9 @@ (void) fprintf(stderr, "select wakeup\n"); if (n != 0 && !FD_ISSET(fd, &r_set) && vflag) printf("No timeout and fd is not ready!\n"); +#ifdef BPF_BUFMODE_ZBUF if (zflag == 0) { +#endif c = rdtsc(); n = read(fd, pbuf, bflag); d = rdtsc(); @@ -203,6 +219,7 @@ bpf_process_packets(&bz, "W"); a = rdtsc(); sum += a - b; +#ifdef BPF_BUFMODE_ZBUF } else { bzha = (struct bpf_zbuf_header *)bufa; bzhb = (struct bpf_zbuf_header *)bufb; @@ -242,6 +259,7 @@ bzhb->bzh_user_gen++; } } +#endif f = rdtsc(); ssum += f - e; } @@ -273,6 +291,7 @@ exit(0); } +#ifdef BPF_BUFMODE_ZBUF static int bpf_zbuf_init(int fd, struct bpf_zbuf *bz) { @@ -301,15 +320,18 @@ "DEBUG: bufa=%p bufb=%p\n", bufa, bufb); return (0); } +#endif static int bpf_rbuf_init(int fd) { int v, bmode; +#ifdef BPF_BUFMODE_ZBUF bmode = BPF_BUFMODE_BUFFER; if (ioctl(fd, BIOCGETBUFMODE, &bmode) < 0) err(1, "ioctl(BIOCGETBUFMODE)"); +#endif for (v = bflag; v != 0; v >>= 1) { (void) ioctl(fd, BIOCSBLEN, &v); if (ioctl(fd, BIOCSETIF, &ifr) == 0) @@ -364,9 +386,11 @@ case 'v': vflag++; break; +#ifdef BPF_BUFMODE_ZBUF case 'z': zflag++; break; +#endif default: usage(); } @@ -386,6 +410,7 @@ (void) fprintf(stderr, "DEBUG: obtained bpf fd=%d\n", in); bpf_init_dumpfile(); +#ifdef BPF_BUFMODE_ZBUF if (zflag) { if (vflag) (void) fprintf(stderr, @@ -395,11 +420,14 @@ if (ioctl(in, BIOCSETIF, &ifr) < 0) err(1, "ioctl(BIOCSETIF)"); } else { +#endif if (vflag) (void) fprintf(stderr, "DEBUG: bufmode=buffer\n"); bpf_rbuf_init(in); +#ifdef BPF_BUFMODE_ZBUF } +#endif if (Iflag) { if (vflag) (void) fprintf(stderr,