From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 12 13:50:21 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A06B1065695 for ; Wed, 12 Jan 2011 13:50:21 +0000 (UTC) (envelope-from onwahe@gmail.com) Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 18F478FC0A for ; Wed, 12 Jan 2011 13:50:20 +0000 (UTC) Received: by qyk36 with SMTP id 36so584026qyk.13 for ; Wed, 12 Jan 2011 05:50:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=hAqVJDHFnSSlNYNJyrx+A27uEsLjZhc0gIGwHNFNAMM=; b=fqxNlh1DWgxHlkpew/1vd4z5Rqz7VkR15kvdULENw04Y5KS2BUTiXf/CHgI6m9Q4S2 UGOXDiG7AeTlkDflfAP6e81DfHGWarvgr6JToAEZJVN3dWKMxLdVnz/6h0507bBod+yE tNjVTxc71zz8/jVaphptfNdkvTEHk/Z+j1Fh8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=wd6dPX06bQb5F3v2ehq3ZjIM2v+gP8TVg47hpuoLkqcvfXmqi6BkghL2ajMxLWUJEl 0VFNF5CF7g3qcidPAI/O4vexLx5sR73HMO5VEkAFKx6ecx7tv6utk/EVknaqcXohHt0s UaRaWtxkxPFa5d+Q5xrPrccsr4mvTB96zpkoQ= MIME-Version: 1.0 Received: by 10.224.60.82 with SMTP id o18mr935433qah.189.1294838769311; Wed, 12 Jan 2011 05:26:09 -0800 (PST) Received: by 10.224.179.141 with HTTP; Wed, 12 Jan 2011 05:26:09 -0800 (PST) Date: Wed, 12 Jan 2011 14:26:09 +0100 Message-ID: From: Svatopluk Kraus To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: A question about "WARNING: attempt to domain_add(xyz) after domainfinalize()" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2011 13:50:21 -0000 Hi, I'd like to add a new network domain into kernel (and never remove it) from loadable module. In fact, I did it, but I got following warning from domain_add(): "WARNING: attempt to domain_add(xyz) after domainfinalize()". Now, I try to figure out what is behind the warning, which seems to become KASSERT (now, in notyet section part of code, which is 6 years old). I found a few iteration on domains list and each domain protosw table, which are not protected by any lock. OK, it is problem but when I only add a domain (it's added at the head of domains list) and never remove it then that could be safe. Moreover, it seems that without any limits, it is possible to add a new protocol into domain on reserved place labeled as PROTO_SPACER by pf_proto_register() function. Well, it's not a list so it's a different case (but a copy into spacer isn't atomic operation). I found two global variables (max_hdr,max_datalen) which are evaluated in each domain_init() from other variables (max_linkhdr,max_protohdr) and a global variable (max_keylen) which is evaluated from all known domains (dom_maxrtkey entry). The variables are used in other parts of kernel. Futher, I know about 'dom_ifattach' and 'dom_ifdetach' pointers to functions defined on each domain, which are responsible for 'if_afdata' entry on ifnet structure. Is there something more I didn't find in current kernel? Will be there something more in future kernels, what legitimize KASSERT in domain_add()? My network domain doesn't influence any mentioned global variables, doesn't define dom_ifattach() and dom_ifdetach() functions, and should be only added from loadable module and never removed. So, I think it's safe. But I'm a little bit nervous because of planned KASSERT in domain_add(). Well, I can implement an empty domain with some spacers for protocols, link it into kernel (thus shut down the warning), and make loadable module in which I only register protocols I want on already added domain, but why should I do it in that (for me good-for-nothing) way? Thanks for any response, Svata