Print this page
2553 mac address should be a dladm link property

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdladm/common/linkprop.c
          +++ new/usr/src/lib/libdladm/common/linkprop.c
↓ open down ↓ 141 lines elided ↑ open up ↑
 142  142  static const char       *dladm_perm2str(uint_t, char *);
 143  143  static link_attr_t      *dladm_name2prop(const char *);
 144  144  static link_attr_t      *dladm_id2prop(mac_prop_id_t);
 145  145  
 146  146  static pd_getf_t        get_zone, get_autopush, get_rate_mod, get_rate,
 147  147                          get_speed, get_channel, get_powermode, get_radio,
 148  148                          get_duplex, get_link_state, get_binary, get_uint32,
 149  149                          get_flowctl, get_maxbw, get_cpus, get_priority,
 150  150                          get_tagmode, get_range, get_stp, get_bridge_forward,
 151  151                          get_bridge_pvid, get_protection, get_rxrings,
 152      -                        get_txrings, get_cntavail,
      152 +                        get_txrings, get_cntavail, get_macaddr,
 153  153                          get_allowedips, get_allowedcids, get_pool,
 154  154                          get_rings_range, get_linkmode_prop;
 155  155  
 156  156  static pd_setf_t        set_zone, set_rate, set_powermode, set_radio,
 157  157                          set_public_prop, set_resource, set_stp_prop,
 158      -                        set_bridge_forward, set_bridge_pvid;
      158 +                        set_bridge_forward, set_bridge_pvid, set_macaddr;
 159  159  
 160  160  static pd_checkf_t      check_zone, check_autopush, check_rate, check_hoplimit,
 161  161                          check_encaplim, check_uint32, check_maxbw, check_cpus,
 162  162                          check_stp_prop, check_bridge_pvid, check_allowedips,
 163      -                        check_allowedcids, check_rings,
      163 +                        check_allowedcids, check_rings, check_macaddr,
 164  164                          check_pool, check_prop;
 165  165  
 166  166  struct prop_desc {
 167  167          /*
 168  168           * link property name
 169  169           */
 170  170          char                    *pd_name;
 171  171  
 172  172          /*
 173  173           * default property value, can be set to { "", NULL }
↓ open down ↓ 182 lines elided ↑ open up ↑
 356  356  
 357  357          { MAC_PROP_MAX_RX_RINGS_AVAIL,  sizeof (uint_t),
 358  358              "rxrings-available"},
 359  359  
 360  360          { MAC_PROP_MAX_RXHWCLNT_AVAIL,  sizeof (uint_t), "rxhwclnt-available"},
 361  361  
 362  362          { MAC_PROP_MAX_TXHWCLNT_AVAIL,  sizeof (uint_t), "txhwclnt-available"},
 363  363  
 364  364          { MAC_PROP_IB_LINKMODE, sizeof (uint32_t),      "linkmode"},
 365  365  
      366 +        { MAC_PROP_MACADDRESS,  sizeof (mac_addrprop_t), "mac-address"},
      367 +
 366  368          { MAC_PROP_PRIVATE,     0,                      "driver-private"}
 367  369  };
 368  370  
 369  371  typedef struct bridge_public_prop_s {
 370  372          const char      *bpp_name;
 371  373          int             bpp_code;
 372  374  } bridge_public_prop_t;
 373  375  
 374  376  static const bridge_public_prop_t bridge_prop[] = {
 375  377          { "stp", PT_CFG_NON_STP },
↓ open down ↓ 299 lines elided ↑ open up ↑
 675  677              link_01_vals, VALCNT(link_01_vals),
 676  678              set_stp_prop, NULL, get_stp, check_stp_prop, PD_AFTER_PERM,
 677  679              DATALINK_CLASS_PHYS|DATALINK_CLASS_AGGR|
 678  680              DATALINK_CLASS_ETHERSTUB|DATALINK_CLASS_SIMNET, DL_ETHER },
 679  681  
 680  682          { "protection", { "--", RESET_VAL },
 681  683              link_protect_vals, VALCNT(link_protect_vals),
 682  684              set_resource, NULL, get_protection, check_prop, 0,
 683  685              DATALINK_CLASS_ALL, DATALINK_ANY_MEDIATYPE },
 684  686  
      687 +        { "mac-address", { "", 0 }, NULL, 0,
      688 +            set_macaddr, NULL, get_macaddr, check_macaddr, PD_CHECK_ALLOC,
      689 +            DATALINK_CLASS_PHYS|DATALINK_CLASS_AGGR|DATALINK_CLASS_VNIC|
      690 +            DATALINK_CLASS_SIMNET, DATALINK_ANY_MEDIATYPE },
      691 +
 685  692          { "allowed-ips", { "--", 0 },
 686  693              NULL, 0, set_resource, NULL,
 687  694              get_allowedips, check_allowedips, PD_CHECK_ALLOC,
 688  695              DATALINK_CLASS_ALL, DATALINK_ANY_MEDIATYPE },
 689  696  
 690  697          { "allowed-dhcp-cids", { "--", 0 },
 691  698              NULL, 0, set_resource, NULL,
 692  699              get_allowedcids, check_allowedcids, PD_CHECK_ALLOC,
 693  700              DATALINK_CLASS_ALL, DATALINK_ANY_MEDIATYPE },
 694  701  
↓ open down ↓ 23 lines elided ↑ open up ↑
 718  725              NULL, NULL, get_cntavail, NULL, 0,
 719  726              DATALINK_CLASS_ALL, DATALINK_ANY_MEDIATYPE },
 720  727  
 721  728          { "rxhwclnt-available", { "", 0 }, NULL, 0,
 722  729              NULL, NULL, get_cntavail, NULL, 0,
 723  730              DATALINK_CLASS_ALL, DATALINK_ANY_MEDIATYPE },
 724  731  
 725  732          { "txhwclnt-available", { "", 0 }, NULL, 0,
 726  733              NULL, NULL, get_cntavail, NULL, 0,
 727  734              DATALINK_CLASS_ALL, DATALINK_ANY_MEDIATYPE },
 728      -
 729  735  };
 730  736  
 731  737  #define DLADM_MAX_PROPS (sizeof (prop_table) / sizeof (prop_desc_t))
 732  738  
 733  739  static resource_prop_t rsrc_prop_table[] = {
 734  740          {"maxbw",               extract_maxbw},
 735  741          {"priority",            extract_priority},
 736  742          {"cpus",                extract_cpus},
 737  743          {"cpus-effective",      extract_cpus},
 738  744          {"pool",                extract_pool},
↓ open down ↓ 1499 lines elided ↑ open up ↑
2238 2244  {
2239 2245          if (flags & DLD_PROP_DEFAULT)
2240 2246                  return (DLADM_STATUS_NOTDEFINED);
2241 2247  
2242 2248          return (get_uint32(handle, pdp, linkid, prop_val, val_cnt, media,
2243 2249              flags, perm_flags));
2244 2250  }
2245 2251  
2246 2252  /* ARGSUSED */
2247 2253  static dladm_status_t
     2254 +get_macaddr(dladm_handle_t handle, prop_desc_t *pdp, datalink_id_t linkid,
     2255 +    char **prop_val, uint_t *val_cnt, datalink_media_t media, uint_t flags,
     2256 +    uint_t *perm_flags)
     2257 +{
     2258 +        mac_addrprop_t  addrprop;
     2259 +        dladm_status_t  status;
     2260 +
     2261 +        status = i_dladm_get_public_prop(handle, linkid, pdp->pd_name,
     2262 +            flags, perm_flags, &addrprop, sizeof (addrprop));
     2263 +        if (status != DLADM_STATUS_OK)
     2264 +                return (status);
     2265 +
     2266 +        (void) _link_ntoa(addrprop.ma_addr, prop_val[0], addrprop.ma_len,
     2267 +            IFT_OTHER);
     2268 +
     2269 +        *val_cnt = 1;
     2270 +
     2271 +        return (DLADM_STATUS_OK);
     2272 +}
     2273 +
     2274 +/* ARGSUSED */
     2275 +static dladm_status_t
     2276 +set_macaddr(dladm_handle_t handle, prop_desc_t *pdp, datalink_id_t linkid,
     2277 +    val_desc_t *vdp, uint_t val_cnt, uint_t flags, datalink_media_t media)
     2278 +{
     2279 +        if (val_cnt != 1)
     2280 +                return (DLADM_STATUS_BADVALCNT);
     2281 +
     2282 +        return (set_public_prop(handle, pdp, linkid, vdp, val_cnt,
     2283 +            flags, media));
     2284 +}
     2285 +
     2286 +/* ARGSUSED */
     2287 +static dladm_status_t
     2288 +check_macaddr(dladm_handle_t handle, prop_desc_t *pdp, datalink_id_t linkid,
     2289 +    char **prop_val, uint_t *val_cntp, uint_t flags, val_desc_t **vdpp,
     2290 +    datalink_media_t media)
     2291 +{
     2292 +        mac_addrprop_t  *addrprop;
     2293 +        val_desc_t      *vdp = *vdpp;
     2294 +        uint_t          val_cnt = *val_cntp;
     2295 +        uchar_t         *macaddr;
     2296 +        int             maclen;
     2297 +        dladm_status_t  status = DLADM_STATUS_OK;
     2298 +
     2299 +        if (val_cnt != 1)
     2300 +                return (DLADM_STATUS_BADVALCNT);
     2301 +
     2302 +        macaddr = _link_aton(*prop_val, &maclen);
     2303 +        if (macaddr == NULL)
     2304 +                return (DLADM_STATUS_BADVAL);
     2305 +
     2306 +        addrprop = malloc(sizeof (mac_addrprop_t));
     2307 +        if (addrprop == NULL) {
     2308 +                status = DLADM_STATUS_NOMEM;
     2309 +                goto out;
     2310 +        }
     2311 +
     2312 +        (void) memcpy(addrprop->ma_addr, macaddr, maclen);
     2313 +        addrprop->ma_len = maclen;
     2314 +
     2315 +        vdp->vd_val = (uintptr_t)addrprop;
     2316 +
     2317 +out:
     2318 +        free(macaddr);
     2319 +        return (status);
     2320 +}
     2321 +
     2322 +/* ARGSUSED */
     2323 +static dladm_status_t
2248 2324  set_resource(dladm_handle_t handle, prop_desc_t *pdp,
2249 2325      datalink_id_t linkid, val_desc_t *vdp, uint_t val_cnt,
2250 2326      uint_t flags, datalink_media_t media)
2251 2327  {
2252 2328          mac_resource_props_t    mrp;
2253 2329          dladm_status_t          status = DLADM_STATUS_OK;
2254 2330          dld_ioc_macprop_t       *dip;
2255 2331          int                     i;
2256 2332  
2257 2333          bzero(&mrp, sizeof (mac_resource_props_t));
↓ open down ↓ 2328 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX