From 76dc73ab0e2fe1d48db2409942b0831c14ff886d Mon Sep 17 00:00:00 2001 From: Jerry Jelinek Date: Fri, 15 Mar 2013 15:41:48 +0000 Subject: OS-2029 upgrade: 6.5 portal zone net config incompatible with vmadm --- usr/src/lib/libzonecfg/common/libzonecfg.c | 41 ++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/usr/src/lib/libzonecfg/common/libzonecfg.c b/usr/src/lib/libzonecfg/common/libzonecfg.c index 97fd1f52e2..55e0e58c82 100644 --- a/usr/src/lib/libzonecfg/common/libzonecfg.c +++ b/usr/src/lib/libzonecfg/common/libzonecfg.c @@ -21,7 +21,7 @@ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, Joyent Inc. All rights reserved. + * Copyright (c) 2013, Joyent Inc. All rights reserved. */ #include @@ -2074,6 +2074,32 @@ zonecfg_ifname_exists(sa_family_t af, char *ifname) return (B_TRUE); } +/* + * Turn an addr that looks like f:2:0:44:5:6C into 0f:02:00:44:05:6c + * We're expecting a dst of at least MAXMACADDRLEN size here. + */ +static void +normalize_mac_addr(char *dst, const char *src, int len) +{ + char *p, *e, *sep = ""; + long n; + char buf[MAXMACADDRLEN], tmp[4]; + + *dst = '\0'; + (void) strlcpy(buf, src, sizeof (buf)); + p = strtok(buf, ":"); + while (p != NULL) { + n = strtol(p, &e, 16); + if (*e != NULL || n > 0xff) + return; + (void) snprintf(tmp, sizeof (tmp), "%s%02x", sep, n); + (void) strlcat(dst, tmp, len); + + sep = ":"; + p = strtok(NULL, ":"); + } +} + /* * Determines whether there is a net resource with the physical interface, IP * address, and default router specified by 'tabptr' in the zone configuration @@ -2099,6 +2125,7 @@ zonecfg_lookup_nwif(zone_dochandle_t handle, struct zone_nwiftab *tabptr) char address[INET6_ADDRSTRLEN]; char physical[LIFNAMSIZ]; char mac[MAXMACADDRLEN]; + char norm_mac[MAXMACADDRLEN]; char gnic[LIFNAMSIZ]; size_t addrspec; /* nonzero if tabptr has IP addr */ size_t physspec; /* nonzero if tabptr has interface */ @@ -2155,10 +2182,14 @@ zonecfg_lookup_nwif(zone_dochandle_t handle, struct zone_nwiftab *tabptr) physical, sizeof (physical)) != Z_OK || strcmp(tabptr->zone_nwif_physical, physical) != 0)) continue; - if (iptype == ZS_EXCLUSIVE && macspec != 0 && - (fetchprop(cur, DTD_ATTR_MAC, mac, sizeof (mac)) != Z_OK || - strcmp(tabptr->zone_nwif_mac, mac) != 0)) - continue; + if (iptype == ZS_EXCLUSIVE && macspec != 0) { + if (fetchprop(cur, DTD_ATTR_MAC, mac, sizeof (mac)) != + Z_OK) + continue; + normalize_mac_addr(norm_mac, mac, sizeof (norm_mac)); + if (strcmp(tabptr->zone_nwif_mac, norm_mac) != 0) + continue; + } if (iptype == ZS_EXCLUSIVE && gnicspec != 0 && (fetchprop(cur, DTD_ATTR_GNIC, gnic, sizeof (gnic)) != Z_OK || -- cgit v1.2.3