Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 02 Mar 2015 22:21:34 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 198211] tcpreplay not working for lo0
Message-ID:  <bug-198211-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-198211-8>