-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
netfilter: nf_flow_table: hardware offload support
This patch adds the dataplane hardware offload to the flowtable infrastructure. Three new flags represent the hardware state of this flow: * FLOW_OFFLOAD_HW: This flow entry resides in the hardware. * FLOW_OFFLOAD_HW_DYING: This flow entry has been scheduled to be remove from hardware. This might be triggered by either packet path (via TCP RST/FIN packet) or via aging. * FLOW_OFFLOAD_HW_DEAD: This flow entry has been already removed from the hardware, the software garbage collector can remove it from the software flowtable. This patch supports for: * IPv4 only. * Aging via FLOW_CLS_STATS, no packet and byte counter synchronization at this stage. This patch also adds the action callback that specifies how to convert the flow entry into the flow_rule object that is passed to the driver. Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: David S. Miller <[email protected]>
- Loading branch information
Showing
8 changed files
with
822 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,6 +250,9 @@ int flow_offload_add(struct nf_flowtable *flow_table, struct flow_offload *flow) | |
return err; | ||
} | ||
|
||
if (flow_table->flags & NF_FLOWTABLE_HW_OFFLOAD) | ||
nf_flow_offload_add(flow_table, flow); | ||
|
||
return 0; | ||
} | ||
EXPORT_SYMBOL_GPL(flow_offload_add); | ||
|
@@ -350,9 +353,20 @@ static void nf_flow_offload_gc_step(struct flow_offload *flow, void *data) | |
{ | ||
struct nf_flowtable *flow_table = data; | ||
|
||
if (flow->flags & FLOW_OFFLOAD_HW) | ||
nf_flow_offload_stats(flow_table, flow); | ||
|
||
if (nf_flow_has_expired(flow) || nf_ct_is_dying(flow->ct) || | ||
(flow->flags & (FLOW_OFFLOAD_DYING | FLOW_OFFLOAD_TEARDOWN))) | ||
flow_offload_del(flow_table, flow); | ||
(flow->flags & (FLOW_OFFLOAD_DYING | FLOW_OFFLOAD_TEARDOWN))) { | ||
if (flow->flags & FLOW_OFFLOAD_HW) { | ||
if (!(flow->flags & FLOW_OFFLOAD_HW_DYING)) | ||
nf_flow_offload_del(flow_table, flow); | ||
else if (flow->flags & FLOW_OFFLOAD_HW_DEAD) | ||
flow_offload_del(flow_table, flow); | ||
} else { | ||
flow_offload_del(flow_table, flow); | ||
} | ||
} | ||
} | ||
|
||
static void nf_flow_offload_work_gc(struct work_struct *work) | ||
|
@@ -485,6 +499,7 @@ int nf_flow_table_init(struct nf_flowtable *flowtable) | |
int err; | ||
|
||
INIT_DEFERRABLE_WORK(&flowtable->gc_work, nf_flow_offload_work_gc); | ||
flow_block_init(&flowtable->flow_block); | ||
|
||
err = rhashtable_init(&flowtable->rhashtable, | ||
&nf_flow_offload_rhash_params); | ||
|
@@ -520,6 +535,7 @@ static void nf_flow_table_do_cleanup(struct flow_offload *flow, void *data) | |
static void nf_flow_table_iterate_cleanup(struct nf_flowtable *flowtable, | ||
struct net_device *dev) | ||
{ | ||
nf_flow_table_offload_flush(flowtable); | ||
nf_flow_table_iterate(flowtable, nf_flow_table_do_cleanup, dev); | ||
flush_delayed_work(&flowtable->gc_work); | ||
} | ||
|
@@ -547,5 +563,18 @@ void nf_flow_table_free(struct nf_flowtable *flow_table) | |
} | ||
EXPORT_SYMBOL_GPL(nf_flow_table_free); | ||
|
||
static int __init nf_flow_table_module_init(void) | ||
{ | ||
return nf_flow_table_offload_init(); | ||
} | ||
|
||
static void __exit nf_flow_table_module_exit(void) | ||
{ | ||
nf_flow_table_offload_exit(); | ||
} | ||
|
||
module_init(nf_flow_table_module_init); | ||
module_exit(nf_flow_table_module_exit); | ||
|
||
MODULE_LICENSE("GPL"); | ||
MODULE_AUTHOR("Pablo Neira Ayuso <[email protected]>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.