Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Jun 2014 22:18:45 +0800
From:      upyzl <zj262144@gmail.com>
To:        freebsd-net@freebsd.org
Subject:   how to capture packets when using netmap?
Message-ID:  <CAMijcFGdU7KqH0dzw4-Ga7cCEWiyc-RA6FvU8ma6OUQ91MsF=A@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi all

I'm using FreeBSD 10 release and with "device netmap" added (recompile
kernel to use netmap)

but it seems didn't support libpcap (I use tcpdump to capture when
netmap-bridge is on and 2 hosts ping each other | topo: host1 --- [em0]
FreeBSD [em1] --- host2 )

I know there is a netmap-libpcap, but I don't know how to generate it to
BSD system...

this is my try:

*1> download source code, extract*

*2> cd src dir*
*3> configure*

root@switch:/usr/src/tools/tools/netmap/netmap-libpcap # ./configure
checking build system type... x86_64-unknown-freebsd10.0
checking host system type... x86_64-unknown-freebsd10.0
checking target system type... x86_64-unknown-freebsd10.0
checking for gcc... no
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking for inline... inline
checking for __attribute__... yes
checking whether __attribute__((unused)) can be used without warnings... yes
checking whether __attribute__((format)) can be used without warnings... yes
checking how to run the C preprocessor... cc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/bitypes.h usability... no
checking sys/bitypes.h presence... no
checking for sys/bitypes.h... no
checking for int8_t... yes
checking for u_int8_t... yes
checking for int16_t... yes
checking for u_int16_t... yes
checking for int32_t... yes
checking for u_int32_t... yes
checking for int64_t... yes
checking for u_int64_t... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for _LARGEFILE_SOURCE value needed for large files... no
checking sys/ioccom.h usability... yes
checking sys/ioccom.h presence... yes
checking for sys/ioccom.h... yes
checking sys/sockio.h usability... yes
checking sys/sockio.h presence... yes
checking for sys/sockio.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking paths.h usability... yes
checking paths.h presence... yes
checking for paths.h... yes
checking linux/types.h usability... no
checking linux/types.h presence... no
checking for linux/types.h... no
checking linux/if_packet.h usability... no
checking linux/if_packet.h presence... no
checking for linux/if_packet.h... no
checking netpacket/packet.h usability... no
checking netpacket/packet.h presence... no
checking for netpacket/packet.h... no
checking netpacket/if_packet.h usability... no
checking netpacket/if_packet.h presence... no
checking for netpacket/if_packet.h... no
checking for net/pfvar.h... yes
checking whether net/pfvar.h defines PF_NAT through PF_NORDR... yes
checking for netinet/if_ether.h... no
configure: Rechecking with some additional includes
checking for netinet/if_ether.h... yes
checking for ANSI ioctl definitions... yes
checking for strerror... yes
checking for strlcpy... yes
checking for vsnprintf... yes
checking for snprintf... yes
checking for library containing gethostbyname... none required
checking for library containing socket... none required
checking for library containing putmsg... no
checking for ether_hostton... yes
checking whether ether_hostton is declared... yes
checking if --disable-protochain option is specified... enabled
checking packet capture type... bpf
checking net/if_media.h usability... yes
checking net/if_media.h presence... yes
checking for net/if_media.h... yes
checking whether the system supports zerocopy BPF... yes
checking for struct BPF_TIMEVAL... no
checking for getifaddrs... yes
checking ifaddrs.h usability... yes
checking ifaddrs.h presence... yes
checking for ifaddrs.h... yes
checking for socklen_t... yes
checking for getaddrinfo... yes
checking whether to build optimizer debugging code... no
checking whether to build parser debugging code... no
checking whether we have DAG API headers... no (/usr/local/include)
checking whether we have the DAG API... no
checking whether we have Septel API... no
checking whether we have Myricom Sniffer API... no (/opt/snf)
checking for flex... flex
checking for flex 2.4 or higher... yes
checking for bison... no
configure: WARNING: don't have both flex and bison; reverting to lex/yacc
checking for capable lex... yes
checking for ranlib... ranlib
checking for ar... ar
checking whether ln -s works... yes
checking if sockaddr struct has the sa_len member... yes
checking if sockaddr_storage struct exists... yes
checking if dl_hp_ppa_info_t struct has dl_module_id_1 member... no
checking if unaligned accesses fail... no
checking for USB sniffing support... no
checking whether the platform could support netfilter sniffing... no
checking for net/netmap_user.h... yes
configure: netmap is supported
configure: no Bluetooth sniffing support implemented for freebsd10.0
configure: no canusb support implemented for freebsd10.0
configure: no CAN sniffing support implemented for freebsd10.0
checking for pkg-config... no
configure: no hardware timestamp support implemented for freebsd10.0
checking for a BSD-compatible install... /usr/bin/install -c
configure: creating ./config.status
config.status: creating Makefile
config.status: creating pcap-filter.manmisc
config.status: creating pcap-linktype.manmisc
config.status: creating pcap-tstamp.manmisc
config.status: creating pcap-savefile.manfile
config.status: creating pcap.3pcap
config.status: creating pcap_compile.3pcap
config.status: creating pcap_datalink.3pcap
config.status: creating pcap_dump_open.3pcap
config.status: creating pcap_get_tstamp_precision.3pcap
config.status: creating pcap_list_datalinks.3pcap
config.status: creating pcap_list_tstamp_types.3pcap
config.status: creating pcap_open_dead.3pcap
config.status: creating pcap_open_offline.3pcap
config.status: creating pcap_set_tstamp_precision.3pcap
config.status: creating pcap_set_tstamp_type.3pcap
config.status: creating config.h
config.status: executing default-1 commands

*4>make*

root@switch:/usr/src/tools/tools/netmap/netmap-libpcap # make
cc -fpic -I. -DHAVE_CONFIG_H  -D_U_="__attribute__((unused))" -g -O2 -c
./pcap-bpf.c
cc -fpic -I. -DHAVE_CONFIG_H  -D_U_="__attribute__((unused))" -g -O2 -c
./pcap-netmap.c
./pcap-netmap.c:117:9: warning: implicit declaration of function
'nm_dispatch'
      is invalid in C99 [-Wimplicit-function-declaration]
                ret = nm_dispatch((void *)d, cnt, (void *)pcap_netmap_fi...
                      ^
./pcap-netmap.c:131:9: warning: implicit declaration of function
'nm_inject' is
      invalid in C99 [-Wimplicit-function-declaration]
        return nm_inject(d, buf, size);
               ^
./pcap-netmap.c:139:15: error: variable has incomplete type 'struct ifreq'
        struct ifreq ifr;
                     ^
./pcap-netmap.c:139:9: note: forward declaration of 'struct ifreq'
        struct ifreq ifr;
               ^
./pcap-netmap.c:140:19: error: incomplete definition of type 'struct
nm_desc'
        int error, fd = d->fd;
                        ~^
./pcap-netmap.c:71:9: note: forward declaration of 'struct nm_desc'
        struct nm_desc *d;      /* pointer returned by nm_open() */
               ^
./pcap-netmap.c:152:7: error: use of undeclared identifier 'SIOCSIFFLAGS'
        case SIOCSIFFLAGS:
             ^
./pcap-netmap.c:157:10: warning: implicit declaration of function 'ioctl' is
      invalid in C99 [-Wimplicit-function-declaration]
        error = ioctl(fd, what, &ifr);
                ^
./pcap-netmap.c:159:4: error: incomplete definition of type 'struct nm_desc'
                d->req.nr_name, what, error);
                ~^
./pcap-netmap.c:71:9: note: forward declaration of 'struct nm_desc'
        struct nm_desc *d;      /* pointer returned by nm_open() */
               ^
./pcap-netmap.c:163:7: error: use of undeclared identifier 'SIOCGIFFLAGS'
        case SIOCGIFFLAGS:
             ^
./pcap-netmap.c:177:24: error: use of undeclared identifier 'SIOCGIFFLAGS'
                pcap_netmap_ioctl(p, SIOCGIFFLAGS, &if_flags); /* fetch
flags */
                                     ^
./pcap-netmap.c:178:18: error: use of undeclared identifier 'IFF_PPROMISC'
                if (if_flags & IFF_PPROMISC) {
                               ^
./pcap-netmap.c:179:17: error: use of undeclared identifier 'IFF_PPROMISC'
                        if_flags &= ~IFF_PPROMISC;
                                     ^
./pcap-netmap.c:180:25: error: use of undeclared identifier 'SIOCSIFFLAGS'
                        pcap_netmap_ioctl(p, SIOCSIFFLAGS, &if_flags);
                                             ^
./pcap-netmap.c:183:2: warning: implicit declaration of function 'nm_close'
is
      invalid in C99 [-Wimplicit-function-declaration]
        nm_close(d);
        ^
./pcap-netmap.c:195:22: warning: implicit declaration of function 'nm_open'
is
      invalid in C99 [-Wimplicit-function-declaration]
        struct nm_desc *d = nm_open(p->opt.source, NULL, 0, NULL);
                            ^
./pcap-netmap.c:195:18: warning: incompatible integer to pointer conversion
      initializing 'struct nm_desc *' with an expression of type 'int'
      [-Wint-conversion]
        struct nm_desc *d = nm_open(p->opt.source, NULL, 0, NULL);
                        ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./pcap-netmap.c:210:36: error: incomplete definition of type 'struct
nm_desc'
                __FUNCTION__, p->opt.source, d, d->fd,
                                                ~^
./pcap-netmap.c:71:9: note: forward declaration of 'struct nm_desc'
        struct nm_desc *d;      /* pointer returned by nm_open() */
               ^
./pcap-netmap.c:213:11: error: incomplete definition of type 'struct
nm_desc'
        p->fd = d->fd;
                ~^
./pcap-netmap.c:71:9: note: forward declaration of 'struct nm_desc'
        struct nm_desc *d;      /* pointer returned by nm_open() */
               ^
./pcap-netmap.c:214:27: error: incomplete definition of type 'struct
nm_desc'
        if (p->opt.promisc && !(d->req.nr_ringid & NETMAP_SW_RING)) {
                                ~^
./pcap-netmap.c:71:9: note: forward declaration of 'struct nm_desc'
        struct nm_desc *d;      /* pointer returned by nm_open() */
               ^
./pcap-netmap.c:214:45: error: use of undeclared identifier 'NETMAP_SW_RING'
        if (p->opt.promisc && !(d->req.nr_ringid & NETMAP_SW_RING)) {
                                                   ^
./pcap-netmap.c:215:24: error: use of undeclared identifier 'SIOCGIFFLAGS'
                pcap_netmap_ioctl(p, SIOCGIFFLAGS, &if_flags); /* fetch
flags */
                                     ^
./pcap-netmap.c:216:20: error: use of undeclared identifier 'IFF_PPROMISC'
                if (!(if_flags & IFF_PPROMISC)) {
                                 ^
./pcap-netmap.c:218:16: error: use of undeclared identifier 'IFF_PPROMISC'
                        if_flags |= IFF_PPROMISC;
                                    ^
./pcap-netmap.c:219:25: error: use of undeclared identifier 'SIOCSIFFLAGS'
                        pcap_netmap_ioctl(p, SIOCSIFFLAGS, &if_flags);
                                             ^
6 warnings and 17 errors generated.
*** Error code 1

Stop.
make: stopped in /usr/src/tools/tools/netmap/netmap-libpcap

and I've no idea to fix the problem...could anybody give me advice?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMijcFGdU7KqH0dzw4-Ga7cCEWiyc-RA6FvU8ma6OUQ91MsF=A>