[Bug 256587] tcpreplay not working for if_tun (tun0)

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 14 Jun 2021 02:41:04 +0000

            Bug ID: 256587
           Summary: tcpreplay not working for if_tun (tun0)
           Product: Base System
           Version: 13.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs_at_FreeBSD.org
          Reporter: micolous+fbsd_at_gmail.com

Created attachment 225789
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=225789&action=edit
Packet captures from reproducing this issue (cap1.pcap, cap3.pcap,

This is a repeat of Bug #198211.  It appears that one cannot send packets to an
if_tun interface using /dev/bpf.

This was previously considered a possibility in
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198211#c1 and
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198211#c3, but it does not
appear that any fix similar to
was applied to if_tun.c (now if_tuntap.c):

I think that applying the same fix to if_tuntap.c will fix this issue.

## Steps to reproduce:

1. Install tcpreplay with: pkg install tcpreplay

2. Start up a tunnel on tun0 where the remote side responds to ICMP echo
requests. My tunnel was configured as:

   tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1500
        inet --> netmask 0xffffff00
        groups: tun
        Opened by PID 1144

3. Capture a trace on tun0: tcpdump -i tun0 -s 0 -n -w loopback.pcap

4. Generate some traffic on tun0: eg: ping -c3

5. Stop the capture, it should have some ICMP packets inside

6. Monitor traffic on tun0: tcpdump -i tun0 -s 0 -n -X

7. Replay the ICMP traffic with: tcpreplay --intf1=tun0 loopback.pcap

## Expected behaviour:

* All ICMP packets are correctly replayed through tun0

## Actual behaviour:

* One packet is sent with af=31 (pseudo_AF_HDRCMPLT), which is invalid (see
attached cap1.pcap)

* tcpreplay reports several warnings:

  Warning: Unable to process unsupported DLT type: BSD loopback (0x0)
  Warning: Unable to send packet: Error with bpf send() [1]: Address family not
supported by protocol family (errno = 47)

## Attachments (in tun-tcpreplay.zip)

* cap1.pcap: packet capture at reproduction step 5, using tun0 – a single
packet is sent out the tun0 interface with af=31

* cap3.pcap: packet capture reproduction at step 5, but using lo0 – this looks
correct, but still issues the "unsupported DLT type" warning

* loopback.pcap: packet capture at reproduction step 2 using tun0 – three pairs
of ICMP Echo requests and replies ->

## Versions:

* FreeBSD 13.0 RELEASE on amd64
* tcpdump 4.9.3
* libpcap 1.9.1
* tcpreplay 4.3.3

You are receiving this mail because:
You are the assignee for the bug.
Received on Mon Jun 14 2021 - 02:41:04 UTC

Original text of this message