On Thu, May 12, 2022 at 5:18 AM Bernd Walter <ti...@cicely7.cicely.de> wrote:
>
> On Wed, May 11, 2022 at 07:13:17PM -0400, Nathan Hartman wrote:
> > On Wed, May 11, 2022 at 5:19 AM Fotis Panagiotopoulos
> > <f.j.pa...@gmail.com> wrote:
> > >
> > > I was thinking the same thing.
> > >
> > > Which layer is responsible for this check?
> > > IP, UDP, or ICMP?
> >
> >
> > Logically it would seem to me that UDP should do the check and trigger
> > sending the ICMP unreachable reply when appropriate, though it seems
> > that it unconditionally calls icmp_reply(), which contains the logic
> > to *avoid* sending it when it's the ANY or BROADCAST address. In other
> > words, it is currently is coded in the ICMP layer.
> >
> > Looking at struct net_driver_s in include/nuttx/net/netdev.h, I am
> > reminded that there is also IPv6, which a grep reveals has a similar
> > handler in the IPv6 ICMP handler in icmpv6_reply() in
> > net/icmpv6/icmpv6_reply.c.
> >
> > There is a function net_is_addr_mcast(), but there is no
> > net_is_addr_bcast() currently. I think that is the function that needs
> > to be coded, and then called from icmp_reply().
>
> There is no broadcast in IPv6.
> Completely replaced by multicast.


Sorry, I was not clear:

I mentioned IPv6 only because I noticed how icmpv6_reply() is coded;
icmpv6_reply() checks if the address is a multicast address by calling
net_is_addr_mcast().

In contrast, the IPv4 version, icmp_reply(), checks against the ANY or
BROADCAST addresses by a simple comparison.

To fix the issue found by the OP, I proposed that we need a
net_is_address_bcast(), which will be similar in purpose to
net_is_address_mcast(), but for broadcast rather than multicast
addresses. Then, icmp_reply() will call net_is_address_bcast() instead
of the above-mentioned simple comparison that it is currently doing.
The proposed new function net_is_address_bcast() will be smart enough
to check for other broadcast addresses besides 255.255.255.255 by
consulting the netmask.

Cheers,
Nathan

Reply via email to