From nobody@FreeBSD.org  Fri May 14 17:48:15 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DF6EF1065673
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 14 May 2010 17:48:15 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id CECDC8FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 14 May 2010 17:48:15 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o4EHmFqg050760
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 14 May 2010 17:48:15 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o4EHmFGw050757;
	Fri, 14 May 2010 17:48:15 GMT
	(envelope-from nobody)
Message-Id: <201005141748.o4EHmFGw050757@www.freebsd.org>
Date: Fri, 14 May 2010 17:48:15 GMT
From: Boris <spawk@acm.poly.edu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] libpcap 1.0.0 doesn't have error message for nonexistent interface
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         146592
>Category:       bin
>Synopsis:       [libpcap] [patch] libpcap 1.0.0 doesn't have error message for nonexistent interface
>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:   Fri May 14 17:50:03 UTC 2010
>Closed-Date:    
>Last-Modified:  Mon Aug 09 18:21:14 UTC 2010
>Originator:     Boris
>Release:        8.0-RELEASE-p2
>Organization:
Kochergin
>Environment:
FreeBSD peer 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #2: Mon Feb 22 23:18:53 EST 2010     root@peer:/usr/obj/usr/src/sys/PEER  i386
>Description:
libpcap 1.0.0, found in FreeBSD 8.0 and CURRENT, does not notify a user if the device they tried to open (via BPF) does not exist. With older versions, one gets:

# tcpdump -i something
tcpdump: BIOCSETIF: no: Device not configured

With 1.0.0, one gets:

# tcpdump -i something
tcpdump: 

The current version of libpcap, 1.1.1, fixes the problem, but I don't know if there are plans to incorporate it into the base system anytime soon. The attached patch fixes the problem in libpcap 1.0.0.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- /usr/src/contrib/libpcap/pcap-bpf.c.orig	2010-05-14 13:20:41.000000000 -0400
+++ /usr/src/contrib/libpcap/pcap-bpf.c	2010-05-14 13:35:31.000000000 -0400
@@ -1601,6 +1601,14 @@
 
 				if (errno != ENOBUFS) {
 					status = check_setif_failure(p, errno);
+					if (errno == ENXIO) {
+						snprintf(p->errbuf,
+						    PCAP_ERRBUF_SIZE,
+						    "BIOCSETIF: %s: %s",
+						    p->opt.source,
+						    pcap_strerror(errno));
+						status = PCAP_ERROR_NO_SUCH_DEVICE;
+					}
 					goto bad;
 				}
 			}


>Release-Note:
>Audit-Trail:
>Unformatted:
