From owner-freebsd-bugs@FreeBSD.ORG Mon Mar 2 22:21:34 2015 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 39FAC376 for ; Mon, 2 Mar 2015 22:21:34 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 06A7CD6 for ; Mon, 2 Mar 2015 22:21:34 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.9/8.14.9) with ESMTP id t22MLXSm011406 for ; Mon, 2 Mar 2015 22:21:33 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 198211] tcpreplay not working for lo0 Date: Mon, 02 Mar 2015 22:21:34 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 10.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: holger@freyther.de X-Bugzilla-Status: New X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter flagtypes.name attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Mar 2015 22:21:34 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198211 Bug ID: 198211 Summary: tcpreplay not working for lo0 Product: Base System Version: 10.1-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: holger@freyther.de Attachment #153698 maintainer-approval? Flags: Created attachment 153698 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=153698&action=edit Check for pseudo_AF_HDRCMPLT to allow tcpreplay on loopback Capturing a pcap file for loopback/null encapsulation and then replaying with tcpreplay doesn't work. Reproduce: * Capture a trace on lo0 e.g. tcpdump -i lo0 -s 0 -n -w loopback.pcap * echo "bla" | nc localhost 1234 * Stop the capture. It has two packages.. the UDP message and ICMP * Install tcpreplay with pkg install tcpreplay * Monitor loopback for traffic tcpdump -i lo0 -s 0 -n -X * Replay with tcpreplay --intf1=lo0 loopback.pcap Expectation: * Replayed packets arriving on the loopback device Outcome: * $ dmesg looutput: af=31 unexpected looutput: af=31 unexpected Reason: tcpreplay is using libpcap for replay and is setting the complete header field open("/dev/bpf0",O_RDWR,00) = 3 (0x3) ioctl(3,BIOCVERSION,0xbfbfe7c8) = 0 (0x0) ioctl(3,BIOCSETIF,0xbfbfe7d0) = 0 (0x0) ioctl(3,BIOCGDLT,0xbfbfe7c4) = 0 (0x0) ioctl(3,BIOCSHDRCMPLT,0xbfbfe7c0) = 0 (0x0) ioctl(3,BIOCGDLT,0xbfbfe808) = 0 (0x0) This means that in bpf.c:bpfwrite if (d->bd_hdrcmplt) dst.sa_family = pseudo_AF_HDRCMPLT; will be executed but in if_loop.c:looutput /* BPF writes need to be handled specially. */ if (dst->sa_family == AF_UNSPEC) bcopy(dst->sa_data, &af, sizeof(af)); else af = dst->sa_family; will be checked. This means that the local variable "af" will contain pseudo_AF_HDRCMPLT which is not handled in the switch. Proposal. Change the check from AF_UNSPEC to pseudo_AF_HDRCMPLT or at least check for pseudo_AF_HDRCMPLT as well. -- You are receiving this mail because: You are the assignee for the bug.