Download paper - AsiaBSDCon

Transcript
NPF - progress and perspective
Mindaugas Rasiukevicius
The NetBSD Project
[email protected]
January 2014
Abstract
information about NPF capabilities, configuration
and the syntax can found in the NPF documentaNPF – is a NetBSD packet filter which can do tion web page [npf14], as well as npf.conf(5) and
TCP/IP traffic filtering, stateful inspection and other manual pages.
network address translation with a development
focus on performance, scalability and modularity.
1.1 Multi-core scalability
The packet filter was first introduced with the
NetBSD 6.0 release. This paper and the presenta- NPF was designed and developed with a focus
tion will cover the main NPF features: its filtering on high performance and scalability. Multi-core
engine, stateful inspection and NAT, application systems became prevalent in the last decade. In
level gateways (ALGs), tables and extensions. It 2009, the Linux Netfilter project announced nftawill give an overview of some internals, e.g. key bles, with one of the main features being: ”the core
data structures used in NPF and the rationale be- is completely lockless ...” [McH09]. At that time
hind some design decisions. Finally, the latest de- there was no SMP-optimised packet filter in *BSD.
velopments in NetBSD -current will be discussed, The NPF idea was partly a BSD response to nftaincluding: addition of BPF coprocessor and just- bles. The main motivation was to design a packet
in-time (JIT) compilation which lead to NPF being filter for multi-core systems from the very beginfully switched to BPF byte-code, support for tables ning, as well as use byte-code based processing to
which use CDB with perfect hashing, stateless NAT have protocol independence and flexibility. For exwith NPTv6 and work in progress towards lockless ample, L7 filtering can be done without any kernel
state lookup.
modifications.
To achieve high concurrency, NPF employs various lockless techniques, e.g. ruleset inspection uses
1 Introduction
passive serialisation1 and implements completely
lockless processing. The details of state lookup will
NPF was introduced with the NetBSD 6.0 release.
be discussed in further sections. Large IP sets can
The expectations for the first release were to let
be stored in the tables for very efficient and concurusers try the technology, get wider testing and thus
rent lookups, which will be discussed in section 2.2.
get the core features stable, as well as gather genOther components of NPF where very high concureral feedback. There have been many improverency is not a concern use fine-grained locking.
ments, fixes and developments since then. In this
section we will briefly review the main features of
NPF. Then will take a look at the recent develop- 1.2 Stateful filtering
ments in section 2. This work will be appear in the
NPF supports stateful filtering – a required feature
NetBSD 7.0 release. Finally, the work in progress
for any modern packet filter. It performs full trackwill be discussed in section 3.
ing of TCP connections. This means tracking and
Some understanding and knowledge of syntax
1 Similar concept to RCU, but patent-free.
will be assumed in the examples. Comprehensive
21