[OpenPower-Firmware] [PATCH 7/7] udhcpc: Support gathering Infiniband HW address
Daniel M. Weeks
weeksd2 at rpi.edu
Fri Apr 17 06:19:48 AEST 2020
Signed-off-by: Daniel M. Weeks <weeksd2 at rpi.edu>
---
networking/udhcp/socket.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c
index b165d1b1c..1d2137bff 100644
--- a/networking/udhcp/socket.c
+++ b/networking/udhcp/socket.c
@@ -26,6 +26,7 @@
#include <net/if.h>
#include <ifaddrs.h>
#include <netpacket/packet.h>
+#include <net/if_arp.h>
int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t *nip, uint8_t *mac, uint8_t *hlen, uint8_t *htype)
{
@@ -44,8 +45,23 @@ int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t
sip = (struct sockaddr_in*)(ifa->ifa_addr);
sll = (struct sockaddr_ll*)(ifa->ifa_addr);
- memcpy(mac, sll->sll_addr, 6);
- log2("MAC %02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+ if (sll->sll_hatype == ARPHRD_ETHER) {
+ memcpy(mac, sll->sll_addr, 6);
+ log2("MAC %02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ } else if (sll->sll_hatype == ARPHRD_INFINIBAND) {
+ memcpy(mac, sll->sll_addr, 20);
+ log2("HW addr "
+ "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:"
+ "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
+ mac[0], mac[1], mac[2], mac[3], mac[4],
+ mac[5], mac[6], mac[7], mac[8], mac[9],
+ mac[10], mac[11], mac[12], mac[13], mac[14],
+ mac[15], mac[16], mac[17], mac[18], mac[19]);
+ } else {
+ break;
+ }
+
*ifindex = sll->sll_ifindex;
log2("ifindex %d", *ifindex);
--
Daniel M. Weeks
--
Daniel M. Weeks
Lead HPC Developer
Center for Computational Innovations
Rensselaer Polytechnic Institute
Troy, NY 12180
518-276-4458
More information about the OpenPower-Firmware
mailing list