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/inet/tcp/tcp_opt_data.c
          +++ new/usr/src/uts/common/inet/tcp/tcp_opt_data.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
  24   24   * Copyright 2019 Joyent, Inc.
  25   25   * Copyright (c) 2016 by Delphix. All rights reserved.
       26 + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
  26   27   */
  27   28  
  28   29  #include <sys/types.h>
  29   30  #include <sys/stream.h>
  30   31  #define _SUN_TPI_VERSION 2
  31   32  #include <sys/tihdr.h>
  32   33  #include <sys/socket.h>
  33   34  #include <sys/xti_xtiopt.h>
  34   35  #include <sys/xti_inet.h>
  35   36  #include <sys/policy.h>
↓ open down ↓ 113 lines elided ↑ open up ↑
 149  150          (OP_VARLEN|OP_NODEFAULT),
 150  151          IP_MAX_OPT_LENGTH + IP_ADDR_LEN, -1 /* not initialized */ },
 151  152  { T_IP_OPTIONS, IPPROTO_IP, OA_RW, OA_RW, OP_NP,
 152  153          (OP_VARLEN|OP_NODEFAULT),
 153  154          IP_MAX_OPT_LENGTH + IP_ADDR_LEN, -1 /* not initialized */ },
 154  155  
 155  156  { IP_TOS,       IPPROTO_IP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
 156  157  { T_IP_TOS,     IPPROTO_IP, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
 157  158  { IP_TTL,       IPPROTO_IP, OA_RW, OA_RW, OP_NP, OP_DEF_FN,
 158  159          sizeof (int), -1 /* not initialized */ },
      160 +{ IP_RECVTOS,   IPPROTO_IP,  OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
 159  161  
 160  162  { IP_SEC_OPT, IPPROTO_IP, OA_RW, OA_RW, OP_NP, OP_NODEFAULT,
 161  163          sizeof (ipsec_req_t), -1 /* not initialized */ },
 162  164  
 163  165  { IP_BOUND_IF, IPPROTO_IP, OA_RW, OA_RW, OP_NP, 0,
 164  166          sizeof (int),   0 /* no ifindex */ },
 165  167  
 166  168  { IP_UNSPEC_SRC, IPPROTO_IP, OA_R, OA_RW, OP_RAW, 0,
 167  169          sizeof (int), 0 },
 168  170  
↓ open down ↓ 351 lines elided ↑ open up ↑
 520  522          coas.coa_ipp = &connp->conn_xmit_ipp;
 521  523          coas.coa_ancillary = B_FALSE;
 522  524          coas.coa_changed = 0;
 523  525  
 524  526          switch (optset_context) {
 525  527          case SETFN_OPTCOM_CHECKONLY:
 526  528                  checkonly = B_TRUE;
 527  529                  /*
 528  530                   * Note: Implies T_CHECK semantics for T_OPTCOM_REQ
 529  531                   * inlen != 0 implies value supplied and
 530      -                 *      we have to "pretend" to set it.
      532 +                 *      we have to "pretend" to set it.
 531  533                   * inlen == 0 implies that there is no
 532      -                 *      value part in T_CHECK request and just validation
      534 +                 *      value part in T_CHECK request and just validation
 533  535                   * done elsewhere should be enough, we just return here.
 534  536                   */
 535  537                  if (inlen == 0) {
 536  538                          *outlenp = 0;
 537  539                          return (0);
 538  540                  }
 539  541                  break;
 540  542          case SETFN_OPTCOM_NEGOTIATE:
 541  543                  checkonly = B_FALSE;
 542  544                  break;
↓ open down ↓ 482 lines elided ↑ open up ↑
1025 1027                  switch (name) {
1026 1028                  case IP_SEC_OPT:
1027 1029                          /*
1028 1030                           * We should not allow policy setting after
1029 1031                           * we start listening for connections.
1030 1032                           */
1031 1033                          if (tcp->tcp_state == TCPS_LISTEN) {
1032 1034                                  return (EINVAL);
1033 1035                          }
1034 1036                          break;
     1037 +                case IP_RECVTOS:
     1038 +                        if (!checkonly) {
     1039 +                                /*
     1040 +                                 * Force it to be sent up with the next msg
     1041 +                                 * by setting it to a value which cannot
     1042 +                                 * appear in a packet (TOS is only 8-bits)
     1043 +                                 */
     1044 +                                tcp->tcp_recvtos = 0xffffffffU;
     1045 +                        }
     1046 +                        break;
1035 1047                  }
1036 1048                  break;
1037 1049          case IPPROTO_IPV6:
1038 1050                  /*
1039 1051                   * IPPROTO_IPV6 options are only supported for sockets
1040 1052                   * that are using IPv6 on the wire.
1041 1053                   */
1042 1054                  if (connp->conn_ipversion != IPV6_VERSION) {
1043 1055                          *outlenp = 0;
1044 1056                          return (EINVAL);
↓ open down ↓ 109 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX