Skip to contentSkip to conversation

nftables: exthdr: Allow checking TCP option presence, too

PATCH Applied Phil Sutter 2 participants 2 messages Feb 20, 2017 – Mar 6, 2017

Subsystems (2)
lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 nftables: exthdr: Allow checking TCP option presence, too

---
 net/netfilter/nft_exthdr.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
net/netfilter/nft_exthdr.c +10 -3
index c308920b194cd..d212a85d2f333 100644
@@ -98,14 +98,21 @@ static void nft_exthdr_tcp_eval(const struct nft_expr *expr,
 			goto err;
 
 		offset = i + priv->offset;
-		dest[priv->len / NFT_REG32_SIZE] = 0;
-		memcpy(dest, opt + offset, priv->len);
+		if (priv->flags & NFT_EXTHDR_F_PRESENT) {
+			*dest = 1;
+		} else {
+			dest[priv->len / NFT_REG32_SIZE] = 0;
+			memcpy(dest, opt + offset, priv->len);
+		}
 
 		return;
 	}
 
 err:
-	regs->verdict.code = NFT_BREAK;
+	if (priv->flags & NFT_EXTHDR_F_PRESENT)
+		*dest = 0;
+	else
+		regs->verdict.code = NFT_BREAK;
 }
 
 static const struct nla_policy nft_exthdr_policy[NFTA_EXTHDR_MAX + 1] = {
Signature · 1 line
2.11.0
maintainer Applied
#1 lore raw

Applied to nf-next, thanks Phil.

I have added a short description to this.