From owner-p4-projects@FreeBSD.ORG Thu Apr 23 22:18:15 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 879BD1065677; Thu, 23 Apr 2009 22:18:15 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47C3B1065670 for ; Thu, 23 Apr 2009 22:18:15 +0000 (UTC) (envelope-from zec@fer.hr) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 2B8608FC12 for ; Thu, 23 Apr 2009 22:18:15 +0000 (UTC) (envelope-from zec@fer.hr) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n3NMIFo5017728 for ; Thu, 23 Apr 2009 22:18:15 GMT (envelope-from zec@fer.hr) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n3NMIEj0017726 for perforce@freebsd.org; Thu, 23 Apr 2009 22:18:14 GMT (envelope-from zec@fer.hr) Date: Thu, 23 Apr 2009 22:18:14 GMT Message-Id: <200904232218.n3NMIEj0017726@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@fer.hr using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 161004 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Apr 2009 22:18:16 -0000 http://perforce.freebsd.org/chv.cgi?CH=161004 Change 161004 by zec@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 */