Print this page
13175 Add support for IP_RECVTOS
13182 CMSG_ macros should have man pages
Change-ID: I784aa36cfd3c17e3cccbf1fd329fa7e69b663ef9

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/sockfs/socksubr.c
          +++ new/usr/src/uts/common/fs/sockfs/socksubr.c
↓ open down ↓ 1310 lines elided ↑ open up ↑
1311 1311                                      (int32_t)(timestamp->tv_nsec /
1312 1312                                      (NANOSEC / MICROSEC));
1313 1313                          }
1314 1314  
1315 1315                  } else {
1316 1316                          if (oldflg)
1317 1317                                  continue;
1318 1318  
1319 1319                          cmsg->cmsg_level = tohp->level;
1320 1320                          cmsg->cmsg_type = tohp->name;
1321      -                        cmsg->cmsg_len = (socklen_t)(_TPI_TOPT_DATALEN(tohp) +
1322      -                            sizeof (struct cmsghdr));
     1321 +                        cmsg->cmsg_len = (socklen_t)sizeof (struct cmsghdr);
     1322 +                        if (tohp->level == IPPROTO_IP &&
     1323 +                            (tohp->name == IP_RECVTOS ||
     1324 +                            tohp->name == IP_RECVTTL)) {
     1325 +                                /*
     1326 +                                 * The data for these is a uint8_t but, in
     1327 +                                 * order to maintain alignment for any
     1328 +                                 * following TPI primitives in the message,
     1329 +                                 * there will be some trailing padding bytes
     1330 +                                 * which are included in the TPI_TOPT_DATALEN.
     1331 +                                 * For these types, we set the cmsg_len
     1332 +                                 * explicitly to the correct value.
     1333 +                                 */
     1334 +                                cmsg->cmsg_len += (socklen_t)sizeof (uint8_t);
     1335 +                        } else {
     1336 +                                cmsg->cmsg_len +=
     1337 +                                    (socklen_t)(_TPI_TOPT_DATALEN(tohp));
     1338 +                        }
1323 1339  
1324 1340                          /* copy content to control data part */
1325 1341                          bcopy(&tohp[1], CMSG_CONTENT(cmsg),
1326 1342                              CMSG_CONTENTLEN(cmsg));
1327 1343                  }
1328 1344                  /* move to next CMSG structure! */
1329 1345                  cmsg = CMSG_NEXT(cmsg);
1330 1346          }
1331 1347          dprint(1, ("so_opt2cmsg: buf %p len %d; cend %p; final cmsg %p\n",
1332 1348              control, controllen, (void *)cend, (void *)cmsg));
↓ open down ↓ 665 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX