diff options
Diffstat (limited to 'usr/src/lib/libdladm/common/libdlvnic.c')
-rw-r--r-- | usr/src/lib/libdladm/common/libdlvnic.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/usr/src/lib/libdladm/common/libdlvnic.c b/usr/src/lib/libdladm/common/libdlvnic.c index 47d007a1e2..7ff0cd5530 100644 --- a/usr/src/lib/libdladm/common/libdlvnic.c +++ b/usr/src/lib/libdladm/common/libdlvnic.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2015, Joyent Inc. + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. */ #include <stdio.h> @@ -406,6 +407,7 @@ dladm_vnic_create(dladm_handle_t handle, const char *vnic, datalink_id_t linkid, datalink_id_t vnic_id; datalink_class_t class; uint32_t media = DL_ETHER; + uint32_t link_flags; char name[MAXLINKNAMELEN]; uchar_t tmp_addr[MAXMACADDRLEN]; dladm_status_t status; @@ -421,6 +423,15 @@ dladm_vnic_create(dladm_handle_t handle, const char *vnic, datalink_id_t linkid, if ((flags & DLADM_OPT_ACTIVE) == 0) return (DLADM_STATUS_NOTSUP); + /* + * It's an anchor VNIC - linkid must be set to DATALINK_INVALID_LINKID + * and the VLAN id must be 0 + */ + if ((flags & DLADM_OPT_ANCHOR) != 0 && + (linkid != DATALINK_INVALID_LINKID || vid != 0)) { + return (DLADM_STATUS_BADARG); + } + is_vlan = ((flags & DLADM_OPT_VLAN) != 0); if (is_vlan && ((vid < 1 || vid > 4094))) return (DLADM_STATUS_VIDINVAL); @@ -430,18 +441,20 @@ dladm_vnic_create(dladm_handle_t handle, const char *vnic, datalink_id_t linkid, if (!dladm_vnic_macaddrtype2str(mac_addr_type)) return (DLADM_STATUS_INVALIDMACADDRTYPE); - if ((flags & DLADM_OPT_ANCHOR) == 0) { - if ((status = dladm_datalink_id2info(handle, linkid, NULL, - &class, &media, NULL, 0)) != DLADM_STATUS_OK) + if (!is_etherstub) { + if ((status = dladm_datalink_id2info(handle, linkid, + &link_flags, &class, &media, NULL, 0)) != DLADM_STATUS_OK) return (status); + /* Disallow persistent objects on top of temporary ones */ + if ((flags & DLADM_OPT_PERSIST) != 0 && + (link_flags & DLMGMT_PERSIST) == 0) + return (DLADM_STATUS_PERSIST_ON_TEMP); + + /* Links cannot be created on top of these object types */ if (class == DATALINK_CLASS_VNIC || class == DATALINK_CLASS_VLAN) return (DLADM_STATUS_BADARG); - } else { - /* it's an anchor VNIC */ - if (linkid != DATALINK_INVALID_LINKID || vid != 0) - return (DLADM_STATUS_BADARG); } /* |