From owner-freebsd-net@freebsd.org Wed Jan 6 16:08:27 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 CB1104D57EC for ; Wed, 6 Jan 2021 16:08:27 +0000 (UTC) (envelope-from shamaz.mazum@gmail.com) Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) (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 4D9vRZ6l1xz4Vqt; Wed, 6 Jan 2021 16:08:26 +0000 (UTC) (envelope-from shamaz.mazum@gmail.com) Received: by mail-oi1-x235.google.com with SMTP id l200so3912768oig.9; Wed, 06 Jan 2021 08:08:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZfHzRkoRbCsAnA26zAknvTh+jyyaIThGXbm3bAnLCak=; b=TOrS4FiVcEA0RU7V3z4iZhRtaPsdCCMa+Wu+CYqA+UfVRXLMdnkxNpJ9Ot5mzorUqP s2sj5Sy6143prAi1tKq4xOjDilVfMCD6RND/IqTNlm609aDgrzOzEmKewzf14GyImzK3 4MjhUMAYjTPLP4ORO/4DEQkwObWkmYi6Xr+PLsoVUDU5BnBbGiF2ANZY/Wux9qxVf4pw 9FsxiC1ns8gzwTNYZtAej76vX0pB7lTtSv4LYz5ZqWMn/9H+QPsL7FSvciFQ92X1dSom yetRocVp8osJmJHntIowLgK08miWNpuWCYcIR5/Jp/aYULTv+yrYkuS+kzuJAib2aYGx y+8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZfHzRkoRbCsAnA26zAknvTh+jyyaIThGXbm3bAnLCak=; b=rM1D5w0htp2vsuxyPuW7DhpqdlqWGCkJAfHQ+jay+2r42fj5pgObbUv5LjvQPF/5Yr HkYC3wnvmNwB1lme0/BeZRMRtrkUPjvNZNQvqdVoNwjiOgkLCmK1xi4rq/lYR92N5HZ6 0uURf4vGCZJ00u9xraE4iXPD3ftLTEyL75EJycG45c1GH/DuIe+TnvSofLqIOJljf2Cg RYk1h65o9NP1p9cQINoitlQ+mXsurBGpxprhjU0chyJtZCqQqYaRLmm++RAPoSZCoA/8 0IfuvXWHItCFSoP/uAoSaOXPO+7aBQOHxI4TmwEoi/N7RRsKF/FmCV4KuSviDhueUMwS Gjaw== X-Gm-Message-State: AOAM530lf19v4z7ADXE1QAK6x2GSxZrLsWGF7e8ZtcMFO5PlTKStTxYT CHFBn2JMAGpcyBBJRDPZCTpXZK7+Tia/6jWOMRY+FWklCtu2WQ== X-Google-Smtp-Source: ABdhPJztlf2s9cMudnRbZKj4Y0NmyxsObLbxVq4g2FkoBfinnSloPjAUIovW9fZuSFHBNQrz++T9fQk4odzVTGn+JMk= X-Received: by 2002:aca:5589:: with SMTP id j131mr3736679oib.140.1609949305499; Wed, 06 Jan 2021 08:08:25 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Vasily Postnicov Date: Wed, 6 Jan 2021 19:08:14 +0300 Message-ID: Subject: Re: DNS using Name Service Switch module and Casper To: Mark Johnston Cc: freebsd-net@freebsd.org X-Rspamd-Queue-Id: 4D9vRZ6l1xz4Vqt X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=TOrS4FiV; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of shamazmazum@gmail.com designates 2607:f8b0:4864:20::235 as permitted sender) smtp.mailfrom=shamazmazum@gmail.com X-Spamd-Result: default: False [-4.00 / 15.00]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RBL_DBL_DONT_QUERY_IPS(0.00)[2607:f8b0:4864:20::235:from]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; TAGGED_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; 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)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; SPAMHAUS_ZRD(0.00)[2607:f8b0:4864:20::235:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::235:from]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-net] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.34 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: Wed, 06 Jan 2021 16:08:27 -0000 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? 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. All this is figured out by inserting printf()'s. LLDB refuses to run ping with 'error: Child exec failed'. =D0=B2=D1=82, 5 =D1=8F=D0=BD=D0=B2. 2021 =D0=B3. =D0=B2 17:43, Mark Johnsto= n : > 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 th= at > > 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 ju= st > > 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? >