diff options
author | Shawn Routhier <sar@isc.org> | 2012-02-16 21:05:28 +0000 |
---|---|---|
committer | Shawn Routhier <sar@isc.org> | 2012-02-16 21:05:28 +0000 |
commit | b047bd385b742331828fd6911ed39f6cb9980ca9 (patch) | |
tree | 136475f16354814a99b44a7fc51107210eca3b64 /common | |
parent | 865afd5e447e23e9af0b888c92a9e9ce6b38e7a8 (diff) | |
download | isc-dhcp-b047bd385b742331828fd6911ed39f6cb9980ca9.tar.gz |
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]
Diffstat (limited to 'common')
-rw-r--r-- | common/conflex.c | 4 | ||||
-rw-r--r-- | common/packet.c | 51 | ||||
-rw-r--r-- | common/parse.c | 62 | ||||
-rw-r--r-- | common/socket.c | 31 | ||||
-rw-r--r-- | common/tables.c | 3 |
5 files changed, 97 insertions, 54 deletions
diff --git a/common/conflex.c b/common/conflex.c index f7247efa..4987fc4c 100644 --- a/common/conflex.c +++ b/common/conflex.c @@ -3,7 +3,7 @@ Lexical scanner for dhcpd config file... */ /* - * 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 @@ -1043,6 +1043,8 @@ intern(char *atom, enum dhcp_token dfv) { 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")) diff --git a/common/packet.c b/common/packet.c index 42bca69c..45e96e82 100644 --- a/common/packet.c +++ b/common/packet.c @@ -3,7 +3,8 @@ 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 @@ -105,18 +106,25 @@ void assemble_hw_header (interface, buf, bufix, to) 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. */ @@ -184,7 +192,9 @@ void assemble_udp_ip_header (interface, buf, bufix, #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; @@ -192,17 +202,22 @@ ssize_t decode_hw_header (interface, buf, bufix, from) 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. */ diff --git a/common/parse.c b/common/parse.c index 61488c15..0d3e7c60 100644 --- a/common/parse.c +++ b/common/parse.c @@ -3,7 +3,7 @@ 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 @@ -569,7 +569,9 @@ parse_ip_addr_with_subnet(cfile, match) /* * 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) @@ -581,24 +583,27 @@ 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; } @@ -612,34 +617,33 @@ void parse_hardware_param (cfile, hardware) 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); } } diff --git a/common/socket.c b/common/socket.c index fa771281..21e1f5f0 100644 --- a/common/socket.c +++ b/common/socket.c @@ -3,7 +3,7 @@ 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 @@ -51,6 +51,7 @@ #include <net/if.h> #include <sys/sockio.h> #include <net/if_dl.h> +#include <sys/dlpi.h> #endif #ifdef USE_SOCKET_FALLBACK @@ -1067,7 +1068,7 @@ void maybe_setup_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)); @@ -1101,7 +1102,8 @@ get_hw_addr(const char *name, struct hardware *hw) { 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; } @@ -1114,8 +1116,27 @@ get_hw_addr(const char *name, struct hardware *hw) { 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); diff --git a/common/tables.c b/common/tables.c index 10e2ce01..c820d83b 100644 --- a/common/tables.c +++ b/common/tables.c @@ -3,6 +3,7 @@ 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 * @@ -601,7 +602,7 @@ const char *hardware_types [] = { "unknown-29", "unknown-30", "unknown-31", - "unknown-32", + "infiniband", "unknown-33", "unknown-34", "unknown-35", |