diff options
author | suz <suz@FreeBSD.org> | 2006-09-22 01:31:22 +0000 |
---|---|---|
committer | suz <suz@FreeBSD.org> | 2006-09-22 01:31:22 +0000 |
commit | c563c8af2963601b3065d39a2911d24aa8f9cde6 (patch) | |
tree | b6c5adb8310355643f311e21d8bea7a3104d19e6 /sys/net | |
parent | 3ce90f2dc4fc5e52591cce9d86a2581ea3f02ea4 (diff) | |
download | FreeBSD-src-c563c8af2963601b3065d39a2911d24aa8f9cde6.zip FreeBSD-src-c563c8af2963601b3065d39a2911d24aa8f9cde6.tar.gz |
fixed a bug that local IPv6 traffic (to an address configured on an
interface other than lo0) does not show up properly on any bpf.
Reported by: mlaier
Reviewed by: gnn, csjp
MFC after: 1 week
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_loop.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index e48a270..fbbf27d 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -259,16 +259,32 @@ if_simloop(ifp, m, af, hlen) m_tag_delete_nonpersistent(m); m->m_pkthdr.rcvif = ifp; - /* Let BPF see incoming packet */ - if (bpf_peers_present(ifp->if_bpf)) { - if (ifp->if_bpf->bif_dlt == DLT_NULL) { - u_int32_t af1 = af; /* XXX beware sizeof(af) != 4 */ - /* - * We need to prepend the address family. - */ - bpf_mtap2(ifp->if_bpf, &af1, sizeof(af1), m); - } else + /* + * Let BPF see incoming packet in the following manner: + * - Emulated packet loopback for a simplex interface + * (net/if_ethersubr.c) + * -> passes it to ifp's BPF + * - IPv4/v6 multicast packet loopback (netinet(6)/ip(6)_output.c) + * -> not passes it to any BPF + * - Normal packet loopback from myself to myself (net/if_loop.c) + * -> passes to lo0's BPF (even in case of IPv6, where ifp!=lo0) + */ + if (hlen > 0) { + if (bpf_peers_present(ifp->if_bpf)) { bpf_mtap(ifp->if_bpf, m); + } + } else { + if (bpf_peers_present(loif->if_bpf)) { + if ((m->m_flags & M_MCAST) == 0 || loif == ifp) { + /* XXX beware sizeof(af) != 4 */ + u_int32_t af1 = af; + + /* + * We need to prepend the address family. + */ + bpf_mtap2(loif->if_bpf, &af1, sizeof(af1), m); + } + } } /* Strip away media header */ |