Skip to content

Commit 5bb486f

Browse files
Pull up following revision(s) (requested by joe in ticket #53):
sys/net/npf/npf.h: revision 1.68 sys/net/npf/npf_ruleset.c: revision 1.57 PR kern/59615 introduce layer checks for 10 userland 11 kernel
1 parent eacb9c6 commit 5bb486f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

sys/net/npf/npf.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,9 @@ typedef enum {
355355
NPF_STAT_PASS_DEFAULT,
356356
NPF_STAT_PASS_RULESET,
357357
NPF_STAT_PASS_CONN,
358-
NPF_ETHER_STAT_PASS,
359358
/* Packets blocked. */
360359
NPF_STAT_BLOCK_DEFAULT,
361360
NPF_STAT_BLOCK_RULESET,
362-
NPF_ETHER_STAT_BLOCK,
363361
/* Connection and NAT entries. */
364362
NPF_STAT_CONN_CREATE,
365363
NPF_STAT_CONN_DESTROY,
@@ -382,6 +380,9 @@ typedef enum {
382380
/* nbuf non-contiguous cases. */
383381
NPF_STAT_NBUF_NONCONTIG,
384382
NPF_STAT_NBUF_CONTIG_FAIL,
383+
/* layer 2 statistics */
384+
NPF_ETHER_STAT_PASS,
385+
NPF_ETHER_STAT_BLOCK,
385386
/* Count (last). */
386387
NPF_STATS_COUNT
387388
} npf_stats_t;

sys/net/npf/npf_ruleset.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#ifdef _KERNEL
3636
#include <sys/cdefs.h>
37-
__KERNEL_RCSID(0, "$NetBSD: npf_ruleset.c,v 1.56 2025/07/01 18:42:37 joe Exp $");
37+
__KERNEL_RCSID(0, "$NetBSD: npf_ruleset.c,v 1.56.2.1 2025/10/13 09:24:53 martin Exp $");
3838

3939
#include <sys/param.h>
4040
#include <sys/types.h>
@@ -925,7 +925,14 @@ npf_ruleset_inspect(npf_cache_t *npc, const npf_ruleset_t *rlset,
925925
const unsigned skip_to = rl->r_skip_to & SKIPTO_MASK;
926926
const uint32_t attr = rl->r_attr;
927927

928-
if ((attr & layer) == 0) {
928+
/*
929+
* PR kern/59615
930+
* we are skipping rule inspection on two cases
931+
* if layer attributes are set but we are on a different layer
932+
* or if no layer attributes set (10 userland), don't inspect at layer 2
933+
*/
934+
if (!(((layer == NPF_RULE_LAYER_3 && ((attr & (NPF_RULE_LAYER_2 | NPF_RULE_LAYER_3)) == 0)) ||
935+
(attr & layer)))) {
929936
n = skip_to;
930937
continue;
931938
}

0 commit comments

Comments
 (0)