Date: Mon, 15 Aug 2005 19:40:40 +0400 From: Sergey Lapin <slapinid@gmail.com> To: freebsd-pf@freebsd.org Subject: Fwd: Fwd: Dual-feed: PF setup troubles Message-ID: <48239d390508150840481420ec@mail.gmail.com> In-Reply-To: <D5972F49810A69449A9EA72A4B360DC238712A@e1.universe.dart.spb> References: <D5972F49810A69449A9EA72A4B360DC238712A@e1.universe.dart.spb>
next in thread | previous in thread | raw e-mail | index | archive | help
---------- Forwarded message ---------- From: Dmitry Andrianov <dimas@dataart.com> Date: Aug 15, 2005 7:31 PM Subject: RE: Fwd: Dual-feed: PF setup troubles To: Sergey Lapin <slapinid@gmail.com>, Max Laier <max@love2party.net>, Daniel Hartmeier <daniel@benzedrine.cx> Hi. > You can try turning of the IFF_SIMPLEX flag on the interface > (unsure about the entire effects of that), or simply exclude those > broadcast packets from getting routed by pf (which isn't really intentional, is it?), like > > - ... from ... to any ... > + ... from ... to !255.255.255.255 ... Well, these are not packets to 255.255.255.255 which cause dead box. As we previously note, ANY packet with broadcast destination MAC and destination IP outside of directly connected networks does that. Which means we can not just block it at Layer 3 level - we need some sort of MAC (Layer 2) filtering which pf does not have (I suppose). After all, I do not see how this ruleset pass in quick on $dmz_if route-to ($ext_if1 $ext_gw1) tagged DMZ_TO_EXT1 keep state pass in quick on $dmz_if route-to ($ext_if2 $ext_gw2) tagged DMZ_TO_EXT2 keep state pass out quick on $ext_if1 route-to ($ext_if2 $ext_gw2) tagged DMZ_TO_EXT2 keep state pass out quick on $ext_if2 route-to ($ext_if1 $ext_gw1) tagged DMZ_TO_EXT1 keep state Causes loop. Even if packet re-enters ext_if1 input queue, it should not be affected by these rules because 1. first two applies only to packets coming to DMZ interfact 2. second two applies only when packet with wrong source is on the interface output queue... Regards, Dmitry Andrianov -----Original Message----- From: Sergey Lapin [mailto:slapinid@gmail.com] Sent: Monday, August 15, 2005 6:51 PM To: Dmitry Andrianov; Max Laier Subject: Fwd: Fwd: Dual-feed: PF setup troubles ---------- Forwarded message ---------- From: Daniel Hartmeier <daniel@benzedrine.cx> Date: Aug 15, 2005 6:34 PM Subject: Re: Fwd: Dual-feed: PF setup troubles To: Sergey Lapin <slapinid@gmail.com> Cc: freebsd-pf@freebsd.org I suspect the loop occurs through sys/net/if_ethersubr.c ether_output() /* * If a simplex interface, and the packet is being sent to our * Ethernet address or a broadcast address, loopback a copy. * XXX To make a simplex device behave exactly like a duplex * device, we should copy in the case of sending to our own * ethernet address (thus letting the original actually appear * on the wire). However, we don't do that here for security * reasons and compatibility with the original behavior. */ if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy !=3D -1)) { int csum_flags =3D 0; if (m->m_pkthdr.csum_flags & CSUM_IP) csum_flags |=3D (CSUM_IP_CHECKED|CSUM_IP_VALID); if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) csum_flags |=3D (CSUM_DATA_VALID|CSUM_PSEUDO_HDR); if ((m->m_flags & M_BCAST) || (loop_copy > 0)) { struct mbuf *n; if ((n =3D m_copy(m, 0, (int)M_COPYALL)) !=3D NULL) { n->m_pkthdr.csum_flags |=3D csum_flags; if (csum_flags & CSUM_DATA_VALID) n->m_pkthdr.csum_data =3D 0xffff; (void)if_simloop(ifp, n, dst->sa_family, hlen); } else ifp->if_iqdrops++; } else if (bcmp(eh->ether_dhost, eh->ether_shost, ETHER_ADDR_LEN) =3D=3D 0) { m->m_pkthdr.csum_flags |=3D csum_flags; if (csum_flags & CSUM_DATA_VALID) m->m_pkthdr.csum_data =3D 0xffff; (void) if_simloop(ifp, m, dst->sa_family, hlen); return (0); /* XXX */ } } You route-to the broadcast packet, pf will call ether_output() to send it out through the new interface, and this piece of code in there will send it right back in through that interface again. If your ruleset then routes that resent packet again, you get a tight endless loop, locking up the kernel, like you describe. OpenBSD doesn't have this piece in ether_output(), I'm not sure in what cases people want outgoing broadcasts on an interface reflected back at them by the stack. You can try turning of the IFF_SIMPLEX flag on the interface (unsure about the entire effects of that), or simply exclude those broadcast packets from getting routed by pf (which isn't really intentional, is it?), like - ... from ... to any ... + ... from ... to !255.255.255.255 ... Or find the person familiar/responsible for this loop_copy code, and ask whether we can bypass it, for instance when the PF_ROUTED mbuf tag is present, or such. I'm not entirely sure this is the loop, but you can confirm by adding simple printf()s along that code path, you'll see them printed endlessly when the lockup occurs. Daniel
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48239d390508150840481420ec>