# HG changeset patch # User Darren Reed # Date 1311951048 25200 # Node ID d0e244fcfff176afeef576cfe8b2ee82f33af533 # Parent 8a584a286658272a7da1d1f4d3c6ebaa9771952f 7003338 infiniband adapters do not work with tcpdump diff -r 8a584a286658 -r d0e244fcfff1 components/libpcap/patches/40-ipoib.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/libpcap/patches/40-ipoib.patch Fri Jul 29 07:50:48 2011 -0700 @@ -0,0 +1,91 @@ +diff -u libpcap-1.1.1/gencode.c libpcap-1.1.1.new/gencode.c +--- libpcap-1.1.1/gencode.c Thu Mar 11 17:56:54 2010 ++++ libpcap-1.1.1.new/gencode.c Thu Jul 14 08:29:39 2011 +@@ -1588,6 +1588,13 @@ + off_nl = 0; + off_nl_nosnap = -1; + return; ++ ++ case DLT_IPOIB: ++ off_linktype = 40; ++ off_macpl = 44; /* IPoIB mac_ib prefix length */ ++ off_nl = 0; ++ off_nl_nosnap = -1; ++ return; + } + bpf_error("unknown data link type %d", linktype); + /* NOTREACHED */ +@@ -2048,6 +2055,16 @@ + return gen_false(); + } + ++static struct block * ++gen_ipoib_linktype(proto) ++ register int proto; ++{ ++ /* ++ * This is an Ethernet type, so compare the length field with it. ++ */ ++ return gen_cmp(OR_LINK, off_linktype, BPF_H, (bpf_int32)proto); ++} ++ + /* + * Generate code to match a particular packet type. + * +@@ -3474,6 +3491,9 @@ + case DLT_IPNET: + return gen_ipnet_linktype(proto); + ++ case DLT_IPOIB: ++ return gen_ipoib_linktype(proto); ++ + case DLT_LINUX_IRDA: + bpf_error("IrDA link-layer type filtering not implemented"); + +diff -u libpcap-1.1.1/pcap-common.c libpcap-1.1.1.new/pcap-common.c +--- libpcap-1.1.1/pcap-common.c Thu Mar 11 17:56:54 2010 ++++ libpcap-1.1.1.new/pcap-common.c Thu Jul 14 08:25:56 2011 +@@ -278,6 +278,11 @@ + #define LINKTYPE_USER15 162 + + /* ++ * IPoIB for Solaris. ++ */ ++#define LINKTYPE_IPOIB DLT_IPOIB ++ ++/* + * For future use with 802.11 captures - defined by AbsoluteValue + * Systems to store a number of bits of link-layer information + * including radio information: +@@ -1067,6 +1072,9 @@ + /* Solaris IPNET */ + { DLT_IPNET, LINKTYPE_IPNET }, + ++ /* Solaris IPoIB */ ++ { DLT_IPOIB, LINKTYPE_IPOIB }, ++ + /* CAN frames with SocketCAN headers */ + { DLT_CAN_SOCKETCAN, LINKTYPE_CAN_SOCKETCAN }, + +diff -u libpcap-1.1.1/pcap.c libpcap-1.1.1.new/pcap.c +--- libpcap-1.1.1/pcap.c Thu Mar 11 17:56:54 2010 ++++ libpcap-1.1.1.new/pcap.c Thu Jul 14 08:29:55 2011 +@@ -670,6 +670,7 @@ + DLT_CHOICE(DLT_FC_2, "Fibre Channel FC-2"), + DLT_CHOICE(DLT_FC_2_WITH_FRAME_DELIMS, "Fibre Channel FC-2 with frame delimiters"), + DLT_CHOICE(DLT_IPNET, "Solaris ipnet"), ++ DLT_CHOICE(DLT_IPOIB, "Solaris IPoIB"), + DLT_CHOICE(DLT_CAN_SOCKETCAN, "CAN-bus with SocketCAN headers"), + DLT_CHOICE(DLT_IPV4, "Raw IPv4"), + DLT_CHOICE(DLT_IPV6, "Raw IPv6"), +--- libpcap-1.1.1/pcap/bpf.h.dist 2010-03-11 17:56:54.000000000 -0800 ++++ libpcap-1.1.1/pcap/bpf.h 2011-07-27 03:06:09.410830949 -0700 +@@ -502,6 +502,8 @@ + #define DLT_USER14 161 + #define DLT_USER15 162 + ++#define DLT_IPOIB DLT_USER15 ++ + /* + * For future use with 802.11 captures - defined by AbsoluteValue + * Systems to store a number of bits of link-layer information diff -r 8a584a286658 -r d0e244fcfff1 components/tcpdump/patches/10-arphrd-infiniband.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/components/tcpdump/patches/10-arphrd-infiniband.patch Fri Jul 29 07:50:48 2011 -0700 @@ -0,0 +1,202 @@ +diff -uN tcpdump-4.1.1/Makefile.in tcpdump-4.1.1.new/Makefile.in +--- tcpdump-4.1.1/Makefile.in 2010-04-05 18:18:35.000000000 -0700 ++++ tcpdump-4.1.1.new/Makefile.in 2011-07-14 08:43:36.561637014 -0700 +@@ -78,6 +78,7 @@ + print-esp.c print-ether.c print-fddi.c print-fr.c \ + print-gre.c print-hsrp.c print-icmp.c print-igmp.c \ + print-igrp.c print-ip.c print-ipcomp.c print-ipfc.c print-ipnet.c \ ++ print-ipoib.c \ + print-ipx.c print-isoclns.c print-juniper.c print-krb.c \ + print-l2tp.c print-lane.c print-ldp.c print-lldp.c print-llc.c \ + print-lmp.c print-lspping.c print-lwapp.c \ +diff -uN tcpdump-4.1.1/interface.h tcpdump-4.1.1.new/interface.h +--- tcpdump-4.1.1/interface.h 2010-03-11 17:56:44.000000000 -0800 ++++ tcpdump-4.1.1.new/interface.h 2011-07-14 08:44:55.908614708 -0700 +@@ -192,6 +192,7 @@ + extern void ether_print(const u_char *, u_int, u_int, + void (*)(const u_char *), const u_char *); + extern u_int ether_if_print(const struct pcap_pkthdr *, const u_char *); ++extern u_int ipoib_if_print(const struct pcap_pkthdr *, const u_char *); + extern u_int token_print(const u_char *, u_int, u_int); + extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *); + extern void fddi_print(const u_char *, u_int, u_int); +Common subdirectories: tcpdump-4.1.1/lbl and tcpdump-4.1.1.new/lbl +Common subdirectories: tcpdump-4.1.1/missing and tcpdump-4.1.1.new/missing +diff -uN tcpdump-4.1.1/netdissect.h tcpdump-4.1.1.new/netdissect.h +--- tcpdump-4.1.1/netdissect.h 2010-03-11 17:56:44.000000000 -0800 ++++ tcpdump-4.1.1.new/netdissect.h 2011-07-14 08:44:35.643598462 -0700 +@@ -320,6 +320,7 @@ + + extern void arcnet_if_print(u_char*,const struct pcap_pkthdr *,const u_char *); + extern void ether_if_print(u_char *,const struct pcap_pkthdr *,const u_char *); ++extern void ipoib_if_print(u_char *,const struct pcap_pkthdr *,const u_char *); + extern void token_if_print(u_char *,const struct pcap_pkthdr *,const u_char *); + extern void fddi_if_print(u_char *,const struct pcap_pkthdr *, const u_char *); + +diff -uN tcpdump-4.1.1/print-arp.c tcpdump-4.1.1.new/print-arp.c +--- tcpdump-4.1.1/print-arp.c 2010-03-11 17:56:44.000000000 -0800 ++++ tcpdump-4.1.1.new/print-arp.c 2011-07-14 09:01:08.965396346 -0700 +@@ -62,6 +62,7 @@ + u_char ar_hln; /* length of hardware address */ + u_char ar_pln; /* length of protocol address */ + u_short ar_op; /* one of: */ ++#define ARPHRD_INFINIBAND 32 /* Infiniband RFC 4391 */ + #define ARPOP_REQUEST 1 /* request to resolve address */ + #define ARPOP_REPLY 2 /* response to previous request */ + #define ARPOP_REVREQUEST 3 /* request protocol address given hardware */ +@@ -118,6 +119,7 @@ + { ARPHRD_STRIP, "Strip" }, + { ARPHRD_IEEE1394, "IEEE 1394" }, + { ARPHRD_ATM2225, "ATM" }, ++ { ARPHRD_INFINIBAND, "Infiniband" }, + { 0, NULL } + }; + +diff -uN tcpdump-4.1.1/print-ipoib.c tcpdump-4.1.1.new/print-ipoib.c +--- tcpdump-4.1.1/print-ipoib.c 1969-12-31 16:00:00.000000000 -0800 ++++ tcpdump-4.1.1.new/print-ipoib.c 2011-07-14 08:46:52.029342720 -0700 +@@ -0,0 +1,131 @@ ++/* ++ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that: (1) source code distributions ++ * retain the above copyright notice and this paragraph in its entirety, (2) ++ * distributions including binary code include the above copyright notice and ++ * this paragraph in its entirety in the documentation or other materials ++ * provided with the distribution, and (3) all advertising materials mentioning ++ * features or use of this software display the following acknowledgement: ++ * ``This product includes software developed by the University of California, ++ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of ++ * the University nor the names of its contributors may be used to endorse ++ * or promote products derived from this software without specific prior ++ * written permission. ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ++ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ++ */ ++/* ++ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. ++ */ ++#ifndef lint ++static const char rcsid[] _U_ = ++ "@(#) $Header$"; ++#endif ++ ++#ifdef HAVE_CONFIG_H ++#include "config.h" ++#endif ++ ++#include ++ ++#include ++#include ++ ++#include "interface.h" ++#include "extract.h" ++#include "addrtoname.h" ++ ++extern const struct tok ethertype_values[]; ++extern int ethertype_print(u_short, const u_char *, u_int, u_int ); ++ ++#define IPOIB_HDRLEN 44 ++ ++static inline void ++ipoib_hdr_print(register const u_char *bp, u_int length) ++{ ++ u_int16_t ether_type; ++ char abuf[40]; ++ ++ ether_type = EXTRACT_16BITS(&bp[40]); ++ if (!qflag) { ++ (void)printf(", ethertype %s (0x%04x)", ++ tok2str(ethertype_values,"Unknown", ether_type), ++ ether_type); ++ } else { ++ (void)printf(", ethertype %s", ++ tok2str(ethertype_values,"Unknown", ether_type)); ++ } ++ ++ (void)printf(", length %u: ", length); ++} ++ ++/* ++ * Print an Infiniband frame. ++ * This might be encapsulated within another frame; we might be passed ++ * a pointer to a function that can print header information for that ++ * frame's protocol, and an argument to pass to that function. ++ */ ++static void ++ipoib_print(const u_char *p, u_int length, u_int caplen, ++ void (*print_encap_header)(const u_char *), const u_char *encap_header_arg) ++{ ++ const u_char *orig_hdr = p; ++ u_int orig_length; ++ u_short ether_type; ++ u_short extracted_ether_type; ++ ++ if (caplen < IPOIB_HDRLEN || length < IPOIB_HDRLEN) { ++ printf("[|ipoib]"); ++ return; ++ } ++ ++ if (eflag) { ++ if (print_encap_header != NULL) ++ (*print_encap_header)(encap_header_arg); ++ ipoib_hdr_print(p, length); ++ } ++ orig_length = length; ++ ++ length -= IPOIB_HDRLEN; ++ caplen -= IPOIB_HDRLEN; ++ ether_type = EXTRACT_16BITS(&p[40]); ++ p += IPOIB_HDRLEN; ++ ++ if (ethertype_print(ether_type, p, length, caplen) == 0) { ++ /* ether_type not known, print raw packet */ ++ if (!eflag) { ++ if (print_encap_header != NULL) ++ (*print_encap_header)(encap_header_arg); ++ ipoib_hdr_print(orig_hdr , orig_length); ++ } ++ ++ if (!suppress_default_print) ++ default_print(p, caplen); ++ } ++} ++ ++/* ++ * This is the top level routine of the printer. 'p' points ++ * to the ether header of the packet, 'h->ts' is the timestamp, ++ * 'h->len' is the length of the packet off the wire, and 'h->caplen' ++ * is the number of bytes actually captured. ++ */ ++u_int ++ipoib_if_print(const struct pcap_pkthdr *h, const u_char *p) ++{ ++ ipoib_print(p, h->len, h->caplen, NULL, NULL); ++ ++ return (IPOIB_HDRLEN); ++} ++ ++/* ++ * Local Variables: ++ * c-style: whitesmith ++ * c-basic-offset: 8 ++ * End: ++ */ ++ +diff -uN tcpdump-4.1.1/tcpdump.c tcpdump-4.1.1.new/tcpdump.c +--- tcpdump-4.1.1/tcpdump.c 2010-03-11 17:56:44.000000000 -0800 ++++ tcpdump-4.1.1.new/tcpdump.c 2011-07-14 08:44:25.329300635 -0700 +@@ -299,6 +299,9 @@ + #ifdef DLT_IPV6 + { raw_if_print, DLT_IPV6 }, + #endif ++#ifdef DLT_IPOIB ++ { ipoib_if_print, DLT_IPOIB }, ++#endif + { NULL, 0 }, + }; +