PERFORCE change 161004 for review
Marko Zec
zec at FreeBSD.org
Thu Apr 23 22:18:16 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=161004
Change 161004 by zec at zec_amdx2 on 2009/04/23 22:17:51
Merge vnet module deregistration handlers, intended to be used
on kldunloading a particular networking subsystem, so that
the vnet framework can clean up all active instances of that
particular subsystem.
Obtained from: vimage
Affected files ...
.. //depot/projects/vimage-commit/src/sys/kern/kern_vimage.c#6 edit
.. //depot/projects/vimage-commit/src/sys/sys/vimage.h#13 edit
Differences ...
==== //depot/projects/vimage-commit/src/sys/kern/kern_vimage.c#6 (text+ko) ====
@@ -47,6 +47,7 @@
static TAILQ_HEAD(vnet_modpending_head, vnet_modlink) vnet_modpending_head;
static void vnet_mod_complete_registration(struct vnet_modlink *);
static int vnet_mod_constructor(struct vnet_modlink *);
+static int vnet_mod_destructor(struct vnet_modlink *);
void
vnet_mod_register(const struct vnet_modinfo *vmi)
@@ -144,6 +145,36 @@
} while (vml_iter != NULL);
}
+void
+vnet_mod_deregister(const struct vnet_modinfo *vmi)
+{
+ vnet_mod_deregister_multi(vmi, NULL, NULL);
+}
+
+void
+vnet_mod_deregister_multi(const struct vnet_modinfo *vmi, void *iarg,
+ char *iname)
+{
+ VNET_ITERATOR_DECL(vnet_iter);
+ struct vnet_modlink *vml;
+
+ TAILQ_FOREACH(vml, &vnet_modlink_head, vml_mod_le)
+ if (vml->vml_modinfo == vmi && vml->vml_iarg == iarg)
+ break;
+ if (vml == NULL)
+ panic("cannot deregister unregistered vnet module %s",
+ vmi->vmi_name);
+
+ VNET_FOREACH(vnet_iter) {
+ CURVNET_SET_QUIET(vnet_iter);
+ vnet_mod_destructor(vml);
+ CURVNET_RESTORE();
+ }
+
+ TAILQ_REMOVE(&vnet_modlink_head, vml, vml_mod_le);
+ free(vml, M_VIMAGE);
+}
+
static int vnet_mod_constructor(struct vnet_modlink *vml)
{
const struct vnet_modinfo *vmi = vml->vml_modinfo;
@@ -176,6 +207,39 @@
return (0);
}
+
+static int
+vnet_mod_destructor(struct vnet_modlink *vml)
+{
+ const struct vnet_modinfo *vmi = vml->vml_modinfo;
+
+#ifdef DEBUG_ORDERING
+ printf("destroying vnet_%s", vmi->vmi_name);
+ if (vml->vml_iarg)
+ printf("/%s", vml->vml_iname);
+ printf(": ");
+ if (vmi->vmi_idetach != NULL)
+ printf("idetach(); ");
+ if (vmi->vmi_size)
+ printf("free()");
+ printf("\n");
+#endif
+
+ if (vmi->vmi_idetach)
+ vmi->vmi_idetach(vml->vml_iarg);
+
+#ifdef VIMAGE
+ if (vmi->vmi_size) {
+ if (curvnet->mod_data[vmi->vmi_id] == NULL)
+ panic("vi_destroy: %s\n", vmi->vmi_name);
+ free(curvnet->mod_data[vmi->vmi_id], M_VNET);
+ curvnet->mod_data[vmi->vmi_id] = NULL;
+ }
+#endif
+
+ return (0);
+}
+
/*
* vi_symlookup() attempts to resolve name to address queries for
* variables which have been moved from global namespace to virtualization
==== //depot/projects/vimage-commit/src/sys/sys/vimage.h#13 (text+ko) ====
@@ -121,6 +121,8 @@
int vi_symlookup(struct kld_sym_lookup *, char *);
void vnet_mod_register(const struct vnet_modinfo *);
void vnet_mod_register_multi(const struct vnet_modinfo *, void *, char *);
+void vnet_mod_deregister(const struct vnet_modinfo *);
+void vnet_mod_deregister_multi(const struct vnet_modinfo *, void *, char *);
#endif /* !VIMAGE_GLOBALS */
More information about the p4-projects
mailing list