Print this page
Commit IPMP changes

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libipadm/common/ipadm_prop.c
          +++ new/usr/src/lib/libipadm/common/ipadm_prop.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) 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright (c) 2013 by Delphix. All rights reserved.
       24 + * Copyright (c) 2014 Nexenta Systems, Inc. All rights reserved
  24   25   */
  25   26  
  26   27  /*
  27   28   * This file contains routines that are used to modify/retrieve protocol or
  28   29   * interface property values. It also holds all the supported properties for
  29   30   * both IP interface and protocols in `ipadm_prop_desc_t'. Following protocols
  30   31   * are supported: IP, IPv4, IPv6, TCP, SCTP, UDP and ICMP.
  31   32   *
  32   33   * This file also contains walkers, which walks through the property table and
  33   34   * calls the callback function, of the form `ipadm_prop_wfunc_t' , for every
↓ open down ↓ 104 lines elided ↑ open up ↑
 138  139              i_ipadm_set_usesrc, NULL, i_ipadm_get_usesrc },
 139  140  
 140  141          { "hostmodel", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0,
 141  142              i_ipadm_set_hostmodel, i_ipadm_get_hostmodel,
 142  143              i_ipadm_get_hostmodel },
 143  144  
 144  145          { "hostmodel", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0,
 145  146              i_ipadm_set_hostmodel, i_ipadm_get_hostmodel,
 146  147              i_ipadm_get_hostmodel },
 147  148  
      149 +        { "standby", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IP, 0,
      150 +            i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
      151 +            i_ipadm_get_ifprop_flags },
      152 +
      153 +
 148  154          { NULL, NULL, 0, 0, 0, NULL, NULL, NULL }
 149  155  };
 150  156  
 151  157  /* possible values for TCP properties `ecn' and `sack' */
 152  158  static const char *ecn_sack_vals[] = {"never", "passive", "active", NULL};
 153  159  
 154  160  /* Supported TCP protocol properties */
 155  161  static ipadm_prop_desc_t ipadm_tcp_prop_table[] = {
 156  162          { "ecn", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 157  163              i_ipadm_set_ecnsack, i_ipadm_get_ecnsack, i_ipadm_get_ecnsack },
↓ open down ↓ 430 lines elided ↑ open up ↑
 588  594          uint64_t        on_flags = 0, off_flags = 0;
 589  595          boolean_t       on = B_FALSE;
 590  596          sa_family_t     af = (proto == MOD_PROTO_IPV6 ? AF_INET6 : AF_INET);
 591  597  
 592  598          /* if we are resetting, set the value to its default value */
 593  599          if (flags & IPADM_OPT_DEFAULT) {
 594  600                  if (strcmp(pdp->ipd_name, "exchange_routes") == 0 ||
 595  601                      strcmp(pdp->ipd_name, "arp") == 0 ||
 596  602                      strcmp(pdp->ipd_name, "nud") == 0) {
 597  603                          pval = IPADM_ONSTR;
 598      -                } else if (strcmp(pdp->ipd_name, "forwarding") == 0) {
      604 +                } else if (strcmp(pdp->ipd_name, "forwarding") == 0 ||
      605 +                    strcmp(pdp->ipd_name, "standby") == 0) {
 599  606                          pval = IPADM_OFFSTR;
 600  607                  } else {
 601  608                          return (IPADM_PROP_UNKNOWN);
 602  609                  }
 603  610          }
 604  611  
 605  612          if (strcmp(pval, IPADM_ONSTR) == 0)
 606  613                  on = B_TRUE;
 607  614          else if (strcmp(pval, IPADM_OFFSTR) == 0)
 608  615                  on = B_FALSE;
↓ open down ↓ 13 lines elided ↑ open up ↑
 622  629          } else if (strcmp(pdp->ipd_name, "nud") == 0) {
 623  630                  if (on)
 624  631                          off_flags = IFF_NONUD;
 625  632                  else
 626  633                          on_flags = IFF_NONUD;
 627  634          } else if (strcmp(pdp->ipd_name, "forwarding") == 0) {
 628  635                  if (on)
 629  636                          on_flags = IFF_ROUTER;
 630  637                  else
 631  638                          off_flags = IFF_ROUTER;
      639 +        } else if (strcmp(pdp->ipd_name, "standby") == 0) {
      640 +                if (on)
      641 +                        on_flags = IFF_STANDBY;
      642 +                else
      643 +                        off_flags = IFF_STANDBY;
 632  644          }
 633  645  
 634  646          if (on_flags || off_flags)  {
 635  647                  status = i_ipadm_set_flags(iph, ifname, af, on_flags,
 636  648                      off_flags);
 637  649          }
 638  650          return (status);
 639  651  }
 640  652  
 641  653  /* ARGSUSED */
↓ open down ↓ 348 lines elided ↑ open up ↑
 990 1002  
 991 1003          switch (valtype) {
 992 1004          case MOD_PROP_PERM:
 993 1005                  nbytes = snprintf(buf, *bufsize, "%d", MOD_PROP_PERM_RW);
 994 1006                  break;
 995 1007          case MOD_PROP_DEFAULT:
 996 1008                  if (strcmp(pdp->ipd_name, "exchange_routes") == 0 ||
 997 1009                      strcmp(pdp->ipd_name, "arp") == 0 ||
 998 1010                      strcmp(pdp->ipd_name, "nud") == 0) {
 999 1011                          val = IPADM_ONSTR;
1000      -                } else if (strcmp(pdp->ipd_name, "forwarding") == 0) {
     1012 +                } else if (strcmp(pdp->ipd_name, "forwarding") == 0 ||
     1013 +                    strcmp(pdp->ipd_name, "standby") == 0) {
1001 1014                          val = IPADM_OFFSTR;
1002 1015                  } else {
1003 1016                          return (IPADM_PROP_UNKNOWN);
1004 1017                  }
1005 1018                  nbytes = snprintf(buf, *bufsize, "%s", val);
1006 1019                  break;
1007 1020          case MOD_PROP_ACTIVE:
1008 1021                  af = (proto == MOD_PROTO_IPV6 ? AF_INET6 : AF_INET);
1009 1022                  status = i_ipadm_get_flags(iph, ifname, af, &intf_flags);
1010 1023                  if (status != IPADM_SUCCESS)
↓ open down ↓ 5 lines elided ↑ open up ↑
1016 1029                                  val = IPADM_ONSTR;
1017 1030                  } else if (strcmp(pdp->ipd_name, "forwarding") == 0) {
1018 1031                          if (intf_flags & IFF_ROUTER)
1019 1032                                  val = IPADM_ONSTR;
1020 1033                  } else if (strcmp(pdp->ipd_name, "arp") == 0) {
1021 1034                          if (!(intf_flags & IFF_NOARP))
1022 1035                                  val = IPADM_ONSTR;
1023 1036                  } else if (strcmp(pdp->ipd_name, "nud") == 0) {
1024 1037                          if (!(intf_flags & IFF_NONUD))
1025 1038                                  val = IPADM_ONSTR;
     1039 +                } else if (strcmp(pdp->ipd_name, "standby") == 0) {
     1040 +                        if (!(intf_flags & IFF_STANDBY))
     1041 +                                val = IPADM_ONSTR;
1026 1042                  }
1027 1043                  nbytes = snprintf(buf, *bufsize, "%s", val);
1028 1044                  break;
1029 1045          default:
1030 1046                  return (IPADM_INVALID_ARG);
1031 1047          }
1032 1048          if (nbytes >= *bufsize) {
1033 1049                  /* insufficient buffer space */
1034 1050                  *bufsize = nbytes + 1;
1035 1051                  status = IPADM_NO_BUFS;
↓ open down ↓ 655 lines elided ↑ open up ↑
1691 1707           */
1692 1708          if (err == ENOENT)
1693 1709                  err = 0;
1694 1710          return (ipadm_errno2status(err));
1695 1711  }
1696 1712  
1697 1713  /*
1698 1714   * This is called from ipadm_set_ifprop() to validate the set operation.
1699 1715   * It does the following steps:
1700 1716   * 1. Validates the interface name.
1701      - * 2. Fails if it is an IPMP meta-interface or an underlying interface.
1702      - * 3. In case of a persistent operation, verifies that the
     1717 + * 2. In case of a persistent operation, verifies that the
1703 1718   *      interface is persistent.
1704 1719   */
1705 1720  static ipadm_status_t
1706 1721  i_ipadm_validate_if(ipadm_handle_t iph, const char *ifname,
1707 1722      uint_t proto, uint_t flags)
1708 1723  {
1709 1724          sa_family_t     af, other_af;
1710 1725          ipadm_status_t  status;
1711 1726          boolean_t       p_exists;
1712 1727          boolean_t       af_exists, other_af_exists, a_exists;
1713 1728  
1714 1729          /* Check if the interface name is valid. */
1715 1730          if (!i_ipadm_validate_ifname(iph, ifname))
1716 1731                  return (IPADM_INVALID_ARG);
1717 1732  
1718 1733          af = (proto == MOD_PROTO_IPV6 ? AF_INET6 : AF_INET);
1719      -        /*
1720      -         * Setting properties on an IPMP meta-interface or underlying
1721      -         * interface is not supported.
1722      -         */
1723      -        if (i_ipadm_is_ipmp(iph, ifname) || i_ipadm_is_under_ipmp(iph, ifname))
1724      -                return (IPADM_NOTSUP);
1725 1734  
1726 1735          /* Check if interface exists in the persistent configuration. */
1727 1736          status = i_ipadm_if_pexists(iph, ifname, af, &p_exists);
1728 1737          if (status != IPADM_SUCCESS)
1729 1738                  return (status);
1730 1739  
1731 1740          /* Check if interface exists in the active configuration. */
1732 1741          af_exists = ipadm_if_enabled(iph, ifname, af);
1733 1742          other_af = (af == AF_INET ? AF_INET6 : AF_INET);
1734 1743          other_af_exists = ipadm_if_enabled(iph, ifname, other_af);
↓ open down ↓ 223 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX