net: pkt_filter: Add more debug prints when matching packets

Add some more useful debug prints when checking packets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
Jukka Rissanen 2025-04-12 11:08:00 +03:00 committed by Benjamin Cabé
commit 3232b6190c
2 changed files with 15 additions and 0 deletions

View file

@ -242,6 +242,10 @@ bool npf_iface_match(struct npf_test *test, struct net_pkt *pkt)
struct npf_test_iface *test_iface =
CONTAINER_OF(test, struct npf_test_iface, test);
NET_DBG("iface %d pkt %d",
net_if_get_by_iface(test_iface->iface),
net_if_get_by_iface(net_pkt_iface(pkt)));
return test_iface->iface == net_pkt_iface(pkt);
}
@ -255,6 +259,10 @@ bool npf_orig_iface_match(struct npf_test *test, struct net_pkt *pkt)
struct npf_test_iface *test_iface =
CONTAINER_OF(test, struct npf_test_iface, test);
NET_DBG("orig iface %d pkt %d",
net_if_get_by_iface(test_iface->iface),
net_if_get_by_iface(net_pkt_orig_iface(pkt)));
return test_iface->iface == net_pkt_orig_iface(pkt);
}
@ -269,6 +277,9 @@ bool npf_size_inbounds(struct npf_test *test, struct net_pkt *pkt)
CONTAINER_OF(test, struct npf_test_size_bounds, test);
size_t pkt_size = net_pkt_get_len(pkt);
NET_DBG("pkt_size %zu min %zu max %zu",
pkt_size, bounds->min, bounds->max);
return pkt_size >= bounds->min && pkt_size <= bounds->max;
}

View file

@ -72,6 +72,10 @@ bool npf_eth_type_match(struct npf_test *test, struct net_pkt *pkt)
struct net_eth_hdr *eth_hdr = NET_ETH_HDR(pkt);
/* note: type_match->type is assumed to be in network order already */
NET_DBG("proto type 0x%04x pkt 0x%04x",
ntohs(test_eth_type->type),
ntohs(eth_hdr->type));
return eth_hdr->type == test_eth_type->type;
}