[PATCH nf-next] netfilter: nft_meta: infer ptktype from IP address from the output path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 net/netfilter/nft_meta.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 516e74635bae..58a87205be8e 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -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;
 		}
-- 
2.30.2




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux