[openib-general] Re: [PATCH] teach ifconfig about ib [WAS: Latest IPoIB Bringup Questions]
Hal Rosenstock
halr at voltaire.com
Wed Apr 13 13:33:59 PDT 2005
Hi Tom,
On Mon, 2005-02-07 at 16:22, Tom Duffy wrote:
> [Responding to an old message]
>
> On Thu, 2004-10-28 at 13:51 -0400, Hal Rosenstock wrote:
> > Should we teach ifconfig to display Link Encap: INFINIBAND ?
>
> Still has the problem of truncating the address to the first 14 bytes.
I finally did this. The HWaddr does not look right to me. Although the
formatting is correct now, it doesn't contain the port GUID as I think
it should. Does it appear for you ? Thanks.
-- Hal
./ifconfig ib0
ib0 Link encap:InfiniBand HWaddr
00:00:04:04:FE:80:00:00:00:00:00:00:00:00:00:00:00:00:00:00
/usr/local/ib/bin/ibstatus
Infiniband device 'mthca0' port 1 status:
default gid: fe80:0000:0000:0000:0008:f104:0396:0559
/usr/local/ib/bin/ibstat
CA 'mthca0'
...
Node GUID: 0x0008f10403960558
...
Port 1:
...
Port GUID: 0x0008f10403960559
Port 2:
...
Port GUID: 0x0008f1040396055a
> diff -Nur net-tools-1.60/config.in net-tools-1.60-ib/config.in
> --- net-tools-1.60/config.in 2000-05-21 07:32:12.000000000 -0700
> +++ net-tools-1.60-ib/config.in 2005-02-07 10:45:14.108286619 -0800
> @@ -82,6 +82,7 @@
> bool '(Cisco)-HDLC/LAPB support' HAVE_HWHDLCLAPB n
> bool 'IrDA support' HAVE_HWIRDA y
> bool 'Econet hardware support' HAVE_HWEC n
> +bool 'InfiniBand hardware support' HAVE_HWIB y
> *
> *
> * Other Features.
> diff -Nur net-tools-1.60/config.make net-tools-1.60-ib/config.make
> --- net-tools-1.60/config.make 2005-02-07 11:58:18.536146922 -0800
> +++ net-tools-1.60-ib/config.make 2005-02-07 12:04:03.596462891 -0800
> @@ -30,6 +30,7 @@
> HAVE_HWHDLCLAPB=1
> HAVE_HWIRDA=1
> HAVE_HWEC=1
> +HAVE_HWIB=1
> HAVE_FW_MASQUERADE=1
> HAVE_IP_TOOLS=1
> HAVE_MII=1
> Binary files net-tools-1.60/ipmaddr and net-tools-1.60-ib/ipmaddr differ
> Binary files net-tools-1.60/iptunnel and net-tools-1.60-ib/iptunnel differ
> diff -Nur net-tools-1.60/lib/hw.c net-tools-1.60-ib/lib/hw.c
> --- net-tools-1.60/lib/hw.c 2000-05-20 11:27:25.000000000 -0700
> +++ net-tools-1.60-ib/lib/hw.c 2005-02-07 09:56:22.315428035 -0800
> @@ -73,6 +73,8 @@
>
> extern struct hwtype ec_hwtype;
>
> +extern struct hwtype ib_hwtype;
> +
> static struct hwtype *hwtypes[] =
> {
>
> @@ -144,6 +146,9 @@
> #if HAVE_HWX25
> &x25_hwtype,
> #endif
> +#if HAVE_HWIB
> + &ib_hwtype,
> +#endif
> &unspec_hwtype,
> NULL
> };
> @@ -217,6 +222,9 @@
> #if HAVE_HWEC
> ec_hwtype.title = _("Econet");
> #endif
> +#if HAVE_HWIB
> + ib_hwtype.title = _("InfiniBand");
> +#endif
> sVhwinit = 1;
> }
>
> diff -Nur net-tools-1.60/lib/ib.c net-tools-1.60-ib/lib/ib.c
> --- net-tools-1.60/lib/ib.c 1969-12-31 16:00:00.000000000 -0800
> +++ net-tools-1.60-ib/lib/ib.c 2005-02-07 12:55:04.635559244 -0800
> @@ -0,0 +1,147 @@
> +/*
> + * lib/ib.c This file contains an implementation of the "Infiniband"
> + * support functions.
> + *
> + * Version: $Id: ib.c,v 1.1 2005/02/06 11:00:47 tduffy Exp $
> + *
> + * Author: Fred N. van Kempen, <waltje at uwalt.nl.mugnet.org>
> + * Copyright 1993 MicroWalt Corporation
> + * Tom Duffy <tduffy at sun.com>
> + *
> + * This program is free software; you can redistribute it
> + * and/or modify it under the terms of the GNU General
> + * Public License as published by the Free Software
> + * Foundation; either version 2 of the License, or (at
> + * your option) any later version.
> + */
> +#include "config.h"
> +
> +#if HAVE_HWIB
> +#include <sys/types.h>
> +#include <sys/socket.h>
> +#include <net/if_arp.h>
> +#include <linux/if_infiniband.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <errno.h>
> +#include <ctype.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include "net-support.h"
> +#include "pathnames.h"
> +#include "intl.h"
> +#include "util.h"
> +
> +extern struct hwtype ib_hwtype;
> +
> +
> +/* Display an InfiniBand address in readable format. */
> +static char *pr_ib(unsigned char *ptr)
> +{
> + static char buff[128];
> + char *pos;
> + unsigned int i;
> +
> + pos = buff;
> + for (i = 0; i < INFINIBAND_ALEN; i++) {
> + pos += sprintf(pos, "%02X:", (*ptr++ & 0377));
> + }
> + buff[strlen(buff) - 1] = '\0';
> +
> + /* snprintf(buff, sizeof(buff), "%02X:%02X:%02X:%02X:%02X:%02X",
> + (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
> + (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)
> + );
> + */
> + return (buff);
> +}
> +
> +
> +/* Input an Infiniband address and convert to binary. */
> +static int in_ib(char *bufp, struct sockaddr *sap)
> +{
> + unsigned char *ptr;
> + char c, *orig;
> + int i;
> + unsigned val;
> +
> + sap->sa_family = ib_hwtype.type;
> + ptr = sap->sa_data;
> +
> + i = 0;
> + orig = bufp;
> + while ((*bufp != '\0') && (i < INFINIBAND_ALEN)) {
> + val = 0;
> + c = *bufp++;
> + if (isdigit(c))
> + val = c - '0';
> + else if (c >= 'a' && c <= 'f')
> + val = c - 'a' + 10;
> + else if (c >= 'A' && c <= 'F')
> + val = c - 'A' + 10;
> + else {
> +#ifdef DEBUG
> + fprintf(stderr, _("in_ib(%s): invalid infiniband address!\n"), orig);
> +#endif
> + errno = EINVAL;
> + return (-1);
> + }
> + val <<= 4;
> + c = *bufp;
> + if (isdigit(c))
> + val |= c - '0';
> + else if (c >= 'a' && c <= 'f')
> + val |= c - 'a' + 10;
> + else if (c >= 'A' && c <= 'F')
> + val |= c - 'A' + 10;
> + else if (c == ':' || c == 0)
> + val >>= 4;
> + else {
> +#ifdef DEBUG
> + fprintf(stderr, _("in_ib(%s): invalid infiniband address!\n"), orig);
> +#endif
> + errno = EINVAL;
> + return (-1);
> + }
> + if (c != 0)
> + bufp++;
> + *ptr++ = (unsigned char) (val & 0377);
> + i++;
> +
> + /* We might get a semicolon here - not required. */
> + if (*bufp == ':') {
> + if (i == INFINIBAND_ALEN) {
> +#ifdef DEBUG
> + fprintf(stderr, _("in_ib(%s): trailing : ignored!\n"),
> + orig)
> +#endif
> + ; /* nothing */
> + }
> + bufp++;
> + }
> + }
> +
> + /* That's it. Any trailing junk? */
> + if ((i == INFINIBAND_ALEN) && (*bufp != '\0')) {
> +#ifdef DEBUG
> + fprintf(stderr, _("in_ib(%s): trailing junk!\n"), orig);
> + errno = EINVAL;
> + return (-1);
> +#endif
> + }
> +#ifdef DEBUG
> + fprintf(stderr, "in_ib(%s): %s\n", orig, pr_ib(sap->sa_data));
> +#endif
> +
> + return (0);
> +}
> +
> +
> +struct hwtype ib_hwtype =
> +{
> + "infiniband", NULL, ARPHRD_INFINIBAND, INFINIBAND_ALEN,
> + pr_ib, in_ib, NULL
> +};
> +
> +
> +#endif /* HAVE_HWETHER */
> diff -Nur net-tools-1.60/lib/Makefile net-tools-1.60-ib/lib/Makefile
> --- net-tools-1.60/lib/Makefile 2000-10-28 03:59:42.000000000 -0700
> +++ net-tools-1.60-ib/lib/Makefile 2005-02-07 10:02:14.662640164 -0800
> @@ -16,7 +16,7 @@
> #
>
>
> -HWOBJS = hw.o loopback.o slip.o ether.o ax25.o ppp.o arcnet.o tr.o tunnel.o frame.o sit.o rose.o ash.o fddi.o hippi.o hdlclapb.o strip.o irda.o ec_hw.o x25.o
> +HWOBJS = hw.o loopback.o slip.o ether.o ax25.o ppp.o arcnet.o tr.o tunnel.o frame.o sit.o rose.o ash.o fddi.o hippi.o hdlclapb.o strip.o irda.o ec_hw.o x25.o ib.o
> AFOBJS = unix.o inet.o inet6.o ax25.o ipx.o ddp.o ipx.o netrom.o af.o rose.o econet.o x25.o
> AFGROBJS = inet_gr.o inet6_gr.o ipx_gr.o ddp_gr.o netrom_gr.o ax25_gr.o rose_gr.o getroute.o x25_gr.o
> AFSROBJS = inet_sr.o inet6_sr.o netrom_sr.o ipx_sr.o setroute.o x25_sr.o
> Binary files net-tools-1.60/mii-tool and net-tools-1.60-ib/mii-tool differ
>
More information about the general
mailing list