[syslinux:lwip] undiif: Theoretical support for infiniband.

syslinux-bot for Eric W. Biederman ebiederm at xmission.com
Fri Apr 22 20:06:12 PDT 2011


Commit-ID:  ab069ae1cf9894aad1c68343e8c568d083f4270c
Gitweb:     http://syslinux.zytor.com/commit/ab069ae1cf9894aad1c68343e8c568d083f4270c
Author:     Eric W. Biederman <ebiederm at xmission.com>
AuthorDate: Tue, 12 Apr 2011 00:50:04 -0700
Committer:  Eric W. Biederman <ebiederm at xmission.com>
CommitDate: Tue, 12 Apr 2011 14:41:24 -0700

undiif: Theoretical support for infiniband.

Sync up the maximum address length between pxe.h and netif.h
and assert if they are different.

PXEENV_UNDI_GET_INFORMATION only returns a 16 hardware
address field, and infiniband has a 20 byte hardware address
so use MAC provided by pxe.c instead which is already set
to the proper 20 byte hardware address.

Signed-off-by: Eric W. Biederman <ebiederm at xmission.com>


---
 core/lwip/src/include/lwip/netif.h |    2 +-
 core/lwip/src/netif/undiif.c       |   32 ++++++++++++++++++++++++--------
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/core/lwip/src/include/lwip/netif.h b/core/lwip/src/include/lwip/netif.h
index 9239723..462d349 100644
--- a/core/lwip/src/include/lwip/netif.h
+++ b/core/lwip/src/include/lwip/netif.h
@@ -58,7 +58,7 @@ extern "C" {
 
 /** must be the maximum of all used hardware address lengths
     across all types of interfaces in use */
-#define NETIF_MAX_HWADDR_LEN 20U
+#define NETIF_MAX_HWADDR_LEN 32U
 
 /** TODO: define the use (where, when, whom) of netif flags */
 
diff --git a/core/lwip/src/netif/undiif.c b/core/lwip/src/netif/undiif.c
index a2787f2..6da8544 100644
--- a/core/lwip/src/netif/undiif.c
+++ b/core/lwip/src/netif/undiif.c
@@ -72,6 +72,9 @@
 #if ETH_PAD_SIZE
 #error "ETH_PAD_SIZE not supported"
 #endif
+#if NETIF_MAX_HWADDR_LEN != MAC_MAX
+#errir "hwaddr_len mismatch"
+#endif
 
 /** the time an ARP entry stays valid after its last update,
  *  for ARP_TMR_INTERVAL = 5000, this is
@@ -136,7 +139,6 @@ struct undiarp_entry {
 #define IFNAME0 'u'
 #define IFNAME1 'n'
 
-static uint16_t undi_hw_type;
 static struct netif undi_netif;
 static struct undiarp_entry arp_table[ARP_TABLE_SIZE];
 #if !LWIP_NETIF_HWADDRHINT
@@ -153,7 +155,7 @@ static u8_t undiarp_cached_entry;
 static inline bool undi_is_ethernet(struct netif *netif)
 {
    (void)netif;
-   return undi_hw_type == ETHER_TYPE;
+   return MAC_type == ETHER_TYPE;
 }
 
 /**
@@ -177,14 +179,28 @@ low_level_init(struct netif *netif)
 	 undi_info.BaseIo, undi_info.IntNumber, undi_info.MaxTranUnit,
 	 undi_info.HwType);
 
-  /* Remember the hardware type for arp */
-  undi_hw_type = undi_info.HwType;
+  /* MAC_type and MAC_len should always match what is returned by
+   * PXENV_UNDI_GET_INFORMATION.  At the moment the both seem to be
+   * reliable but if they disagree that is a sign of a nasty bug
+   * somewhere so abort.
+   */
+  /* If we are in conflict abort */
+  if (MAC_type != undi_info.HwType) {
+    printf("HwType conflicit: %u != %u\n",
+	    MAC_type, undi_info.HwType);
+    kaboom();
+  }
+  if (MAC_len != undi_info.HwAddrLen) {
+     printf("HwAddrLen conflict: %u != %u\n",
+	     MAC_len, undi_info.HwAddrLen);
+     kaboom();
+  }
 
   /* set MAC hardware address length */
-  netif->hwaddr_len = undi_info.HwAddrLen;
+  netif->hwaddr_len = MAC_len;
 
   /* set MAC hardware address */
-  memcpy(netif->hwaddr, undi_info.CurrentNodeAddress, undi_info.HwAddrLen);
+  memcpy(netif->hwaddr, MAC, MAC_len);
 
   /* maximum transfer unit */
   netif->mtu = undi_info.MaxTranUnit;
@@ -314,7 +330,7 @@ undiarp_request(struct netif *netif, struct ip_addr *ipaddr)
   hdr = p->payload;
   LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_request: sending raw ARP packet.\n"));
   hdr->opcode = htons(ARP_REQUEST);
-  hdr->hwtype = htons(undi_hw_type);
+  hdr->hwtype = htons(MAC_type);
   hdr->proto = htons(ETHTYPE_IP);
   /* set hwlen and protolen together */
   hdr->_hwlen_protolen = htons((netif->hwaddr_len << 8) | sizeof(struct ip_addr));
@@ -1059,7 +1075,7 @@ undiarp_input(struct netif *netif, struct pbuf *p)
 
   hdr = p->payload;
   /* RFC 826 "Packet Reception": */
-  if ((hdr->hwtype != htons(undi_hw_type)) ||
+  if ((hdr->hwtype != htons(MAC_type)) ||
       (hdr->_hwlen_protolen != htons((netif->hwaddr_len << 8) | sizeof(struct ip_addr))) ||
       (hdr->proto != htons(ETHTYPE_IP))) {
     LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,



More information about the Syslinux-commits mailing list