From patchwork Fri Aug 26 11:40:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldvogel X-Patchwork-Id: 1670686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=NQR6UQMK; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=I1x24Gpt; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MDdJx5GkYz1yhX for ; Fri, 26 Aug 2022 21:44:01 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=W2NYM8hjTcipt+H56jG6xS6BP0grlbfLKeaQmG/ADu0=; b=NQR6UQMKJqzI6g TsaliVmAGayZ8Haxd+KW5LFxGRWe2muDmhICmAi6UvqhC/mTnyvUuHdim7O6p4VlnbPiCkkYhV1P2 R8N1IHD82zc3s+40W7CZ0Y8ZrLf+50W6LkkhLj1e6R88pn8f0aIB9thnuOKOy+7SU1O+ewrWpRBhd KsepTg3oTfFOa0Mb2Qh8wHyiTMzrKz9oEN7R0BLzM7CRFw2HNNND4MfFw88r1dLAaWocf2lM0XKMk uy6AwQUY4mFTumDJYETHHmVWU6ziijYtQrOswquiSd9HmLWEb/UbWzp1zro44+XJStb+INqv9H6cU iSjc+uMABzIwa6jTsVLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oRXi4-002611-Fa; Fri, 26 Aug 2022 11:41:12 +0000 Received: from mail-vk1-xa35.google.com ([2607:f8b0:4864:20::a35]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oRXi1-0025zJ-CC for openwrt-devel@lists.openwrt.org; Fri, 26 Aug 2022 11:41:10 +0000 Received: by mail-vk1-xa35.google.com with SMTP id w129so524276vkg.10 for ; Fri, 26 Aug 2022 04:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc; bh=qWe4uRHoRWWo+8C8Su4HCmpW17M8rTASRJPvjHIdSFw=; b=I1x24GptHmTosM9WnEBG31htEOgbHNngnD+WymKjP9bz6t3odJo+UgWN+OSE/G6m5W a2Vn9M7Ie65H1H1Zr2PMywojkoAc15UhUnj4KB73RRxxMwgHLRaUuVlZmEvnwIyPZUXk ECYIO/za4Kb2zjq7YFaWNKDMaKpLzUnMjb90wWVrIq0ouYCS19kC4Lqpcqkd6Vt3gjWL cWbaBaE0SO1ML6RFxAS/N2YkkSOTRnMwLeW/8R7mZlFeGQKWq9HTHjKb7dGieChRHtMY iq3Ft3MO4099JbIwXmvSsx6ceLyYxBKfzJigZrYDeg5vReaRwxYCdWqSeDC+mmTlWf0X xlpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc; bh=qWe4uRHoRWWo+8C8Su4HCmpW17M8rTASRJPvjHIdSFw=; b=fdP0+77V4Q6YutrJ/UI3lT1soB1HuevAF8+pdSoQqlKpbQJvq2rOdU03McVmhvRT8W hbUySU4xjsB3I8H6UuxZmChiVPjh4jZe1iLCdY73rZpatDhh85j18NZsFVXnW63W5sGX ppfAHYKKyhF+YTFllc1MTQRU3XmVf7CWtb6cmzMRoZ8OrUn+6DqzUDiehNr2mB+bHZg7 7b1C0QmGpARrUQl6OYWNC1z34iTotnY1HFqttBv+NrKsBhwVFOAm+jQKIlP4Kd20vclR +XLT4jNI87zth4VHTWhRuZzhaIGkfMKEVi07zlkQj7lSrEdp2gAG9Fh7yF97IyH/xtq8 gXZQ== X-Gm-Message-State: ACgBeo2wQWBQ5B/IGyXR9etMxVfLYnmuSQMWkvbX9GR3mebPZEMTKL62 Jgj0+tR+w6noXaQJYGRsm8IAsRtpqHEO+91aJUxSEY+CkE0= X-Google-Smtp-Source: AA6agR5yCZBaQeFfoFKkfv0sG2BwyVO2K+rWF8Tzib3FE5crucyZHjdbiZO8uNr/1SwsDlO3YhnZLBTv+KtHPSirf/k= X-Received: by 2002:a1f:1644:0:b0:378:c157:d0f5 with SMTP id 65-20020a1f1644000000b00378c157d0f5mr2825293vkw.5.1661514064221; Fri, 26 Aug 2022 04:41:04 -0700 (PDT) MIME-Version: 1.0 From: Tobias Waldvogel Date: Fri, 26 Aug 2022 13:40:53 +0200 Message-ID: Subject: [PATCH] umdns: add timeout_lookup parameter for services To: john@phrozen.org Cc: OpenWrt Development List X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220826_044109_459506_453B0BD0 X-CRM114-Status: GOOD ( 11.65 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Tobias Waldvogel Printing on Android devices via mdns IPP does not work with the default value of 60 seconds for the lookup timeout. It seems that Androd expects an immediate answer just when trying to print. Neverthe [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:a35 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [tobias.waldvogel[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Tobias Waldvogel Printing on Android devices via mdns IPP does not work with the default value of 60 seconds for the lookup timeout. It seems that Androd expects an immediate answer just when trying to print. Nevertheless the umdns debug messages show that the answer is supressed due to the timeout. As a result the printer does not show up. This patch implements an additional parameter timeout_lookup for setting a dedicated timeout value with a fallback to TOUT_LOOKUP (60s). This is a sample ipp service definition, which works now with Android standard printing: { "ipp": { "service": "_ipp._tcp.local", "instance": "HL3040CN @ router", "port": 631, "timeout_lookup": -1, "txt": [ "txtvers=1", "UUID=308f65f9-5393-3027-4c83-374cb704e729", "rp=printers/HL3040CN", "ty=Brother HL3040CN", "note=Office", "pdl=application/pdf,image/jpeg,image/png,image/pwg-raster", "Color=T", "Copies=T" ] } } Signed-off-by: Tobias Waldvogel --- [SERVICE_PORT] = { .name = "port", .type = BLOBMSG_TYPE_INT32 }, @@ -122,8 +125,8 @@ service_timeout(struct service *s) { time_t t = monotonic_time(); - if (t - s->t <= TOUT_LOOKUP) { - DBG(2, "t=%" PRId64 ", s->t=%" PRId64 ", t - s->t = %" PRId64 "\n", (int64_t)t, (int64_t)s->t, (int64_t)(t - s->t)); + if (t - s->t <= s->tout_lookup) { + DBG(2, "t=%" PRId64 ", s->t=%" PRId64 ", s->tout_lookup=%d, t - s->t = %" PRId64 "\n", (int64_t)t, (int64_t)s->t, s->tout_lookup, (int64_t)(t - s->t)); return 0; } @@ -239,6 +242,7 @@ service_load_blob(struct blob_attr *b) if (!s) return; + s->tout_lookup = _tb[SERVICE_TOUT_LOOKUP] ? blobmsg_get_u32(_tb[SERVICE_TOUT_LOOKUP]) : TOUT_LOOKUP; s->port = blobmsg_get_u32(_tb[SERVICE_PORT]); s->id = strncpy(d_id, blobmsg_name(b), n); if (_tb[SERVICE_INSTANCE]) diff --git a/service.c b/service.c index bd9f985..dc7f330 100644 --- a/service.c +++ b/service.c @@ -35,6 +35,7 @@ #include "announce.h" enum { + SERVICE_TOUT_LOOKUP, SERVICE_INSTANCE, SERVICE_SERVICE, SERVICE_PORT, @@ -51,12 +52,14 @@ struct service { const char *instance; const char *service; const uint8_t *txt; + int32_t tout_lookup; int txt_len; int port; int active; }; static const struct blobmsg_policy service_policy[__SERVICE_MAX] = { + [SERVICE_TOUT_LOOKUP] = { .name = "timeout_lookup", .type = BLOBMSG_TYPE_INT32 }, [SERVICE_INSTANCE] = { .name = "instance", .type = BLOBMSG_TYPE_STRING }, [SERVICE_SERVICE] = { .name = "service", .type = BLOBMSG_TYPE_STRING },