Skip to content

Commit 090ce41

Browse files
committed
Fix compiler errors on Solaris, NetBSD, and OpenBSD:
* Per http://www.open-mpi.org/community/lists/devel/2013/12/13504.php, protect usage of struct ifreq->ifr_hwaddr * Per http://www.open-mpi.org/community/lists/devel/2013/12/13503.php, avoid #define conflict with the token "if_mtu" * Also fix some whitespace and string naming issues in opal/util/if.c Tested by Paul Hargrove. Refs trac:4010 This commit was SVN r30006. The following Trac tickets were found above: Ticket 4010 --> https://svn.open-mpi.org/trac/ompi/ticket/4010
1 parent d78a9cd commit 090ce41

File tree

6 files changed

+22
-19
lines changed

6 files changed

+22
-19
lines changed

opal/mca/if/base/if_base_components.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,5 @@ static void opal_if_construct(opal_if_t *obj)
8686
obj->if_mask = 0;
8787
obj->if_bandwidth = 0;
8888
memset(obj->if_mac, 0, sizeof(obj->if_mac));
89-
obj->if_mtu = 0;
89+
obj->ifmtu = 0;
9090
}

opal/mca/if/if.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ typedef struct opal_if_t {
9595
uint32_t if_mask;
9696
uint32_t if_bandwidth;
9797
uint8_t if_mac[6];
98-
int if_mtu;
98+
int ifmtu; /* Can't use if_mtu because of a
99+
#define collision on some BSDs */
99100
} opal_if_t;
100101
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_if_t);
101102

opal/mca/if/posix_ipv4/configure.m4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ AC_DEFUN([MCA_opal_if_posix_ipv4_CONFIG], [
4242
)
4343

4444
AS_IF([test "$opal_if_posix_ipv4_happy" = "yes"],
45-
[AC_CHECK_MEMBERS([struct ifreq.ifr_mtu], [], [],
45+
[AC_CHECK_MEMBERS([struct ifreq.ifr_hwaddr], [], [],
46+
[[#include <net/if.h>]])
47+
AC_CHECK_MEMBERS([struct ifreq.ifr_mtu], [], [],
4648
[[#include <net/if.h>]])
4749
])
4850

opal/mca/if/posix_ipv4/if_posix.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,22 +263,22 @@ static int if_posix_open(void)
263263
/* generate CIDR and assign to netmask */
264264
intf->if_mask = prefix(((struct sockaddr_in*) &ifr->ifr_addr)->sin_addr.s_addr);
265265

266-
#ifdef SIOCGIFHWADDR
267-
/* get the MAC address */
268-
if (ioctl(sd, SIOCGIFHWADDR, ifr) < 0) {
269-
opal_output(0, "btl_usnic_opal_ifinit: ioctl(SIOCGIFHWADDR) failed with errno=%d", errno);
270-
break;
271-
}
272-
memcpy(intf->if_mac, ifr->ifr_hwaddr.sa_data, 6);
266+
#if defined(SIOCGIFHWADDR) && defined(HAVE_STRUCT_IFREQ_IFR_HWADDR)
267+
/* get the MAC address */
268+
if (ioctl(sd, SIOCGIFHWADDR, ifr) < 0) {
269+
opal_output(0, "opal_ifinit: ioctl(SIOCGIFHWADDR) failed with errno=%d", errno);
270+
break;
271+
}
272+
memcpy(intf->if_mac, ifr->ifr_hwaddr.sa_data, 6);
273273
#endif
274274

275275
#if defined(SIOCGIFMTU) && defined(HAVE_STRUCT_IFREQ_IFR_MTU)
276-
/* get the MTU */
277-
if (ioctl(sd, SIOCGIFMTU, ifr) < 0) {
278-
opal_output(0, "btl_usnic_opal_ifinit: ioctl(SIOCGIFMTU) failed with errno=%d", errno);
279-
break;
280-
}
281-
intf->if_mtu = ifr->ifr_mtu;
276+
/* get the MTU */
277+
if (ioctl(sd, SIOCGIFMTU, ifr) < 0) {
278+
opal_output(0, "opal_ifinit: ioctl(SIOCGIFMTU) failed with errno=%d", errno);
279+
break;
280+
}
281+
intf->ifmtu = ifr->ifr_mtu;
282282
#endif
283283

284284
opal_list_append(&opal_if_list, &(intf->super));

opal/util/if.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,15 +479,15 @@ int opal_ifindextomac(int if_index, uint8_t mac[6])
479479
* MTU assigned to the interface.
480480
*/
481481

482-
int opal_ifindextomtu(int if_index, int *if_mtu)
482+
int opal_ifindextomtu(int if_index, int *mtu)
483483
{
484484
opal_if_t* intf;
485485

486486
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
487487
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
488488
intf = (opal_if_t*)opal_list_get_next(intf)) {
489489
if (intf->if_index == if_index) {
490-
*if_mtu = intf->if_mtu;
490+
*mtu = intf->ifmtu;
491491
return OPAL_SUCCESS;
492492
}
493493
}

opal/util/if.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ OPAL_DECLSPEC int opal_ifindextomac(int if_index, uint8_t if_mac[6]);
179179
* @param if_index (IN) Interface index
180180
* @param if_mtu (OUT) Interface's MTU
181181
*/
182-
OPAL_DECLSPEC int opal_ifindextomtu(int if_index, int *if_mtu);
182+
OPAL_DECLSPEC int opal_ifindextomtu(int if_index, int *mtu);
183183

184184
/**
185185
* Lookup an interface by index and return its flags.

0 commit comments

Comments
 (0)