lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #44608] connectionless UDP dst address not being check


From: Adam
Subject: [lwip-devel] [bug #44608] connectionless UDP dst address not being checked within udp_input
Date: Mon, 23 Mar 2015 15:54:10 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36

URL:
  <http://savannah.nongnu.org/bugs/?44608>

                 Summary: connectionless UDP dst address not being checked
within udp_input
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: anewman
            Submitted on: Mon 23 Mar 2015 03:54:08 PM GMT
                Category: UDP
                Severity: 3 - Normal
              Item Group: Change Request
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 
            lwIP version: 1.4.1

    _______________________________________________________

Details:

In udp_input (udp.c) the dst address is not being checked vs. the pcb when the
pcb is connectionless. Arriving UDP is only checked for matching port number.

If two Multicast UDP sockets are open using different addresses but the same
port number then the frame will arrive on both.

My application requires that the UDP frame is only copied to the PCB with the
matching multicast address.

May I propose an enhancement to include an option to check for a match vs.
pcb.multicast_ip when current_iphdr_dest is multicast? I've implemented the
following in udp.c and it works for me:

//FROM LINE 239
/* compare PCB local addr+port to UDP destination addr+port */
      if (pcb->local_port == dest) {
#if MC_MATCH_DSTADDRESS
        bool mc_match_dstaddress = true;
        
        if (ip_addr_ismulticast(&current_iphdr_dest))
        {
            if (!ip_addr_cmp(&(pcb->multicast_ip), &current_iphdr_dest))
            {
                mc_match_dstaddress = false;
            }
        }

        if (mc_match_dstaddress)
        {
#endif          
        if (
           (!broadcast && ip_addr_isany(&pcb->local_ip)) ||
           ip_addr_cmp(&(pcb->local_ip), &current_iphdr_dest) ||
#if LWIP_IGMP
           ip_addr_ismulticast(&current_iphdr_dest) ||
#endif /* LWIP_IGMP */
#if IP_SOF_BROADCAST_RECV
            (broadcast && ip_get_option(pcb, SOF_BROADCAST) &&
             (ip_addr_isany(&pcb->local_ip) ||
              ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(),
&inp->netmask)))) {
#else /* IP_SOF_BROADCAST_RECV */
            (broadcast &&
             (ip_addr_isany(&pcb->local_ip) ||
              ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(),
&inp->netmask)))) {
#endif /* IP_SOF_BROADCAST_RECV */ 
          local_match = 1;
          if ((uncon_pcb == NULL) && 
              ((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) {
            /* the first unconnected matching PCB */
            uncon_pcb = pcb;
          }
        }
#if MC_MATCH_DSTADDRESS              
        }
#endif


I also added "#define MC_MATCH_DSTADDRESS 1" to opt.h. multicast_ip is set
using setsockopt with the IP_MULTICAST_IF option.





    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?44608>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]