summaryrefslogtreecommitdiff
path: root/sys/net/if_pfsync.c
AgeCommit message (Collapse)Author
2010-11-29use m_pulldown to get a contig view of the pfsync_header instead ofDavid Gwynne
m_pullup. not really a significant change since most rx bufs (which we read pfsync packets from) are a single contig cluster coming off the network, so we rarely hit the case m_pullup was called in.
2010-11-29get rid of struct pfsync_pkt. it was used to store data on the stack toDavid Gwynne
pass to all the submessage handlers, but only the flags part of it was ever used. just pass the flags directly instead.
2010-11-28there's no need to take splsoftnet in the input packet action handlersDavid Gwynne
since theyre only ever called from pfsync_input, which is only called from ipintr, which is only called by softnet.
2010-09-27must have either PR_WAITOK or PR_NOWAIT set.David Gwynne
2010-09-08creating a pfsync interface is always done from process context, soBret Lambert
we can pass M_WAITOK to malloc(9) (which was already done a few lines down, which set off my aesthetic alarm). While here, include malloc.h, since we're calling malloc. ok dlg@
2010-07-28pfsync_bulk_fail was mucking around with pfsync_softc and sending packetsDavid Gwynne
without holding splsoftnet. this adds the necessary protection. reported by patrick coleman
2010-07-25Add missing braces so a loop will function as intended.Jonathan Gray
ok dlg@
2010-07-09Add support for using IPsec in multiple rdomains.Reyk Floeter
This allows to run isakmpd/iked/ipsecctl in multiple rdomains independently (with "route exec"); the kernel will pickup the rdomain from the process context of the pfkey socket and load the flows and SAs into the matching rdomain encap routing table. The network stack also needs to pass the rdomain to the ipsec stack to lookup the correct rdomain that belongs to an interface/mbuf/... You can now run individual IPsec configs per rdomain or create IPsec VPNs between multiple rdomains on the same machine ;). Note that a primary enc(4) in addition to enc0 interface is required per rdomain, eg. enc1 rdomain 1. Test by some people, mostly on existing "rdomain 0" setups. Was in snaps for some days and people didn't complain. ok claudio@ naddy@
2010-07-09instead of saying we're using the all the states in the table whenDavid Gwynne
sending a bulk update, only say we're using the states referenced by the next and last pointers into the table. this means the pf timeout thread can keep trimming states during a bulk update.
2010-07-09-#if 1 || defined(PFSYNC_DEBUG)David Gwynne
+#if defined(PFSYNC_DEBUG)
2010-07-09the current code doesnt detect when its filled a bulk packet so itDavid Gwynne
keeps on building them, which means that it floods the tx ring on the pfsync interface rather than actually sending many packets. this change correctly calculates when we've filled a bulk update packet. many thanks to david@ for making me go chase this. ive been wondering why the state count on my firewalls has had such a discrepency for a long time now.
2010-07-09sending of bulk updates has been very broken since r1.124.David Gwynne
pfsync_bulk_start sets up a bulk transfer by doing this: sc->sc_bulk_next = TAILQ_FIRST(&state_list); sc->sc_bulk_last = sc->sc_bulk_next; and then calls pfsync_bulk_update which loops over state_list like this: st = sc->sc_bulk_next; while (st != sc->sc_bulk_last) { basically bulk updates never got sent. this diff handles jjs problem by not attempting to send a bulk update when the state table is empty and fixed the loop to break at the right times. reported by david@ who's initial tests are positive. reviewed by mcbride@ tested in production at work.
2010-05-24remove bpfdetach() here, because it is called correctly in if_detach()David Gwynne
afterwards diff from gleydson soares ok claudio@
2010-05-12bzero() the full compressed update struct before setting the values.Claudio Jeker
This is needed because pf_state_peer_hton() skips some fields in certain situations which could result in garbage beeing sent to the other peer. This seems to fix the pfsync storms seen by stephan@ and so dlg owes me a whiskey. OK dlg@, stephan@
2010-04-25Properly adjust group demotion counters when groups are added orMarco Pfatschbacher
removed. Extend carp demote logging to also show the reason for the demote. Return EINVAL instead of ERANGE if a carpdemote request is out range. Requested from otto. OK mcbride, henning.
2010-03-23Fix a crash in pfsync when running IPSEC.Pierre-Yves Ritschard
Found out the hard way by Laurent ``bucky'' Lavaud and myself. Input by claudio@, ok dlg@
2010-03-01shuffle slightly and add more splassert.David Gwynne
also protect the flushing of the deferred packet queue in clone_destroy with the right spls. noticed by claudio@
2010-02-17dont defer broadcast or multicast packets.David Gwynne
ok sthen@ henning@
2010-01-18Convert pf debug logging to using log()/addlog(), a single standardisedRyan Thomas McBride
definition of DPFPRINTF(), and log priorities from syslog.h. Old debug levels will still work for now, but will eventually be phased out. discussed with henning, ok dlg
2010-01-12factor m_pulldown out of the message handlers up into pfsync_input nowDavid Gwynne
that it knows how big the messages are. rework the message handlers to use the pfsync_subheader.len value to iterate over the message regions. deprecate the EOF subheader since trying to pulldown a 0 byte buffer is fail. ok mcbride@ sperreault@
2010-01-12check the new pfsync_subheader len field on input.David Gwynne
this makes sure there is enough of the message to try and parse it, and allows implementations to skip past regions prefixed by unknown subheaders. based on discussion with mcbride@ deraadt@ and simon perreault
2010-01-12Remove bpfdetach() call right in front of the if_detach() call sinceClaudio Jeker
bpfdetach() will be called in if_detach(). Diff by Gleydson Soares
2010-01-11remove some debug code that snuck in somehow.David Gwynne
2010-01-10replace a pad in the pfsync subheader with a length field. it stores theDavid Gwynne
length of its message in dwords. multiply that by the count of the messages to figure out how to skip to the next subheader. "old" code still thinks the len field is a pad, which it doesnt look at, so new messages with a filled in len are still parsed correctly by "old" code. input and ok mcbride@ sounds good! Simon Perreault
2009-12-14fix sticky-address - by pretty much re-implementing it. still followingHenning Brauer
the original approach using a source tracking node. the reimplementation i smore flexible than the original one, we now have an slist of source tracking nodes per state. that is cheap because more than one entry will be an absolute exception. ok beck and jsg, also stress tested by Sebastian Benoit <benoit-lists at fb12.de>
2009-12-03fix order dependency of pfsync interface setup, with claudio;Otto Moerbeek
ok claudio@ dlg@
2009-11-23remove the nat_rule pointer on pf_state and pf_pdesc, obsolete afterHenning Brauer
the NAT rewrite and ever since then only checked in a couple of plaes but never set. same for nat_src_node on pf_state. with this the NAT rewrite made pf over 1000 lines shorter.
2009-11-22cleanup after the NAT changes. we used to have multiple rulesets (scrub,Henning Brauer
NAT, filter). now we only have one. no need for an array any more. simplifies the code quite a bit. in the process fix the abuse of PF_RULESET_* by (surprise, isn't it) the table code. written at the filesystem hackathon in stockholm, committed from the hardware hackathon in portugal. ok gcc and jsing
2009-11-12be paranoid in case the action array changes size (again, grr)Theo de Raadt
ok dlg
2009-11-03rtables are stacked on rdomains (it is possible to have multiple routingClaudio Jeker
tables on top of a rdomain) but until now our code was a crazy mix so that it was impossible to correctly use rtables in that case. Additionally pf(4) only knows about rtables and not about rdomains. This is especially bad when tracking (possibly conflicting) states in various domains. This diff fixes all or most of these issues. It adds a lookup function to get the rdomain id based on a rtable id. Makes pf understand rdomains and allows pf to move packets between rdomains (it is similar to NAT). Because pf states now track the rdomain id as well it is necessary to modify the pfsync wire format. So old and new systems will not sync up. A lot of help by dlg@, tested by sthen@, jsg@ and probably more OK dlg@, mpf@, deraadt@
2009-09-28when inserting a state, turn the error that pf_state_insert returnsDavid Gwynne
into something usable by ioctl. makes DIOCADDSTATE on /dev/pf cope when inserting an already existing state.
2009-08-16remove prototypes of a bunch of functions that had their implementationsJonathan Gray
removed in pfsync v5.
2009-06-17do better detection of when we have a better version of the tcp sequenceDavid Gwynne
windows than our peer. this resolves the last of the pfsync traffic storm issues ive been able to produce, and therefore makes it possible to do usable active-active statuful firewalls with pf. lots of testing locally on the production firewalls, also tested by sthen@
2009-06-14enable support for deferring the packet that creates a state so that yourDavid Gwynne
sync peers are able to get the states before the replies. previously there was a race where the reply could hit a partner firewall before it had the state for it, which caused the reply to get processed by the ruleset which probably would drop it. this behaviour is off by default because it does delay packets, which is only wanted in active-active firewalls or when an upstream router is slow to learn that you're moved the active member of the pfsync cluster. it also uses memory keeping the packets in the kernel. use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to disable. tested by sthen@ who loves it. he's got manpage changes coming up for me.
2009-06-12rewrite the way states from pfsync are merged into the local state treeDavid Gwynne
and the conditions on which pfsync will notify its peers on a stale update. each side (ie, the sending and receiving side) of the state update is compared separately. any side that is further along than the local state tree is merged. if any side is further along in the local state table, an update is sent out telling the peers about it. this has been flogged to death on my firewalls.
2009-06-10jj reported a panic in bulk updates to me. this is my attempt to fix theDavid Gwynne
most obvious problem. if the state table is empty, we'd deref a null pointer. tested on my firewalls with big state tables, so existing use cases still work.
2009-05-13dont go splx(s) in the ioctl handler if we havent done splnet(). this addsDavid Gwynne
the splnet calls and the extra splx(s)s necessary for it to be safe. bug found by sthen@
2009-05-13only keep track of the number of updates on tcp connections. state sync onDavid Gwynne
all the other protocols is simply pushing the timeouts along which has a resolution of 1 second, so it isnt going to be hurt by pfsync taking up to a second to send it over. keep track of updates on tcp still though, their windows need constant attention. tested by sthen@
2009-04-15move pfsync stale update messages to NOISY level; ok dlg@ henning@David Krause
2009-04-04use time_uptime instead of time_second internally. time_uptime isntDavid Gwynne
affected by adjusting the clock.
2009-03-31do not include space in the end of the from for a hmac. after discussionDavid Gwynne
with deraadt@, mcbride@, and mpf@ it is obvious that a hmac doesnt make sense for pfsync. this also firms up some of the input parsing so it handles short frames a bit better.
2009-03-23wait an appropriate amount of time before giving up on a bulk update,David Gwynne
rather than giving up after a hardcoded 5 seconds (which is generally much too short an interval for a bulk update). pointed out by david@, eyeballed by mcbride@
2009-03-17we do know how to handle iack. in the rx path at least.David Gwynne
2009-03-15Introduce splsoftassert(), similar to splassert() but for soft interruptMiod Vallat
levels. This will allow for platforms where soft interrupt levels do not map to real hardware interrupt levels to have soft ipl values overlapping hard ipl values without breaking spl asserts.
2009-03-01rework serialisation of messages slightly.David Gwynne
- pass a void *, rather than an mbuf and an offset into m_data, the callers can do the math for it. - we need to store the size of the messages these functions will serialise into, so dont get the funcs to return it, just add it on in the caller.
2009-03-01check pfsyncs IFF_RUNNING flag before doing stuff. should save time forDavid Gwynne
people who hate^Wdont use pfsync.
2009-03-01i can't see a reason that we'd need to go to splnet to call ip_output.David Gwynne
this cleans up use of splnet.
2009-02-26bulk updates are sent from a timeout which walks over the state tree andDavid Gwynne
modifies the pfsync state queues, however, it didnt prevent interrupts from whacking the same structures. this diff makes the bulk update code take splsoftnet() to prevent the panics ive been suffering all day when a firewall peer was booted. ok deraadt@
2009-02-24restore the parsing of incoming tdb update messages. this was disabledDavid Gwynne
while i was replacing the guts of pfsync, but i forgot to put it back again. this will make ipsec gateway failover work again. tested by sthen@ and david@ ok deraadt@
2009-02-24request a bulk update when the pfsync if configuration is changed via anDavid Gwynne
ioctl. without this peers would not request a bulk update when they come up, and therefore will not have the full state tree available for use in failover. ok mcbride@ "go for it" deraadt@