Print this page
OS-1573 vnic_dev.c insufficiently explicit

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/vnic/vnic_dev.c
          +++ new/usr/src/uts/common/io/vnic/vnic_dev.c
↓ open down ↓ 44 lines elided ↑ open up ↑
  45   45  #include <sys/mac_provider.h>
  46   46  #include <sys/mac_client.h>
  47   47  #include <sys/mac_client_priv.h>
  48   48  #include <sys/mac_ether.h>
  49   49  #include <sys/dls.h>
  50   50  #include <sys/pattr.h>
  51   51  #include <sys/time.h>
  52   52  #include <sys/vlan.h>
  53   53  #include <sys/vnic.h>
  54   54  #include <sys/vnic_impl.h>
       55 +#include <sys/mac_impl.h>
  55   56  #include <sys/mac_flow_impl.h>
  56   57  #include <inet/ip_impl.h>
  57   58  
  58   59  /*
  59   60   * Note that for best performance, the VNIC is a passthrough design.
  60   61   * For each VNIC corresponds a MAC client of the underlying MAC (lower MAC).
  61   62   * This MAC client is opened by the VNIC driver at VNIC creation,
  62   63   * and closed when the VNIC is deleted.
  63   64   * When a MAC client of the VNIC itself opens a VNIC, the MAC layer
  64   65   * (upper MAC) detects that the MAC being opened is a VNIC. Instead
↓ open down ↓ 775 lines elided ↑ open up ↑
 840  841  }
 841  842  
 842  843  /*
 843  844   * Callback functions for set/get of properties
 844  845   */
 845  846  /*ARGSUSED*/
 846  847  static int
 847  848  vnic_m_setprop(void *m_driver, const char *pr_name, mac_prop_id_t pr_num,
 848  849      uint_t pr_valsize, const void *pr_val)
 849  850  {
 850      -        int             err = ENOTSUP;
      851 +        int             err = 0;
 851  852          vnic_t          *vn = m_driver;
 852  853  
 853  854          switch (pr_num) {
 854  855          case MAC_PROP_MTU: {
 855  856                  uint32_t        mtu;
 856  857  
 857  858                  /* allow setting MTU only on an etherstub */
 858      -                if (vn->vn_link_id != DATALINK_INVALID_LINKID)
 859      -                        return (err);
      859 +                if (vn->vn_link_id != DATALINK_INVALID_LINKID) {
      860 +                        err = ENOTSUP;
      861 +                        break;
      862 +                }
 860  863  
 861  864                  if (pr_valsize < sizeof (mtu)) {
 862  865                          err = EINVAL;
 863  866                          break;
 864  867                  }
 865  868                  bcopy(pr_val, &mtu, sizeof (mtu));
 866  869                  if (mtu < ANCHOR_VNIC_MIN_MTU || mtu > ANCHOR_VNIC_MAX_MTU) {
 867  870                          err = EINVAL;
 868  871                          break;
 869  872                  }
↓ open down ↓ 2 lines elided ↑ open up ↑
 872  875          }
 873  876          case MAC_PROP_VN_PROMISC_FILTERED: {
 874  877                  boolean_t filtered;
 875  878  
 876  879                  if (pr_valsize < sizeof (filtered)) {
 877  880                          err = EINVAL;
 878  881                          break;
 879  882                  }
 880  883  
 881  884                  bcopy(pr_val, &filtered, sizeof (filtered));
 882      -                err = mac_set_promisc_filtered(vn->vn_mch, filtered);
      885 +                mac_set_promisc_filtered(vn->vn_mch, filtered);
 883  886          }
 884  887          default:
      888 +                err = ENOTSUP;
 885  889                  break;
 886  890          }
 887  891          return (err);
 888  892  }
 889  893  
 890  894  static int
 891  895  vnic_m_getprop(void *arg, const char *pr_name, mac_prop_id_t pr_num,
 892  896      uint_t pr_valsize, void *pr_val)
 893  897  {
 894  898          vnic_t          *vn = arg;
↓ open down ↓ 111 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX