344e29
diff -up dhcp-4.2.4-P2/client/dhclient.c.lpf-ib dhcp-4.2.4-P2/client/dhclient.c
344e29
--- dhcp-4.2.4-P2/client/dhclient.c.lpf-ib	2012-11-30 14:05:07.399394154 +0100
344e29
+++ dhcp-4.2.4-P2/client/dhclient.c	2012-11-30 14:05:07.406394070 +0100
d5d042
@@ -113,6 +113,8 @@ static int check_domain_name_list(const
bd3a57
 static int check_option_values(struct universe *universe, unsigned int opt,
bd3a57
 			       const char *ptr, size_t len);
bd3a57
 
bd3a57
+static void setup_ib_interface(struct interface_info *ip);
bd3a57
+
bd3a57
 int
bd3a57
 main(int argc, char **argv) {
bd3a57
 	int fd;
d5d042
@@ -909,6 +911,14 @@ main(int argc, char **argv) {
bd3a57
 	}
bd3a57
 	srandom(seed + cur_time + (unsigned)getpid());
bd3a57
 
bd3a57
+	/* Setup specific Infiniband options */
bd3a57
+	for (ip = interfaces; ip; ip = ip->next) {
bd3a57
+		if (ip->client &&
bd3a57
+		    (ip->hw_address.hbuf[0] == HTYPE_INFINIBAND)) {
bd3a57
+			setup_ib_interface(ip);
bd3a57
+		}
bd3a57
+	}
bd3a57
+
bd3a57
 	/* Start a configuration state machine for each interface. */
bd3a57
 #ifdef DHCPv6
bd3a57
 	if (local_family == AF_INET6) {
d5d042
@@ -1185,6 +1195,29 @@ int find_subnet (struct subnet **sp,
bd3a57
 	return 0;
bd3a57
 }
bd3a57
 
bd3a57
+static void setup_ib_interface(struct interface_info *ip)
bd3a57
+{
bd3a57
+	struct group *g;
bd3a57
+
bd3a57
+	/* Set the broadcast flag */
bd3a57
+	ip->client->config->bootp_broadcast_always = 1;
bd3a57
+
bd3a57
+	/*
bd3a57
+	 * Find out if a dhcp-client-identifier option was specified either
bd3a57
+	 * in the config file or on the command line
bd3a57
+	 */
bd3a57
+	for (g = ip->client->config->on_transmission; g != NULL; g = g->next) {
bd3a57
+		if ((g->statements != NULL) &&
bd3a57
+		    (strcmp(g->statements->data.option->option->name,
bd3a57
+			    "dhcp-client-identifier") == 0)) {
bd3a57
+			return;
bd3a57
+		}
bd3a57
+	}
bd3a57
+
bd3a57
+	/* No client ID specified */
bd3a57
+	log_fatal("dhcp-client-identifier must be specified for InfiniBand");
bd3a57
+}
bd3a57
+
bd3a57
 /* Individual States:
bd3a57
  *
bd3a57
  * Each routine is called from the dhclient_state_machine() in one of
344e29
diff -up dhcp-4.2.4-P2/common/bpf.c.lpf-ib dhcp-4.2.4-P2/common/bpf.c
344e29
--- dhcp-4.2.4-P2/common/bpf.c.lpf-ib	2012-11-30 14:05:07.394394214 +0100
344e29
+++ dhcp-4.2.4-P2/common/bpf.c	2012-11-30 14:05:07.407394058 +0100
bd3a57
@@ -198,11 +198,44 @@ struct bpf_insn dhcp_bpf_filter [] = {
bd3a57
 	BPF_STMT(BPF_RET+BPF_K, 0),
bd3a57
 };
bd3a57
 
bd3a57
+/* Packet filter program for DHCP over Infiniband.
bd3a57
+ *
bd3a57
+ * XXX
bd3a57
+ * Changes to the filter program may require changes to the constant offsets
bd3a57
+ * used in lpf_gen_filter_setup to patch the port in the BPF program!
bd3a57
+ * XXX
bd3a57
+ */
bd3a57
+struct bpf_insn dhcp_ib_bpf_filter [] = {
bd3a57
+	/* Packet filter for Infiniband */
bd3a57
+	/* Make sure it's a UDP packet... */
bd3a57
+	BPF_STMT(BPF_LD + BPF_B + BPF_ABS, 9),
bd3a57
+	BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 0, 6),
bd3a57
+
bd3a57
+	/* Make sure this isn't a fragment... */
bd3a57
+	BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 6),
bd3a57
+	BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 4, 0),
bd3a57
+
bd3a57
+	/* Get the IP header length... */
bd3a57
+	BPF_STMT(BPF_LDX + BPF_B + BPF_MSH, 0),
bd3a57
+
bd3a57
+	/* Make sure it's to the right port... */
bd3a57
+	BPF_STMT(BPF_LD + BPF_H + BPF_IND, 2),
bd3a57
+	BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 67, 0, 1),
bd3a57
+
bd3a57
+	/* If we passed all the tests, ask for the whole packet. */
bd3a57
+	BPF_STMT(BPF_RET + BPF_K, (u_int)-1),
bd3a57
+
bd3a57
+	/* Otherwise, drop it. */
bd3a57
+	BPF_STMT(BPF_RET + BPF_K, 0),
bd3a57
+};
bd3a57
+
bd3a57
 #if defined (DEC_FDDI)
bd3a57
 struct bpf_insn *bpf_fddi_filter;
bd3a57
 #endif
bd3a57
 
bd3a57
 int dhcp_bpf_filter_len = sizeof dhcp_bpf_filter / sizeof (struct bpf_insn);
bd3a57
+int dhcp_ib_bpf_filter_len = sizeof dhcp_ib_bpf_filter / sizeof (struct bpf_insn);
bd3a57
+
bd3a57
 #if defined (HAVE_TR_SUPPORT)
bd3a57
 struct bpf_insn dhcp_bpf_tr_filter [] = {
bd3a57
         /* accept all token ring packets due to variable length header */
344e29
diff -up dhcp-4.2.4-P2/common/lpf.c.lpf-ib dhcp-4.2.4-P2/common/lpf.c
344e29
--- dhcp-4.2.4-P2/common/lpf.c.lpf-ib	2012-11-30 14:05:07.394394214 +0100
344e29
+++ dhcp-4.2.4-P2/common/lpf.c	2012-11-30 14:19:27.211031532 +0100
bd3a57
@@ -42,6 +42,7 @@
bd3a57
 #include "includes/netinet/udp.h"
bd3a57
 #include "includes/netinet/if_ether.h"
bd3a57
 #include <net/if.h>
bd3a57
+#include <ifaddrs.h>
bd3a57
 
bd3a57
 #ifndef PACKET_AUXDATA
bd3a57
 #define PACKET_AUXDATA 8
bd3a57
@@ -59,6 +60,15 @@ struct tpacket_auxdata
bd3a57
 /* Reinitializes the specified interface after an address change.   This
bd3a57
    is not required for packet-filter APIs. */
bd3a57
 
bd3a57
+/* Default broadcast address for IPoIB */
bd3a57
+static unsigned char default_ib_bcast_addr[20] = {
bd3a57
+ 	0x00, 0xff, 0xff, 0xff,
bd3a57
+	0xff, 0x12, 0x40, 0x1b,
bd3a57
+	0x00, 0x00, 0x00, 0x00,
bd3a57
+	0x00, 0x00, 0x00, 0x00,
bd3a57
+	0xff, 0xff, 0xff, 0xff
bd3a57
+};
bd3a57
+
bd3a57
 #ifdef USE_LPF_SEND
bd3a57
 void if_reinitialize_send (info)
bd3a57
 	struct interface_info *info;
bd3a57
@@ -86,10 +96,21 @@ int if_register_lpf (info)
bd3a57
 		struct sockaddr common;
bd3a57
 	} sa;
bd3a57
 	struct ifreq ifr;
bd3a57
+	int type;
bd3a57
+	int protocol;
bd3a57
 
bd3a57
 	/* Make an LPF socket. */
bd3a57
-	if ((sock = socket(PF_PACKET, SOCK_RAW,
bd3a57
-			   htons((short)ETH_P_ALL))) < 0) {
bd3a57
+	get_hw_addr(info);
bd3a57
+
bd3a57
+	if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) {
bd3a57
+		type = SOCK_DGRAM;
bd3a57
+		protocol = ETHERTYPE_IP;
bd3a57
+	} else {
bd3a57
+		type = SOCK_RAW;
bd3a57
+		protocol = ETH_P_ALL;
bd3a57
+	}
bd3a57
+
bd3a57
+	if ((sock = socket(PF_PACKET, type, htons((short)protocol))) < 0) {
bd3a57
 		if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
bd3a57
 		    errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
bd3a57
 		    errno == EAFNOSUPPORT || errno == EINVAL) {
bd3a57
@@ -112,6 +133,7 @@ int if_register_lpf (info)
bd3a57
 	/* Bind to the interface name */
bd3a57
 	memset (&sa, 0, sizeof sa);
bd3a57
 	sa.ll.sll_family = AF_PACKET;
bd3a57
+	sa.ll.sll_protocol = htons(protocol);
bd3a57
 	sa.ll.sll_ifindex = ifr.ifr_ifindex;
bd3a57
 	if (bind (sock, &sa.common, sizeof sa)) {
bd3a57
 		if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
bd3a57
@@ -127,8 +149,6 @@ int if_register_lpf (info)
bd3a57
 		log_fatal ("Bind socket to interface: %m");
bd3a57
 	}
bd3a57
 
bd3a57
-	get_hw_addr(info->name, &info->hw_address);
bd3a57
-
bd3a57
 	return sock;
bd3a57
 }
bd3a57
 #endif /* USE_LPF_SEND || USE_LPF_RECEIVE */
bd3a57
@@ -183,6 +203,8 @@ void if_deregister_send (info)
bd3a57
    in bpf includes... */
bd3a57
 extern struct sock_filter dhcp_bpf_filter [];
bd3a57
 extern int dhcp_bpf_filter_len;
bd3a57
+extern struct sock_filter dhcp_ib_bpf_filter [];
bd3a57
+extern int dhcp_ib_bpf_filter_len;
bd3a57
 
bd3a57
 #if defined (HAVE_TR_SUPPORT)
bd3a57
 extern struct sock_filter dhcp_bpf_tr_filter [];
bd3a57
@@ -200,11 +222,13 @@ void if_register_receive (info)
bd3a57
 	/* Open a LPF device and hang it on this interface... */
bd3a57
 	info -> rfdesc = if_register_lpf (info);
bd3a57
 
bd3a57
-	val = 1;
bd3a57
-	if (setsockopt (info -> rfdesc, SOL_PACKET, PACKET_AUXDATA, &val,
bd3a57
-			sizeof val) < 0) {
bd3a57
-		if (errno != ENOPROTOOPT)
bd3a57
-			log_fatal ("Failed to set auxiliary packet data: %m");
bd3a57
+	if (info->hw_address.hbuf[0] != HTYPE_INFINIBAND) {
bd3a57
+		val = 1;
bd3a57
+		if (setsockopt (info -> rfdesc, SOL_PACKET, PACKET_AUXDATA,
bd3a57
+				&val, sizeof val) < 0) {
bd3a57
+			if (errno != ENOPROTOOPT)
bd3a57
+				log_fatal ("Failed to set auxiliary packet data: %m");
bd3a57
+		}
bd3a57
 	}
bd3a57
 
bd3a57
 #if defined (HAVE_TR_SUPPORT)
bd3a57
@@ -250,15 +274,28 @@ static void lpf_gen_filter_setup (info)
bd3a57
 
bd3a57
 	memset(&p, 0, sizeof(p));
bd3a57
 
bd3a57
-	/* Set up the bpf filter program structure.    This is defined in
bd3a57
-	   bpf.c */
bd3a57
-	p.len = dhcp_bpf_filter_len;
bd3a57
-	p.filter = dhcp_bpf_filter;
bd3a57
-
bd3a57
-        /* Patch the server port into the LPF  program...
bd3a57
-	   XXX changes to filter program may require changes
bd3a57
-	   to the insn number(s) used below! XXX */
bd3a57
-	dhcp_bpf_filter [8].k = ntohs ((short)local_port);
bd3a57
+	if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) {
bd3a57
+		/* Set up the bpf filter program structure. */
bd3a57
+		p.len = dhcp_ib_bpf_filter_len;
bd3a57
+		p.filter = dhcp_ib_bpf_filter;
bd3a57
+
bd3a57
+		/* Patch the server port into the LPF program...
bd3a57
+		   XXX
bd3a57
+		   changes to filter program may require changes
bd3a57
+		   to the insn number(s) used below!
bd3a57
+		   XXX */
bd3a57
+		dhcp_ib_bpf_filter[6].k = ntohs ((short)local_port);
bd3a57
+	} else {
bd3a57
+		/* Set up the bpf filter program structure.
bd3a57
+		   This is defined in bpf.c */
bd3a57
+		p.len = dhcp_bpf_filter_len;
bd3a57
+		p.filter = dhcp_bpf_filter;
bd3a57
+
bd3a57
+		/* Patch the server port into the LPF  program...
bd3a57
+		   XXX changes to filter program may require changes
bd3a57
+		   to the insn number(s) used below! XXX */
bd3a57
+		dhcp_bpf_filter [8].k = ntohs ((short)local_port);
bd3a57
+	}
bd3a57
 
bd3a57
 	if (setsockopt (info -> rfdesc, SOL_SOCKET, SO_ATTACH_FILTER, &p,
bd3a57
 			sizeof p) < 0) {
bd3a57
@@ -315,6 +352,54 @@ static void lpf_tr_filter_setup (info)
bd3a57
 #endif /* USE_LPF_RECEIVE */
bd3a57
 
bd3a57
 #ifdef USE_LPF_SEND
bd3a57
+ssize_t send_packet_ib(interface, packet, raw, len, from, to, hto)
bd3a57
+	struct interface_info *interface;
bd3a57
+	struct packet *packet;
bd3a57
+	struct dhcp_packet *raw;
bd3a57
+	size_t len;
bd3a57
+	struct in_addr from;
bd3a57
+	struct sockaddr_in *to;
bd3a57
+	struct hardware *hto;
bd3a57
+{
bd3a57
+	unsigned ibufp = 0;
bd3a57
+	double ih [1536 / sizeof (double)];
bd3a57
+	unsigned char *buf = (unsigned char *)ih;
bd3a57
+	ssize_t result;
bd3a57
+
bd3a57
+	union sockunion {
bd3a57
+		struct sockaddr sa;
bd3a57
+		struct sockaddr_ll sll;
bd3a57
+		struct sockaddr_storage ss;
bd3a57
+	} su;
bd3a57
+
bd3a57
+	assemble_udp_ip_header (interface, buf, &ibufp, from.s_addr,
bd3a57
+				to->sin_addr.s_addr, to->sin_port,
bd3a57
+				(unsigned char *)raw, len);
bd3a57
+	memcpy (buf + ibufp, raw, len);
bd3a57
+
bd3a57
+	memset(&su, 0, sizeof(su));
bd3a57
+	su.sll.sll_family = AF_PACKET;
bd3a57
+	su.sll.sll_protocol = htons(ETHERTYPE_IP);
bd3a57
+
bd3a57
+	if (!(su.sll.sll_ifindex = if_nametoindex(interface->name))) {
bd3a57
+		errno = ENOENT;
bd3a57
+		log_error ("send_packet_ib: %m - failed to get if index");
bd3a57
+		return -1;
bd3a57
+	}
bd3a57
+
bd3a57
+	su.sll.sll_hatype = htons(HTYPE_INFINIBAND);
bd3a57
+	su.sll.sll_halen = sizeof(interface->bcast_addr);
bd3a57
+	memcpy(&su.sll.sll_addr, interface->bcast_addr, 20);
bd3a57
+
bd3a57
+	result = sendto(interface->wfdesc, buf, ibufp + len, 0,
bd3a57
+			&su.sa, sizeof(su));
bd3a57
+
bd3a57
+	if (result < 0)
bd3a57
+		log_error ("send_packet_ib: %m");
bd3a57
+
bd3a57
+	return result;
bd3a57
+}
bd3a57
+
bd3a57
 ssize_t send_packet (interface, packet, raw, len, from, to, hto)
bd3a57
 	struct interface_info *interface;
bd3a57
 	struct packet *packet;
d5d042
@@ -335,6 +420,11 @@ ssize_t send_packet (interface, packet,
bd3a57
 		return send_fallback (interface, packet, raw,
bd3a57
 				      len, from, to, hto);
bd3a57
 
bd3a57
+	if (interface->hw_address.hbuf[0] == HTYPE_INFINIBAND) {
bd3a57
+		return send_packet_ib(interface, packet, raw, len, from,
bd3a57
+				      to, hto);
bd3a57
+	}
bd3a57
+
bd3a57
 	if (hto == NULL && interface->anycast_mac_addr.hlen)
bd3a57
 		hto = &interface->anycast_mac_addr;
bd3a57
 
d5d042
@@ -356,6 +446,42 @@ ssize_t send_packet (interface, packet,
bd3a57
 #endif /* USE_LPF_SEND */
bd3a57
 
bd3a57
 #ifdef USE_LPF_RECEIVE
bd3a57
+ssize_t receive_packet_ib (interface, buf, len, from, hfrom)
bd3a57
+	struct interface_info *interface;
bd3a57
+	unsigned char *buf;
bd3a57
+	size_t len;
bd3a57
+	struct sockaddr_in *from;
bd3a57
+	struct hardware *hfrom;
bd3a57
+{
bd3a57
+	int length = 0;
bd3a57
+	int offset = 0;
bd3a57
+	unsigned char ibuf [1536];
bd3a57
+	unsigned bufix = 0;
bd3a57
+	unsigned paylen;
bd3a57
+
bd3a57
+	length = read(interface->rfdesc, ibuf, sizeof(ibuf));
bd3a57
+
bd3a57
+	if (length <= 0)
bd3a57
+		return length;
bd3a57
+
bd3a57
+	offset = decode_udp_ip_header(interface, ibuf, bufix, from,
bd3a57
+				       (unsigned)length, &paylen, 0);
bd3a57
+
bd3a57
+	if (offset < 0)
bd3a57
+		return 0;
bd3a57
+
bd3a57
+	bufix += offset;
bd3a57
+	length -= offset;
bd3a57
+
bd3a57
+	if (length < paylen)
bd3a57
+		log_fatal("Internal inconsistency at %s:%d.", MDL);
bd3a57
+
bd3a57
+	/* Copy out the data in the packet... */
bd3a57
+	memcpy(buf, &ibuf[bufix], paylen);
bd3a57
+
bd3a57
+	return (ssize_t)paylen;
bd3a57
+}
bd3a57
+
bd3a57
 ssize_t receive_packet (interface, buf, len, from, hfrom)
bd3a57
 	struct interface_info *interface;
bd3a57
 	unsigned char *buf;
d5d042
@@ -382,6 +508,10 @@ ssize_t receive_packet (interface, buf,
bd3a57
 	};
bd3a57
 	struct cmsghdr *cmsg;
bd3a57
 
bd3a57
+	if (interface->hw_address.hbuf[0] == HTYPE_INFINIBAND) {
bd3a57
+		return receive_packet_ib(interface, buf, len, from, hfrom);
bd3a57
+	}
bd3a57
+
bd3a57
 	length = recvmsg (interface -> rfdesc, &msg, 0);
bd3a57
 	if (length <= 0)
bd3a57
 		return length;
cd552e
@@ -461,11 +591,32 @@ void maybe_setup_fallback ()
ac22d3
 	}
bd3a57
 }
bd3a57
 
ac22d3
-void
bd3a57
-get_hw_addr(const char *name, struct hardware *hw) {
ac22d3
+struct sockaddr_ll *
ac22d3
+get_ll (struct ifaddrs *ifaddrs, struct ifaddrs **ifa, char *name)
bd3a57
+{
ac22d3
+	for (*ifa = ifaddrs; *ifa != NULL; *ifa = (*ifa)->ifa_next) {
ac22d3
+		if ((*ifa)->ifa_addr == NULL)
ac22d3
+			continue;
cd552e
+
ac22d3
+		if ((*ifa)->ifa_addr->sa_family != AF_PACKET)
ac22d3
+			continue;
ac22d3
+
ac22d3
+		if ((*ifa)->ifa_flags & IFF_LOOPBACK)
ac22d3
+			continue;
cd552e
+
ac22d3
+		if (strcmp((*ifa)->ifa_name, name) == 0)
47fd45
+			return (struct sockaddr_ll *)(void *)(*ifa)->ifa_addr;
cd552e
+	}
ac22d3
+	return NULL;
ac22d3
+}
cd552e
+
cd552e
+struct sockaddr_ll *
cd552e
+ioctl_get_ll(char *name)
cd552e
+{
cd552e
 	int sock;
cd552e
 	struct ifreq tmp;
cd552e
-	struct sockaddr *sa;
cd552e
+	struct sockaddr *sa = NULL;
cd552e
+	struct sockaddr_ll *sll = NULL;
bd3a57
 
cd552e
 	if (strlen(name) >= sizeof(tmp.ifr_name)) {
cd552e
 		log_fatal("Device name too long: \"%s\"", name);
344e29
@@ -479,16 +630,52 @@ get_hw_addr(const char *name, struct har
cd552e
 	memset(&tmp, 0, sizeof(tmp));
cd552e
 	strcpy(tmp.ifr_name, name);
cd552e
 	if (ioctl(sock, SIOCGIFHWADDR, &tmp) < 0) {
bd3a57
-		log_fatal("Error getting hardware address for \"%s\": %m", 
cd552e
+		log_fatal("Error getting hardware address for \"%s\": %m",
cd552e
 			  name);
cd552e
 	}
344e29
+	close(sock);
cd552e
 
cd552e
 	sa = &tmp.ifr_hwaddr;
cd552e
-	switch (sa->sa_family) {
344e29
+	// needs to be freed outside this function
cd552e
+	sll = dmalloc (sizeof (struct sockaddr_ll), MDL);
cd552e
+	if (!sll)
cd552e
+		log_fatal("Unable to allocate memory for link layer address");
cd552e
+	memcpy(&sll->sll_hatype, &sa->sa_family, sizeof (sll->sll_hatype));
cd552e
+	memcpy(sll->sll_addr, sa->sa_data, sizeof (sll->sll_addr));
cd552e
+	return sll;
cd552e
+}
cd552e
+
ac22d3
+void
ac22d3
+get_hw_addr(struct interface_info *info)
ac22d3
+{
ac22d3
+	struct hardware *hw = &info->hw_address;
ac22d3
+	char *name = info->name;
ac22d3
+	struct ifaddrs *ifaddrs = NULL;
ac22d3
+	struct ifaddrs *ifa = NULL;
ac22d3
+	struct sockaddr_ll *sll = NULL;
344e29
+	int sll_allocated = 0;
ac22d3
+
ac22d3
+	if (getifaddrs(&ifaddrs) == -1)
ac22d3
+		log_fatal("Failed to get interfaces");
ac22d3
+
ac22d3
+	if ((sll = get_ll(ifaddrs, &ifa, name)) == NULL) {
ac22d3
+		/*
ac22d3
+		 * We were unable to get link-layer address for name.
cd552e
+		 * Fall back to ioctl(SIOCGIFHWADDR).
ac22d3
+		 */
cd552e
+		sll = ioctl_get_ll(name);
344e29
+		if (sll != NULL)
344e29
+			sll_allocated = 1;
344e29
+		else
344e29
+			// shouldn't happed
344e29
+			log_fatal("Unexpected internal error");
cd552e
+	}
cd552e
+
bd3a57
+	switch (sll->sll_hatype) {
bd3a57
 		case ARPHRD_ETHER:
bd3a57
 			hw->hlen = 7;
bd3a57
 			hw->hbuf[0] = HTYPE_ETHER;
bd3a57
-			memcpy(&hw->hbuf[1], sa->sa_data, 6);
bd3a57
+			memcpy(&hw->hbuf[1], sll->sll_addr, 6);
bd3a57
 			break;
bd3a57
 		case ARPHRD_IEEE802:
bd3a57
 #ifdef ARPHRD_IEEE802_TR
344e29
@@ -496,18 +683,35 @@ get_hw_addr(const char *name, struct har
bd3a57
 #endif /* ARPHRD_IEEE802_TR */
bd3a57
 			hw->hlen = 7;
bd3a57
 			hw->hbuf[0] = HTYPE_IEEE802;
bd3a57
-			memcpy(&hw->hbuf[1], sa->sa_data, 6);
bd3a57
+			memcpy(&hw->hbuf[1], sll->sll_addr, 6);
bd3a57
 			break;
bd3a57
 		case ARPHRD_FDDI:
c72a79
 			hw->hlen = 7;
bd3a57
 			hw->hbuf[0] = HTYPE_FDDI;
c72a79
-			memcpy(&hw->hbuf[1], sa->sa_data, 6);
c72a79
+			memcpy(&hw->hbuf[1], sll->sll_addr, 6);
bd3a57
+			break;
bd3a57
+		case ARPHRD_INFINIBAND:
bd3a57
+			/* For Infiniband, save the broadcast address and store
bd3a57
+			 * the port GUID into the hardware address.
bd3a57
+			 */
bd3a57
+			if (ifa->ifa_flags & IFF_BROADCAST) {
bd3a57
+				struct sockaddr_ll *bll;
bd3a57
+
bd3a57
+				bll = (struct sockaddr_ll *)ifa->ifa_broadaddr;
bd3a57
+				memcpy(&info->bcast_addr, bll->sll_addr, 20);
bd3a57
+			} else {
bd3a57
+				memcpy(&info->bcast_addr, default_ib_bcast_addr,
bd3a57
+				       20);
bd3a57
+			}
bd3a57
+
bd3a57
+			hw->hlen = 1;
bd3a57
+			hw->hbuf[0] = HTYPE_INFINIBAND;
bd3a57
 			break;
bd3a57
 #if defined(ARPHRD_PPP)
bd3a57
 		case ARPHRD_PPP:
bd3a57
 			if (local_family != AF_INET6)
bd3a57
-				log_fatal("Unsupported device type %d for \"%s\"",
bd3a57
-				           sa->sa_family, name);
cd552e
+				log_fatal("local_family != AF_INET6 for \"%s\"",
cd552e
+					  name);
bd3a57
 			hw->hlen = 0;
bd3a57
 			hw->hbuf[0] = HTYPE_RESERVED;
bd3a57
 			/* 0xdeadbeef should never occur on the wire,
344e29
@@ -520,10 +724,13 @@ get_hw_addr(const char *name, struct har
bd3a57
 			break;
bd3a57
 #endif
bd3a57
 		default:
cd552e
-			log_fatal("Unsupported device type %ld for \"%s\"",
bd3a57
-				  (long int)sa->sa_family, name);
cd552e
+			freeifaddrs(ifaddrs);
cd552e
+			log_fatal("Unsupported device type %h for \"%s\"",
cd552e
+				  sll->sll_hatype, name);
bd3a57
 	}
bd3a57
 
bd3a57
-	close(sock);
344e29
+	if (sll_allocated)
344e29
+		dfree(sll, MDL);
bd3a57
+	freeifaddrs(ifaddrs);
bd3a57
 }
bd3a57
 #endif
344e29
diff -up dhcp-4.2.4-P2/common/socket.c.lpf-ib dhcp-4.2.4-P2/common/socket.c
344e29
--- dhcp-4.2.4-P2/common/socket.c.lpf-ib	2012-08-24 21:11:21.000000000 +0200
344e29
+++ dhcp-4.2.4-P2/common/socket.c	2012-11-30 14:05:07.408394046 +0100
d5d042
@@ -325,7 +325,7 @@ void if_register_send (info)
bd3a57
 	info->wfdesc = if_register_socket(info, AF_INET, 0);
bd3a57
 	/* If this is a normal IPv4 address, get the hardware address. */
bd3a57
 	if (strcmp(info->name, "fallback") != 0)
bd3a57
-		get_hw_addr(info->name, &info->hw_address);
bd3a57
+		get_hw_addr(info);
bd3a57
 #if defined (USE_SOCKET_FALLBACK)
bd3a57
 	/* Fallback only registers for send, but may need to receive as
bd3a57
 	   well. */
d5d042
@@ -388,7 +388,7 @@ void if_register_receive (info)
bd3a57
 #endif /* IP_PKTINFO... */
bd3a57
 	/* If this is a normal IPv4 address, get the hardware address. */
bd3a57
 	if (strcmp(info->name, "fallback") != 0)
bd3a57
-		get_hw_addr(info->name, &info->hw_address);
bd3a57
+		get_hw_addr(info);
bd3a57
 
bd3a57
 	if (!quiet_interface_discovery)
bd3a57
 		log_info ("Listening on Socket/%s%s%s",
d5d042
@@ -498,7 +498,7 @@ if_register6(struct interface_info *info
bd3a57
 	if (req_multi)
bd3a57
 		if_register_multicast(info);
bd3a57
 
bd3a57
-	get_hw_addr(info->name, &info->hw_address);
bd3a57
+	get_hw_addr(info);
bd3a57
 
bd3a57
 	if (!quiet_interface_discovery) {
bd3a57
 		if (info->shared_network != NULL) {
344e29
diff -up dhcp-4.2.4-P2/includes/dhcpd.h.lpf-ib dhcp-4.2.4-P2/includes/dhcpd.h
344e29
--- dhcp-4.2.4-P2/includes/dhcpd.h.lpf-ib	2012-11-30 14:05:07.400394142 +0100
344e29
+++ dhcp-4.2.4-P2/includes/dhcpd.h	2012-11-30 14:05:07.409394034 +0100
344e29
@@ -1249,6 +1249,7 @@ struct interface_info {
bd3a57
 	struct shared_network *shared_network;
bd3a57
 				/* Networks connected to this interface. */
bd3a57
 	struct hardware hw_address;	/* Its physical address. */
bd3a57
+	u_int8_t bcast_addr[20];	/* Infiniband broadcast address */
bd3a57
 	struct in_addr *addresses;	/* Addresses associated with this
bd3a57
 					 * interface.
bd3a57
 					 */
344e29
@@ -2368,7 +2369,7 @@ void print_dns_status (int, struct dhcp_
bd3a57
 #endif
bd3a57
 const char *print_time(TIME);
bd3a57
 
bd3a57
-void get_hw_addr(const char *name, struct hardware *hw);
bd3a57
+void get_hw_addr(struct interface_info *info);
bd3a57
 
bd3a57
 /* socket.c */
bd3a57
 #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_RECEIVE) \