netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fw: [Bug 212353] New: Requesting IP_RECVTTL via setsockopt returns IP_TTL via recvmsg()'s cmsghdr
@ 2021-03-19 18:50 Stephen Hemminger
  2021-03-19 18:59 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2021-03-19 18:50 UTC (permalink / raw)
  To: netdev



Begin forwarded message:

Date: Fri, 19 Mar 2021 07:04:12 +0000
From: bugzilla-daemon@bugzilla.kernel.org
To: stephen@networkplumber.org
Subject: [Bug 212353] New: Requesting IP_RECVTTL via setsockopt returns IP_TTL via recvmsg()'s cmsghdr


https://bugzilla.kernel.org/show_bug.cgi?id=212353

            Bug ID: 212353
           Summary: Requesting IP_RECVTTL via setsockopt returns IP_TTL
                    via recvmsg()'s cmsghdr
           Product: Networking
           Version: 2.5
    Kernel Version: 4.12.14-122.63-default (SLES12 SP5)
          Hardware: All
                OS: Linux
              Tree: Mainline
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Other
          Assignee: stephen@networkplumber.org
          Reporter: Ulrich.Windl@rz.uni-regensburg.de
        Regression: No

Trying to get IP_RECVTTL, I noticed that recvmsg() returns IP_TTL, not
IP_RECVTTL in struct cmsghdr.
Example xode being used was similar to
https://stackoverflow.com/a/49308499/6607497 that checks for IP_RECVTTL in
struct cmsghdr:

...
int yes = 1;
setsockopt(soc, IPPROTO_IP, IP_RECVTTL, &yes, sizeof(yes));
...
int ttl = -1;
struct cmsghdr * cmsg = CMSG_FIRSTHDR(&hdr); 
for (; cmsg; cmsg = CMSG_NXTHDR(&hdr, cmsg)) {
    if (cmsg->cmsg_level == IPPROTO_IP
        && cmsg->cmsg_type == IP_RECVTTL
    ) {
        uint8_t * ttlPtr = (uint8_t *)CMSG_DATA(cmsg);
        ttl = *ttlPtr;
        break;
    }
}
// ttl is now either the real ttl or -1 if something went wrong

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Bug 212353] New: Requesting IP_RECVTTL via setsockopt returns IP_TTL via recvmsg()'s cmsghdr
  2021-03-19 18:50 Fw: [Bug 212353] New: Requesting IP_RECVTTL via setsockopt returns IP_TTL via recvmsg()'s cmsghdr Stephen Hemminger
@ 2021-03-19 18:59 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2021-03-19 18:59 UTC (permalink / raw)
  To: stephen; +Cc: netdev


Although IP_RECVTTL is the socket option used to control the reporting, the value is reported using IP_TTL.

This is intentional, and correct.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-19 19:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-19 18:50 Fw: [Bug 212353] New: Requesting IP_RECVTTL via setsockopt returns IP_TTL via recvmsg()'s cmsghdr Stephen Hemminger
2021-03-19 18:59 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).