forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
netfilter: nft_fib: add reduce support
The fib expression stores to a register, so we can't add empty stub. Check that the register that is being written is in fact redundant. In most cases, this is expected to cancel tracking as re-use is unlikely. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
- Loading branch information
Showing
6 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,5 +156,47 @@ void nft_fib_store_result(void *reg, const struct nft_fib *priv, | |
} | ||
EXPORT_SYMBOL_GPL(nft_fib_store_result); | ||
|
||
bool nft_fib_reduce(struct nft_regs_track *track, | ||
const struct nft_expr *expr) | ||
{ | ||
const struct nft_fib *priv = nft_expr_priv(expr); | ||
unsigned int len = NFT_REG32_SIZE; | ||
const struct nft_fib *fib; | ||
|
||
switch (priv->result) { | ||
case NFT_FIB_RESULT_OIF: | ||
break; | ||
case NFT_FIB_RESULT_OIFNAME: | ||
if (priv->flags & NFTA_FIB_F_PRESENT) | ||
len = NFT_REG32_SIZE; | ||
else | ||
len = IFNAMSIZ; | ||
break; | ||
case NFT_FIB_RESULT_ADDRTYPE: | ||
break; | ||
default: | ||
WARN_ON_ONCE(1); | ||
break; | ||
} | ||
|
||
if (!nft_reg_track_cmp(track, expr, priv->dreg)) { | ||
nft_reg_track_update(track, expr, priv->dreg, len); | ||
return false; | ||
} | ||
|
||
fib = nft_expr_priv(track->regs[priv->dreg].selector); | ||
if (priv->result != fib->result || | ||
priv->flags != fib->flags) { | ||
nft_reg_track_update(track, expr, priv->dreg, len); | ||
return false; | ||
} | ||
|
||
if (!track->regs[priv->dreg].bitwise) | ||
return true; | ||
|
||
return false; | ||
} | ||
EXPORT_SYMBOL_GPL(nft_fib_reduce); | ||
|
||
MODULE_LICENSE("GPL"); | ||
MODULE_AUTHOR("Florian Westphal <[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
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