Network Services | NTP broadcast client fails to open sockets on lwIP (#10)

Kinsey Moore (@opticron) gitlab at rtems.org
Fri Jan 31 18:30:52 UTC 2025



Kinsey Moore created an issue: https://gitlab.rtems.org/rtems/pkg/rtems-net-services/-/issues/10

Assignee: Trac Migrate

Reproduction:
* Install lwIP on top of a compatible BSP
* Modify the existing ntp01 test to use the broadcast client
 * Set NTP_DEBUG to 1
 * Replace the first two lines of etc_ntp_conf with:
  * broadcastclient
  * disable auth
* Build rtems-net-services against the installed BSP with lwIP network stack
* Run the modified ntp01 test

Expected result:
NTP opens broadcast listener successfully.

Actual result:
NTP fails to open broadcast listener with error message:
bind(37) AF_INET 0.0.0.0#123 flags 0x409 failed: Address already in use

Workaround:
In open_socket() in bsd/freebsd/contrib/ntp/ntpd/ntp_io.c, there is a test for wildcard addresses inside a OS_NEEDS_REUSEADDR_FOR_IFADDRBIND conditional. If the set_wildcard_reuse() call is made unconditional, the socket creation succeeds.

The root cause is that behavior differs between LibBSD and lwIP. On lwIP, early-bound wildcard and non-wildcard address bindings succeed, but late-bound wildcard address bindings fail. Once any any address is bound, lwIP will fail to bind any further wildcard sockets. Either we can change lwIP's behavior to be closer to LibBSD or we can alter the NTP client to check for lwIP or blindly apply the address reuse flags.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/pkg/rtems-net-services/-/issues/10
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250131/300f28dd/attachment.htm>


More information about the bugs mailing list