Skip to content

gnrc_ipv6_nib: Add capability to handle and send RDNSS option#8646

Merged
smlng merged 7 commits intoRIOT-OS:masterfrom
miri64:gnrc/enh/dns-config
Jul 5, 2018
Merged

gnrc_ipv6_nib: Add capability to handle and send RDNSS option#8646
smlng merged 7 commits intoRIOT-OS:masterfrom
miri64:gnrc/enh/dns-config

Conversation

@miri64
Copy link
Copy Markdown
Member

@miri64 miri64 commented Feb 27, 2018

Contribution description

With the RDNSS option sock_dns can be auto-configured by the administrative router (either the border router or the upstream router configuring the border router).

Also some fixes/convenience enhancements to sock_dns and sock_util piggy-backed.

Issues/PRs references

None

@miri64 miri64 added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: network Area: Networking Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties GNRC labels Feb 27, 2018
@miri64 miri64 assigned kaspar030, smlng and bergzand and unassigned kaspar030 and smlng Feb 27, 2018
@miri64 miri64 force-pushed the gnrc/enh/dns-config branch from bf067c5 to 44529ea Compare June 4, 2018 13:20
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jun 4, 2018

Ping @bergzand @kaspar030 @smlng this would allow us to finally include DNS into gnrc_networking ;-).

USEMODULE += sock_util
endif

ifneq (,$(filter sock_util,$(USEMODULE)))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems unrelated, at least for this PR its usage is unclear

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit is describing the change sufficiently enough IMHO: 3b79b2c

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But to explain it more in-depth: sock_util requires POSIX, but this wasn't declared when it was introduced. This PR uses sock_util via sock_dns and thus the module is not compilable if the user does not explicitly include posix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #9498

return pkt;
}

gnrc_pktsnip_t *gnrc_ndp_opt_rdnss_build(uint32_t ltime, ipv6_addr_t *addrs,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is only used with GNRC_IPV6_NIB_CONF_DNS, IMHO the internal #if is not needed, but compiler might complain about unused function if DNS is not used?!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a public function. The unused function warning does not apply here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried without the '#if` guard and it works so no need for this ugly construct. Hence, you can remove the preprocessor if and omit the else path for unused params.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then it will be compiled in, when we don't use DNS...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(aka the code size will be affected)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. It isn't. Will remove.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, just wanted to report the same:

this PR

55104	    508	  14972	  70584	  113b8	/RIOT/tests/gnrc_sock_dns/bin/samr21-xpro/tests_gnrc_sock_dns.elf
47108	    144	   7252	  54504	   d4e8	/RIOT/tests/gnrc_ipv6_nib/bin/samr21-xpro/tests_gnrc_ipv6_nib.elf

without pre-if

55104	    508	  14972	  70584	  113b8	/RIOT/tests/gnrc_sock_dns/bin/samr21-xpro/tests_gnrc_sock_dns.elf
47108	    144	   7252	  54504	   d4e8	/RIOT/tests/gnrc_ipv6_nib/bin/samr21-xpro/tests_gnrc_ipv6_nib.elf

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ;-)

#define DNS_MIN_REPLY_LEN (unsigned)(sizeof(sock_dns_hdr_t ) + 7)

/* global DNS server UDP endpoint */
sock_udp_ep_t sock_dns_server;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is one global DNS server sufficient?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hoped that this could be const for some use-cases, but I'm OK with moving it here for now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is one global DNS server sufficient?

For now it should be. Your local LAN usually also is happy with just one ;-).

}
else {
evtimer_del(&_nib_evtimer, &_rdnss_timeout.event);
memset(&sock_dns_server, 0, sizeof(sock_dns_server));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this use _handle_rdnss_timeout too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure, if replacing one function with another calling that function makes a difference, but if you insist...

Copy link
Copy Markdown
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK for the changes to sock_dns.

#define DNS_MIN_REPLY_LEN (unsigned)(sizeof(sock_dns_hdr_t ) + 7)

/* global DNS server UDP endpoint */
sock_udp_ep_t sock_dns_server;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hoped that this could be const for some use-cases, but I'm OK with moving it here for now.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jun 5, 2018

Adressed comments.

@tcschmidt
Copy link
Copy Markdown
Member

@smlng agree?

@miri64 miri64 force-pushed the gnrc/enh/dns-config branch from 8bfc522 to b365d4a Compare June 21, 2018 12:37
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jun 21, 2018

Rebased

@smlng
Copy link
Copy Markdown
Member

smlng commented Jun 22, 2018

please squash

#if GNRC_IPV6_NIB_CONF_DNS
static void _handle_rdnss_timeout(sock_udp_ep_t *dns_server)
{
memset(&dns_server, 0, sizeof(sock_udp_ep_t));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dns_server is a pointer already, hence should be memset(dns_server, 0, sizeof(sock_udp_ep_t));? at least on macOS I get compile error:

/RIOT/sys/net/gnrc/network_layer/ipv6/nib/nib.c:1255:5: error: '__builtin___memset_chk' will always overflow destination buffer [-Werror,-Wbuiltin-memcpy-chk-size]
    memset(&dns_server, 0, sizeof(sock_udp_ep_t));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/secure/_string.h:76:3: note: expanded from macro 'memset'
                __builtin___memset_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops (but what did you use to compile that finds this type confusion)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS -> clang

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really should start having a clang config for the CI ;-).

*/
static void _handle_mtuo(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
const ndp_opt_mtu_t *mtuo);
static uint32_t _handle_rdnsso(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be guarded with #if GNRC_IPV6_NIB_CONF_DNS, got error:

/RIOT/sys/net/gnrc/network_layer/ipv6/nib/nib.c:405:17: error: unused function '_handle_rdnsso' [-Werror,-Wunused-function]
static uint32_t _handle_rdnsso(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
                ^
1 error generated.

otherwise

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

return pkt;
}

gnrc_pktsnip_t *gnrc_ndp_opt_rdnss_build(uint32_t ltime, ipv6_addr_t *addrs,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried without the '#if` guard and it works so no need for this ugly construct. Hence, you can remove the preprocessor if and omit the else path for unused params.

}
}
}
#if SOCK_HAS_IPV6
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this make sense, I would assume if GNRC_IPV6_NIB_CONF_DNS is true, we have IPv6 support?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IPv6-support for sock is independent of GNRC's inclusion of GNRC. So it makes sense.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from sys/Makefile.include:

ifneq (,$(filter gnrc_sock,$(USEMODULE)))
  USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/gnrc/sock/include
  ifneq (,$(filter gnrc_ipv6,$(USEMODULE)))
    CFLAGS += -DSOCK_HAS_IPV6
  endif
endif

Hence, I would (recursively) resolve/deduce GNRC_IPV6_NIB_CONF_DNS -> GNRC_IPV6 -> SOCK_HAS_IPV6.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather prefer to keep the dependency explicit as it is instead of implicit, which addressing this change would make it.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jun 22, 2018

Adressed comments.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jun 22, 2018

May I squash?

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jul 4, 2018

Ping?

Copy link
Copy Markdown
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK, works with tests/gnrc_sock_dns on native according to readme. Note: one problem I had was that the firewall on Fedora is active by default and blocks DNS, after explicitly allowing DNS on tap0 it work as expected.

@smlng
Copy link
Copy Markdown
Member

smlng commented Jul 5, 2018

please squash, and trigger CI when ready.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jul 5, 2018

Should I either rebase to #9498 now or close #9498?

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jul 5, 2018

Rebased Squashed. I really don't care either way regarding my question.

@miri64 miri64 force-pushed the gnrc/enh/dns-config branch from f050cb6 to fa9315a Compare July 5, 2018 08:23
@smlng
Copy link
Copy Markdown
Member

smlng commented Jul 5, 2018

I would rather go for rebase, I just ACKed #9498 so we can move both forward. IMHO its better to have the dependency update separate, okay?

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jul 5, 2018

Okay!

@miri64 miri64 force-pushed the gnrc/enh/dns-config branch from fa9315a to b0fb99d Compare July 5, 2018 09:01
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jul 5, 2018

Rebased! :-)

@miri64 miri64 force-pushed the gnrc/enh/dns-config branch from b0fb99d to 95c1992 Compare July 5, 2018 09:09
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jul 5, 2018

Fixed and squashed error reported by Travis.

@miri64 miri64 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jul 5, 2018
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jul 5, 2018

@smlng Ok to merge?

@smlng smlng merged commit dd16562 into RIOT-OS:master Jul 5, 2018
@miri64 miri64 deleted the gnrc/enh/dns-config branch July 5, 2018 11:09
@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jul 5, 2018

🎉

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Jul 5, 2018

@danpetry @bergzand now that this is merged, this might help you with your respective works (if the RAdvD is configured correctly [@smlng maybe something to consider to put in the example config @RIOT-Makers?] and the applications you write use sock_dns).

@cladmi cladmi added this to the Release 2018.07 milestone Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants