Permalink
Commits on Sep 15, 2017
  1. trafgen: fix packet socket initialization with multiple CPUs

    Paolo Abeni committed with tklauser Sep 13, 2017
    The commit 78c13b7 ("trafgen: Allow to generate packets
    to output pcap file") introduced a regression when output is
    a network device and multiple CPU are in use: the packet
    socket is created before fork() and thus the socket is shared
    among all the processes: all of them except the first will
    fail while setting the tx_ring.
    
    Fix it splitting the io open() helper in a create() op,
    called before forking, and the open() op called by each process.
    
    Fixes: 78c13b7 ("trafgen: Allow to generate packets to output pcap file")
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on Sep 13, 2017
  1. ifpps: fix unintendet assignment

    tklauser committed Sep 13, 2017
    Variable rate is assigned instead of compared in the check of the
    interval in relation to the line rate. Fix it and at the same time fix
    the compared against interval value to match the message we show if the
    condition is fulfilled.
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  2. link: use uint32_t instead of u32

    tklauser committed Sep 13, 2017
    Use type uint32_t instead of u32 (which is typedef'ed to uint32_t in
    built_in.h) in order to avoid confusion wrt. kernel-/user-space types.
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  3. ifpps: use uint32_t instead of u32

    tklauser committed Sep 13, 2017
    Use type uint32_t instead of u32 (which is typedef'ed to uint32_t in
    built_in.h) in order to avoid confusion wrt. kernel-/user-space types.
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  4. dev: only calculate wireless bitrate if necessary

    tklauser committed Sep 13, 2017
    Only call wireless_bitrate (and thus the underlying ioctl) if strictly
    necessary, i.e. ethtool_bitrate returned 0.
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on Aug 10, 2017
  1. trafgen: Dump proto headers in *.cfg format

    vkochan committed with tklauser Jul 29, 2017
    Added trafgen_dump.c module which dumps headers from packet
    in .cfg format. Packet is dumped if -o <file>.cfg was specified,
    it might be useful to specify *.pcap file as input and convert it
    into .cfg file to edit proto fields in human readable format.
    
    To make it possible several main changes were added:
    
        1) packet id is embedded into struct packet.id, and
           it is updated on each realloc_packet()
    
        2) Added new struct proto_hdr.get_next_proto callback
           to make possible apply fields of next header.
    
        3) Added new dev_io ops for writting packets into .cfg file,
           to re-use common dev_io mechsnism for packets dumping.
    
    Before dump the default ETH_PROTO fields are applied as first header and
    then next proto_hdr is identified via .get_next_proto(...) callback.
    
    Meanwhile only eth, arp, vlan, ip4, udp, & tcp protos can be dissected
    into *.cfg format.
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  2. trafgen: dev_io: Change read/write to specify struct packet *

    vkochan committed with tklauser Jul 29, 2017
    Refactor dev_io_ops read & write to specify struct packet *,
    it may simplify a bit a caller logic. And it allow to keep
    required members within one struct packet object.
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  3. trafgen: Get packet from proto_hdr if possible

    vkochan committed with tklauser Jul 29, 2017
    Replace using current_packet() by new proto_hdr_packet(hdr)
    function to obtain packet directly from header. This is more
    generic and flexible way, because it guarantees that packet really
    belongs to the header, which in case in current_packet() is not right
    because it means getting of last allocated packet.
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on Jul 25, 2017
  1. AUTHOR: add Zhouyang Jia

    tklauser committed Jul 25, 2017
    Add Zhouyang jia for commit 9f87a7b (PR #180).
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  2. mausezahn: fix segmentation fault

    ZhouyangJia committed with tklauser Jul 24, 2017
    Mausezahn will crash when given wrong payload file, e.g., "$./mausezahn
    -f wrong_file". This patch fixes the segmentation fault by adding
    error-handling code to fopen.
    
    Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on Jul 17, 2017
  1. trafgen: Delegate creation of rfraw to dev_io API

    vkochan committed with tklauser Jul 17, 2017
    Simplify a bit of creation rfraw device by delegating it to the dev_io
    API, also in case the output device is pcap file the --rfraw option
    sets the link type to ieee80211 radio tap.
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on Jul 4, 2017
  1. staging: compilation fix with new gcc

    yarda committed with tklauser Jul 3, 2017
    Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
Commits on Jun 27, 2017
  1. netsniff-ng: fix --bind-cpu option in example command line

    tklauser committed Jun 27, 2017
    Change the invalid --b option in one of the examples listed in the help
    to --bind-cpu.
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on Jun 20, 2017
  1. trafgen: gracefully handle ENOBUFS on tx ring teardown

    tklauser committed Jun 20, 2017
    pull_and_flush_tx_ring_wait() in the exit path of xmit_fastpath_or_die()
    might return with errno ENOBUFS (due to the other CPU's processes
    concurrent access) but will eventually suceed. Thus retry
    pull_and_flush_tx_ring_wait() as in the main loop of
    xmit_fastpath_or_die().
    
    Fixes #175
    
    Reported-by: Eduardo Miravalls Sierra
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on Jun 19, 2017
  1. trafgen: Fix output pcap file name length trimming

    vkochan committed with tklauser Jun 12, 2017
    Trim output name to IFNAMSIZ only if the output is a networking device,
    otherwise the following error occured if output name is greater then
    IFNAMSIZ:
    
      $ trafgen -n 1 '{ udp() }' -o /tmp/xxxxxxxxxxxxxx.pcap
      No networking device or pcap file: /tmp/xxxxxxxxxx
      Failed to open output device
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on Jun 9, 2017
  1. trafgen: Allow to generate packets to output pcap file

    vkochan committed with tklauser Jun 7, 2017
    Add trafgen_dev.c module which provides generic way of
    reading and writing packets to/from networking device or a pcap file.
    
    Also allow to handle output pcap file via '-o, --out, --dev' option.
    
    It might be useful in future for testing some link protocols which is
    not easy to capture (e.g. wlan packets) w/o having some special setup.
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    [tklauser: fix whitespace issues]
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on Jun 2, 2017
  1. flowtop: Move out stats fields from flow & proc entry

    vkochan committed with tklauser Jun 1, 2017
    Move rate, bytes & pkts stats fields from flow & proc entry
    to separate flow_stat struct.
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  2. trafgen: parser: Add syntax to generate DNS header

    vkochan committed with tklauser Jun 1, 2017
    Add new syntax for DNS header generation via 'dns()' proto function.
    
    The fields are supported:
    
    	id		- 16 bit identifier
    	qr		- message is a query(0) or response(1)
    	op|oper		- specified kind of query
    	aanswer		- authoritative answer flag
    	trunc		- message was truncated flag
    	rdesired	- recursion desired flag
    	ravail		- recursion available flag
    	zero		- reserved for future use
    	rcode		- response code
    	qdcount		- number of entries in question section
    	ancount		- number of entries in answer section
    	nscount		- number of entries in authority section
    	arcount		- number of entries in additional section
    
    Also there are functions to generate DNS sections:
    
    'qry()' function to generate separate query entry:
    
    	name		- variable domain name
    	type		- type of the query
    	class		- class of the query
    
    'ans()', 'auth()', 'add'  functions to generate separate answer,
    authoritative, adidditional entry with the same fields layout:
    
    	name		- variable domain name
    	type		- resource record type
    	class		- class of the data
    	ttl		- time interval that the record may be cached
    	len		- length of data
    	data		- variable length of bytes
    
    All the DNS section entries will be automaticlly sorted by DNS proto API
    in the way which is required by DNS header:
    
    	query entries
    	answer entries
    	authoritative entries
    	additional entries
    
    'name' field in qry/ans/auth/add functions is automatically converted to
    FQDN format if it was specified as "string".
    
    There are also added functions to simplify the way of filling
    some often used RR types for using them inside ans/auth/add functions:
    
    	addr(ipv4_addr | ipv6_addr) - fills the following RR fields:
    		len  - 4 or 16 depends on IPv4 or IPv6 address was specified
    		data - is filled with IPv4 or IPv6 address
    		type - 1 for IPv4 address, 28 - for IPv6
    
    	ns(string)
    		type - 2
    
    	cname(string)
    		type - 5
    
    	ptr(string)
    		type - 12
    
    EXAMPLES:
    
    {
        dns(qr=1,
            auth(name="ns1", ns("ns1.org")),
    	ans(name="www.google.com", cname("google.com")),
    	auth(name="aa", ns("bb")),
    	qry(name="www.google.com"))
    }
    
    {
        dns(qr=1, ans(name="www.google.com", addr(1.2.3.4)))
    }
    
    {
        dns(qr=1, ans(name="www.google.com", addr(1::)))
    }
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  3. trafgen: l7: Add DNS header generation API

    vkochan committed with tklauser Jun 1, 2017
    Add trafgen_l7.c module with DNS proto header generation with
    support of filling DNS query/answer/authority/additional sections
    as sub headers.
    
    Introcuded new concept as 'sub header' which is needed to easy handle
    DNS sections which might be added on-demand, and to simplify using
    sub-header as regular header with a fields, offset, etc. There is a
    parent header which contains array of pointers of sub-headers, and the
    array is ordered as they are located in the parent header. The
    sub-headers mostly encapsulated by the parent header which 'knows'
    the semantic of them. The new proto_hdr->push_sub_header(...) callback
    was added to tell the parent header to push the sub-header's fields,
    sub-header also may have proto_ops which must be filled by the parent.
    This sub-header concept might be used in the future if it will be needed
    to support DHCP, WLAN headers.
    
    There are 4 kinds of DNS sub-headers - query, answer, authority,
    additional. 'id' of each sub-header is used to only differentiate these
    types of sections. These sections have strict order inside DNS header,
    and there was added the proto_hdr_move_sub_header(...) to sort them in
    required order.
    
    Actually there are only 2 proto_hdr's which describes 4 DNS sections -
    query & rrecord, because rrecord covers another 3 - answer, auhority,
    additional which have the same layout.
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  4. str: Add function for converting string into DNS name

    vkochan committed with tklauser Jun 1, 2017
    Add str2fqdn for converting hostname string into DNS name notation:
    
        www.xxxx.yy.com -> 3www4xxxx2yy3com0
    
    Returned string must be freed after use by the caller.
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  5. trafgen: proto: Allow to set field with variable length

    vkochan committed with tklauser Jun 1, 2017
    It is quite tricky to set field value with a variable length
    (i.e. DNS query name), to make it possible the field
    needs to be added to header with 'len=0' in that case there
    will be no any payload allocation, but only while setting the field
    value the packet will be appended with a real length bytes and after
    the field needs to be relocated to the right place.
    
    Also add 'len' parameter to *_set_bytes(...) functoins to have better
    control over it.
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on May 30, 2017
  1. flowtop: Improve and unify up/down scrolling

    vkochan committed with tklauser May 27, 2017
    Move scrolling logic to the ui.c module, it requires to have
    some data iteration provided in flowtop.c and delegated to ui.c part.
    
    So approach is that now flowtop provides 2 additional callbacks for:
    
        1) Iterate over flows/procs list
        2) Draw flow/proc on each iteration which is controlled from ui.c
    
    it allows to unify scrolling logic and delegate it to the ui.c, in the
    future it should allow to easy handle press event on selected row and
    drow some additional information, or draw a cursor line per selected
    row.
    
    Also fixed case when down scrolling was bigger that printed rows, not
    it is handled by ui part.
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on May 23, 2017
  1. AUTHORS: add Baruch Siach

    tklauser committed May 23, 2017
    Add Baruch for commits 4de312b ("flowtop: take PKG_CONFIG into
    account for libnetfilter_conntrack") and 95f6019 ("proc.h: add
    missing headers").
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  2. proc.h: add missing headers

    baruchsiach committed with tklauser May 23, 2017
    ino_t and pid_t require stat.h and types.h, respectively. Fixes the following
    build failure with musl libc:
    
    In file included from cpp.c:7:0:
    proc.h:11:31: error: unknown type name =E2=80=98ino_t=E2=80=99
     extern int proc_find_by_inode(ino_t ino, char *cmdline, size_t len, pid_t =
    *pid);
                                   ^
    proc.h:11:69: error: unknown type name =E2=80=98pid_t=E2=80=99
     extern int proc_find_by_inode(ino_t ino, char *cmdline, size_t len, pid_t =
    *pid);
                                                                         ^
    proc.h:12:25: error: unknown type name =E2=80=98pid_t=E2=80=99
     extern bool proc_exists(pid_t pid);
                             ^
    
    Signed-off-by: Baruch Siach <baruch@tkos.co.il>
    [tk: complementary fix to commit a9f4431]
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  3. flowtop: take PKG_CONFIG into account for libnetfilter_conntrack

    baruchsiach committed with tklauser Apr 16, 2017
    Use $PKG_CONFIG to determine the linker flags for libnetfilter_conntrack. This
    fixes static link failure like the following:
    
      LD	flowtop
    .../usr/x86_64-buildroot-linux-musl/sysroot/usr/lib/../lib64/libnetfilter_conntrack.a(main.o): In function `nfct_open_nfnl':
    main.c:(.text+0x52): undefined reference to `nfnl_subsys_open'
    main.c:(.text+0x69): undefined reference to `nfnl_subsys_close'
    main.c:(.text+0x87): undefined reference to `nfnl_subsys_open'
    main.c:(.text+0xa3): undefined reference to `nfnl_subsys_close'
    .../usr/x86_64-buildroot-linux-musl/sysroot/usr/lib/../lib64/libnetfilter_conntrack.a(main.o): In function `nfct_open':
    main.c:(.text+0xc9): undefined reference to `nfnl_open'
    main.c:(.text+0xf0): undefined reference to `nfnl_close'
    ...
    
    Signed-off-by: Baruch Siach <baruch@tkos.co.il>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on May 15, 2017
  1. trafgen: parser: Use proto_field_set_xxx where it is possible

    vkochan committed with tklauser May 14, 2017
    Use proto_field_set_xxx(field, ...)  instead of
    proto_hdr_field_set_xxx(hdr, fid, ...) to be more generic and do not
    depend on 'hdr' variable.
    
    Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on May 12, 2017
  1. trafgen: disable NLS in the parser

    tklauser committed May 12, 2017
    There is no point in having the parser show translated error messages
    while the rest of the program does only show them in English.
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  2. bpfc: disable NLS in the parser

    tklauser committed May 12, 2017
    There is no point in having the parser show translated error messages
    while the rest of the program does only show them in English.
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  3. built_in: don't redefine memcpy/memset

    tklauser committed May 12, 2017
    Redefining memset/memcpy causes problems when building with fortified
    headers on Alpine Linux. Instead of uncoditionally defining these,
    explicitely use fmemcpy/fmemset in performance critical paths and
    otherwise let the compiler decide about optimizations.
    
    Fixes #173
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on May 10, 2017
  1. all: use <net/*> headers instead of <linux/*> where possible

    tklauser committed May 10, 2017
    The musl libc headers redefine some of the structs in linux/if_arp.h and
    linux/if_ether.h, leading to compilation errors. Fix those by using the
    libc provided versions of these headers and provide compatibility
    defines for those that aren't present in older glibc versions.
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on May 3, 2017
  1. geoip: adjust geoip{4,6}_{city,region}_name prototypes for !HAVE_GEOIP

    tklauser committed May 3, 2017
    Make the return type make the functions for HAVE_GEOIP. This fixes GCC's
    -Wdiscarded-qualifiers warnings when building without geoip support.
    
    Fixes: 8fd19ee ("geoip: Fix memory leak when using GeoIPRecord")
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  2. proc: include headers to get definitions for ino_t and pid_t

    tklauser committed May 3, 2017
    Include <unistd.h> and <sys/types.h> in the header already as the
    declarations for proc_find_by_inode(...) and proc_exists(...) use ino_t
    and pid_t, respectively.
    
    Fixes: 1edfb24 ("flowtop: Move & refactor walk_processes() to proc.c")
    Fixes: 1df0f48 ("flowtop: Add process UI tab entry")
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  3. make: use sed instead of perl to extract lex/yacc prefix

    tklauser committed May 3, 2017
    Perl is not available on certain distributions by default (e.g. Alpine
    Linux). In order to avoid depending on perl just to extract the lex/yacc
    prefix, use sed instead which should be available almost everywhere.
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on Apr 12, 2017
  1. netsniff-ng: remove unnecessary zeroing of packet counters in init_ctx()

    tklauser committed Apr 12, 2017
    The struct ctx in initialized using memset(ctx, 0, sizeof(*ctx) in
    init_ctx(), so there is no need to zero these members again.
    
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Commits on Apr 11, 2017
  1. netsniff-ng v0.6.3

    tklauser committed Apr 11, 2017
    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>