- Tidy up the receive calls and eliminate the need for found_pkt
[ISC-Bugs #25066]
+- Add support for Infiniband over sockets to the server and
+ relay code. We've tested this on Solaris and hope to expand
+ support for Infiniband in the future. This patch also corrects
+ some issues we found in the socket code. [ISC-Bugs #24245]
+
Changes since 4.1-ESV-R3
- Add AM_MAINTAINER_MODE to configure.ac to avoid rebuilding
Lexical scanner for dhcpd config file... */
/*
- * Copyright (c) 2004-2009,2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2011-2012 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
return INCLUDE;
if (!strcasecmp (atom + 1, "nteger"))
return INTEGER;
+ if (!strcasecmp (atom + 1, "nfiniband"))
+ return TOKEN_INFINIBAND;
if (!strcasecmp (atom + 1, "nfinite"))
return INFINITE;
if (!strcasecmp (atom + 1, "nfo"))
Packet assembly code, originally contributed by Archie Cobbs. */
/*
- * Copyright (c) 2004,2005,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2005,2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
unsigned *bufix;
struct hardware *to;
{
-#if defined (HAVE_TR_SUPPORT)
- if (interface -> hw_address.hbuf [0] == HTYPE_IEEE802)
- assemble_tr_header (interface, buf, bufix, to);
- else
+ switch (interface->hw_address.hbuf[0]) {
+#if defined(HAVE_TR_SUPPORT)
+ case HTYPE_IEEE802:
+ assemble_tr_header(interface, buf, bufix, to);
+ break;
#endif
#if defined (DEC_FDDI)
- if (interface -> hw_address.hbuf [0] == HTYPE_FDDI)
- assemble_fddi_header (interface, buf, bufix, to);
- else
+ case HTYPE_FDDI:
+ assemble_fddi_header(interface, buf, bufix, to);
+ break;
#endif
- assemble_ethernet_header (interface, buf, bufix, to);
-
+ case HTYPE_INFINIBAND:
+ log_error("Attempt to assemble hw header for infiniband");
+ break;
+ case HTYPE_ETHER:
+ default:
+ assemble_ethernet_header(interface, buf, bufix, to);
+ break;
+ }
}
/* UDP header and IP header assembled together for convenience. */
#ifdef PACKET_DECODING
/* Decode a hardware header... */
-/* XXX currently only supports ethernet; doesn't check for other types. */
+/* Support for ethernet, TR and FDDI
+ * Doesn't support infiniband yet as the supported oses shouldn't get here
+ */
ssize_t decode_hw_header (interface, buf, bufix, from)
struct interface_info *interface;
unsigned bufix;
struct hardware *from;
{
+ switch(interface->hw_address.hbuf[0]) {
#if defined (HAVE_TR_SUPPORT)
- if (interface -> hw_address.hbuf [0] == HTYPE_IEEE802)
- return decode_tr_header (interface, buf, bufix, from);
- else
+ case HTYPE_IEEE802:
+ return (decode_tr_header(interface, buf, bufix, from));
#endif
#if defined (DEC_FDDI)
- if (interface -> hw_address.hbuf [0] == HTYPE_FDDI)
- return decode_fddi_header (interface, buf, bufix, from);
- else
+ case HTYPE_FDDI:
+ return (decode_fddi_header(interface, buf, bufix, from));
#endif
- return decode_ethernet_header (interface, buf, bufix, from);
+ case HTYPE_INFINIBAND:
+ log_error("Attempt to decode hw header for infiniband");
+ return (0);
+ case HTYPE_ETHER:
+ default:
+ return (decode_ethernet_header(interface, buf, bufix, from));
+ }
}
/* UDP header and IP header decoded together for convenience. */
Common parser code for dhcpd and dhclient. */
/*
- * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
/*
* hardware-parameter :== HARDWARE hardware-type colon-separated-hex-list SEMI
- * hardware-type :== ETHERNET | TOKEN_RING | TOKEN_FDDI
+ * hardware-type :== ETHERNET | TOKEN_RING | TOKEN_FDDI | INFINIBAND
+ * Note that INFINIBAND may not be useful for some items, such as classification
+ * as the hardware address won't always be available.
*/
void parse_hardware_param (cfile, hardware)
unsigned hlen;
unsigned char *t;
- token = next_token (&val, (unsigned *)0, cfile);
+ token = next_token(&val, NULL, cfile);
switch (token) {
case ETHERNET:
- hardware -> hbuf [0] = HTYPE_ETHER;
+ hardware->hbuf[0] = HTYPE_ETHER;
break;
case TOKEN_RING:
- hardware -> hbuf [0] = HTYPE_IEEE802;
+ hardware->hbuf[0] = HTYPE_IEEE802;
break;
case TOKEN_FDDI:
- hardware -> hbuf [0] = HTYPE_FDDI;
+ hardware->hbuf[0] = HTYPE_FDDI;
+ break;
+ case TOKEN_INFINIBAND:
+ hardware->hbuf[0] = HTYPE_INFINIBAND;
break;
default:
- if (!strncmp (val, "unknown-", 8)) {
- hardware -> hbuf [0] = atoi (&val [8]);
+ if (!strncmp(val, "unknown-", 8)) {
+ hardware->hbuf[0] = atoi(&val[8]);
} else {
- parse_warn (cfile,
- "expecting a network hardware type");
- skip_to_semi (cfile);
+ parse_warn(cfile,
+ "expecting a network hardware type");
+ skip_to_semi(cfile);
return;
}
that data in the lease file rather than simply failing on such
clients. Yuck. */
hlen = 0;
- token = peek_token (&val, (unsigned *)0, cfile);
+ token = peek_token(&val, NULL, cfile);
if (token == SEMI) {
- hardware -> hlen = 1;
+ hardware->hlen = 1;
goto out;
}
- t = parse_numeric_aggregate (cfile, (unsigned char *)0, &hlen,
- COLON, 16, 8);
- if (!t) {
- hardware -> hlen = 1;
+ t = parse_numeric_aggregate(cfile, NULL, &hlen, COLON, 16, 8);
+ if (t == NULL) {
+ hardware->hlen = 1;
return;
}
- if (hlen + 1 > sizeof hardware -> hbuf) {
- dfree (t, MDL);
- parse_warn (cfile, "hardware address too long");
+ if (hlen + 1 > sizeof(hardware->hbuf)) {
+ dfree(t, MDL);
+ parse_warn(cfile, "hardware address too long");
} else {
- hardware -> hlen = hlen + 1;
- memcpy ((unsigned char *)&hardware -> hbuf [1], t, hlen);
- if (hlen + 1 < sizeof hardware -> hbuf)
- memset (&hardware -> hbuf [hlen + 1], 0,
- (sizeof hardware -> hbuf) - hlen - 1);
- dfree (t, MDL);
+ hardware->hlen = hlen + 1;
+ memcpy((unsigned char *)&hardware->hbuf[1], t, hlen);
+ if (hlen + 1 < sizeof(hardware->hbuf))
+ memset(&hardware->hbuf[hlen + 1], 0,
+ (sizeof(hardware->hbuf)) - hlen - 1);
+ dfree(t, MDL);
}
out:
- token = next_token (&val, (unsigned *)0, cfile);
+ token = next_token(&val, NULL, cfile);
if (token != SEMI) {
- parse_warn (cfile, "expecting semicolon.");
- skip_to_semi (cfile);
+ parse_warn(cfile, "expecting semicolon.");
+ skip_to_semi(cfile);
}
}
BSD socket interface code... */
/*
- * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
#include <net/if.h>
#include <sys/sockio.h>
#include <net/if_dl.h>
+#include <sys/dlpi.h>
#endif
#ifdef USE_SOCKET_FALLBACK
void
get_hw_addr(const char *name, struct hardware *hw) {
struct sockaddr_dl *dladdrp;
- int rv, sock, i;
+ int sock, i;
struct lifreq lifr;
memset(&lifr, 0, sizeof (lifr));
hw->hlen = sizeof (hw->hbuf);
srandom((long)gethrtime());
- for (i = 0; i < hw->hlen; ++i) {
+ hw->hbuf[0] = HTYPE_IPMP;
+ for (i = 1; i < hw->hlen; ++i) {
hw->hbuf[i] = random() % 256;
}
log_fatal("Couldn't get interface hardware address for %s: %m",
name);
dladdrp = (struct sockaddr_dl *)&lifr.lifr_addr;
- hw->hlen = dladdrp->sdl_alen;
- memcpy(hw->hbuf, LLADDR(dladdrp), hw->hlen);
+ hw->hlen = dladdrp->sdl_alen+1;
+ switch (dladdrp->sdl_type) {
+ case DL_CSMACD: /* IEEE 802.3 */
+ case DL_ETHER:
+ hw->hbuf[0] = HTYPE_ETHER;
+ break;
+ case DL_TPR:
+ hw->hbuf[0] = HTYPE_IEEE802;
+ break;
+ case DL_FDDI:
+ hw->hbuf[0] = HTYPE_FDDI;
+ break;
+ case DL_IB:
+ hw->hbuf[0] = HTYPE_INFINIBAND;
+ break;
+ default:
+ log_fatal("%s: unsupported DLPI MAC type %lu", name,
+ (unsigned long)dladdrp->sdl_type);
+ }
+
+ memcpy(hw->hbuf+1, LLADDR(dladdrp), hw->hlen-1);
if (sock != -1)
(void) close(sock);
Tables of information... */
/*
+ * Copyright (c) 2011-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
"unknown-29",
"unknown-30",
"unknown-31",
- "unknown-32",
+ "infiniband",
"unknown-33",
"unknown-34",
"unknown-35",
[Define to any value to chroot() prior to loading config.])
fi
-AC_ARG_ENABLE(IPv4_PKTINFO,
+AC_ARG_ENABLE(ipv4_pktinfo,
AC_HELP_STRING([--enable-ipv4-pktinfo],
[enable use of pktinfo on IPv4 sockets (default is no)]))
[Define to 1 to enable IPv4 packet info support.])
fi
-AC_ARG_ENABLE(USE_SOCKETS,
+AC_ARG_ENABLE(use_sockets,
AC_HELP_STRING([--enable-use-sockets],
[use the standard BSD socket API (default is no)]))
AC_CHECK_HEADER(net/bpf.h, DO_BPF=1)
if test -n "$DO_BPF"
then
- AC_DEFINE([HAVE_BPF], [""],
+ AC_DEFINE([HAVE_BPF], [1],
[Define to 1 to use the
Berkeley Packet Filter interface code.])
fi
Protocol structures... */
/*
+ * Copyright (c) 2011-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
#define HTYPE_ETHER 1 /* Ethernet 10Mbps */
#define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */
#define HTYPE_FDDI 8 /* FDDI... */
+#define HTYPE_INFINIBAND 32 /* IP over Infiniband */
+#define HTYPE_IPMP 255 /* IPMP - random hw address - there
+ * is no standard for this so we
+ * just steal a type */
/* Magic cookie validating dhcp options field (and bootp vendor
extensions field). */
Definitions for dhcpd... */
/*
- * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
struct hardware {
u_int8_t hlen;
- u_int8_t hbuf [17];
+ u_int8_t hbuf[21];
};
typedef enum {
Tokens for config file lexer and parser. */
/*
- * Copyright (c) 2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2011-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004,2007-2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
FIXED_PREFIX6 = 658,
CONFLICT_DONE = 660,
INITIAL_DELAY = 664,
- GETHOSTBYNAME = 665
+ GETHOSTBYNAME = 665,
+ TOKEN_INFINIBAND = 668
};
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
Server-specific in-memory database support. */
/*
+ * Copyright (c) 2011-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
const char *file, int line)
{
if (hwlen == 0)
- return 0;
- return lease_id_hash_lookup(lp, lease_hw_addr_hash, hwaddr, hwlen,
- file, line);
+ return (0);
+
+ /*
+ * If it's an infiniband address don't bother
+ * as we don't have a useful address to hash.
+ */
+ if ((hwlen == 1) && (hwaddr[0] == HTYPE_INFINIBAND))
+ return (0);
+
+ return (lease_id_hash_lookup(lp, lease_hw_addr_hash, hwaddr, hwlen,
+ file, line));
}
/* If the lease is preferred over the candidate, return truth. The
}
/* Add the specified lease to the hardware address hash. */
+/* We don't add leases with infiniband addresses to the
+ * hash as there isn't any address to hash on. */
void
hw_hash_add(struct lease *lease)
struct lease *prev = NULL;
struct lease *next = NULL;
+ /*
+ * If it's an infiniband address don't bother
+ * as we don't have a useful address to hash.
+ */
+ if ((lease->hardware_addr.hlen == 1) &&
+ (lease->hardware_addr.hbuf[0] == HTYPE_INFINIBAND))
+ return;
+
/* If it's not in the hash, just add it. */
if (!find_lease_by_hw_addr (&head, lease -> hardware_addr.hbuf,
lease -> hardware_addr.hlen, MDL))
struct lease *head = (struct lease *)0;
struct lease *next = (struct lease *)0;
+ /*
+ * If it's an infiniband address don't bother
+ * as we don't have a useful address to hash.
+ */
+ if ((lease->hardware_addr.hlen == 1) &&
+ (lease->hardware_addr.hbuf[0] == HTYPE_INFINIBAND))
+ return;
+
/* If it's not in the hash, we have no work to do. */
if (!find_lease_by_hw_addr (&head, lease -> hardware_addr.hbuf,
lease -> hardware_addr.hlen, MDL)) {