1
1

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
Этот коммит содержится в:
Jeff Squyres 2013-12-20 11:17:30 +00:00
родитель d78a9cdd77
Коммит 090ce4187a
6 изменённых файлов: 22 добавлений и 19 удалений

Просмотреть файл

@ -86,5 +86,5 @@ static void opal_if_construct(opal_if_t *obj)
obj->if_mask = 0;
obj->if_bandwidth = 0;
memset(obj->if_mac, 0, sizeof(obj->if_mac));
obj->if_mtu = 0;
obj->ifmtu = 0;
}

Просмотреть файл

@ -95,7 +95,8 @@ typedef struct opal_if_t {
uint32_t if_mask;
uint32_t if_bandwidth;
uint8_t if_mac[6];
int if_mtu;
int ifmtu; /* Can't use if_mtu because of a
#define collision on some BSDs */
} opal_if_t;
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_if_t);

Просмотреть файл

@ -42,7 +42,9 @@ AC_DEFUN([MCA_opal_if_posix_ipv4_CONFIG], [
)
AS_IF([test "$opal_if_posix_ipv4_happy" = "yes"],
[AC_CHECK_MEMBERS([struct ifreq.ifr_mtu], [], [],
[AC_CHECK_MEMBERS([struct ifreq.ifr_hwaddr], [], [],
[[#include <net/if.h>]])
AC_CHECK_MEMBERS([struct ifreq.ifr_mtu], [], [],
[[#include <net/if.h>]])
])

Просмотреть файл

@ -263,22 +263,22 @@ static int if_posix_open(void)
/* generate CIDR and assign to netmask */
intf->if_mask = prefix(((struct sockaddr_in*) &ifr->ifr_addr)->sin_addr.s_addr);
#ifdef SIOCGIFHWADDR
/* get the MAC address */
if (ioctl(sd, SIOCGIFHWADDR, ifr) < 0) {
opal_output(0, "btl_usnic_opal_ifinit: ioctl(SIOCGIFHWADDR) failed with errno=%d", errno);
break;
}
memcpy(intf->if_mac, ifr->ifr_hwaddr.sa_data, 6);
#if defined(SIOCGIFHWADDR) && defined(HAVE_STRUCT_IFREQ_IFR_HWADDR)
/* get the MAC address */
if (ioctl(sd, SIOCGIFHWADDR, ifr) < 0) {
opal_output(0, "opal_ifinit: ioctl(SIOCGIFHWADDR) failed with errno=%d", errno);
break;
}
memcpy(intf->if_mac, ifr->ifr_hwaddr.sa_data, 6);
#endif
#if defined(SIOCGIFMTU) && defined(HAVE_STRUCT_IFREQ_IFR_MTU)
/* get the MTU */
if (ioctl(sd, SIOCGIFMTU, ifr) < 0) {
opal_output(0, "btl_usnic_opal_ifinit: ioctl(SIOCGIFMTU) failed with errno=%d", errno);
break;
}
intf->if_mtu = ifr->ifr_mtu;
/* get the MTU */
if (ioctl(sd, SIOCGIFMTU, ifr) < 0) {
opal_output(0, "opal_ifinit: ioctl(SIOCGIFMTU) failed with errno=%d", errno);
break;
}
intf->ifmtu = ifr->ifr_mtu;
#endif
opal_list_append(&opal_if_list, &(intf->super));

Просмотреть файл

@ -479,7 +479,7 @@ int opal_ifindextomac(int if_index, uint8_t mac[6])
* MTU assigned to the interface.
*/
int opal_ifindextomtu(int if_index, int *if_mtu)
int opal_ifindextomtu(int if_index, int *mtu)
{
opal_if_t* intf;
@ -487,7 +487,7 @@ int opal_ifindextomtu(int if_index, int *if_mtu)
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
intf = (opal_if_t*)opal_list_get_next(intf)) {
if (intf->if_index == if_index) {
*if_mtu = intf->if_mtu;
*mtu = intf->ifmtu;
return OPAL_SUCCESS;
}
}

Просмотреть файл

@ -179,7 +179,7 @@ OPAL_DECLSPEC int opal_ifindextomac(int if_index, uint8_t if_mac[6]);
* @param if_index (IN) Interface index
* @param if_mtu (OUT) Interface's MTU
*/
OPAL_DECLSPEC int opal_ifindextomtu(int if_index, int *if_mtu);
OPAL_DECLSPEC int opal_ifindextomtu(int if_index, int *mtu);
/**
* Lookup an interface by index and return its flags.