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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/brand/lx/lx_init/lxinit.c
          +++ new/usr/src/lib/brand/lx/lx_init/lxinit.c
↓ open down ↓ 179 lines elided ↑ open up ↑
 180  180          if (zonecfg_get_iptype(handle, &iptype) != Z_OK ||
 181  181              iptype != ZS_EXCLUSIVE) {
 182  182                  zonecfg_fini_handle(handle);
 183  183                  lxi_err("lx zones do not support shared IP stacks");
 184  184          }
 185  185  
 186  186          return (handle);
 187  187  
 188  188  }
 189  189  
 190      -#if 0 /* XXX KEBE SAYS NOT YET */
 191  190  static int
 192  191  zone_find_attr(struct zone_res_attrtab *attrs, const char *name,
 193  192      const char **result)
 194  193  {
 195  194          while (attrs != NULL) {
 196  195                  if (strncmp(attrs->zone_res_attr_name, name,
 197  196                      MAXNAMELEN) == 0) {
 198  197                          *result = attrs->zone_res_attr_value;
 199  198                          return (0);
 200  199                  }
 201  200                  attrs = attrs->zone_res_attr_next;
 202  201          }
 203  202          return (-1);
 204  203  }
 205      -#endif /* XXX KEBE SAYS NOT YET */
 206  204  
 207  205  static void
 208  206  lxi_svc_start(char *name, char *path, char *fmri)
 209  207  {
 210  208          pid_t pid;
 211  209          int status;
 212  210          char *argv[] = {
 213  211                  NULL,
 214  212                  NULL
 215  213          };
↓ open down ↓ 184 lines elided ↑ open up ↑
 400  398  
 401  399          if (af == AF_INET) {
 402  400                  *first_ipv4_configured = B_TRUE;
 403  401          }
 404  402  
 405  403  done:
 406  404          ipadm_destroy_addrobj(ipaddr);
 407  405          return (err);
 408  406  }
 409  407  
 410      -#if 0 /* XXX KEBE SAYS NOT YET */
 411  408  static int
 412  409  lxi_iface_dhcp(const char *origiface, boolean_t *first_ipv4_configured)
 413  410  {
 414  411          dhcp_ipc_request_t *dhcpreq = NULL;
 415  412          dhcp_ipc_reply_t *dhcpreply = NULL;
 416  413          int err = 0, timeout = 5;
 417  414          char iface[LIFNAMSIZ];
 418  415  
 419  416          (void) strncpy(iface, origiface, sizeof (iface));
 420  417  
↓ open down ↓ 31 lines elided ↑ open up ↑
 452  449                  goto done;
 453  450          }
 454  451  
 455  452          *first_ipv4_configured = B_TRUE;
 456  453  
 457  454  done:
 458  455          free(dhcpreq);
 459  456          free(dhcpreply);
 460  457          return (err);
 461  458  }
 462      -#endif /* XXX KEBE SAYS NOT YET */
 463  459  
 464  460  /*
 465  461   * Initialize an IPv6 link-local address on a given interface
 466  462   */
 467  463  static int
 468  464  lxi_iface_ipv6_link_local(const char *iface)
 469  465  {
 470  466          struct lifreq lifr;
 471  467          int s;
 472  468  
↓ open down ↓ 97 lines elided ↑ open up ↑
 570  566  lxi_net_loopback()
 571  567  {
 572  568          const char *iface = "lo0";
 573  569          boolean_t first_ipv4_configured = B_FALSE;
 574  570  
 575  571          lxi_net_plumb(iface);
 576  572          (void) lxi_iface_ip(iface, "127.0.0.1/8", &first_ipv4_configured);
 577  573          (void) lxi_iface_ipv6_link_local(iface);
 578  574  }
 579  575  
 580      -
 581      -
 582      -#if 0 /* XXX KEBE SAYS NOT YET */
 583      -/*
 584      - * This function is used when the "ips" property doesn't exist in a zone's
 585      - * configuration. It may be an older configuration, so we should search for
 586      - * "ip" and "netmask" and convert them into the new format.
 587      - */
 588      -static int
 589      -lxi_get_old_ip(struct zone_res_attrtab *attrs, const char **ipaddrs,
 590      -    char *cidraddr, int len)
 591      -{
 592      -
 593      -        const char *netmask;
 594      -        int prefixlen;
 595      -        struct sockaddr_in mask_sin;
 596      -
 597      -        lxi_warn("Could not find \"ips\" property for zone. Looking "
 598      -            "for older \"ip\" and \"netmask\" properties, instead.");
 599      -
 600      -        if (zone_find_attr(attrs, "ip", ipaddrs) != 0) {
 601      -                return (-1);
 602      -        }
 603      -
 604      -        if (strcmp(*ipaddrs, "dhcp") == 0) {
 605      -                return (0);
 606      -        }
 607      -
 608      -        if (zone_find_attr(attrs, "netmask", &netmask) != 0) {
 609      -                lxi_err("could not find netmask for interface");
 610      -                /* NOTREACHED */
 611      -        }
 612      -
 613      -        /* Convert the netmask to a number */
 614      -        mask_sin.sin_family = AF_INET;
 615      -        if (inet_pton(AF_INET, netmask, &mask_sin.sin_addr) != 1) {
 616      -                lxi_err("invalid netmask address: %s\n",
 617      -                    strerror(errno));
 618      -                /* NOTREACHED */
 619      -        }
 620      -        prefixlen = mask2plen((struct sockaddr *)&mask_sin);
 621      -
 622      -        /*
 623      -         * Write out the IP address in the new format and use
 624      -         * that instead
 625      -         */
 626      -        (void) snprintf(cidraddr, len, "%s/%d", *ipaddrs, prefixlen);
 627      -
 628      -        *ipaddrs = cidraddr;
 629      -        return (0);
 630      -}
 631      -#endif /* XXX KEBE SAYS NOT YET */
 632      -
 633  576  static void
 634  577  lxi_net_setup(zone_dochandle_t handle)
 635  578  {
 636  579          struct zone_nwiftab lookup;
 637  580          boolean_t do_addrconf = B_FALSE;
 638  581  
 639  582          if (zonecfg_setnwifent(handle) != Z_OK)
 640  583                  return;
 641  584          while (zonecfg_getnwifent(handle, &lookup) == Z_OK) {
 642  585                  const char *iface = lookup.zone_nwif_physical;
 643      -#if 0   /* XXX KEBE SAYS NOT YET */
 644  586                  struct zone_res_attrtab *attrs = lookup.zone_nwif_attrp;
 645  587                  const char *ipaddrs, *primary, *gateway;
 646      -                char ipaddrs_copy[MAXNAMELEN], cidraddr[BUFSIZ],
      588 +                char ipaddrs_copy[MAXNAMELEN], /* cidraddr[BUFSIZ], */
 647  589                      *ipaddr, *tmp, *lasts;
 648  590                  boolean_t first_ipv4_configured = B_FALSE;
 649  591                  boolean_t *ficp = &first_ipv4_configured;
 650      -#endif  /* XXX KEBE */
      592 +                boolean_t no_zonecfg;
 651  593  
      594 +                /*
      595 +                 * Regardless of whether we're configured in zonecfg(1M), or
      596 +                 * configured by other means, make sure we plumb every
      597 +                 * physical=<foo> for IPv4 and IPv6.
      598 +                 */
 652  599                  lxi_net_plumb(iface);
 653  600  
 654      -                /* XXX KEBE SAYS this bit was shuffled around. */
      601 +                if (zone_find_attr(attrs, "ips", &ipaddrs) != 0 /* &&
      602 +                    lxi_get_old_ip(attrs, &ipaddrs, cidraddr, BUFSIZ) != 0*/) {
      603 +                        /*
      604 +                         * Do not panic.  This interface has no in-zonecfg(1M)
      605 +                         * configuration.  We keep a warning around.
      606 +                         */
      607 +                        lxi_warn("Could not find zonecfg(1M) network "
      608 +                            "configuration for the %s interface", iface);
      609 +                        no_zonecfg = B_TRUE;
      610 +                } else {
      611 +                        no_zonecfg = B_FALSE;
      612 +                }
      613 +
 655  614                  if (lxi_iface_ipv6_link_local(iface) != 0) {
 656  615                          lxi_warn("unable to bring up link-local address on "
 657  616                              "interface %s", iface);
 658      -                } else {
 659      -                        /* XXX KEBE SAYS this bit is new. */
 660      -                        do_addrconf = B_TRUE;
 661  617                  }
 662  618  
 663      -#if 0   /* XXX KEBE SAYS NOT YET */
 664      -                if (zone_find_attr(attrs, "ips", &ipaddrs) != 0 &&
 665      -                    lxi_get_old_ip(attrs, &ipaddrs, cidraddr, BUFSIZ) != 0) {
 666      -                        lxi_warn("Could not find a valid network configuration "
 667      -                            "for the %s interface", iface);
      619 +                /*
      620 +                 * Every thing else below only happens if we have zonecfg(1M)
      621 +                 * network configuration.
      622 +                 */
      623 +                if (no_zonecfg)
 668  624                          continue;
 669      -                }
 670  625  
 671  626                  /*
 672      -                 * If we're going to be doing DHCP, we have to do it first since
 673      -                 * dhcpagent doesn't like to operate on non-zero logical
      627 +                 * If we're going to be doing DHCP, we have to do it first
      628 +                 * since dhcpagent doesn't like to operate on non-zero logical
 674  629                   * interfaces.
 675  630                   */
 676  631                  if (strstr(ipaddrs, "dhcp") != NULL &&
 677  632                      lxi_iface_dhcp(iface, ficp) != 0) {
 678  633                          lxi_warn("Failed to start DHCP on %s\n", iface);
 679  634                  }
 680  635  
 681  636                  /*
 682  637                   * Copy the ipaddrs string, since strtok_r will write NUL
 683  638                   * characters into it.
↓ open down ↓ 14 lines elided ↑ open up ↑
 698  653                                  lxi_warn("Unable to add new IP address (%s) "
 699  654                                      "to interface %s", ipaddr, iface);
 700  655                          }
 701  656                  }
 702  657  
 703  658                  if (zone_find_attr(attrs, "primary", &primary) == 0 &&
 704  659                      strncmp(primary, "true", MAXNAMELEN) == 0 &&
 705  660                      zone_find_attr(attrs, "gateway", &gateway) == 0) {
 706  661                          lxi_iface_gateway(iface, NULL, 0, gateway);
 707  662                  }
 708      -#endif /* XXX KEBE */
 709  663          }
 710  664  
 711  665          if (do_addrconf) {
 712  666                  lxi_net_ndpd_start();
 713  667          }
 714  668  
 715  669          (void) zonecfg_endnwifent(handle);
 716  670  }
 717  671  
 718  672  static void
↓ open down ↓ 171 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX