Begin forwarded message:

Date: Fri, 19 Mar 2021 07:04:12 +0000
From: bugzilla-dae...@bugzilla.kernel.org
To: step...@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: step...@networkplumber.org
          Reporter: ulrich.wi...@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.

Reply via email to