summaryrefslogtreecommitdiff
path: root/usr/src/cmd/zoneadmd/vplat.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/zoneadmd/vplat.c')
-rw-r--r--usr/src/cmd/zoneadmd/vplat.c95
1 files changed, 16 insertions, 79 deletions
diff --git a/usr/src/cmd/zoneadmd/vplat.c b/usr/src/cmd/zoneadmd/vplat.c
index cd5a5681e9..616da5c564 100644
--- a/usr/src/cmd/zoneadmd/vplat.c
+++ b/usr/src/cmd/zoneadmd/vplat.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This module contains functions used to bring up and tear down the
* Virtual Platform: [un]mounting file-systems, [un]plumbing network
@@ -2609,28 +2607,8 @@ configure_shared_network_interfaces(zlog_t *zlogp)
return (0);
}
-static void
-show_owner(zlog_t *zlogp, char *dlname)
-{
- zoneid_t dl_owner_zid;
- char dl_owner_zname[ZONENAME_MAX];
-
- dl_owner_zid = ALL_ZONES;
- if (zone_check_datalink(&dl_owner_zid, dlname) != 0)
- (void) snprintf(dl_owner_zname, ZONENAME_MAX, "<unknown>");
- else if (getzonenamebyid(dl_owner_zid, dl_owner_zname, ZONENAME_MAX)
- < 0)
- (void) snprintf(dl_owner_zname, ZONENAME_MAX, "<%d>",
- dl_owner_zid);
-
- errno = EPERM;
- zerror(zlogp, B_TRUE, "WARNING: skipping network interface '%s' "
- "which is used by the non-global zone '%s'.\n",
- dlname, dl_owner_zname);
-}
-
static int
-add_datalink(zlog_t *zlogp, zoneid_t zoneid, char *dlname)
+add_datalink(zlog_t *zlogp, char *zone_name, char *dlname)
{
/* First check if it's in use by global zone. */
if (zonecfg_ifname_exists(AF_INET, dlname) ||
@@ -2641,22 +2619,10 @@ add_datalink(zlog_t *zlogp, zoneid_t zoneid, char *dlname)
return (-1);
}
- /* Add access control information */
- if (zone_add_datalink(zoneid, dlname) != 0) {
- /* If someone got this link before us, show its name */
- if (errno == EPERM)
- show_owner(zlogp, dlname);
- else
- zerror(zlogp, B_TRUE, "WARNING: unable to add network "
- "interface '%s'.", dlname);
- return (-1);
- }
-
/* Set zoneid of this link. */
- if (dladm_setzid(dlname, zoneid) != DLADM_STATUS_OK) {
+ if (dladm_setzid(dlname, zone_name) != DLADM_STATUS_OK) {
zerror(zlogp, B_TRUE, "WARNING: unable to add network "
"interface '%s'.", dlname);
- (void) zone_remove_datalink(zoneid, dlname);
return (-1);
}
@@ -2664,22 +2630,10 @@ add_datalink(zlog_t *zlogp, zoneid_t zoneid, char *dlname)
}
static int
-remove_datalink(zlog_t *zlogp, zoneid_t zoneid, char *dlname)
+remove_datalink(zlog_t *zlogp, char *dlname)
{
- /*
- * Remove access control information.
- * If the errno is ENXIO, the interface is not added yet,
- * nothing to report then.
- */
- if (zone_remove_datalink(zoneid, dlname) != 0) {
- if (errno == ENXIO)
- return (0);
- zerror(zlogp, B_TRUE, "unable to remove network interface '%s'",
- dlname);
- return (-1);
- }
-
- if (dladm_setzid(dlname, GLOBAL_ZONEID) != DLADM_STATUS_OK) {
+ if (dladm_setzid(dlname, GLOBAL_ZONENAME)
+ != DLADM_STATUS_OK) {
zerror(zlogp, B_TRUE, "unable to release network "
"interface '%s'", dlname);
return (-1);
@@ -2697,17 +2651,11 @@ configure_exclusive_network_interfaces(zlog_t *zlogp)
{
zone_dochandle_t handle;
struct zone_nwiftab nwiftab;
- zoneid_t zoneid;
char rootpath[MAXPATHLEN];
char path[MAXPATHLEN];
di_prof_t prof = NULL;
boolean_t added = B_FALSE;
- if ((zoneid = getzoneidbyname(zone_name)) == -1) {
- zerror(zlogp, B_TRUE, "unable to get zoneid");
- return (-1);
- }
-
if ((handle = zonecfg_init_handle()) == NULL) {
zerror(zlogp, B_TRUE, "getting zone configuration handle");
return (-1);
@@ -2758,24 +2706,14 @@ configure_exclusive_network_interfaces(zlog_t *zlogp)
* created in that case. The /dev/net entry is always
* accessible.
*/
- if (add_datalink(zlogp, zoneid, nwiftab.zone_nwif_physical)
+ if (add_datalink(zlogp, zone_name, nwiftab.zone_nwif_physical)
== 0) {
- char name[DLPI_LINKNAME_MAX];
- datalink_id_t linkid;
-
- if (dladm_name2info(nwiftab.zone_nwif_physical,
- &linkid, NULL, NULL, NULL) == DLADM_STATUS_OK &&
- dladm_linkid2legacyname(linkid, name,
- sizeof (name)) == DLADM_STATUS_OK) {
- if (di_prof_add_dev(prof, name) != 0) {
- (void) zonecfg_endnwifent(handle);
- zonecfg_fini_handle(handle);
- zerror(zlogp, B_TRUE,
- "failed to add network device");
- return (-1);
- }
- added = B_TRUE;
- }
+ added = B_TRUE;
+ } else {
+ (void) zonecfg_endnwifent(handle);
+ zonecfg_fini_handle(handle);
+ zerror(zlogp, B_TRUE, "failed to add network device");
+ return (-1);
}
}
(void) zonecfg_endnwifent(handle);
@@ -2832,7 +2770,7 @@ again:
ptr = dlnames;
for (i = 0; i < dlnum; i++) {
/* Remove access control information */
- if (remove_datalink(zlogp, zoneid, ptr) != 0) {
+ if (remove_datalink(zlogp, ptr) != 0) {
free(dlnames);
return (-1);
}
@@ -2846,7 +2784,7 @@ again:
* Get the list of the data-links from configuration, and try to remove it
*/
static int
-unconfigure_exclusive_network_interfaces_static(zlog_t *zlogp, zoneid_t zoneid)
+unconfigure_exclusive_network_interfaces_static(zlog_t *zlogp)
{
zone_dochandle_t handle;
struct zone_nwiftab nwiftab;
@@ -2868,7 +2806,7 @@ unconfigure_exclusive_network_interfaces_static(zlog_t *zlogp, zoneid_t zoneid)
if (zonecfg_getnwifent(handle, &nwiftab) != Z_OK)
break;
/* Remove access control information */
- if (remove_datalink(zlogp, zoneid, nwiftab.zone_nwif_physical)
+ if (remove_datalink(zlogp, nwiftab.zone_nwif_physical)
!= 0) {
(void) zonecfg_endnwifent(handle);
zonecfg_fini_handle(handle);
@@ -2888,8 +2826,7 @@ static int
unconfigure_exclusive_network_interfaces(zlog_t *zlogp, zoneid_t zoneid)
{
if (unconfigure_exclusive_network_interfaces_run(zlogp, zoneid) != 0) {
- return (unconfigure_exclusive_network_interfaces_static(zlogp,
- zoneid));
+ return (unconfigure_exclusive_network_interfaces_static(zlogp));
}
return (0);