Skip to contentSkip to conversation

netfilter: nft_meta: infer ptktype from IP address from the output path

PATCH New Pablo Neira Ayuso 1 participant 1 message Oct 26, 2021

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nft_meta: infer ptktype from IP address from the output path

meta pkttype always says 0 (host) from the output path. The code to infer the packet type from the IP address is already in place for loopback traffic, extend it to infer it the packet type from the output, postrouting and egress path too.

---
 net/netfilter/nft_meta.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/netfilter/nft_meta.c +5 -1
index 516e74635bae..58a87205be8e 100644
@@ -371,7 +371,11 @@ void nft_meta_get_eval(const struct nft_expr *expr,
 		break;
 #endif
 	case NFT_META_PKTTYPE:
-		if (skb->pkt_type != PACKET_LOOPBACK) {
+		if (skb->pkt_type != PACKET_LOOPBACK &&
+		    nft_hook(pkt) != NF_INET_LOCAL_OUT &&
+		    nft_hook(pkt) != NF_INET_POST_ROUTING &&
+		    (nft_pf(pkt) == NFPROTO_NETDEV &&
+		     nft_hook(pkt) != NF_NETDEV_EGRESS)) {
 			nft_reg_store8(dest, skb->pkt_type);
 			break;
 		}
Signature · 1 line
2.30.2