# implementation of IP_RECVOPTS



## Fidaullah (May 28, 2022)

I was building an application on F-Stack which underling uses FreeBSD TCP/IP stack and I wanted to use IP_RECVOPTS flag. This is where I found out that this flag is not implemented in FreeBSD TCP/IP stack. upon further investigation I came across the following code.

freebsd-src commit: 18054d0220cfc8df9c9568c437bd6fbb59d53c3c
sys/netinet/ip_input.c 
ip_savecontrol() line 1150

```
#ifdef notyet
    /* XXX
     * Moving these out of udp_input() made them even more broken
     * than they already were.
     */
    /* options were tossed already */
    if (inp->inp_flags & INP_RECVOPTS) {
        *mp = sbcreatecontrol(opts_deleted_above,
            sizeof(struct in_addr), IP_RECVOPTS, IPPROTO_IP, M_NOWAIT);
        if (*mp)
            mp = &(*mp)->m_next;
    }
    /* ip_srcroute doesn't do what we want here, need to fix */
    if (inp->inp_flags & INP_RECVRETOPTS) {
        *mp = sbcreatecontrol(ip_srcroute(m), sizeof(struct in_addr),
            IP_RECVRETOPTS, IPPROTO_IP, M_NOWAIT);
        if (*mp)
            mp = &(*mp)->m_next;
    }
#endif
```

Removing this #ifdef statement make IP_RECVOPTS work in F-Stack but I am concerned about the comment that mention this block "made them broken" I want to how this made them broken in FreeBSD. Also, I am willing to contribute in implementation of this flag in FreeBSD as well.


----------

