summaryrefslogtreecommitdiffstats
path: root/sys/netpfil
diff options
context:
space:
mode:
authorkp <kp@FreeBSD.org>2015-09-01 19:04:04 +0000
committerkp <kp@FreeBSD.org>2015-09-01 19:04:04 +0000
commite2b95e62f08d5f978031e2217f0d623e6aa5bfa5 (patch)
treeed27852a23d10f719ea65623baa3890102dab278 /sys/netpfil
parent5fbb8e5fa1fa251599f3a172bf83df8bf15ce6f3 (diff)
downloadFreeBSD-src-e2b95e62f08d5f978031e2217f0d623e6aa5bfa5.zip
FreeBSD-src-e2b95e62f08d5f978031e2217f0d623e6aa5bfa5.tar.gz
pf: Fix misdetection of forwarding when net.link.bridge.pfil_bridge is set
If net.link.bridge.pfil_bridge is set we can end up thinking we're forwarding in pf_test6() because the rcvif and the ifp (output interface) are different. In that case we're bridging though, and the rcvif the the bridge member on which the packet was received and ifp is the bridge itself. If we'd set dir to PF_FWD we'd end up calling ip6_forward() which is incorrect. Instead check if the rcvif is a member of the ifp bridge. (In other words, the if_bridge is the ifp's softc). If that's the case we're not forwarding but bridging. PR: 202351 Reviewed by: eri Differential Revision: https://reviews.freebsd.org/D3534
Diffstat (limited to 'sys/netpfil')
-rw-r--r--sys/netpfil/pf/pf.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index fba0432..2afd77f 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -6085,7 +6085,17 @@ pf_test6(int dir, struct ifnet *ifp, struct mbuf **m0, struct inpcb *inp)
M_ASSERTPKTHDR(m);
- if (dir == PF_OUT && m->m_pkthdr.rcvif && ifp != m->m_pkthdr.rcvif)
+ /* Detect packet forwarding.
+ * If the input interface is different from the output interface we're
+ * forwarding.
+ * We do need to be careful about bridges. If the
+ * net.link.bridge.pfil_bridge sysctl is set we can be filtering on a
+ * bridge, so if the input interface is a bridge member and the output
+ * interface is its bridge we're not actually forwarding but bridging.
+ */
+ if (dir == PF_OUT && m->m_pkthdr.rcvif && ifp != m->m_pkthdr.rcvif
+ && (m->m_pkthdr.rcvif->if_bridge == NULL
+ || m->m_pkthdr.rcvif->if_bridge != ifp->if_softc))
fwdir = PF_FWD;
if (!V_pf_status.running)
OpenPOWER on IntegriCloud