2.13. Accelerating nftables packet forwarding by using flowtables
The nftables utility uses the Netfilter framework, which provides the fastpath feature-based flowtable mechanism to accelerate data packets of established connections.
The flowtable mechanism has the following features:
- Uses connection tracking to bypass the classic packet forwarding path.
- Avoids revisiting the routing table by bypassing the classic packet processing.
- Works only with TCP and UDP protocols.
- Hardware independent software fast path.
Procedure
Add an
example-tabletable ofinetfamily:# nft add table inet <example-table>Add an
example-flowtableflowtable withingresshook andfilteras a priority type:# nft add flowtable inet <example-table> <example-flowtable> { hook ingress priority filter \; devices = { example_device_one, example_device_two } \; }Add an
example-forwardchainflow to the flowtable from a packet processing table:# nft add chain inet <example-table> <example-forwardchain> { type filter hook forward priority filter \; }This command adds a flowtable of
filtertype withforwardhook andfilterpriority.Add a rule with
establishedconnection tracking state to offloadexample-flowtableflow:# nft add rule inet <example-table> <example-forwardchain> ct state { established, related } flow add @<example-flowtable>
Verification
Verify the properties of
example-table:# nft list table inet <example-table> table inet example-table { flowtable example-flowtable { hook ingress priority filter devices = { example_device_one, example_device_two } } chain example-forwardchain { type filter hook forward priority filter; policy accept; ct state established flow add @example-flowtable } }