[RTEMS Project] #4958: NTP broadcast client fails to open sockets on lwIP

RTEMS trac trac at rtems.org
Wed Oct 4 19:44:27 UTC 2023


#4958: NTP broadcast client fails to open sockets on lwIP
--------------------------+---------------------
 Reporter:  Kinsey Moore  |       Owner:  (none)
     Type:  defect        |      Status:  new
 Priority:  normal        |   Milestone:  6.2
Component:  network/lwip  |     Version:  6
 Severity:  normal        |  Resolution:
 Keywords:                |  Blocked By:
 Blocking:                |
--------------------------+---------------------
Description changed by Kinsey Moore:

Old description:

> 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.

New description:

 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.

--

--
Ticket URL: <http://devel.rtems.org/ticket/4958#comment:1>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list