All of lore.kernel.org
 help / color / mirror / Atom feed
* iptables as a state machine
@ 2004-10-01  2:39 David S. Miller
  2004-10-01  3:47 ` shemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: David S. Miller @ 2004-10-01  2:39 UTC (permalink / raw)
  To: netfilter-devel


So while waiting for a kernel build to finish I was sniffing
around the iptables code thinking about how one might optimize
the lookups.

The ipt targets are simple enough already, and I think this
shows the elegance of the core iptables design.

It's the main ip header + indev + outdev matching that is
the real memory and cpu cycle killer in these paths.  Once
we match the target, the verdict is determined quickly.

This made me think about how in the old days gcc's instruction
scheduler was computationally complex.  This was fixed by
representing the processor as a state machine, and this is how
the gcc insn scheduler works currently.  It's very fast and all
of the complexity is in building the state machine which is done
at gcc build time.

I think iptables core IP header + indev + outdev match is a
state machine problem as well.  Such a state machine can be
made extremely small memory wise.  The lookup can be something
like running a berkeley packet filter on the frame.  Except
that instead of a "yes or no" answer we get a pointer to a
target.

I think this would run as efficiently, if not more so, than the
various B-tree based schemes and it certainly would consume much
less memory.

The only trick is making the state machine building fast, and
where to put it (kernel or user space).

Comments?

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2004-10-04 15:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-01  2:39 iptables as a state machine David S. Miller
2004-10-01  3:47 ` shemminger
2004-10-01  4:01   ` David S. Miller
2004-10-01  8:24     ` Thomas Heinz
2004-10-01 19:46       ` David S. Miller
2004-10-01 20:26         ` Thomas Heinz
2004-10-01 20:33         ` Stephen Hemminger
2004-10-01 11:12     ` Henrik Nordstrom
2004-10-01 12:06       ` Henrik Nordstrom
2004-10-02  8:44   ` Roberto Nibali
2004-10-02 14:42     ` Henrik Nordstrom
2004-10-04 10:04     ` Jozsef Kadlecsik
2004-10-04 15:51     ` Stephen Hemminger
2004-10-01 20:06 ` Gonzalo A. Arana
2004-10-02 21:01 ` Tobias DiPasquale
2004-10-02 21:52   ` Thomas Heinz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.