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