Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS-7120 ipmi_lan_get_config() doesn't really get IPv6 #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions usr/src/lib/fm/topo/libtopo/common/topo_hc.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ extern "C" {
#define TOPO_PROP_NETCFG_IPV4_SUBNET "ipv4-subnet"
#define TOPO_PROP_NETCFG_IPV4_GATEWAY "ipv4-gateway"
#define TOPO_PROP_NETCFG_IPV4_TYPE "ipv4-config-type"
#define TOPO_PROP_NETCFG_IPV6_ADDR "ipv6-address"
#define TOPO_PROP_NETCFG_IPV6_ROUTES "ipv6-routes"
#define TOPO_PROP_NETCFG_IPV6_ADDRS "ipv6-addresses"
#define TOPO_PROP_NETCFG_IPV6_ROUTES "ipv6-route-targets"
#define TOPO_PROP_NETCFG_IPV6_TYPE "ipv6-config-type"

/* Possible values for TOPO_PROP_NETCFG_TYPE */
Expand Down
77 changes: 57 additions & 20 deletions usr/src/lib/fm/topo/modules/common/ipmi/ipmi_enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,11 @@ static int
ipmi_enum_sp(topo_mod_t *mod, tnode_t *pnode)
{
ipmi_handle_t *ihp;
ipmi_channel_info_t *chinfo;
ipmi_lan_config_t lancfg = { 0 };
boolean_t found_lan = B_TRUE;
char ipv4_addr[INET_ADDRSTRLEN], subnet[INET_ADDRSTRLEN];
char gateway[INET_ADDRSTRLEN], macaddr[18];
char ipv6_addr[INET6_ADDRSTRLEN];
char **ipv6_routes;
char **ipv6_addrs = NULL, **ipv6_routes = NULL;
const char *sp_rev, *ipv4_cfgtype, *ipv6_cfgtype;
nvlist_t *auth, *fmri;
tnode_t *sp_node;
Expand Down Expand Up @@ -580,6 +578,8 @@ ipmi_enum_sp(topo_mod_t *mod, tnode_t *pnode)
* Iterate through the channels to find the LAN channel.
*/
for (ch = 0; ch <= IPMI_MAX_CHANNEL; ch++) {
ipmi_channel_info_t *chinfo;

if ((chinfo = ipmi_get_channel_info(ihp, ch)) != NULL &&
chinfo->ici_medium == IPMI_MEDIUM_8023LAN) {
found_lan = B_TRUE;
Expand All @@ -592,7 +592,7 @@ ipmi_enum_sp(topo_mod_t *mod, tnode_t *pnode)
*/
if (found_lan != B_TRUE ||
ipmi_lan_get_config(ihp, ch, &lancfg) != 0) {
(void) fprintf(stderr, "failed to get LAN config\n");
topo_mod_dprintf(mod, "failed to get LAN config\n");
(void) topo_mod_seterrno(mod, EMOD_UNKNOWN);
goto out;
}
Expand Down Expand Up @@ -642,7 +642,7 @@ ipmi_enum_sp(topo_mod_t *mod, tnode_t *pnode)
sizeof (subnet)) == NULL ||
inet_ntop(AF_INET, &lancfg.ilc_gateway_addr, gateway,
sizeof (gateway)) == NULL)) {
(void) fprintf(stderr, "failed to convert IP addresses: %s\n",
topo_mod_dprintf(mod, "failed to convert IP addresses: %s\n",
strerror(errno));
(void) topo_mod_seterrno(mod, EMOD_UNKNOWN);
goto out;
Expand Down Expand Up @@ -671,41 +671,71 @@ ipmi_enum_sp(topo_mod_t *mod, tnode_t *pnode)
if (lancfg.ilc_ipv6_enabled == B_TRUE) {
ipv6_cfgtype = ipmi2toposrc(lancfg.ilc_ipv6_source);

if (inet_ntop(AF_INET6, &lancfg.ilc_ipv6_addr, ipv6_addr,
sizeof (ipv6_addr)) == NULL) {
(void) fprintf(stderr, "failed to convert IPv6 "
"address: %s\n", strerror(errno));
(void) topo_mod_seterrno(mod, EMOD_UNKNOWN);
/* allocate and populate ipv6-naddrs string array */
if ((ipv6_addrs = topo_mod_zalloc(mod,
lancfg.ilc_ipv6_naddrs * sizeof (char *))) == NULL) {
/* errno set */
goto out;
}

/* allocate and populate ipv6-routes string array */
if ((ipv6_routes = topo_mod_zalloc(mod,
for (i = 0; i < lancfg.ilc_ipv6_naddrs; i++) {
if ((ipv6_addrs[i] = topo_mod_alloc(mod,
INET6_ADDRSTRLEN + 4)) == NULL) {
/* errno set */
goto out;
}
}

for (i = 0; i < lancfg.ilc_ipv6_naddrs; i++) {
char v6addr[INET6_ADDRSTRLEN];

if (inet_ntop(AF_INET6,
&lancfg.ilc_ipv6_addrs[i].iiv6_addr, v6addr,
sizeof (v6addr)) == NULL) {
topo_mod_dprintf(mod, "failed to convert "
"IPv6 addresses: %s\n", strerror(errno));
(void) topo_mod_seterrno(mod, EMOD_UNKNOWN);
goto out;
}
(void) snprintf(ipv6_addrs[i], INET6_ADDRSTRLEN + 3,
"%s/%u", v6addr,
lancfg.ilc_ipv6_addrs[i].iiv6_pfxlen);
}

/* allocate and populate ipv6-route-targets string array */
if (lancfg.ilc_ipv6_nroutes > 0 &&
(ipv6_routes = topo_mod_zalloc(mod,
lancfg.ilc_ipv6_nroutes * sizeof (char *))) == NULL) {
/* errno set */
goto out;
}
for (i = 0; i < lancfg.ilc_ipv6_nroutes; i++) {
if ((ipv6_routes[i] = topo_mod_alloc(mod,
INET6_ADDRSTRLEN)) == NULL) {
INET6_ADDRSTRLEN + 4)) == NULL) {
/* errno set */
goto out;
}
}
for (i = 0; i < lancfg.ilc_ipv6_nroutes; i++) {
if (inet_ntop(AF_INET6, &lancfg.ilc_ipv6_routes[i],
ipv6_routes[i], sizeof (ipv6_routes[i])) == NULL) {
(void) fprintf(stderr, "failed to convert "
char v6route[INET6_ADDRSTRLEN];

if (inet_ntop(AF_INET6,
&lancfg.ilc_ipv6_routes[i].iiv6_addr, v6route,
sizeof (v6route)) == NULL) {
topo_mod_dprintf(mod, "failed to convert "
"IPv6 addresses: %s\n", strerror(errno));
(void) topo_mod_seterrno(mod, EMOD_UNKNOWN);
goto out;
}
(void) snprintf(ipv6_routes[i], INET6_ADDRSTRLEN + 3,
"%s/%u", v6route,
lancfg.ilc_ipv6_routes[i].iiv6_pfxlen);
}
}
if (lancfg.ilc_ipv6_enabled == B_TRUE &&
(topo_prop_set_string(sp_node, TOPO_PGROUP_NETCFG,
TOPO_PROP_NETCFG_IPV6_ADDR, TOPO_PROP_IMMUTABLE, ipv6_addr,
&err) != 0 ||
(topo_prop_set_string_array(sp_node, TOPO_PGROUP_NETCFG,
TOPO_PROP_NETCFG_IPV6_ADDRS, TOPO_PROP_IMMUTABLE,
(const char **)ipv6_addrs, lancfg.ilc_ipv6_naddrs, &err) != 0 ||
topo_prop_set_string_array(sp_node, TOPO_PGROUP_NETCFG,
TOPO_PROP_NETCFG_IPV6_ROUTES, TOPO_PROP_IMMUTABLE,
(const char **)ipv6_routes, lancfg.ilc_ipv6_nroutes, &err) != 0 ||
Expand All @@ -719,7 +749,14 @@ ipmi_enum_sp(topo_mod_t *mod, tnode_t *pnode)
}
ret = 0;
out:
if (lancfg.ilc_ipv6_nroutes > 0) {
ipmi_lan_free_config(&lancfg);
if (lancfg.ilc_ipv6_naddrs > 0 && ipv6_addrs != NULL) {
for (i = 0; i < lancfg.ilc_ipv6_naddrs; i++)
topo_mod_free(mod, ipv6_addrs[i], INET6_ADDRSTRLEN);
topo_mod_free(mod, ipv6_addrs,
lancfg.ilc_ipv6_naddrs * sizeof (char *));
}
if (lancfg.ilc_ipv6_nroutes > 0 && ipv6_routes != NULL) {
for (i = 0; i < lancfg.ilc_ipv6_nroutes; i++)
topo_mod_free(mod, ipv6_routes[i], INET6_ADDRSTRLEN);
topo_mod_free(mod, ipv6_routes,
Expand Down
Loading