Print this page
Re-enable commented-out lxinit code, as a prelude to
enabling zonecfg(1M)-property networking configuration for LX.

@@ -185,11 +185,10 @@
 
         return (handle);
 
 }
 
-#if 0 /* XXX KEBE SAYS NOT YET */
 static int
 zone_find_attr(struct zone_res_attrtab *attrs, const char *name,
     const char **result)
 {
         while (attrs != NULL) {

@@ -200,11 +199,10 @@
                 }
                 attrs = attrs->zone_res_attr_next;
         }
         return (-1);
 }
-#endif /* XXX KEBE SAYS NOT YET */
 
 static void
 lxi_svc_start(char *name, char *path, char *fmri)
 {
         pid_t pid;

@@ -405,11 +403,10 @@
 done:
         ipadm_destroy_addrobj(ipaddr);
         return (err);
 }
 
-#if 0 /* XXX KEBE SAYS NOT YET */
 static int
 lxi_iface_dhcp(const char *origiface, boolean_t *first_ipv4_configured)
 {
         dhcp_ipc_request_t *dhcpreq = NULL;
         dhcp_ipc_reply_t *dhcpreply = NULL;

@@ -457,11 +454,10 @@
 done:
         free(dhcpreq);
         free(dhcpreply);
         return (err);
 }
-#endif /* XXX KEBE SAYS NOT YET */
 
 /*
  * Initialize an IPv6 link-local address on a given interface
  */
 static int

@@ -575,63 +571,10 @@
         lxi_net_plumb(iface);
         (void) lxi_iface_ip(iface, "127.0.0.1/8", &first_ipv4_configured);
         (void) lxi_iface_ipv6_link_local(iface);
 }
 
-
-
-#if 0 /* XXX KEBE SAYS NOT YET */
-/*
- * This function is used when the "ips" property doesn't exist in a zone's
- * configuration. It may be an older configuration, so we should search for
- * "ip" and "netmask" and convert them into the new format.
- */
-static int
-lxi_get_old_ip(struct zone_res_attrtab *attrs, const char **ipaddrs,
-    char *cidraddr, int len)
-{
-
-        const char *netmask;
-        int prefixlen;
-        struct sockaddr_in mask_sin;
-
-        lxi_warn("Could not find \"ips\" property for zone. Looking "
-            "for older \"ip\" and \"netmask\" properties, instead.");
-
-        if (zone_find_attr(attrs, "ip", ipaddrs) != 0) {
-                return (-1);
-        }
-
-        if (strcmp(*ipaddrs, "dhcp") == 0) {
-                return (0);
-        }
-
-        if (zone_find_attr(attrs, "netmask", &netmask) != 0) {
-                lxi_err("could not find netmask for interface");
-                /* NOTREACHED */
-        }
-
-        /* Convert the netmask to a number */
-        mask_sin.sin_family = AF_INET;
-        if (inet_pton(AF_INET, netmask, &mask_sin.sin_addr) != 1) {
-                lxi_err("invalid netmask address: %s\n",
-                    strerror(errno));
-                /* NOTREACHED */
-        }
-        prefixlen = mask2plen((struct sockaddr *)&mask_sin);
-
-        /*
-         * Write out the IP address in the new format and use
-         * that instead
-         */
-        (void) snprintf(cidraddr, len, "%s/%d", *ipaddrs, prefixlen);
-
-        *ipaddrs = cidraddr;
-        return (0);
-}
-#endif /* XXX KEBE SAYS NOT YET */
-
 static void
 lxi_net_setup(zone_dochandle_t handle)
 {
         struct zone_nwiftab lookup;
         boolean_t do_addrconf = B_FALSE;

@@ -638,41 +581,53 @@
 
         if (zonecfg_setnwifent(handle) != Z_OK)
                 return;
         while (zonecfg_getnwifent(handle, &lookup) == Z_OK) {
                 const char *iface = lookup.zone_nwif_physical;
-#if 0   /* XXX KEBE SAYS NOT YET */
                 struct zone_res_attrtab *attrs = lookup.zone_nwif_attrp;
                 const char *ipaddrs, *primary, *gateway;
-                char ipaddrs_copy[MAXNAMELEN], cidraddr[BUFSIZ],
+                char ipaddrs_copy[MAXNAMELEN], /* cidraddr[BUFSIZ], */
                     *ipaddr, *tmp, *lasts;
                 boolean_t first_ipv4_configured = B_FALSE;
                 boolean_t *ficp = &first_ipv4_configured;
-#endif  /* XXX KEBE */
+                boolean_t no_zonecfg;
 
+                /*
+                 * Regardless of whether we're configured in zonecfg(1M), or
+                 * configured by other means, make sure we plumb every
+                 * physical=<foo> for IPv4 and IPv6.
+                 */
                 lxi_net_plumb(iface);
 
-                /* XXX KEBE SAYS this bit was shuffled around. */
+                if (zone_find_attr(attrs, "ips", &ipaddrs) != 0 /* &&
+                    lxi_get_old_ip(attrs, &ipaddrs, cidraddr, BUFSIZ) != 0*/) {
+                        /*
+                         * Do not panic.  This interface has no in-zonecfg(1M)
+                         * configuration.  We keep a warning around.
+                         */
+                        lxi_warn("Could not find zonecfg(1M) network "
+                            "configuration for the %s interface", iface);
+                        no_zonecfg = B_TRUE;
+                } else {
+                        no_zonecfg = B_FALSE;
+                }
+
                 if (lxi_iface_ipv6_link_local(iface) != 0) {
                         lxi_warn("unable to bring up link-local address on "
                             "interface %s", iface);
-                } else {
-                        /* XXX KEBE SAYS this bit is new. */
-                        do_addrconf = B_TRUE;
                 }
 
-#if 0   /* XXX KEBE SAYS NOT YET */
-                if (zone_find_attr(attrs, "ips", &ipaddrs) != 0 &&
-                    lxi_get_old_ip(attrs, &ipaddrs, cidraddr, BUFSIZ) != 0) {
-                        lxi_warn("Could not find a valid network configuration "
-                            "for the %s interface", iface);
+                /*
+                 * Every thing else below only happens if we have zonecfg(1M)
+                 * network configuration.
+                 */
+                if (no_zonecfg)
                         continue;
-                }
 
                 /*
-                 * If we're going to be doing DHCP, we have to do it first since
-                 * dhcpagent doesn't like to operate on non-zero logical
+                 * If we're going to be doing DHCP, we have to do it first
+                 * since dhcpagent doesn't like to operate on non-zero logical
                  * interfaces.
                  */
                 if (strstr(ipaddrs, "dhcp") != NULL &&
                     lxi_iface_dhcp(iface, ficp) != 0) {
                         lxi_warn("Failed to start DHCP on %s\n", iface);

@@ -703,11 +658,10 @@
                 if (zone_find_attr(attrs, "primary", &primary) == 0 &&
                     strncmp(primary, "true", MAXNAMELEN) == 0 &&
                     zone_find_attr(attrs, "gateway", &gateway) == 0) {
                         lxi_iface_gateway(iface, NULL, 0, gateway);
                 }
-#endif /* XXX KEBE */
         }
 
         if (do_addrconf) {
                 lxi_net_ndpd_start();
         }