On Tue, May 10, 2022 at 6:01 AM Fotis Panagiotopoulos <f.j.pa...@gmail.com> wrote:
> Hello, > > I just noticed that NuttX responds with an ICMP port unreachable on UDP > broadcasts. > AFAIK this shouldn't happen. > > I followed the code, and I found that the broadcast reaches udp_input.c: > line 256, where the ICMP response is generated. > > There is a note there that indeed the ICMP shouldn't be sent if this is a > broadcast. > As I see, the ICMP code is left to check this condition. > > Within icmp_reply.c: line 105 I see that there is a check about broadcasts. > My understanding is that this check is wrong. > > It checks for pure equality, between the destination IP and > INADDR_BROADCAST. > > In my (quite typical) network, the broadcast IP is 192.168.1.255. > The check expects to see exactly 255.255.255.255, so it fails to realise > that this is a broadcast and responds nevertheless. > > Shall this check be fixed somehow? > Or have I misunderstood something? > Yes it is a good idea to fix it. Does this code know the netmask so as to check properly for all types of broadcast addresses? E.g. with a netmask of 255.255.0.0 the broadcast address is x.x.255.255. Nathan