Skip to content

odhcpd: ensure zero padding on DNSSL#386

Merged
openwrt-bot merged 1 commit intoopenwrt:masterfrom
efahl:ra-padding
Mar 16, 2026
Merged

odhcpd: ensure zero padding on DNSSL#386
openwrt-bot merged 1 commit intoopenwrt:masterfrom
efahl:ra-padding

Conversation

@efahl
Copy link
Copy Markdown
Contributor

@efahl efahl commented Mar 11, 2026

From https://www.rfc-editor.org/rfc/rfc8106#section-5.2 regarding the DNSSL field:

Because the size of this field MUST be a multiple of
8 octets, for the minimum multiple including the domain
name representations, the remaining octets other than the
encoding parts of the domain name representations MUST be
padded with zeros.

The current code leaves the trailing octets in uninitialized state, resulting in parsing errors on (at least) systemd RA clients. This commit restores the explicit zeroing of the trailing octets.

Fixes: 0a54ce0
Fixes: openwrt/openwrt#22351


Tested on x86/64 snapshot:

$ tcpdump -v -n -p 'icmp6[icmp6type] == icmp6-routeradvert' -i br-lan -X -s0
tcpdump: listening on br-lan, link-type EN10MB (Ethernet), snapshot length 262144 bytes
06:52:22.514144 IP6 (flowlabel 0x6e2ab, hlim 255, next-header ICMPv6 (58), payload length 256) fe80::7e2b:e1ff:fe13:73a8 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 256
...
          dnssl option (31), length 24 (3):  lifetime 5163s, domain(s): xxx.lan.
...
        0x0100:                      1f03 0000 0000 142b  ...............+
        0x0110:  0378 7878 036c 616e 0000 0000 0000 0000  .xxx.lan........

@efahl
Copy link
Copy Markdown
Contributor Author

efahl commented Mar 11, 2026

@hauke
This might be important for 25.12, as it caused issues for me on at least 3 Ubuntu servers (2x 22.04, 1x 24.04) which could not get IPv6 addresses due to systemd failing to parse the RAs when using local domain names.

@efahl
Copy link
Copy Markdown
Contributor Author

efahl commented Mar 11, 2026

As part of my preliminary investigation, I did a sanity check to make sure I understood where things were going by writing 0xdd instead of zeros into the DNSSL block. Here's what I saw on the test device:

dnssl option (31), length 24 (3):  lifetime 4727s, domain(s): wang.lan. <BAD PTR> [|icmp6]

0x0100:  0000 0000 0000 0001 1f03 0000 0000 1277  ...............w
0x0110:  0477 616e 6703 6c61 6e00 dddd dddd dddd  .wang.lan.......
0x0120:  0701 0000 0009 27c0                      ......'.

Note that with this failure to parse the DNSSL block, that the final advertisement interval option (7), length 8 (1): 600000ms block is ignored by tcpdump. I assume that systemd is doing likewise...

@efahl efahl changed the title odhcp: ensure zero padding on DNSSL odhcpd: ensure zero padding on DNSSL Mar 11, 2026
From https://www.rfc-editor.org/rfc/rfc8106#section-5.2 regarding
the DNSSL field:

  Because the size of this field MUST be a multiple of
  8 octets, for the minimum multiple including the domain
  name representations, the remaining octets other than the
  encoding parts of the domain name representations MUST be
  padded with zeros.

The current code leaves the trailing octets in uninitialized state,
resulting in parsing errors on (at least) systemd RA clients.
This commit restores the explicit zeroing of the trailing octets.

Closes: openwrt/openwrt#22351
Fixes: 0a54ce0 ("odhcpd: rename iface->search -> iface->dns_search")
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
Link: openwrt#386
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
@openwrt-bot openwrt-bot merged commit 160e5fa into openwrt:master Mar 16, 2026
9 checks passed
@Noltari
Copy link
Copy Markdown
Member

Noltari commented Mar 16, 2026

Merged, thanks @efahl!

@efahl efahl deleted the ra-padding branch March 16, 2026 17:53
Noltari pushed a commit to Noltari/odhcpd that referenced this pull request Mar 16, 2026
From https://www.rfc-editor.org/rfc/rfc8106#section-5.2 regarding
the DNSSL field:

  Because the size of this field MUST be a multiple of
  8 octets, for the minimum multiple including the domain
  name representations, the remaining octets other than the
  encoding parts of the domain name representations MUST be
  padded with zeros.

The current code leaves the trailing octets in uninitialized state,
resulting in parsing errors on (at least) systemd RA clients.
This commit restores the explicit zeroing of the trailing octets.

(cherry picked from commit 160e5fa)
Closes: openwrt/openwrt#22351
Fixes: 0a54ce0 ("odhcpd: rename iface->search -> iface->dns_search")
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
Link: openwrt#386
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

odhcpd not playing nice with ubuntu/systemd

3 participants