summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/pf.c4
-rw-r--r--sys/net/pf_if.c16
-rw-r--r--sys/net/pfvar.h6
3 files changed, 21 insertions, 5 deletions
diff --git a/sys/net/pf.c b/sys/net/pf.c
index d40aacea574..26c3d420254 100644
--- a/sys/net/pf.c
+++ b/sys/net/pf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf.c,v 1.1083 2019/07/02 09:04:53 yasuoka Exp $ */
+/* $OpenBSD: pf.c,v 1.1084 2019/07/09 11:30:19 yasuoka Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -589,6 +589,7 @@ pf_insert_src_node(struct pf_src_node **sn, struct pf_rule *rule,
(*sn)->kif = kif;
pf_status.scounters[SCNT_SRC_NODE_INSERT]++;
pf_status.src_nodes++;
+ pfi_kif_ref(kif, PFI_KIF_REF_SRCNODE);
} else {
if (rule->max_src_states &&
(*sn)->states >= rule->max_src_states) {
@@ -612,6 +613,7 @@ pf_remove_src_node(struct pf_src_node *sn)
RB_REMOVE(pf_src_tree, &tree_src_tracking, sn);
pf_status.scounters[SCNT_SRC_NODE_REMOVALS]++;
pf_status.src_nodes--;
+ pfi_kif_unref(sn->kif, PFI_KIF_REF_SRCNODE);
pool_put(&pf_src_tree_pl, sn);
}
diff --git a/sys/net/pf_if.c b/sys/net/pf_if.c
index 9ef234da9e7..00684f80093 100644
--- a/sys/net/pf_if.c
+++ b/sys/net/pf_if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_if.c,v 1.96 2018/12/10 16:48:15 kn Exp $ */
+/* $OpenBSD: pf_if.c,v 1.97 2019/07/09 11:30:19 yasuoka Exp $ */
/*
* Copyright 2005 Henning Brauer <henning@openbsd.org>
@@ -147,6 +147,9 @@ pfi_kif_ref(struct pfi_kif *kif, enum pfi_kif_refs what)
case PFI_KIF_REF_ROUTE:
kif->pfik_routes++;
break;
+ case PFI_KIF_REF_SRCNODE:
+ kif->pfik_srcnodes++;
+ break;
default:
panic("pfi_kif_ref with unknown type");
}
@@ -185,6 +188,14 @@ pfi_kif_unref(struct pfi_kif *kif, enum pfi_kif_refs what)
}
kif->pfik_routes--;
break;
+ case PFI_KIF_REF_SRCNODE:
+ if (kif->pfik_srcnodes <= 0) {
+ DPFPRINTF(LOG_ERR,
+ "pfi_kif_unref: src-node refcount <= 0");
+ return;
+ }
+ kif->pfik_srcnodes--;
+ break;
default:
panic("pfi_kif_unref with unknown type");
}
@@ -192,7 +203,8 @@ pfi_kif_unref(struct pfi_kif *kif, enum pfi_kif_refs what)
if (kif->pfik_ifp != NULL || kif->pfik_group != NULL || kif == pfi_all)
return;
- if (kif->pfik_rules || kif->pfik_states || kif->pfik_routes)
+ if (kif->pfik_rules || kif->pfik_states || kif->pfik_routes ||
+ kif->pfik_srcnodes)
return;
RB_REMOVE(pfi_ifhead, &pfi_ifs, kif);
diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h
index d524f6eb2aa..aa6dfd89692 100644
--- a/sys/net/pfvar.h
+++ b/sys/net/pfvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfvar.h,v 1.491 2019/07/02 09:04:53 yasuoka Exp $ */
+/* $OpenBSD: pfvar.h,v 1.492 2019/07/09 11:30:19 yasuoka Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -1162,6 +1162,7 @@ struct pfi_kif {
int pfik_states;
int pfik_rules;
int pfik_routes;
+ int pfik_srcnodes;
TAILQ_HEAD(, pfi_dynaddr) pfik_dynaddrs;
};
@@ -1169,7 +1170,8 @@ enum pfi_kif_refs {
PFI_KIF_REF_NONE,
PFI_KIF_REF_STATE,
PFI_KIF_REF_RULE,
- PFI_KIF_REF_ROUTE
+ PFI_KIF_REF_ROUTE,
+ PFI_KIF_REF_SRCNODE
};
#define PFI_IFLAG_SKIP 0x0100 /* skip filtering on interface */