From patchwork Tue Feb 22 09:07:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: patchwork-bot+netdevbpf--- via dev X-Patchwork-Id: 1595962 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=Be7zyszc; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K2ypT6nbRz9sGC for ; Tue, 22 Feb 2022 23:17:05 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 1635260EBF; Tue, 22 Feb 2022 12:17:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id W-GT6nMtg6ur; Tue, 22 Feb 2022 12:17:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 13E9660B83; Tue, 22 Feb 2022 12:17:01 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D3855C001A; Tue, 22 Feb 2022 12:17:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 91F87C0011 for ; Tue, 22 Feb 2022 09:07:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 714F5408B8 for ; Tue, 22 Feb 2022 09:07:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=qq.com Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rTrp1RiTxuCG for ; Tue, 22 Feb 2022 09:07:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from out203-205-251-60.mail.qq.com (out203-205-251-60.mail.qq.com [203.205.251.60]) by smtp4.osuosl.org (Postfix) with ESMTPS id 121654089B for ; Tue, 22 Feb 2022 09:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1645520836; bh=9UhkQ3KKj6LOCz7OLQR9gI1OwQWnlBiVkxKqjyu3mX8=; h=From:To:Cc:Subject:Date; b=Be7zyszcinCNkbgke5qW5Eb9gAgDXo1h/rw2FZoOYiB1Fi5Fdtbdw5a0PiNxHX45r kRbvG7LAnMd4xhHFRYPFpXPKsK8qGIMg1Dkda+2xeQ/aGfkx4bT8mGWg3cDSgV+n+A jqKliG5oGEH2NPbV+xQ6pBMtXNHSWZ989sAZ5eBk= Received: from zydev.localdomain ([117.160.246.157]) by newxmesmtplogicsvrsza8.qq.com (NewEsmtp) with SMTP id 1CF1DE3C; Tue, 22 Feb 2022 17:07:15 +0800 X-QQ-mid: xmsmtpt1645520835t669eomr8 Message-ID: X-QQ-XMAILINFO: NV9lVvsB36Op1tovXwVvhzQSnB8XFCiYYCZqcwNXjgH7zetrY73BaDNp/fR3+w ykfiI0VrvnNMWt2faEdMTl/NlEMIuumh7IliJGHdKW3Cluu3XIPnu80d1uHRkVd3RSQUFlHOleuQ Z6OD0eomRWPjUS74fV4hFX8EGYP44nHe+BRBSjOm++Kh+zTX4f+OJkMEbD3+AVtM+eKp4mnRvVBG iBuhJ48oBKWzUtrnQtDHuox8BLKqoVFlhxEBxYwdO4QfpMlpeAu5wabTg2QFSCs+Q6eukT7ji8RB bWexkV9yCMn7gEq29tZdXNZJmSB2xBx9g1dLhHjmnBaiH3yPrIlyXwse0P8hcbsak28R/8Ik6bbw rpFlGlIPMYM+P6NNZhthB9ib1W4jKsN4bqISSXFLY+gR/WKcWz6yh2rfIgNo7WTZ8BL6ZcWygT74 4mhmiJApIMG8yfvr67N1QVFCdQVPuYCrri235W51uzPlPSVtAi2Uu1F1DOMqgFYo3k4oG/TBA6rQ xmJDwMx2EWRB/f+xFq/0NskFIsKE0tJ5v8fWxhNJehfJfN+iDYjgtDnDc0GOfJatyh67TlBRHryZ zEGxmiXPk9SR/2dfrObyueRdQquxLfkY1V3Pp6pGUaYCLNGE2EJmxwi7F8PyMm+dEbwDz7KTKQyU R93e0/y90+xUDUX5qHjFisHa/W2+pBSHrADldWgcFlpsZ/LNRGkvqlBN9AePVzJido1tBixSKEzL /0qS4EonHYz9asbJWjsw4YgS1xrj2c2Ac9/PsH9/uzOBhFgNwAu0aErCfcfR1x9JahIBxKJpN06+ EIyJS4eob1k2RzYADkA8BkoV2yKJOyLXZt56sFP07eSIajbZyO6wiEQsuxqAX9BAZ3irVALWtUxf pmcEZ8wy6RYjGj/KSDDjXatDFmb8IBbQ== To: dev@openvswitch.org Date: Tue, 22 Feb 2022 04:07:13 -0500 X-OQ-MSGID: <1645520834-15976-1-git-send-email-294754599@qq.com> X-Mailer: git-send-email 1.8.3.1 X-Mailman-Approved-At: Tue, 22 Feb 2022 12:16:59 +0000 Cc: Yuan-96 <294754599@qq.com> Subject: [ovs-dev] [PATCH ovn] pinctrl: give a 'no such name' response when no DNS record is available X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: 294754599--- via dev From: patchwork-bot+netdevbpf--- via dev Reply-To: 294754599@qq.com MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Yuan-96 <294754599@qq.com> While the CentOS 8 requests an IPv4 DNS record, the response will be slow without a correct IPv6 DNS record on server. It will send a DNS request(type AAAA) message first but ovn controller will not reply. And the DNS request(type A) message will be sent until DNS request(type AAAA) is timeout. So the DNS client may expect to receive a reponse with RCODE 3(RFC1035. Name Error) instead of nothing when DNS record is not available. And this patch is for that. Signed-off-by: Yuan-96 <294754599@qq.com> --- controller/pinctrl.c | 72 +++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index 1b8b475..a2fc1a2 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -2952,47 +2952,41 @@ pinctrl_handle_dns_lookup( } ds_destroy(&query_name); - if (!answer_data) { - goto exit; - } - uint16_t ancount = 0; - uint64_t dns_ans_stub[128 / 8]; - struct ofpbuf dns_answer = OFPBUF_STUB_INITIALIZER(dns_ans_stub); + if (answer_data) { + uint16_t ancount = 0; + uint64_t dns_ans_stub[128 / 8]; + struct ofpbuf dns_answer = OFPBUF_STUB_INITIALIZER(dns_ans_stub); - if (query_type == DNS_QUERY_TYPE_PTR) { - dns_build_ptr_answer(&dns_answer, in_queryname, idx, answer_data); - ancount++; - } else { - struct lport_addresses ip_addrs; - if (!extract_ip_addresses(answer_data, &ip_addrs)) { - goto exit; - } + if (query_type == DNS_QUERY_TYPE_PTR) { + dns_build_ptr_answer(&dns_answer, in_queryname, idx, answer_data); + ancount++; + } else { + struct lport_addresses ip_addrs; + if (!extract_ip_addresses(answer_data, &ip_addrs)) { + goto exit; + } - if (query_type == DNS_QUERY_TYPE_A || - query_type == DNS_QUERY_TYPE_ANY) { - for (size_t i = 0; i < ip_addrs.n_ipv4_addrs; i++) { - dns_build_a_answer(&dns_answer, in_queryname, idx, - ip_addrs.ipv4_addrs[i].addr); - ancount++; + if (query_type == DNS_QUERY_TYPE_A || + query_type == DNS_QUERY_TYPE_ANY) { + for (size_t i = 0; i < ip_addrs.n_ipv4_addrs; i++) { + dns_build_a_answer(&dns_answer, in_queryname, idx, + ip_addrs.ipv4_addrs[i].addr); + ancount++; + } } - } - if (query_type == DNS_QUERY_TYPE_AAAA || - query_type == DNS_QUERY_TYPE_ANY) { - for (size_t i = 0; i < ip_addrs.n_ipv6_addrs; i++) { - dns_build_aaaa_answer(&dns_answer, in_queryname, idx, - &ip_addrs.ipv6_addrs[i].addr); - ancount++; + if (query_type == DNS_QUERY_TYPE_AAAA || + query_type == DNS_QUERY_TYPE_ANY) { + for (size_t i = 0; i < ip_addrs.n_ipv6_addrs; i++) { + dns_build_aaaa_answer(&dns_answer, in_queryname, idx, + &ip_addrs.ipv6_addrs[i].addr); + ancount++; + } } + destroy_lport_addresses(&ip_addrs); } - destroy_lport_addresses(&ip_addrs); - } - - if (!ancount) { - ofpbuf_uninit(&dns_answer); - goto exit; } uint16_t new_l4_size = ntohs(in_udp->udp_len) + dns_answer.size; @@ -3023,6 +3017,12 @@ pinctrl_handle_dns_lookup( /* Set the response bit to 1 in the flags. */ out_dns_header->lo_flag |= 0x80; + if (ancount == 0) { + /*Set the reply code bits to 0011 in the flags + *when here is no dns record. */ + out_dns_header->hi_flag |= 0x03; + } + /* Set the answer RRs. */ out_dns_header->ancount = htons(ancount); out_dns_header->arcount = 0; @@ -3030,8 +3030,10 @@ pinctrl_handle_dns_lookup( /* Copy the Query section. */ dp_packet_put(&pkt_out, dp_packet_data(pkt_in), dp_packet_size(pkt_in)); - /* Copy the answer sections. */ - dp_packet_put(&pkt_out, dns_answer.data, dns_answer.size); + if (dns_answer.size > 0) { + /* Copy the answer sections. */ + dp_packet_put(&pkt_out, dns_answer.data, dns_answer.size); + } ofpbuf_uninit(&dns_answer); out_udp->udp_len = htons(new_l4_size);