Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dhcpv6_client: add DNS recursive name server option handling #16585

Merged
merged 1 commit into from
Jun 25, 2021

Conversation

miri64
Copy link
Member

@miri64 miri64 commented Jun 24, 2021

Contribution description

Now that I finally have IPv6 at home, I started playing around with configuring my OpenWRT as a 6LoWPAN border router, using an nrf52840dongle with cdc-ecm as the actual border router.

It took me a while to remember that I also can get the DNS server information from the WRT's router advertisements using the gnrc_ipv6_nib_dns, so I added this optional feature to the DHCPv6 client.

Testing procedure

Compile the border router example with DHCPv6 with dhcpv6_client_dns and sock_dns, flash it, and wait until the DHCPv6 initialization is completed (you can check by looking at the 6LoWPAN interface; when it has a global address the procedure is complete). Given that you have your DHCPv6 server and firewall configured properly, you should now be able to ping a host name from the border router (did not test from downstream nodes as there are currently other problems in my network preventing that... but that would be unrelated from this PR anyway since that config would not come via DHCPv6).

Here is the excerpt from my home setup:

$ UPLINK=cdc-ecm BOARD=nrf52840dongle USEMODULE="sock_dns" USE_DHCPV6=1 QUIETER=1 make -C examples/gnrc_border_router/ flash -j
make: Entering directory '/home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_border_router'
Building application "gnrc_border_router" for "nrf52840dongle" with MCU "nrf52".

stty -F /dev/ttyACM0 raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255
sleep 1
   text	   data	    bss	    dec	    hex	filename
  87916	    240	  25868	 114024	  1bd68	/home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_border_router/bin/nrf52840dongle/gnrc_border_router.elf
nrfutil pkg generate --hw-version 52 --sd-req 0x00 --application-version 1 --application /home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_border_router/bin/nrf52840dongle/gnrc_border_router.hex /home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_border_router/bin/nrf52840dongle/gnrc_border_router.hex.zip

|===============================================================|
|##      ##    ###    ########  ##    ## #### ##    ##  ######  |
|##  ##  ##   ## ##   ##     ## ###   ##  ##  ###   ## ##    ## |
|##  ##  ##  ##   ##  ##     ## ####  ##  ##  ####  ## ##       |
|##  ##  ## ##     ## ########  ## ## ##  ##  ## ## ## ##   ####|
|##  ##  ## ######### ##   ##   ##  ####  ##  ##  #### ##    ## |
|##  ##  ## ##     ## ##    ##  ##   ###  ##  ##   ### ##    ## |
| ###  ###  ##     ## ##     ## ##    ## #### ##    ##  ######  |
|===============================================================|
|You are not providing a signature key, which means the DFU     |
|files will not be signed, and are vulnerable to tampering.     |
|This is only compatible with a signature-less bootloader and is|
|not suitable for production environments.                      |
|===============================================================|

Zip created at /home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_border_router/bin/nrf52840dongle/gnrc_border_router.hex.zip
nrfutil dfu usb-serial --port=/dev/ttyACM0 --package=/home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_border_router/bin/nrf52840dongle/gnrc_border_router.hex.zip
  [####################################]  100%          
Device programmed.
make: Leaving directory '/home/mlenders/Repositories/RIOT-OS/RIOT/examples/gnrc_border_router'

Unplug dongle and plug it to OpenWRT router

$ ssh "<openwrt_router>"
# dmesg
[…]
[163858.252830] cdc_acm 1-1.2:1.0: ttyACM0: USB ACM device
[163858.270239] cdc_ether 1-1.2:1.2 usb0: register 'cdc_ether' at usb-1b000000.usb-1.2, CDC Ethernet Device, XX:XX:XX:XX:XX:XX
[…]
# ip link show dev usb0
83: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
# picocom --nolock --imap lfcrlf --baud 115200 /dev/ttyACM0
picocom v3.1

port is        : /dev/ttyACM0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
hangup is      : no
nolock is      : yes
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : lfcrlf,
omap is        : 
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

Type [C-a] [C-h] to see available commands
Terminal ready
ifconfig
Iface  7  HWaddr: 57:64  Channel: 26  NID: 0x23  PHY: O-QPSK 
          Long HWaddr: BA:F0:25:3A:6F:23:57:64 
           State: IDLE 
          ACK_REQ  L2-PDU:102  MTU:1280  HL:64  RTR  
          RTR_ADV  6LO  IPHC  
          Source address length: 8
          Link type: wireless
          inet6 addr: fe80::b8f0:253a:6f23:5764  scope: link  VAL
          inet6 addr: 2a01:5241:28c:1f14:b8f0:253a:6f23:5764  scope: global  VAL
          inet6 group: ff02::2
          inet6 group: ff02::1
          inet6 group: ff02::1:ff23:5764
          
Iface  6  HWaddr: 7A:10:C2:67:B2:24 
          L2-PDU:1500  MTU:1500  HL:64  RTR  
          Source address length: 6
          Link type: wired
          inet6 addr: fe80::7810:c2ff:fe67:b224  scope: link  VAL
          inet6 addr: 2a01:5241:28c:1f10:7810:c2ff:fe67:b224  scope: global  VAL
          inet6 group: ff02::2
          inet6 group: ff02::1
          inet6 group: ff02::1:ff67:b224
          
> ping riot-os.org
12 bytes from 2001:67c:254:b0b0::1: icmp_seq=0 ttl=57 time=30.069 ms
12 bytes from 2001:67c:254:b0b0::1: icmp_seq=1 ttl=57 time=24.455 ms
12 bytes from 2001:67c:254:b0b0::1: icmp_seq=2 ttl=57 time=26.435 ms

--- riot-os.org PING statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 24.455/26.986/30.069 ms

Issues/PRs references

Signed-off-by: Martine Lenders <m.lenders@fu-berlin.de>
@miri64 miri64 added Area: network Area: Networking Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Jun 24, 2021
@miri64 miri64 requested a review from benpicco June 24, 2021 14:02
@github-actions github-actions bot added Area: build system Area: Build system Area: sys Area: System labels Jun 24, 2021
sock_dns_server.netif = netif;
memcpy(sock_dns_server.addr.ipv6, opt->dns_rns,
sizeof(sock_dns_server.addr.ipv6));
return;
Copy link
Member Author

Choose a reason for hiding this comment

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

The idea behind this return is that maybe other DNS client implementations could be added after this.

Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

Works with gnrc_dhcpv6_client_simple_pd and sock_dns, without gnrc_ipv6_nib_dns

@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 Jun 24, 2021
@miri64 miri64 merged commit 472a8d1 into RIOT-OS:master Jun 25, 2021
@miri64 miri64 deleted the dhcpv6_client_dns/feat/init branch June 25, 2021 08:17
@MrKevinWeiss MrKevinWeiss added this to the Release 2021.07 milestone Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants