Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/usr/src/uts/common/inet/ipf/solaris.c b/usr/src/uts/common/inet/ipf/solaris.c
index c541f4d..1d391dd 100644
--- a/usr/src/uts/common/inet/ipf/solaris.c
+++ b/usr/src/uts/common/inet/ipf/solaris.c
@@ -7,6 +7,7 @@
* Use is subject to license terms.
*
* Copyright (c) 2014, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2018, Alasdair Lumsden. All rights reserved.
*/
/*
@@ -268,28 +269,43 @@ static int ipf_kstat_update(kstat_t *ksp, int rwflag);
static void
ipf_kstat_init(ipf_stack_t *ifs, boolean_t from_gz)
{
- ifs->ifs_kstatp[0] = net_kstat_create(ifs->ifs_netid,
- (from_gz ? "ipf_gz" : "ipf"),
- 0, "inbound", "net", KSTAT_TYPE_NAMED,
- sizeof (filter_kstats_t) / sizeof (kstat_named_t), 0);
- if (ifs->ifs_kstatp[0] != NULL) {
- bcopy(&ipf_kstat_tmp, ifs->ifs_kstatp[0]->ks_data,
- sizeof (filter_kstats_t));
- ifs->ifs_kstatp[0]->ks_update = ipf_kstat_update;
- ifs->ifs_kstatp[0]->ks_private = &ifs->ifs_frstats[0];
- kstat_install(ifs->ifs_kstatp[0]);
- }
+ netstackid_t stackid = net_getnetstackidbynetid(ifs->ifs_netid);
+
+ if (stackid != -1) {
+ ifs->ifs_kstatp[0] = kstat_create_netstack(
+ (from_gz ? "ipf_gz" : "ipf"),
+ stackid,"inbound", "net", KSTAT_TYPE_NAMED,
+ sizeof (filter_kstats_t) / sizeof (kstat_named_t), 0, stackid);
+
+ if (ifs->ifs_kstatp[0] != NULL) {
+ bcopy(&ipf_kstat_tmp, ifs->ifs_kstatp[0]->ks_data,
+ sizeof (filter_kstats_t));
+ ifs->ifs_kstatp[0]->ks_update = ipf_kstat_update;
+ ifs->ifs_kstatp[0]->ks_private = &ifs->ifs_frstats[0];
+ kstat_install(ifs->ifs_kstatp[0]);
+ }
+
+ ifs->ifs_kstatp[1] = kstat_create_netstack(
+ (from_gz ? "ipf_gz" : "ipf"),
+ stackid,"outbound", "net", KSTAT_TYPE_NAMED,
+ sizeof (filter_kstats_t) / sizeof (kstat_named_t), 0, stackid);
+
+ if (ifs->ifs_kstatp[1] != NULL) {
+ bcopy(&ipf_kstat_tmp, ifs->ifs_kstatp[1]->ks_data,
+ sizeof (filter_kstats_t));
+ ifs->ifs_kstatp[1]->ks_update = ipf_kstat_update;
+ ifs->ifs_kstatp[1]->ks_private = &ifs->ifs_frstats[1];
+ kstat_install(ifs->ifs_kstatp[1]);
+ }
- ifs->ifs_kstatp[1] = net_kstat_create(ifs->ifs_netid,
- (from_gz ? "ipf_gz" : "ipf"),
- 0, "outbound", "net", KSTAT_TYPE_NAMED,
- sizeof (filter_kstats_t) / sizeof (kstat_named_t), 0);
- if (ifs->ifs_kstatp[1] != NULL) {
- bcopy(&ipf_kstat_tmp, ifs->ifs_kstatp[1]->ks_data,
- sizeof (filter_kstats_t));
- ifs->ifs_kstatp[1]->ks_update = ipf_kstat_update;
- ifs->ifs_kstatp[1]->ks_private = &ifs->ifs_frstats[1];
- kstat_install(ifs->ifs_kstatp[1]);
+ /*
+ * If this is an exclusive netstack for a local zone, the global zone
+ * should still be able to read these kstats.
+ */
+ if (stackid != GLOBAL_NETSTACKID) {
+ kstat_zone_add(ifs->ifs_kstatp[0], GLOBAL_ZONEID);
+ kstat_zone_add(ifs->ifs_kstatp[1], GLOBAL_ZONEID);
+ }
}
#ifdef IPFDEBUG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment