From owner-freebsd-net@freebsd.org Fri Jan 8 15:45:45 2021 Return-Path: Delivered-To: freebsd-net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C7CE44CD89B for ; Fri, 8 Jan 2021 15:45:45 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DC6rT107jz4Xk4 for ; Fri, 8 Jan 2021 15:45:44 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qv1-xf36.google.com with SMTP id j18so4462668qvu.3 for ; Fri, 08 Jan 2021 07:45:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=fjlC2xUTUl9SCVmhVmaPVfrclmJyga+qJcn65mvI89Y=; b=sVB8iRh4UIiRIHmLP6GcvtdynDuPnDA8vC+nRzcSNCkVy/WWbLW4qdW38rAqXczQnE bY3Pw33Rl0FIdfWDSBTKPNQec73tBxR6zYREVxgSAXVT13MgWic6BLa/UnZuqbOHfaIT S0TNSZD/5JXC6rzzWEKpytXf8KlSn2riN5W7HLe7oIcVXKh2weDL2gGIbQ/MpVrYAOJm 9pohemgsiIG2gNGy9teG0/jZNioJDkLiyZI+adrHb0bgXQVLn3GCHU4kKVL6UMk7TSA0 1BltDFajeR4Yabjdb05VIAzjhllqXThta+edIQOSG3zfoTL3tGiJJkzTP1bZa904vIQ3 hrEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=fjlC2xUTUl9SCVmhVmaPVfrclmJyga+qJcn65mvI89Y=; b=ZFtOvzxH5v0BUfVQZXnwvswGRif1hTz25Bg8R8HO4GHomAe6Zi9dxjYWaZ+neywENG fECWbDkj/pswzt0gZcb5SHuk5B6BjRhjAu2I6wIaf7mHe7HuhrBF+N/AYOT8MQV4QHnC aRljgpgryLVHCjSWjgbGarz+SOpBQb397yNlCu62KbhmexYcXYw8dDsnFRZVFw3opKqQ VG9ikIdCYUng5wb7jVb02vKZIPeOQj7ZI90OjB7OfAGcWN8bNBZtuEIopI0B5+lhoNw2 gFkpyUOx/Kvp0NAkybNQKa8ZmXXapKfQ1eLhKgsWQRkxOLcSXdwigBAxn/G+s77ZIXbq JGWw== X-Gm-Message-State: AOAM532vdqbvpAvrwpqntF9vjgCnySdEPwoPIBenqcYiqGwa5Hum/JE9 kE6JOT8KQsESRFad20bhP93TqPkhx6fN9g== X-Google-Smtp-Source: ABdhPJys1IlmG/8h6VhsPKrv9Pv07F+R++jXD9jg1wWMXaFCQVk3Leh6dvsBJv//nZmkazvbqEgDcg== X-Received: by 2002:a05:6214:4e2:: with SMTP id cl2mr4049714qvb.27.1610120744160; Fri, 08 Jan 2021 07:45:44 -0800 (PST) Received: from raichu ([142.126.164.150]) by smtp.gmail.com with ESMTPSA id y22sm4842862qkj.129.2021.01.08.07.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 07:45:43 -0800 (PST) Sender: Mark Johnston Date: Fri, 8 Jan 2021 10:45:41 -0500 From: Mark Johnston To: Vasily Postnicov Cc: freebsd-net@freebsd.org Subject: Re: DNS using Name Service Switch module and Casper Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: 4DC6rT107jz4Xk4 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=sVB8iRh4; dmarc=none; spf=pass (mx1.freebsd.org: domain of markjdb@gmail.com designates 2607:f8b0:4864:20::f36 as permitted sender) smtp.mailfrom=markjdb@gmail.com X-Spamd-Result: default: False [-0.70 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_SENDER(0.30)[markj@freebsd.org,markjdb@gmail.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[markj@freebsd.org,markjdb@gmail.com]; RBL_DBL_DONT_QUERY_IPS(0.00)[2607:f8b0:4864:20::f36:from]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-net@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; SPAMHAUS_ZRD(0.00)[2607:f8b0:4864:20::f36:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(1.00)[1.000]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::f36:from]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-net] X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2021 15:45:45 -0000 On Wed, Jan 06, 2021 at 07:08:14PM +0300, Vasily Postnicov wrote: > That's what I found. > > At first, ping calls cap_init() in capdns_setup(). cap_init() forks a > process, then the parent returns and the child calls casper_main_loop(). > The child and the parent both have a socket to communicate. > casper_main_loop() calls zygote_init() and that one blocks on fork(). I do > not know how it could be. How can fork() block? Does you module somehow use pthread_atfork()? > The parent process later calls cap_service_open() and that function calls > cap_xfer_nvlist(). Because the child process is stuck somewhere in > zygote_init() it never sends an nvlist back. So ping blocks. Can you show output from "procstat -kk " when this hang occurs? > All this is figured out by inserting printf()'s. LLDB refuses to run ping > with 'error: Child exec failed'. Presumably it needs to be run as root since ping(8) is a setuid executable. > вт, 5 янв. 2021 г. в 17:43, Mark Johnston : > > > On Tue, Jan 05, 2021 at 10:02:37AM +0300, Vasily Postnicov wrote: > > > Hello. I wrote a simple daemon called ZeroDNS which provides > > functionality > > > similar to multicast DNS, namely it discovers other participating > > machines > > > over the LAN and stores their hostname and IPv4 address pairs. > > > > > > Here is a NSS module which allows the system to use information from that > > > daemon: > > > https://github.com/shamazmazum/nss-zero-dns > > > > > > You need to modify /etc/nsswitch.conf, changing the line 'hosts: files > > dns' > > > to 'hosts: files dns zerodns'. > > > > > > It all works on FreeBSD 12.2-RELEASE, but sometimes not on 13.0-CURRENT. > > > For example, ping(8) just blocks when trying to ping a host whose name is > > > resolvable with ZeroDNS. Turns out that programs built with casper > > support > > > (like ping(8) and some others) stop working with my NSS module (they just > > > block trying to resolve the name). > > > > Presumably it's the casper process (i.e., cap_dns) that uses your > > module? If the main ping process is blocked trying to resolve a name, > > it's waiting for the cap_dns process - where exactly is it getting > > stuck? > > > > > Is there some kind of manual on how to write casper-compatible NSS > > modules? > >