You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "SPRESENSE (via GitHub)" <gi...@apache.org> on 2023/09/14 07:48:33 UTC

[GitHub] [nuttx] SPRESENSE opened a new pull request, #10622: libs:netdb: Restrict DNS query types

SPRESENSE opened a new pull request, #10622:
URL: https://github.com/apache/nuttx/pull/10622

   ## Summary
   Corresponds to the problem of name resolution with different IP address types in networks where only one of IPv4 or IPv6 can be used due to physical layer reasons (e.g., LTE networks).
   
   ## Impact
   DNS client.
   
   ## Testing
   Test with Spresense LTE board.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #10622: libs:netdb: Restrict DNS query types

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #10622:
URL: https://github.com/apache/nuttx/pull/10622#discussion_r1325899189


##########
include/nuttx/net/dns.h:
##########
@@ -247,6 +247,16 @@ int dns_register_notify(dns_callback_t callback, FAR void *arg);
 
 int dns_unregister_notify(dns_callback_t callback, FAR void *arg);
 
+/****************************************************************************
+ * Name: dns_set_queryaddrtype
+ *
+ * Description:
+ *   Configure the address type to be used for queries.
+ *
+ ****************************************************************************/
+
+int dns_set_queryaddrtype(sa_family_t addrtype);

Review Comment:
   ```suggestion
   int dns_set_queryfamily(sa_family_t addrtype);
   ```



##########
libs/libc/netdb/lib_dnsqueryaddrtype.c:
##########
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * libs/libc/netdb/lib_dnsqueryaddrtype.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <errno.h>
+#include <assert.h>
+#include <debug.h>
+
+#include "netdb/lib_dns.h"
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static int g_query_addrtype = AF_UNSPEC;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: dns_isavail_queryaddrtype
+ *
+ * Description:
+ *   Determine if the specified address type is available for DNS query.
+ *
+ ****************************************************************************/
+
+bool dns_isavail_queryaddrtype(sa_family_t addrtype)

Review Comment:
   ```suggestion
   bool dns_is_queryfamily(sa_family_t addrtype)
   ```



##########
libs/libc/netdb/CMakeLists.txt:
##########
@@ -55,6 +55,7 @@ if(CONFIG_LIBC_NETDB)
     list(APPEND SRCS lib_dnsinit.c lib_dnsbind.c lib_dnsquery.c)
     list(APPEND SRCS lib_dnsaddserver.c lib_dnsdefaultserver.c)
     list(APPEND SRCS lib_dnsforeach.c lib_dnsnotify.c)
+    list(APPEND SRCS lib_dnsqueryaddrtype.c)

Review Comment:
   ```suggestion
       list(APPEND SRCS lib_dnsqueryfamily.c)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] SPRESENSE commented on pull request #10622: libs:netdb: Restrict DNS query types

Posted by "SPRESENSE (via GitHub)" <gi...@apache.org>.
SPRESENSE commented on PR #10622:
URL: https://github.com/apache/nuttx/pull/10622#issuecomment-1720406768

   @xiaoxiang781216 
   I fix it. Please review again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] SPRESENSE commented on pull request #10622: libs:netdb: Restrict DNS query types

Posted by "SPRESENSE (via GitHub)" <gi...@apache.org>.
SPRESENSE commented on PR #10622:
URL: https://github.com/apache/nuttx/pull/10622#issuecomment-1720739378

   @xiaoxiang781216
   I fix it. Please review again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #10622: libs:netdb: Restrict DNS query types

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #10622:
URL: https://github.com/apache/nuttx/pull/10622#discussion_r1326724992


##########
libs/libc/netdb/lib_dnsqueryfamily.c:
##########
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * libs/libc/netdb/lib_dnsqueryfamily.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <errno.h>
+#include <assert.h>
+#include <debug.h>
+
+#include "netdb/lib_dns.h"
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static int g_query_family = AF_UNSPEC;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: dns_is_queryfamily
+ *
+ * Description:
+ *   Determine if the specified address family is available for DNS query.
+ *
+ ****************************************************************************/
+
+bool dns_is_queryfamily(sa_family_t family)
+{
+  DEBUGASSERT(family == AF_INET || family == AF_INET6);
+
+  return (g_query_family == AF_UNSPEC) ? true :

Review Comment:
   ```suggestion
     return g_query_family == AF_UNSPEC ||  g_query_family  == family:
   ```



##########
libs/libc/netdb/lib_dnsqueryfamily.c:
##########
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * libs/libc/netdb/lib_dnsqueryfamily.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <errno.h>
+#include <assert.h>
+#include <debug.h>
+
+#include "netdb/lib_dns.h"
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static int g_query_family = AF_UNSPEC;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: dns_is_queryfamily
+ *
+ * Description:
+ *   Determine if the specified address family is available for DNS query.
+ *
+ ****************************************************************************/
+
+bool dns_is_queryfamily(sa_family_t family)
+{
+  DEBUGASSERT(family == AF_INET || family == AF_INET6);
+
+  return (g_query_family == AF_UNSPEC) ? true :
+         (g_query_family == family);
+}
+
+/****************************************************************************
+ * Name: dns_set_queryfamily
+ *
+ * Description:
+ *   Configure the address family to be used for queries.
+ *
+ ****************************************************************************/
+
+int dns_set_queryfamily(sa_family_t family)
+{
+  int ret = OK;
+
+  switch (family)
+    {
+#ifdef CONFIG_NET_IPv4
+      case AF_INET:
+#endif
+#ifdef CONFIG_NET_IPv6
+      case AF_INET6:
+#endif
+      case AF_UNSPEC:
+        dns_lock();
+        g_query_family = family;
+        dns_unlock();
+        ninfo("Configure address type for dns query: %d\n", family);
+        break;
+      default:
+        nerr("ERROR: Unsupported family: %d\n", family);
+        ret = -ENOSYS;
+        break;
+    }
+
+#if CONFIG_NETDB_DNSCLIENT_ENTRIES > 0
+  dns_clear_answer();

Review Comment:
   should we skip clear if family isn't changed?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on pull request #10622: libs:netdb: Restrict DNS query types

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #10622:
URL: https://github.com/apache/nuttx/pull/10622#issuecomment-1719022280

   Please fix the error:
   ```
   /usr/bin/ld: nuttx.rel: in function `dns_query_callback':
   /github/workspace/sources/nuttx/libs/libc/netdb/lib_dnsquery.c:646: undefined reference to `dns_isavail_queryaddrtype'
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 merged pull request #10622: libs:netdb: Restrict DNS query types

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #10622:
URL: https://github.com/apache/nuttx/pull/10622


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] SPRESENSE commented on a diff in pull request #10622: libs:netdb: Restrict DNS query types

Posted by "SPRESENSE (via GitHub)" <gi...@apache.org>.
SPRESENSE commented on code in PR #10622:
URL: https://github.com/apache/nuttx/pull/10622#discussion_r1326848195


##########
libs/libc/netdb/lib_dnsqueryfamily.c:
##########
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * libs/libc/netdb/lib_dnsqueryfamily.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <errno.h>
+#include <assert.h>
+#include <debug.h>
+
+#include "netdb/lib_dns.h"
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static int g_query_family = AF_UNSPEC;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: dns_is_queryfamily
+ *
+ * Description:
+ *   Determine if the specified address family is available for DNS query.
+ *
+ ****************************************************************************/
+
+bool dns_is_queryfamily(sa_family_t family)
+{
+  DEBUGASSERT(family == AF_INET || family == AF_INET6);
+
+  return (g_query_family == AF_UNSPEC) ? true :
+         (g_query_family == family);
+}
+
+/****************************************************************************
+ * Name: dns_set_queryfamily
+ *
+ * Description:
+ *   Configure the address family to be used for queries.
+ *
+ ****************************************************************************/
+
+int dns_set_queryfamily(sa_family_t family)
+{
+  int ret = OK;
+
+  switch (family)
+    {
+#ifdef CONFIG_NET_IPv4
+      case AF_INET:
+#endif
+#ifdef CONFIG_NET_IPv6
+      case AF_INET6:
+#endif
+      case AF_UNSPEC:
+        dns_lock();
+        g_query_family = family;
+        dns_unlock();
+        ninfo("Configure address type for dns query: %d\n", family);
+        break;
+      default:
+        nerr("ERROR: Unsupported family: %d\n", family);
+        ret = -ENOSYS;
+        break;
+    }
+
+#if CONFIG_NETDB_DNSCLIENT_ENTRIES > 0
+  dns_clear_answer();

Review Comment:
   Yes. We should skip it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org