ipfw3: lockless in-kernel NAT
authorBill Yuan <bycn82@dragonflybsd.org>
Tue, 21 Jun 2016 18:13:10 +0000 (18:13 +0000)
committerBill Yuan <bycn82@dragonflybsd.org>
Tue, 21 Jun 2016 18:13:10 +0000 (18:13 +0000)
commit9187b359203f12156672d8e1db35aaca69f1f482
treef4dcea68fbe46bb8804de20d31afef08c076aa47
parentb8b0be74d9deffb6be0d589c4412c9efdc7e7811
ipfw3: lockless in-kernel NAT

The libalias is used in kernel space for in-kernel NAT, and its alias_link
entries are stored with LIST. so all the packets which need to be NAT will scan
against the LIST and trying to find the matched alias_link. by seperating the
libalias into context of different CPUs, the lock can be removed. and due to the
nature of NAT, the outgoing and incoming packets are possible to be handled by
different CPUs, to ensure the returning packet can be translated properly, the
newly created alias_link is required to be duplicated and inserted into contexts
of both CPUs.

e.g.
ipfw3 nat 1 config if em0
ipfw3 nat 1 all via em0
ipfw3 nat 1 show state
33 files changed:
lib/libipfw3/basic/ipfw3_basic.c
lib/libipfw3/basic/ipfw3_basic.h
lib/libipfw3/dummynet/ipfw3_dummynet.c
lib/libipfw3/dummynet/ipfw3_dummynet.h
lib/libipfw3/layer2/ipfw3_layer2.c
lib/libipfw3/layer2/ipfw3_layer2.h
lib/libipfw3/layer4/ipfw3_layer4.c
lib/libipfw3/layer4/ipfw3_layer4.h
lib/libipfw3/nat/ipfw3_nat.c
lib/libipfw3/nat/ipfw3_nat.h
sbin/ipfw3/Makefile
sbin/ipfw3/ipfw3.c
sbin/ipfw3/ipfw3.h [new file with mode: 0644]
sbin/ipfw3/ipfw3nat.c [new file with mode: 0644]
sbin/ipfw3/ipfw3nat.h [moved from sbin/ipfw3/ipfw.h with 61% similarity]
sbin/ipfw3/ipfw3sync.c
sys/net/dummynet3/ip_dummynet.h
sys/net/ipfw3/ip_fw3.c
sys/net/ipfw3/ip_fw3.h
sys/net/ipfw3/ip_fw3_log.c
sys/net/ipfw3/ip_fw3_log.h
sys/net/ipfw3/ip_fw3_table.c
sys/net/ipfw3/ip_fw3_table.h
sys/net/ipfw3_basic/ip_fw3_basic.c
sys/net/ipfw3_basic/ip_fw3_basic.h
sys/net/ipfw3_layer2/ip_fw3_layer2.c
sys/net/ipfw3_layer2/ip_fw3_layer2.h
sys/net/ipfw3_layer4/ip_fw3_layer4.c
sys/net/ipfw3_layer4/ip_fw3_layer4.h
sys/net/ipfw3_nat/ip_fw3_nat.c
sys/net/ipfw3_nat/ip_fw3_nat.h
sys/net/libalias/alias.c
sys/net/libalias/alias.h