summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorHans Rosenfeld <rosenfeld@grumpf.hope-2000.org>2021-06-16 19:05:20 +0200
committerHans Rosenfeld <rosenfeld@grumpf.hope-2000.org>2021-07-27 18:12:26 +0200
commited1e93792d7c9ea04a0cb44cffe34c24c135b002 (patch)
tree93953c51fe624d8de5a298c239cb3b9a2139f8ca /usr/src
parentf3a2bc1eccb884e62be4c0b42935466b79b1342d (diff)
downloadillumos-gate-ed1e93792d7c9ea04a0cb44cffe34c24c135b002.tar.gz
13882 libipadm ipadm_if_info() is not 64bit safe
Reviewed by: Jason King <jason.brian.king+illumos@gmail.com> Reviewed by: Robert Mustacchi <rm+illumos@gmail.com> Reviewed by: Andy Fiddaman <andy@omnios.org> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_door.c15
-rw-r--r--usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_impl.h9
-rw-r--r--usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_main.c6
-rw-r--r--usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_persist.c15
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c28
-rw-r--r--usr/src/cmd/rcm_daemon/common/ip_rcm.c9
-rw-r--r--usr/src/lib/libipadm/common/ipadm_if.c96
-rw-r--r--usr/src/lib/libipadm/common/libipadm.h22
8 files changed, 117 insertions, 83 deletions
diff --git a/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_door.c b/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_door.c
index c851b38baf..92e3f73f55 100644
--- a/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_door.c
+++ b/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_door.c
@@ -737,7 +737,8 @@ ipmgmt_getif_handler(void *argp)
ipmgmt_getif_rval_t *rvalp;
ipmgmt_retval_t rval;
ipmgmt_getif_cbarg_t cbarg;
- ipadm_if_info_t *ifp, *rifp, *curifp;
+ ipadm_if_info_list_t *ifl, *curifl;
+ ipadm_if_info_t *ifp, *rifp;
int i, err = 0, count = 0;
size_t rbufsize;
@@ -760,7 +761,7 @@ ipmgmt_getif_handler(void *argp)
}
/* allocate sufficient buffer to return the interface info */
- for (ifp = cbarg.cb_ifinfo; ifp != NULL; ifp = ifp->ifi_next)
+ for (ifl = cbarg.cb_ifinfo; ifl != NULL; ifl = ifl->ifil_next)
++count;
rbufsize = sizeof (*rvalp) + count * sizeof (*ifp);
rvalp = alloca(rbufsize);
@@ -768,7 +769,7 @@ ipmgmt_getif_handler(void *argp)
rvalp->ir_ifcnt = count;
rifp = rvalp->ir_ifinfo;
- ifp = cbarg.cb_ifinfo;
+ ifl = cbarg.cb_ifinfo;
/*
* copy the interface info to buffer allocated on stack. The reason
@@ -776,12 +777,12 @@ ipmgmt_getif_handler(void *argp)
* return
*/
for (i = 0; i < count; i++) {
+ ifp = &ifl->ifil_ifi;
rifp = rvalp->ir_ifinfo + i;
(void) bcopy(ifp, rifp, sizeof (*rifp));
- rifp->ifi_next = NULL;
- curifp = ifp->ifi_next;
- free(ifp);
- ifp = curifp;
+ curifl = ifl->ifil_next;
+ free(ifl);
+ ifl = curifl;
}
rvalp->ir_err = err;
(void) door_return((char *)rvalp, rbufsize, NULL, 0);
diff --git a/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_impl.h b/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_impl.h
index e95e5c7e00..968fa77923 100644
--- a/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_impl.h
+++ b/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_impl.h
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
+ * Copyright 2021, Tintri by DDN. All rights reserved.
*/
#ifndef _IPMGMT_IMPL_H
@@ -62,8 +63,8 @@ extern db_wfunc_t ipmgmt_db_getprop, ipmgmt_db_resetprop;
extern db_wfunc_t ipmgmt_db_add, ipmgmt_db_update;
typedef struct {
- char *cb_ifname;
- ipadm_if_info_t *cb_ifinfo;
+ char *cb_ifname;
+ ipadm_if_info_list_t *cb_ifinfo;
} ipmgmt_getif_cbarg_t;
extern db_wfunc_t ipmgmt_db_getif;
@@ -98,7 +99,7 @@ extern db_wfunc_t ipmgmt_db_initif;
* A linked list of address object nodes. Each node in the list tracks
* following information for the address object identified by `am_aobjname'.
* - interface on which the address is created
- * - logical interface number on which the address is created
+ * - logical interface number on which the address is created
* - address family
* - `am_nextnum' identifies the next number to use to generate user part
* of `aobjname'.
@@ -185,7 +186,7 @@ extern int ipmgmt_db_walk(db_wfunc_t *, void *, ipadm_db_op_t);
extern int ipmgmt_aobjmap_op(ipmgmt_aobjmap_t *, uint32_t);
extern boolean_t ipmgmt_aobjmap_init(void *, nvlist_t *, char *,
size_t, int *);
-extern int ipmgmt_persist_aobjmap(ipmgmt_aobjmap_t *,
+extern int ipmgmt_persist_aobjmap(ipmgmt_aobjmap_t *,
ipadm_db_op_t);
extern boolean_t ipmgmt_ngz_firstboot_postinstall();
extern int ipmgmt_persist_if(ipmgmt_if_arg_t *);
diff --git a/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_main.c b/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_main.c
index 5cdc0f5697..e3a8d3e817 100644
--- a/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_main.c
+++ b/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_main.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2021, Tintri by DDN. All rights reserved.
*/
/*
@@ -534,13 +535,14 @@ ipmgmt_persist_if_exists(char *ifname, sa_family_t af)
bzero(&cbarg, sizeof (cbarg));
cbarg.cb_ifname = ifname;
(void) ipmgmt_db_walk(ipmgmt_db_getif, &cbarg, IPADM_DB_READ);
- if ((ifp = cbarg.cb_ifinfo) != NULL) {
+ if (cbarg.cb_ifinfo != NULL) {
+ ifp = &cbarg.cb_ifinfo->ifil_ifi;
if ((af == AF_INET && (ifp->ifi_pflags & IFIF_IPV4)) ||
(af == AF_INET6 && (ifp->ifi_pflags & IFIF_IPV6))) {
exists = B_TRUE;
}
}
- free(ifp);
+ free(cbarg.cb_ifinfo);
return (exists);
}
diff --git a/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_persist.c b/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_persist.c
index c1995611e9..5f9d24df7a 100644
--- a/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_persist.c
+++ b/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_persist.c
@@ -24,6 +24,7 @@
* Copyright 2018 Joyent, Inc.
* Copyright 2016 Argo Technologie SA.
* Copyright (c) 2016-2017, Chris Fraire <cfraire@me.com>.
+ * Copyright 2021, Tintri by DDN. All rights reserved.
*/
/*
@@ -566,7 +567,8 @@ ipmgmt_db_getif(void *arg, nvlist_t *db_nvl, char *buf, size_t buflen,
ipmgmt_getif_cbarg_t *cbarg = arg;
char *ifname = cbarg->cb_ifname;
char *intf = NULL;
- ipadm_if_info_t *ifp = NULL;
+ ipadm_if_info_list_t *ifl = NULL;
+ ipadm_if_info_t *ifp;
sa_family_t af;
char *afstr;
@@ -577,20 +579,21 @@ ipmgmt_db_getif(void *arg, nvlist_t *db_nvl, char *buf, size_t buflen,
return (B_TRUE);
}
af = atoi(afstr);
- for (ifp = cbarg->cb_ifinfo; ifp != NULL; ifp = ifp->ifi_next) {
+ for (ifl = cbarg->cb_ifinfo; ifl != NULL; ifl = ifl->ifil_next) {
+ ifp = &ifl->ifil_ifi;
if (strcmp(ifp->ifi_name, intf) == 0)
break;
}
- if (ifp == NULL) {
- ipadm_if_info_t *new;
+ if (ifl == NULL) {
+ ipadm_if_info_list_t *new;
if ((new = calloc(1, sizeof (*new))) == NULL) {
*errp = ENOMEM;
return (B_FALSE); /* don't continue the walk */
}
- new->ifi_next = cbarg->cb_ifinfo;
+ new->ifil_next = cbarg->cb_ifinfo;
cbarg->cb_ifinfo = new;
- ifp = new;
+ ifp = &new->ifil_ifi;
(void) strlcpy(ifp->ifi_name, intf, sizeof (ifp->ifi_name));
}
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c
index 30e2f0f549..c195e7be80 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c
@@ -25,6 +25,7 @@
* Copyright (c) 2018, Joyent, Inc.
* Copyright 2017 Gary Mills
* Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
+ * Copyright 2021, Tintri by DDN. All rights reserved.
*/
#include <arpa/inet.h>
@@ -278,7 +279,7 @@ typedef struct show_addr_args_s {
typedef struct show_if_args_s {
show_if_state_t *si_state;
- ipadm_if_info_t *si_info;
+ ipadm_if_info_list_t *si_info;
} show_if_args_t;
typedef enum {
@@ -675,7 +676,7 @@ do_show_ifprop(int argc, char **argv, const char *use)
uint_t proto;
boolean_t m_arg = _B_FALSE;
char *protostr;
- ipadm_if_info_t *ifinfo, *ifp;
+ ipadm_if_info_list_t *ifinfo, *ifl;
ipadm_status_t status;
show_prop_state_t state;
@@ -739,8 +740,9 @@ do_show_ifprop(int argc, char **argv, const char *use)
if (status != IPADM_SUCCESS)
die("Error retrieving interface(s): %s",
ipadm_status2str(status));
- for (ifp = ifinfo; ifp; ifp = ifp->ifi_next) {
- (void) strlcpy(state.sps_ifname, ifp->ifi_name, LIFNAMSIZ);
+ for (ifl = ifinfo; ifl != NULL; ifl = ifl->ifil_next) {
+ (void) strlcpy(state.sps_ifname, ifl->ifil_ifi.ifi_name,
+ LIFNAMSIZ);
state.sps_proto = proto;
show_properties(&state, IPADMPROP_CLASS_IF);
}
@@ -1611,7 +1613,7 @@ flags2str(uint64_t flags, fmask_t *tbl, boolean_t is_bits,
static boolean_t
is_from_gz(const char *lifname)
{
- ipadm_if_info_t *if_info;
+ ipadm_if_info_list_t *if_info;
char phyname[LIFNAMSIZ], *cp;
boolean_t ret = _B_FALSE;
ipadm_status_t status;
@@ -1634,7 +1636,7 @@ is_from_gz(const char *lifname)
if (status != IPADM_SUCCESS)
return (ret);
- if (if_info->ifi_cflags & IFIF_L3PROTECT)
+ if (if_info->ifil_ifi.ifi_cflags & IFIF_L3PROTECT)
ret = _B_TRUE;
ipadm_free_if_info(if_info);
return (ret);
@@ -1889,8 +1891,8 @@ static boolean_t
print_si_cb(ofmt_arg_t *ofarg, char *buf, uint_t bufsize)
{
show_if_args_t *arg = ofarg->ofmt_cbarg;
- ipadm_if_info_t *ifinfo = arg->si_info;
- char *ifname = ifinfo->ifi_name;
+ ipadm_if_info_list_t *ifinfo = arg->si_info;
+ char *ifname = ifinfo->ifil_ifi.ifi_name;
fmask_t intf_state[] = {
{ "ok", IFIS_OK, IPADM_ALL_BITS},
{ "down", IFIS_DOWN, IPADM_ALL_BITS},
@@ -1927,15 +1929,15 @@ print_si_cb(ofmt_arg_t *ofarg, char *buf, uint_t bufsize)
(void) snprintf(buf, bufsize, "%s", ifname);
break;
case SI_STATE:
- flags2str(ifinfo->ifi_state, intf_state, _B_FALSE,
+ flags2str(ifinfo->ifil_ifi.ifi_state, intf_state, _B_FALSE,
buf, bufsize);
break;
case SI_CURRENT:
- flags2str(ifinfo->ifi_cflags, intf_cflags, _B_TRUE,
+ flags2str(ifinfo->ifil_ifi.ifi_cflags, intf_cflags, _B_TRUE,
buf, bufsize);
break;
case SI_PERSISTENT:
- flags2str(ifinfo->ifi_pflags, intf_pflags, _B_TRUE,
+ flags2str(ifinfo->ifil_ifi.ifi_pflags, intf_pflags, _B_TRUE,
buf, bufsize);
break;
default:
@@ -1956,7 +1958,7 @@ do_show_if(int argc, char *argv[], const char *use)
ipadm_status_t status;
show_if_state_t state;
char *fields_str = NULL;
- ipadm_if_info_t *if_info, *ptr;
+ ipadm_if_info_list_t *if_info, *ptr;
show_if_args_t sargs;
int option;
ofmt_handle_t ofmt;
@@ -2001,7 +2003,7 @@ do_show_if(int argc, char *argv[], const char *use)
ipadm_status2str(status));
}
- for (ptr = if_info; ptr; ptr = ptr->ifi_next) {
+ for (ptr = if_info; ptr != NULL; ptr = ptr->ifil_next) {
sargs.si_info = ptr;
ofmt_print(state.si_ofmt, &sargs);
}
diff --git a/usr/src/cmd/rcm_daemon/common/ip_rcm.c b/usr/src/cmd/rcm_daemon/common/ip_rcm.c
index a389fc770d..7d2eeec9b7 100644
--- a/usr/src/cmd/rcm_daemon/common/ip_rcm.c
+++ b/usr/src/cmd/rcm_daemon/common/ip_rcm.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2021, Tintri by DDN. All rights reserved.
*/
/*
@@ -2373,7 +2374,7 @@ if_configure_ipadm(datalink_id_t linkid)
{
char ifinst[MAXLINKNAMELEN];
boolean_t found;
- ipadm_if_info_t *ifinfo, *ptr;
+ ipadm_if_info_list_t *ifinfo, *ptr;
ipadm_status_t status;
assert(linkid != DATALINK_INVALID_LINKID);
@@ -2398,14 +2399,14 @@ if_configure_ipadm(datalink_id_t linkid)
}
if (ifinfo != NULL) {
found = B_FALSE;
- for (ptr = ifinfo; ptr; ptr = ptr->ifi_next) {
- if (strncmp(ptr->ifi_name, ifinst,
+ for (ptr = ifinfo; ptr != NULL; ptr = ptr->ifil_next) {
+ if (strncmp(ptr->ifil_ifi.ifi_name, ifinst,
sizeof (ifinst)) == 0) {
found = B_TRUE;
break;
}
}
- free(ifinfo);
+ ipadm_free_if_info(ifinfo);
if (!found) {
return (0);
}
diff --git a/usr/src/lib/libipadm/common/ipadm_if.c b/usr/src/lib/libipadm/common/ipadm_if.c
index 41f22e4eeb..c140f4ca40 100644
--- a/usr/src/lib/libipadm/common/ipadm_if.c
+++ b/usr/src/lib/libipadm/common/ipadm_if.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2021, Tintry by DDN. All rights reserved.
*/
#include <errno.h>
@@ -82,12 +83,12 @@ i_ipadm_is_if_down(char *ifname, struct ifaddrs *ifa)
*/
static ipadm_status_t
i_ipadm_active_if_info(ipadm_handle_t iph, const char *ifname,
- ipadm_if_info_t **if_info, int64_t lifc_flags)
+ ipadm_if_info_list_t **if_info, int64_t lifc_flags)
{
struct lifreq *buf;
struct lifreq *lifrp;
struct lifreq lifrl;
- ipadm_if_info_t *last = NULL;
+ ipadm_if_info_list_t *ifl, *last = NULL;
ipadm_if_info_t *ifp;
int s;
int n;
@@ -117,24 +118,26 @@ i_ipadm_active_if_info(ipadm_handle_t iph, const char *ifname,
* Check if the interface already exists in our list.
* If it already exists, we need to update its flags.
*/
- for (ifp = *if_info; ifp != NULL; ifp = ifp->ifi_next) {
+ for (ifl = *if_info; ifl != NULL; ifl = ifl->ifil_next) {
+ ifp = &ifl->ifil_ifi;
if (strcmp(lifrp->lifr_name, ifp->ifi_name) == 0)
break;
}
- if (ifp == NULL) {
- ifp = calloc(1, sizeof (ipadm_if_info_t));
- if (ifp == NULL) {
+ if (ifl == NULL) {
+ ifl = calloc(1, sizeof (ipadm_if_info_list_t));
+ if (ifl == NULL) {
status = ipadm_errno2status(errno);
goto fail;
}
+ ifp = &ifl->ifil_ifi;
(void) strlcpy(ifp->ifi_name, lifrp->lifr_name,
sizeof (ifp->ifi_name));
- /* Update the `ifi_next' pointer for this new node */
+ /* Update the `ifil_next' pointer for this new node */
if (*if_info == NULL)
- *if_info = ifp;
+ *if_info = ifl;
else
- last->ifi_next = ifp;
- last = ifp;
+ last->ifil_next = ifl;
+ last = ifl;
}
/*
@@ -188,12 +191,13 @@ fail:
*/
static ipadm_status_t
i_ipadm_persist_if_info(ipadm_handle_t iph, const char *ifname,
- ipadm_if_info_t **if_info)
+ ipadm_if_info_list_t **if_info)
{
ipadm_status_t status = IPADM_SUCCESS;
ipmgmt_getif_arg_t getif;
ipmgmt_getif_rval_t *rvalp;
- ipadm_if_info_t *ifp, *curr, *prev = NULL;
+ ipadm_if_info_t *ifp;
+ ipadm_if_info_list_t *curr, *prev = NULL;
int i = 0, err = 0;
bzero(&getif, sizeof (getif));
@@ -225,8 +229,8 @@ i_ipadm_persist_if_info(ipadm_handle_t iph, const char *ifname,
ipadm_free_if_info(prev);
break;
}
- (void) bcopy(ifp, curr, sizeof (*curr));
- curr->ifi_next = prev;
+ (void) bcopy(ifp, &curr->ifil_ifi, sizeof (*ifp));
+ curr->ifil_next = prev;
prev = curr;
}
*if_info = curr;
@@ -242,14 +246,16 @@ i_ipadm_persist_if_info(ipadm_handle_t iph, const char *ifname,
*/
ipadm_status_t
i_ipadm_get_all_if_info(ipadm_handle_t iph, const char *ifname,
- ipadm_if_info_t **if_info, int64_t lifc_flags)
+ ipadm_if_info_list_t **if_info, int64_t lifc_flags)
{
ipadm_status_t status;
- ipadm_if_info_t *aifinfo = NULL;
- ipadm_if_info_t *pifinfo = NULL;
+ ipadm_if_info_list_t *aifinfo = NULL;
+ ipadm_if_info_list_t *pifinfo = NULL;
+ ipadm_if_info_list_t *last = NULL;
+ ipadm_if_info_list_t *aifl;
+ ipadm_if_info_list_t *pifl;
ipadm_if_info_t *aifp;
ipadm_if_info_t *pifp;
- ipadm_if_info_t *last = NULL;
struct ifaddrs *ifa;
struct ifaddrs *ifap;
@@ -269,7 +275,9 @@ retry:
status = ipadm_errno2status(errno);
goto fail;
}
- for (aifp = aifinfo; aifp != NULL; aifp = aifp->ifi_next) {
+ for (aifl = aifinfo; aifl != NULL; aifl = aifl->ifil_next) {
+ aifp = &aifl->ifil_ifi;
+
/*
* Find the `ifaddrs' structure from `ifa'
* for this interface. We need the IFF_* flags
@@ -299,8 +307,8 @@ retry:
aifp->ifi_state = IFIS_DOWN;
else
aifp->ifi_state = IFIS_OK;
- if (aifp->ifi_next == NULL)
- last = aifp;
+ if (aifl->ifil_next == NULL)
+ last = aifl;
}
freeifaddrs(ifa);
}
@@ -321,27 +329,29 @@ retry:
* `aifinfo', it means that this interface was disabled. We should
* add this interface to `aifinfo' and set it state to IFIF_DISABLED.
*/
- for (pifp = pifinfo; pifp != NULL; pifp = pifp->ifi_next) {
- for (aifp = aifinfo; aifp != NULL; aifp = aifp->ifi_next) {
+ for (pifl = pifinfo; pifl != NULL; pifl = pifl->ifil_next) {
+ pifp = &pifl->ifil_ifi;
+ for (aifl = aifinfo; aifl != NULL; aifl = aifl->ifil_next) {
+ aifp = &aifl->ifil_ifi;
if (strcmp(aifp->ifi_name, pifp->ifi_name) == 0) {
aifp->ifi_pflags = pifp->ifi_pflags;
break;
}
}
- if (aifp == NULL) {
- aifp = malloc(sizeof (ipadm_if_info_t));
- if (aifp == NULL) {
+ if (aifl == NULL) {
+ aifl = malloc(sizeof (ipadm_if_info_list_t));
+ if (aifl == NULL) {
status = ipadm_errno2status(errno);
goto fail;
}
- *aifp = *pifp;
- aifp->ifi_next = NULL;
- aifp->ifi_state = IFIS_DISABLED;
+ *aifl = *pifl;
+ aifl->ifil_next = NULL;
+ aifl->ifil_ifi.ifi_state = IFIS_DISABLED;
if (last != NULL)
- last->ifi_next = aifp;
+ last->ifil_next = aifl;
else
- aifinfo = aifp;
- last = aifp;
+ aifinfo = aifl;
+ last = aifl;
}
}
*if_info = aifinfo;
@@ -375,7 +385,7 @@ ipadm_status_t
i_ipadm_if_pexists(ipadm_handle_t iph, const char *ifname, sa_family_t af,
boolean_t *exists)
{
- ipadm_if_info_t *ifinfo;
+ ipadm_if_info_list_t *ifinfo;
ipadm_status_t status;
/*
@@ -390,9 +400,9 @@ i_ipadm_if_pexists(ipadm_handle_t iph, const char *ifname, sa_family_t af,
status = i_ipadm_persist_if_info(iph, ifname, &ifinfo);
if (status == IPADM_SUCCESS) {
*exists = ((af == AF_INET &&
- (ifinfo->ifi_pflags & IFIF_IPV4)) ||
+ (ifinfo->ifil_ifi.ifi_pflags & IFIF_IPV4)) ||
(af == AF_INET6 &&
- (ifinfo->ifi_pflags & IFIF_IPV6)));
+ (ifinfo->ifil_ifi.ifi_pflags & IFIF_IPV6)));
free(ifinfo);
} else if (status == IPADM_NOTFOUND) {
status = IPADM_SUCCESS;
@@ -495,7 +505,7 @@ i_ipadm_create_ipmp_peer(ipadm_handle_t iph, char *ifname, sa_family_t af)
lifgroupinfo_t lifgr;
ipadm_status_t status = IPADM_SUCCESS;
struct lifreq lifr;
- int other_af_sock;
+ int other_af_sock;
assert(af == AF_INET || af == AF_INET6);
@@ -1387,7 +1397,7 @@ ipadm_delete_if(ipadm_handle_t iph, const char *ifname, sa_family_t af,
* If af is AF_UNSPEC, then we return the following:
* status1, if status1 == status2
* IPADM_SUCCESS, if either of status1 or status2 is SUCCESS
- * and the other status is ENXIO
+ * and the other status is ENXIO
* IPADM_ENXIO, if both status1 and status2 are ENXIO
* IPADM_FAILURE otherwise.
*/
@@ -1411,12 +1421,12 @@ ipadm_delete_if(ipadm_handle_t iph, const char *ifname, sa_family_t af,
* identified by `ifname'.
*
* Return values:
- * On success: IPADM_SUCCESS.
- * On error : IPADM_INVALID_ARG, IPADM_ENXIO or IPADM_FAILURE.
+ * On success: IPADM_SUCCESS.
+ * On error : IPADM_INVALID_ARG, IPADM_ENXIO or IPADM_FAILURE.
*/
ipadm_status_t
ipadm_if_info(ipadm_handle_t iph, const char *ifname,
- ipadm_if_info_t **if_info, uint32_t flags, int64_t lifc_flags)
+ ipadm_if_info_list_t **if_info, uint32_t flags, int64_t lifc_flags)
{
ipadm_status_t status;
ifspec_t ifsp;
@@ -1442,12 +1452,12 @@ ipadm_if_info(ipadm_handle_t iph, const char *ifname,
* Frees the linked list allocated by ipadm_if_info().
*/
void
-ipadm_free_if_info(ipadm_if_info_t *ifinfo)
+ipadm_free_if_info(ipadm_if_info_list_t *ifinfo)
{
- ipadm_if_info_t *ifinfo_next;
+ ipadm_if_info_list_t *ifinfo_next;
for (; ifinfo != NULL; ifinfo = ifinfo_next) {
- ifinfo_next = ifinfo->ifi_next;
+ ifinfo_next = ifinfo->ifil_next;
free(ifinfo);
}
}
diff --git a/usr/src/lib/libipadm/common/libipadm.h b/usr/src/lib/libipadm/common/libipadm.h
index 0d8e3fdd7b..0ae9d89e4b 100644
--- a/usr/src/lib/libipadm/common/libipadm.h
+++ b/usr/src/lib/libipadm/common/libipadm.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
+ * Copyright 2021, Tintri by DDN. All rights reserved.
*/
#ifndef _LIBIPADM_H
#define _LIBIPADM_H
@@ -205,14 +206,27 @@ typedef enum {
IFIS_DISABLED /* Interface has been disabled. */
} ipadm_if_state_t;
+/*
+ * Declare ipadm_if_info_list_t as a container for ipadm_if_info_t.
+ *
+ * ipadm_if_info_t used to have a list pointer ifi_next for linking a number
+ * of ipadm_if_info_t's together. Even though this linking wasn't used in the
+ * data exchange between ipmgmtd and libipadm, this meant the structure wasn't
+ * safe for passing through the door between 32bit and 64bit processes.
+ */
typedef struct ipadm_if_info_s {
- struct ipadm_if_info_s *ifi_next;
char ifi_name[LIFNAMSIZ]; /* interface name */
ipadm_if_state_t ifi_state; /* see above */
uint_t ifi_cflags; /* current flags */
uint_t ifi_pflags; /* persistent flags */
} ipadm_if_info_t;
+typedef struct ipadm_if_info_list_s {
+ struct ipadm_if_info_list_s *ifil_next;
+ ipadm_if_info_t ifil_ifi;
+} ipadm_if_info_list_t;
+
+
/* ipadm_if_info_t flags */
#define IFIF_BROADCAST 0x00000001
#define IFIF_MULTICAST 0x00000002
@@ -279,8 +293,8 @@ extern ipadm_status_t ipadm_disable_if(ipadm_handle_t, const char *,
uint32_t);
extern ipadm_status_t ipadm_enable_if(ipadm_handle_t, const char *, uint32_t);
extern ipadm_status_t ipadm_if_info(ipadm_handle_t, const char *,
- ipadm_if_info_t **, uint32_t, int64_t);
-extern void ipadm_free_if_info(ipadm_if_info_t *);
+ ipadm_if_info_list_t **, uint32_t, int64_t);
+extern void ipadm_free_if_info(ipadm_if_info_list_t *);
extern ipadm_status_t ipadm_delete_if(ipadm_handle_t, const char *,
sa_family_t, uint32_t);
extern void ipadm_if_move(ipadm_handle_t, const char *);
@@ -362,7 +376,7 @@ extern ipadm_status_t ipadm_get_prop(ipadm_handle_t, const char *, char *,
/*
* miscellaneous helper functions.
*/
-extern const char *ipadm_status2str(ipadm_status_t);
+extern const char *ipadm_status2str(ipadm_status_t);
extern int ipadm_str2nvlist(const char *, nvlist_t **, uint_t);
extern size_t ipadm_nvlist2str(nvlist_t *, char *, size_t);
extern char *ipadm_proto2str(uint_t);