Print this page
3942 inject sanity into ipadm tcp buffer size properties
3943 _snd_lowat_fraction tcp tunable has no effect
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Peng Dai <peng.dai@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/ip/ip_if.c
          +++ new/usr/src/uts/common/inet/ip/ip_if.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  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) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright (c) 1990 Mentat Inc.
       24 + * Copyright (c) 2013 by Delphix. All rights reserved.
  24   25   */
  25   26  
  26   27  /*
  27   28   * This file contains the interface control functions for IP.
  28   29   */
  29   30  
  30   31  #include <sys/types.h>
  31   32  #include <sys/stream.h>
  32   33  #include <sys/dlpi.h>
  33   34  #include <sys/stropts.h>
↓ open down ↓ 8813 lines elided ↑ open up ↑
8847 8848   */
8848 8849  /* ARGSUSED */
8849 8850  static void
8850 8851  ip_sioctl_getsetprop(queue_t *q, mblk_t *mp)
8851 8852  {
8852 8853          struct iocblk   *iocp = (struct iocblk *)mp->b_rptr;
8853 8854          mblk_t          *mp1 = mp->b_cont;
8854 8855          mod_ioc_prop_t  *pioc;
8855 8856          mod_prop_info_t *ptbl = NULL, *pinfo = NULL;
8856 8857          ip_stack_t      *ipst;
8857      -        icmp_stack_t    *is;
8858      -        tcp_stack_t     *tcps;
8859      -        sctp_stack_t    *sctps;
8860      -        udp_stack_t     *us;
8861 8858          netstack_t      *stack;
8862      -        void            *cbarg;
8863 8859          cred_t          *cr;
8864      -        boolean_t       set;
     8860 +        boolean_t       set;
8865 8861          int             err;
8866 8862  
8867 8863          ASSERT(q->q_next == NULL);
8868 8864          ASSERT(CONN_Q(q));
8869 8865  
8870 8866          if (!getset_ioctl_checks(mp)) {
8871 8867                  miocnak(q, mp, 0, EINVAL);
8872 8868                  return;
8873 8869          }
8874 8870          ipst = CONNQ_TO_IPST(q);
8875 8871          stack = ipst->ips_netstack;
8876 8872          pioc = (mod_ioc_prop_t *)mp1->b_rptr;
8877 8873  
8878 8874          switch (pioc->mpr_proto) {
8879 8875          case MOD_PROTO_IP:
8880 8876          case MOD_PROTO_IPV4:
8881 8877          case MOD_PROTO_IPV6:
8882 8878                  ptbl = ipst->ips_propinfo_tbl;
8883      -                cbarg = ipst;
8884 8879                  break;
8885 8880          case MOD_PROTO_RAWIP:
8886      -                is = stack->netstack_icmp;
8887      -                ptbl = is->is_propinfo_tbl;
8888      -                cbarg = is;
     8881 +                ptbl = stack->netstack_icmp->is_propinfo_tbl;
8889 8882                  break;
8890 8883          case MOD_PROTO_TCP:
8891      -                tcps = stack->netstack_tcp;
8892      -                ptbl = tcps->tcps_propinfo_tbl;
8893      -                cbarg = tcps;
     8884 +                ptbl = stack->netstack_tcp->tcps_propinfo_tbl;
8894 8885                  break;
8895 8886          case MOD_PROTO_UDP:
8896      -                us = stack->netstack_udp;
8897      -                ptbl = us->us_propinfo_tbl;
8898      -                cbarg = us;
     8887 +                ptbl = stack->netstack_udp->us_propinfo_tbl;
8899 8888                  break;
8900 8889          case MOD_PROTO_SCTP:
8901      -                sctps = stack->netstack_sctp;
8902      -                ptbl = sctps->sctps_propinfo_tbl;
8903      -                cbarg = sctps;
     8890 +                ptbl = stack->netstack_sctp->sctps_propinfo_tbl;
8904 8891                  break;
8905 8892          default:
8906 8893                  miocnak(q, mp, 0, EINVAL);
8907 8894                  return;
8908 8895          }
8909 8896  
8910      -        /* search for given property in respective protocol propinfo table */
8911      -        for (pinfo = ptbl; pinfo->mpi_name != NULL; pinfo++) {
8912      -                if (strcmp(pinfo->mpi_name, pioc->mpr_name) == 0 &&
8913      -                    pinfo->mpi_proto == pioc->mpr_proto)
8914      -                        break;
8915      -        }
8916      -        if (pinfo->mpi_name == NULL) {
     8897 +        pinfo = mod_prop_lookup(ptbl, pioc->mpr_name, pioc->mpr_proto);
     8898 +        if (pinfo == NULL) {
8917 8899                  miocnak(q, mp, 0, ENOENT);
8918 8900                  return;
8919 8901          }
8920 8902  
8921 8903          set = (iocp->ioc_cmd == SIOCSETPROP) ? B_TRUE : B_FALSE;
8922 8904          if (set && pinfo->mpi_setf != NULL) {
8923 8905                  cr = msg_getcred(mp, NULL);
8924 8906                  if (cr == NULL)
8925 8907                          cr = iocp->ioc_cr;
8926      -                err = pinfo->mpi_setf(cbarg, cr, pinfo, pioc->mpr_ifname,
     8908 +                err = pinfo->mpi_setf(stack, cr, pinfo, pioc->mpr_ifname,
8927 8909                      pioc->mpr_val, pioc->mpr_flags);
8928 8910          } else if (!set && pinfo->mpi_getf != NULL) {
8929      -                err = pinfo->mpi_getf(cbarg, pinfo, pioc->mpr_ifname,
     8911 +                err = pinfo->mpi_getf(stack, pinfo, pioc->mpr_ifname,
8930 8912                      pioc->mpr_val, pioc->mpr_valsize, pioc->mpr_flags);
8931 8913          } else {
8932 8914                  err = EPERM;
8933 8915          }
8934 8916  
8935 8917          if (err != 0) {
8936 8918                  miocnak(q, mp, 0, err);
8937 8919          } else {
8938 8920                  if (set)
8939 8921                          miocack(q, mp, 0, 0);
↓ open down ↓ 8 lines elided ↑ open up ↑
8948 8930   * but well-known ioctls.
8949 8931   */
8950 8932  /* ARGSUSED */
8951 8933  static void
8952 8934  ip_process_legacy_nddprop(queue_t *q, mblk_t *mp)
8953 8935  {
8954 8936          struct iocblk   *iocp = (struct iocblk *)mp->b_rptr;
8955 8937          mblk_t          *mp1 = mp->b_cont;
8956 8938          char            *pname, *pval, *buf;
8957 8939          uint_t          bufsize, proto;
8958      -        mod_prop_info_t *ptbl = NULL, *pinfo = NULL;
     8940 +        mod_prop_info_t *pinfo = NULL;
8959 8941          ip_stack_t      *ipst;
8960 8942          int             err = 0;
8961 8943  
8962 8944          ASSERT(CONN_Q(q));
8963 8945          ipst = CONNQ_TO_IPST(q);
8964 8946  
8965 8947          if (iocp->ioc_count == 0 || mp1 == NULL) {
8966 8948                  miocnak(q, mp, 0, EINVAL);
8967 8949                  return;
8968 8950          }
↓ open down ↓ 6 lines elided ↑ open up ↑
8975 8957                  pname = "forwarding";
8976 8958                  proto = MOD_PROTO_IPV4;
8977 8959          } else if (strcmp(pname, "ip6_forwarding") == 0) {
8978 8960                  pname = "forwarding";
8979 8961                  proto = MOD_PROTO_IPV6;
8980 8962          } else {
8981 8963                  miocnak(q, mp, 0, EINVAL);
8982 8964                  return;
8983 8965          }
8984 8966  
8985      -        ptbl = ipst->ips_propinfo_tbl;
8986      -        for (pinfo = ptbl; pinfo->mpi_name != NULL; pinfo++) {
8987      -                if (strcmp(pinfo->mpi_name, pname) == 0 &&
8988      -                    pinfo->mpi_proto == proto)
8989      -                        break;
8990      -        }
     8967 +        pinfo = mod_prop_lookup(ipst->ips_propinfo_tbl, pname, proto);
8991 8968  
8992      -        ASSERT(pinfo->mpi_name != NULL);
8993      -
8994 8969          switch (iocp->ioc_cmd) {
8995 8970          case ND_GET:
8996      -                if ((err = pinfo->mpi_getf(ipst, pinfo, NULL, buf, bufsize,
8997      -                    0)) == 0) {
     8971 +                if ((err = pinfo->mpi_getf(ipst->ips_netstack, pinfo, NULL, buf,
     8972 +                    bufsize, 0)) == 0) {
8998 8973                          miocack(q, mp, iocp->ioc_count, 0);
8999 8974                          return;
9000 8975                  }
9001 8976                  break;
9002 8977          case ND_SET:
9003 8978                  /*
9004 8979                   * buffer will have property name and value in the following
9005 8980                   * format,
9006 8981                   * <property name>'\0'<property value>'\0', extract them;
9007 8982                   */
9008 8983                  while (*pval++)
9009 8984                          noop;
9010 8985  
9011 8986                  if (!*pval || pval >= (char *)mp1->b_wptr) {
9012 8987                          err = EINVAL;
9013      -                } else if ((err = pinfo->mpi_setf(ipst, NULL, pinfo, NULL,
9014      -                    pval, 0)) == 0) {
     8988 +                } else if ((err = pinfo->mpi_setf(ipst->ips_netstack, NULL,
     8989 +                    pinfo, NULL, pval, 0)) == 0) {
9015 8990                          miocack(q, mp, 0, 0);
9016 8991                          return;
9017 8992                  }
9018 8993                  break;
9019 8994          default:
9020 8995                  err = EINVAL;
9021 8996                  break;
9022 8997          }
9023 8998          miocnak(q, mp, 0, err);
9024 8999  }
↓ open down ↓ 10138 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX