buglwIP - A Lightweight TCP/IP stack - Bugs: bug #55037, lwip 2.1.0 socket raw api lack of...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #55037: lwip 2.1.0 socket raw api lack of IPv6 cmsghdr information

Submitted by:  yanhc <yanhc>
Submitted on:  Fri 16 Nov 2018 03:03:11 PM UTC  
 
Category:  IPv6 Severity:  3 - Normal
Item Group:  Feature Request Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  2.1.0

Sat 17 Nov 2018 03:40:14 AM UTC, comment #2: 

I Checked the patch #9554 and it really provides most of this post already except the pbuf_clone changes if I did not miss it.

I have another question.
Since I use SOCK_RAW to get exactly IPv6 payload info, however, I will receive all IPv6 packet include IPv6 header in the application. I notice that in line 1053 of ip6.c, the ipv6 header is added again as following:

#if LWIP_RAW
  /* p points to IPv6 header again for raw_input. */
  pbuf_add_header_force(p, hlen_tot);
  /* raw input did not eat the packet? */
  raw_status = raw_input(p, inp);

So why raw_input need the IPv6 header info? What is the motivation behind this? At least, I do not need the IPv6 header in my application since the cmsghdr has already provide destaddr information which maybe the most commonly used IPv6 header information.

Thanks!

yanhc <yanhc>
Fri 16 Nov 2018 04:13:07 PM UTC, comment #1: 

I think we already have code for this ready to be merged in patch #9554. I just haven't found the time to correctly review it...

Simon Goldschmidt <goldsimon>
Project Administrator
Fri 16 Nov 2018 03:03:11 PM UTC, original submission:  

Recently, I am using socket raw api to just receive ipv6 payload. In my project, I need the cmsghdr information. However, I found that there is only IPv4 cmsghdr support and no IPv6 cmsghdr support in "lwip_recvfrom_udp_raw" function in sockets.c. So I add the IPv6 cmsghdr support following the example of IPv4 in sockets.c and sockets.h which can be found the attached diff file.

Since the IPv6 cmsghdr need the destaddr and if_idx info, again, I found that in "recv_raw" function in api_msg.c, there is lack support for LWIP_NETBUF_RECVINFO. So I add the LWIP_NETBUF_RECVINFO support following the example in "recv_udp" function.
The information of buf->p->if_idx is also lost in "pbuf_clone" in "recv_udp" function in api_msg.c where pbuf p is copied to pbuf q. So I just add the "q->if_idx = p->if_idx;" in "pbuf_clone" function.
The changing of api_msg.c and pbuf.c can also be found in the attached diff file.

Another issue is about MLD for socket raw api, I found that MLD only check UDP and ignore RAW in "lwip_setsockopt_impl" function in sockets.c. Since in my project I only use MLD from RAW api so I just change the following line to NETCONN_RAW rather than support both RAW and UDP which is not appropriate.
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, struct ipv6_mreq, NETCONN_RAW);

I am not sure whether the above changes are appropriate, so I just pointed out and wait for offical update.

Thanks for this cool project.

yanhc <yanhc>

 

Attached Files
file #45448:  diff.txt added by yanhc (4KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by yanhc (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-11-16 yanhc Attached File- => Added diff.txt, #45448

    Back to the top


    Powered by Savane 3.5