Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package netsniff-ng for openSUSE:Factory 
checked in at 2025-01-12 11:21:18
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/netsniff-ng (Old)
 and      /work/SRC/openSUSE:Factory/.netsniff-ng.new.1881 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "netsniff-ng"

Sun Jan 12 11:21:18 2025 rev:11 rq:1236873 version:0.6.9

Changes:
--------
--- /work/SRC/openSUSE:Factory/netsniff-ng/netsniff-ng.changes  2024-02-25 
14:06:16.337232650 +0100
+++ /work/SRC/openSUSE:Factory/.netsniff-ng.new.1881/netsniff-ng.changes        
2025-01-12 11:28:20.393439405 +0100
@@ -1,0 +2,13 @@
+Tue Jan  7 13:29:47 UTC 2025 - Martin Hauke <mar...@gmx.de>
+
+- Update to version 0.6.9
+  * Allow to manually define CPUs for trafgen.
+  * Fix make install and output netsniff-ng stats on stderr.
+  * trafgen: Fix for ipv6 header generation when L3-only devices
+    are present.
+  * mausezahn: use getopt_long instead of getopt.
+  * build: fix install dependencies in Makefile template.
+  * trafgen: move cpu stats temp file to /tmp.
+  * ring_tx: handle EINTR from sendto.
+
+-------------------------------------------------------------------

Old:
----
  netsniff-ng-0.6.8.tar.xz

New:
----
  netsniff-ng-0.6.9.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ netsniff-ng.spec ++++++
--- /var/tmp/diff_new_pack.SGYkin/_old  2025-01-12 11:28:20.841457842 +0100
+++ /var/tmp/diff_new_pack.SGYkin/_new  2025-01-12 11:28:20.841457842 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package netsniff-ng
 #
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2025 SUSE LLC
 # Copyright (c) 2012 Pascal Bleser <pascal.ble...@opensuse.org>
 #
 # All modifications and additions to the file contributed by third parties
@@ -18,13 +18,14 @@
 
 
 Name:           netsniff-ng
-Version:        0.6.8
+Version:        0.6.9
 Release:        0
 Summary:        Network Sniffer for Packet Inspection
 License:        GPL-2.0-only
 Group:          Productivity/Networking/Diagnostic
 URL:            http://netsniff-ng.org/
 Source:         
http://pub.netsniff-ng.org/netsniff-ng/netsniff-ng-%{version}.tar.xz
+Patch0:         netsniff-ng-ncursesw.patch
 BuildRequires:  autoconf
 BuildRequires:  automake
 BuildRequires:  bison
@@ -43,8 +44,6 @@
 BuildRequires:  pkgconfig
 BuildRequires:  zlib-devel
 BuildRequires:  pkgconfig(ncursesw)
-Patch0:         netsniff-ng-ncursesw.patch
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 
 %description
 netsniff-ng is a network sniffer for packet inspection. It is similar
@@ -70,19 +69,34 @@
 
 %build
 export NACL_LIB=sodium
-export NACL_INC_DIR=/usr/include/sodium
+export NACL_INC_DIR=%{_includedir}/sodium
 ./configure --disable-geoip
-make %{?_smp_mflags} ETCDIR=%{_sysconfdir} Q= STRIP=: CFLAGS="%{optflags}"
+%make_build ETCDIR=%{_sysconfdir} Q= STRIP=: CFLAGS="%{optflags}"
 
 %install
 # disable parrallel execution with -j1 because it cause an error with make 4.4
 make -j1 install PREFIX=%{_prefix} ETCDIR=%{_sysconfdir} DESTDIR=%{buildroot}
+rm -Rf %{buildroot}%{_docdir}/netsniff-ng %{buildroot}%{_datadir}/licenses/
 
 %files
 %license COPYING
 %doc AUTHORS README REPORTING-BUGS
 %dir %{_sysconfdir}/netsniff-ng
 %config(noreplace) %{_sysconfdir}/netsniff-ng/*
-%{_sbindir}/*
-%{_mandir}/man8/*
+%{_sbindir}/astraceroute
+%{_sbindir}/bpfc
+%{_sbindir}/curvetun
+%{_sbindir}/flowtop
+%{_sbindir}/ifpps
+%{_sbindir}/mausezahn
+%{_sbindir}/netsniff-ng
+%{_sbindir}/trafgen
+%{_mandir}/man8/astraceroute.8%{?ext_man}
+%{_mandir}/man8/bpfc.8%{?ext_man}
+%{_mandir}/man8/curvetun.8%{?ext_man}
+%{_mandir}/man8/flowtop.8%{?ext_man}
+%{_mandir}/man8/ifpps.8%{?ext_man}
+%{_mandir}/man8/mausezahn.8%{?ext_man}
+%{_mandir}/man8/netsniff-ng.8%{?ext_man}
+%{_mandir}/man8/trafgen.8%{?ext_man}
 

++++++ netsniff-ng-0.6.8.tar.xz -> netsniff-ng-0.6.9.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/.github/workflows/build.yml 
new/netsniff-ng-0.6.9/.github/workflows/build.yml
--- old/netsniff-ng-0.6.8/.github/workflows/build.yml   1970-01-01 
01:00:00.000000000 +0100
+++ new/netsniff-ng-0.6.9/.github/workflows/build.yml   2025-01-07 
13:54:39.000000000 +0100
@@ -0,0 +1,53 @@
+name: Build
+
+on:
+  push:
+    branches:
+    - master
+  pull_request:
+    branches:
+    - master
+
+jobs:
+  build:
+    strategy:
+      matrix:
+        CC: [gcc, clang]
+    runs-on: ubuntu-latest
+
+    steps:
+    - name: Install dependencies
+      run: |
+        sudo apt-get install -y --no-install-recommends libnl-3-dev 
libnl-genl-3-dev libnl-route-3-dev libnetfilter-conntrack-dev libgeoip-dev 
liburcu-dev libpcap-dev libnet1-dev libcli-dev libsodium-dev clang
+
+    - name: Check out code
+      uses: actions/checkout@v2
+
+    - name: Build (with all features)
+      run: |
+        CC=${{ matrix.CC }} ./configure
+        make CC=${{ matrix.CC }}
+
+    - name: Build (without GeoIP)
+      run: |
+        make clean
+        CC=${{ matrix.CC }} ./configure --disable-geoip
+        make CC=${{ matrix.CC }}
+
+    - name: Build (without zlib)
+      run: |
+        make clean
+        CC=${{ matrix.CC }} ./configure --disable-zlib
+        make CC=${{ matrix.CC }}
+
+    - name: Build (without GeoIP and zlib)
+      run: |
+        make clean
+        CC=${{ matrix.CC }} ./configure --disable-geoip --disable-zlib
+        make CC=${{ matrix.CC }}
+
+    - name: Build (without libnl)
+      run: |
+        make clean
+        CC=${{ matrix.CC }} ./configure --disable-libnl
+        make CC=${{ matrix.CC }}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/Cmds new/netsniff-ng-0.6.9/Cmds
--- old/netsniff-ng-0.6.8/Cmds  2021-01-11 12:47:32.000000000 +0100
+++ new/netsniff-ng-0.6.9/Cmds  2025-01-07 13:54:39.000000000 +0100
@@ -44,7 +44,8 @@
   INSTX = echo -e "  INST\t$(1)" && install -d $(2) && \
        install -C $(1) $(2)/$(shell basename $(1))
 else
-  INSTX = echo -e "  INST\t$(1)" && install -C $(1) $(2)/$(shell basename $(1))
+  INSTX = echo -e "  INST\t$(1)" && install -d $(2) && \
+       install -C $(1) $(2)/$(shell basename $(1))
 endif
 
 MKDIR = echo -e  "  MKDIR\t$(1)" && mkdir -p $(1)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/Makefile 
new/netsniff-ng-0.6.9/Makefile
--- old/netsniff-ng-0.6.8/Makefile      2021-01-11 12:47:32.000000000 +0100
+++ new/netsniff-ng-0.6.9/Makefile      2025-01-07 13:54:39.000000000 +0100
@@ -15,9 +15,9 @@
 
 VERSION = 0
 PATCHLEVEL = 6
-SUBLEVEL = 8
+SUBLEVEL = 9
 EXTRAVERSION =
-NAME = Flutternozzle
+NAME = Analogue Bubblebath
 
 TOOLS ?= $(CONFIG_TOOLS)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/README.devel 
new/netsniff-ng-0.6.9/README.devel
--- old/netsniff-ng-0.6.8/README.devel  2021-01-11 12:47:32.000000000 +0100
+++ new/netsniff-ng-0.6.9/README.devel  2025-01-07 13:54:39.000000000 +0100
@@ -1,8 +1,3 @@
-A Travis CI instance for continuous integration testing of netsniff-ng
-can be found here:
-
-  https://travis-ci.org/netsniff-ng/netsniff-ng
-
 An analysis by the Coverity Scanner is run occasionally against the source of
 netsniff-ng. The corresponding scan reports can be found here:
 
@@ -12,6 +7,4 @@
 
   `make COV_EMAIL=<email> COV_PASSWD=<passwd> coverity'
 
-to trigger a new scan yourself. Alternatively, the Coverity integration of
-Travis CI can be used by pushing to the branch 'coverity_scan' to trigger a new
-analysis.
+to trigger a new scan yourself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/Template 
new/netsniff-ng-0.6.9/Template
--- old/netsniff-ng-0.6.8/Template      2021-01-11 12:47:32.000000000 +0100
+++ new/netsniff-ng-0.6.9/Template      2025-01-07 13:54:39.000000000 +0100
@@ -12,6 +12,7 @@
        $(Q)eval GZIP= gzip $(GZIP_ENV) $(1).8 > $(1)/$(1).8.gz
        $(Q)$$(call INST,$(1)/$(1).8.gz,$$(DESTDIR)$$(MAN8DIR))
        $(Q)$$(foreach file,$$($(1)-confs),$$(call 
INST,$$(file),$$(DESTDIR)$$(ETCDIRE));)
+  $(1)_post_install: $(1)_do_install
   $(1)_install: $(1)_do_install $(1)_post_install
   $(1)_uninstall: $(1)_uninstall_custom
        $(Q)$$(call RM,$$(DESTDIR)$$(SBINDIR)/$(1))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/configure 
new/netsniff-ng-0.6.9/configure
--- old/netsniff-ng-0.6.8/configure     2021-01-11 12:47:32.000000000 +0100
+++ new/netsniff-ng-0.6.9/configure     2025-01-07 13:54:39.000000000 +0100
@@ -588,7 +588,9 @@
 }
 EOF
 
-       $CC -o $TMPDIR/pcaptest $TMPDIR/pcaptest.c -lpcap >> config.log 2>&1
+       $CC -o $TMPDIR/pcaptest $TMPDIR/pcaptest.c \
+               $($PKG_CONFIG --libs libpcap 2>> config.log) \
+               >> config.log 2>&1
        if [ ! -x $TMPDIR/pcaptest ] ; then
                echo "[NO]"
                echo "CONFIG_LIBPCAP=0" >> Config
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/dev.c new/netsniff-ng-0.6.9/dev.c
--- old/netsniff-ng-0.6.8/dev.c 2021-01-11 12:47:32.000000000 +0100
+++ new/netsniff-ng-0.6.9/dev.c 2025-01-07 13:54:39.000000000 +0100
@@ -82,6 +82,8 @@
                panic("Cannot get device addresses for IPv6!\n");
 
        for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+               if (ifa->ifa_addr == NULL)
+                       continue;
                family = ifa->ifa_addr->sa_family;
                if (family != AF_INET6)
                        continue;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/mausezahn/Makefile 
new/netsniff-ng-0.6.9/mausezahn/Makefile
--- old/netsniff-ng-0.6.8/mausezahn/Makefile    2021-01-11 12:47:32.000000000 
+0100
+++ new/netsniff-ng-0.6.9/mausezahn/Makefile    2025-01-07 13:54:39.000000000 
+0100
@@ -1,6 +1,6 @@
 mausezahn-libs =       -lcli \
                        -lnet \
-                       -lpcap \
+                       $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) 
$(PKG_CONFIG) --libs libpcap 2> /dev/null ) \
                        -lrt \
                        -lpthread \
                        -lm
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/netsniff-ng.c 
new/netsniff-ng-0.6.9/netsniff-ng.c
--- old/netsniff-ng-0.6.8/netsniff-ng.c 2021-01-11 12:47:32.000000000 +0100
+++ new/netsniff-ng-0.6.9/netsniff-ng.c 2025-01-07 13:54:39.000000000 +0100
@@ -238,16 +238,21 @@
        if (update_rx_stats(ctx, sock, is_v3))
                return;
 
-       printf("\r%12"PRIu64"  packets incoming (%"PRIu64" unread on exit)\n",
+       FILE *fd = stdout;
+       // In case the out device is stdout redirect to stderr
+       if (ctx->device_out && !strncmp("-", ctx->device_out, strlen("-")))
+               fd = stderr;
+
+       fprintf(fd, "\r%12"PRIu64"  packets incoming (%"PRIu64" unread on 
exit)\n",
               is_v3 ? ctx->pkts_seen : ctx->pkts_recvd,
               is_v3 ? ctx->pkts_recvd - ctx->pkts_seen : 0);
-       printf("\r%12"PRIu64"  packets passed filter\n",
+       fprintf(fd, "\r%12"PRIu64"  packets passed filter\n",
               ctx->pkts_recvd - ctx->pkts_drops);
-       printf("\r%12"PRIu64"  packets failed filter (out of space)\n",
+       fprintf(fd, "\r%12"PRIu64"  packets failed filter (out of space)\n",
               ctx->pkts_drops);
 
        if (ctx->pkts_recvd  > 0)
-               printf("\r%12.4lf%% packet droprate\n",
+               fprintf(fd, "\r%12.4lf%% packet droprate\n",
                       (1.0 * ctx->pkts_drops / ctx->pkts_recvd) * 100.0);
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/ring_tx.h 
new/netsniff-ng-0.6.9/ring_tx.h
--- old/netsniff-ng-0.6.8/ring_tx.h     2021-01-11 12:47:32.000000000 +0100
+++ new/netsniff-ng-0.6.9/ring_tx.h     2025-01-07 13:54:39.000000000 +0100
@@ -30,12 +30,24 @@
 
 static inline int pull_and_flush_tx_ring(int sock)
 {
-       return sendto(sock, NULL, 0, MSG_DONTWAIT, NULL, 0);
+       int ret;
+
+       do {
+               ret = sendto(sock, NULL, 0, MSG_DONTWAIT, NULL, 0);
+       } while (ret == -1 && errno == EINTR);
+
+       return ret;
 }
 
 static inline int pull_and_flush_tx_ring_wait(int sock)
 {
-       return sendto(sock, NULL, 0, 0, NULL, 0);
+       int ret;
+
+       do {
+               ret = sendto(sock, NULL, 0, 0, NULL, 0);
+       } while (ret == -1 && errno == EINTR);
+
+       return ret;
 }
 
 #endif /* TX_RING_H */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/staging/mausezahn.c 
new/netsniff-ng-0.6.9/staging/mausezahn.c
--- old/netsniff-ng-0.6.8/staging/mausezahn.c   2021-01-11 12:47:32.000000000 
+0100
+++ new/netsniff-ng-0.6.9/staging/mausezahn.c   2025-01-07 13:54:39.000000000 
+0100
@@ -23,7 +23,8 @@
 #include <sys/ioctl.h>
 #include <netinet/in.h>
 #include <stdarg.h>
- 
+#include <getopt.h>
+
 #include "mz.h"
 #include "cli.h"
 #include "mops.h"
@@ -447,9 +448,7 @@
        char unit;
 
        opterr = 1; // let getopt print error message if necessary
-
-
-       while ((c = getopt(argc, argv, short_options)) != -1)
+       while ((c = getopt_long(argc, argv, short_options, NULL, NULL)) != -1) {
                switch (c) {
                 case '4':
                        tx.eth_type = 0x0800;
@@ -646,7 +645,7 @@
                        fprintf (stderr," mz/getopts: Could not handle 
arguments properly!\n");
                        return 1;
                }
-   
+       }
        // ********************************************
        //       Handle additional arguments
        // ********************************************
@@ -660,8 +659,8 @@
                        "-- Verbose mode --\n"
                        "\n");
        }
-   
-       if (argc<2) {
+
+       if (optind+2 < argc) {
                help();
        }
    
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/trafgen.8 
new/netsniff-ng-0.6.9/trafgen.8
--- old/netsniff-ng-0.6.8/trafgen.8     2021-01-11 12:47:32.000000000 +0100
+++ new/netsniff-ng-0.6.9/trafgen.8     2025-01-07 13:54:39.000000000 +0100
@@ -131,11 +131,15 @@
 transmission in a round robin fashion. With this option, they are selected
 randomly instread.
 .TP
-.B -P <uint>, --cpus <uint>
+.B -P <uint>[-<uint>], --cpus <uint>[-<uint>]
 Specify the number of processes trafgen shall
 .BR fork (2)
-off. By default trafgen will start as many processes as CPUs that are online 
and
-pin them to each, respectively. Allowed value must be within interval [1,CPUs].
+off or list exact CPUs to use. By default trafgen will start as many processes
+as CPUs that are online and pin them to each, respectively. A single integer
+within interval [1,CPUs] overrides number of processes, which will be spawned
+starting from the first CPU. A pair of integers within interval [0,CPUs-1], and
+separated using  ''-'' represents an interval of CPUs, which will be used to
+spawn worker processes.
 .TP
 .B -t <time>, --gap <time>
 Specify a static inter-packet timegap in seconds, milliseconds, microseconds,
@@ -156,7 +160,7 @@
 Furthermore, the TX_RING interface does not cope with interpacket gaps.
 .TP
 .B -b <rate>, --rate <rate>
-Specify the packet send rate <num>pps/B/kB/MB/GB/kbit/Mbit/Gbit/KiB/MiB/GiB 
units.
+Specify the packet send rate 
<num>pps/kpps/Mpps/B/kB/MB/GB/kbit/Mbit/Gbit/KiB/MiB/GiB units.
 Like with the \fB-t\fP/\fB--gap\fP option, the packets are sent in slow mode.
 .TP
 .B -S <size>, --ring-size <size>
@@ -267,8 +271,8 @@
    byte fill function:      fill(<content>, <times>): fill(0xca, 128)
    compile-time random:     rnd(<times>): rnd(128), rnd()
    runtime random numbers:  drnd(<times>): drnd(128), drnd()
-   compile-time counter:    seqinc(<start-val>, <increment>, <times>)
-                            seqdec(<start-val>, <decrement>, <times>)
+   compile-time counter:    seqinc(<start-val>, <times>, <increment>)
+                            seqdec(<start-val>, <times>, <decrement>)
    runtime counter (1byte): dinc(<min-val>, <max-val>, <increment>)
                             ddec(<min-val>, <max-val>, <decrement>)
 .PP
@@ -910,7 +914,7 @@
 .PP
    {
      # --- ethernet header ---
-     eth(da=00:1b:21:3c:9d:f8, da=90:e2:ba:0a:56:b4)
+     eth(da=00:1b:21:3c:9d:f8, sa=90:e2:ba:0a:56:b4)
      # --- ip header ---
      ipv4(id=drnd(), mf, ttl=64, sa=192.168.51.1, da=192.168.51.2)
      # --- udp header ---
@@ -926,6 +930,9 @@
 will generate traffic defined in the configuration file ''trafgen.cfg'' and
 transmit this via the ''eth0'' networking device. All online CPUs are used.
 .TP
+.B trafgen --dev eth0 --conf trafgen.cfg --cpus 2-4
+Instead of using all online CPUs, transmit traffic from CPUs 2, 3, and 4.
+.TP
 .B trafgen -e | trafgen -i - -o lo --cpp -n 1
 This is an example where we send one packet of the built-in example through
 the loopback device. The example configuration is passed via stdin and also
@@ -941,7 +948,8 @@
 .B trafgen --dev wlan0 --rfraw --conf beacon-test.txf -V --cpus 2
 As an output device ''wlan0'' is used and put into monitoring mode, thus we
 are going to transmit raw 802.11 frames through the air. Use the 
''beacon-test.txf''
-configuration file, set trafgen into verbose mode and use only 2 CPUs.
+configuration file, set trafgen into verbose mode and use only 2 CPUs starting
+from CPU 0.
 .TP
 .B trafgen --dev em1 --conf frag_dos.cfg --rand --gap 1000us
 Use trafgen in sendto(2) mode instead of TX_RING mode and sleep after each
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/netsniff-ng-0.6.8/trafgen.c 
new/netsniff-ng-0.6.9/trafgen.c
--- old/netsniff-ng-0.6.8/trafgen.c     2021-01-11 12:47:32.000000000 +0100
+++ new/netsniff-ng-0.6.9/trafgen.c     2025-01-07 13:54:39.000000000 +0100
@@ -82,7 +82,8 @@
        struct dev_io *dev_out;
        struct dev_io *dev_in;
        unsigned long num;
-       unsigned int cpus;
+       unsigned int cpu_start;
+       unsigned int cpu_num;
        uid_t uid; gid_t gid;
        char *device, *rhost;
        struct sockaddr_in dest;
@@ -118,7 +119,6 @@
        {"rate",                required_argument,      NULL, 'b'},
        {"cpus",                required_argument,      NULL, 'P'},
        {"ring-size",           required_argument,      NULL, 'S'},
-       {"kernel-pull",         required_argument,      NULL, 'k'},
        {"smoke-test",          required_argument,      NULL, 's'},
        {"seed",                required_argument,      NULL, 'E'},
        {"user",                required_argument,      NULL, 'u'},
@@ -195,9 +195,9 @@
             "  -s|--smoke-test <ipv4>                Probe if machine survived 
fuzz-tested packet\n"
             "  -n|--num <uint>                       Number of packets until 
exit (def: 0)\n"
             "  -r|--rand                             Randomize packet 
selection (def: round robin)\n"
-            "  -P|--cpus <uint>                      Specify number of 
forks(<= CPUs) (def: #CPUs)\n"
+            "  -P|--cpus <uint>[-<uint>]             Specify number of 
forks(<= CPUs) (def: #CPUs)\n"
             "  -t|--gap <time>                       Set approx. interpacket 
gap (s/ms/us/ns, def: us)\n"
-            "  -b|--rate <rate>                      Send traffic at specified 
rate (pps/B/kB/MB/GB/kbit/Mbit/Gbit/KiB/MiB/GiB)\n"
+            "  -b|--rate <rate>                      Send traffic at specified 
rate (pps/kpps/Mpps/B/kB/MB/GB/kbit/Mbit/Gbit/KiB/MiB/GiB)\n"
             "  -S|--ring-size <size>                 Manually set mmap size 
(KiB/MiB/GiB)\n"
             "  -E|--seed <uint>                      Manually set srand(3) 
seed\n"
             "  -u|--user <userid>                    Drop privileges and 
change to userid\n"
@@ -213,6 +213,7 @@
             "  -h|--help                             Guess what?!\n\n"
             "Examples:\n"
             "  trafgen --dev eth0 --conf trafgen.cfg\n"
+            "  trafgen --dev eth0 --conf trafgen.cfg --cpus 2-4\n"
             "  trafgen -e | trafgen -i - -o eth0 --cpp -n 1\n"
             "  trafgen --dev eth0 --conf fuzzing.cfg --smoke-test 10.0.0.1\n"
             "  trafgen --dev wlan0 --rfraw --conf beacon-test.txf -V --cpus 
2\n"
@@ -414,7 +415,7 @@
        char *zbuff, file[256];
        struct cpu_stats *buff;
 
-       slprintf(file, sizeof(file), ".tmp_mmap.XXXXXX");
+       slprintf(file, sizeof(file), "/tmp/.tmp_mmap.XXXXXX");
        fd = mkostemp_or_die(file, O_RDWR | O_CREAT | O_TRUNC);
        zbuff = xzmalloc(len);
        write_or_die(fd, zbuff, len);
@@ -830,7 +831,7 @@
        unsigned int i;
        unsigned long total;
 
-       for (i = 0, total = plen; i < ctx->cpus; i++) {
+       for (i = 0, total = plen; i < ctx->cpu_num; i++) {
                if (i == cpu)
                        continue;
 
@@ -853,7 +854,7 @@
        int cpu_sel;
        long long delta_correction = 0;
 
-       for (i = 0, total = ctx->num; i < ctx->cpus; i++) {
+       for (i = 0, total = ctx->num; i < ctx->cpu_num; i++) {
                if (i == cpu)
                        continue;
 
@@ -871,7 +872,7 @@
        if (total < orig)
                delta_correction = +1 * ((long long) orig - total);
 
-       for (cpu_sel = -1, i = 0; i < ctx->cpus; i++) {
+       for (cpu_sel = -1, i = 0; i < ctx->cpu_num; i++) {
                if (stats[i].cd_packets > 0) {
                        if ((long long) stats[i].cd_packets +
                            delta_correction >= 0) {
@@ -956,7 +957,7 @@
                unsigned int i;
                size_t total_len = 0, total_pkts = 0;
 
-               for (i = 0; i < ctx->cpus; ++i) {
+               for (i = 0; i < ctx->cpu_num; ++i) {
                        total_len  += stats[i].cf_bytes;
                        total_pkts += stats[i].cf_packets;
                }
@@ -1011,7 +1012,7 @@
        uint64_t gap = 0;
        unsigned int i;
        char *confname = NULL, *ptr;
-       unsigned long cpus_tmp, orig_num = 0;
+       unsigned long cpu_n, orig_num = 0;
        unsigned long long tx_packets, tx_bytes;
        struct ctx ctx;
        int min_opts = 5;
@@ -1022,7 +1023,7 @@
        struct timespec delay;
 
        memset(&ctx, 0, sizeof(ctx));
-       ctx.cpus = get_number_cpus_online();
+       ctx.cpu_num = get_number_cpus_online();
        ctx.uid = getuid();
        ctx.gid = getgid();
        ctx.qdisc_path = false;
@@ -1056,9 +1057,20 @@
                        ctx.verbose = true;
                        break;
                case 'P':
-                       cpus_tmp = strtoul(optarg, NULL, 0);
-                       if (cpus_tmp > 0 && cpus_tmp < ctx.cpus)
-                               ctx.cpus = cpus_tmp;
+                       if (slow)
+                               break;
+                       cpu_n = strtoul(optarg, &ptr, 0);
+                       if (ptr && *ptr == '-') {
+                               if (cpu_n < 0 || cpu_n >= ctx.cpu_num)
+                                       break;
+                               ctx.cpu_start = cpu_n;
+                               cpu_n = strtoul(ptr + 1, NULL, 0);
+                               if (cpu_n < ctx.cpu_start || cpu_n >= 
ctx.cpu_num)
+                                       ctx.cpu_num -= ctx.cpu_start;
+                               else
+                                       ctx.cpu_num = cpu_n - ctx.cpu_start + 1;
+                       } else if (cpu_n > 0 && cpu_n <= ctx.cpu_num)
+                               ctx.cpu_num = cpu_n;
                        break;
                case 'd':
                case 'o':
@@ -1081,7 +1093,8 @@
                        break;
                case 's':
                        slow = true;
-                       ctx.cpus = 1;
+                       ctx.cpu_start = 0;
+                       ctx.cpu_num = 1;
                        ctx.smoke_test = true;
                        ctx.rhost = xstrdup(optarg);
                        break;
@@ -1097,8 +1110,10 @@
                        if (c == 'i' && strstr(confname, ".pcap")) {
                                ctx.sh.type = SHAPER_TSTAMP;
                                ctx.pcap_in = confname;
-                       } else if (!strncmp("-", confname, strlen("-")))
-                               ctx.cpus = 1;
+                       } else if (!strncmp("-", confname, strlen("-"))) {
+                               ctx.cpu_start = 0;
+                               ctx.cpu_num = 1;
+                       }
                        break;
                case 'u':
                        ctx.uid = strtoul(optarg, NULL, 0);
@@ -1108,10 +1123,6 @@
                        ctx.gid = strtoul(optarg, NULL, 0);
                        ctx.enforce = true;
                        break;
-               case 'k':
-                       printf("Option -k/--kernel-pull is no longer used and "
-                              "will be removed in a future release!\n");
-                       break;
                case 'E':
                        seed = strtoul(optarg, NULL, 0);
                        reseed = false;
@@ -1153,6 +1164,12 @@
 
                        if (strncmp(ptr, "pps", strlen("pps")) == 0) {
                                shape_type = SHAPER_PKTS;
+                       } else if (strncmp(ptr, "kpps", strlen("kpps")) == 0) {
+                               shape_type = SHAPER_PKTS;
+                               rate *= 1000;
+                       } else if (strncmp(ptr, "Mpps", strlen("Mpps")) == 0) {
+                               shape_type = SHAPER_PKTS;
+                               rate *= 1000 * 1000;
                        } else if (strncmp(ptr, "B", strlen("B")) == 0) {
                                shape_type = SHAPER_BYTES;
                        } else if (strncmp(ptr, "kB", strlen("kB")) == 0) {
@@ -1285,7 +1302,8 @@
                /* Fall back to single core to not mess up correct timing.
                 * We are slow anyway!
                 */
-               ctx.cpus = 1;
+               ctx.cpu_start = 0;
+               ctx.cpu_num = 1;
                slow = true;
        }
 
@@ -1295,16 +1313,21 @@
         * packets than intended or none at all.
         */
        if (ctx.num)
-               ctx.cpus = min_t(unsigned int, ctx.num, ctx.cpus);
+               ctx.cpu_num = min_t(unsigned int, ctx.num, ctx.cpu_num);
 
        if (set_irq_aff && dev_io_is_netdev(ctx.dev_out)) {
                irq = device_irq_number(ctx.device);
-               device_set_irq_affinity_list(irq, 0, ctx.cpus - 1);
+               device_set_irq_affinity_list(irq, ctx.cpu_start,
+                                            ctx.cpu_start + ctx.cpu_num - 1);
        }
 
-       stats = setup_shared_var(ctx.cpus);
+       stats = setup_shared_var(ctx.cpu_num);
+
 
-       for (i = 0; i < ctx.cpus; i++) {
+       if (ctx.verbose)
+               printf("Start %u worker processes on cpus [%u-%u].\n",
+                      ctx.cpu_num, ctx.cpu_start, ctx.cpu_start + ctx.cpu_num 
- 1);
+       for (i = 0; i < ctx.cpu_num; i++) {
                pid_t pid = fork();
 
                switch (pid) {
@@ -1313,7 +1336,7 @@
                                seed = generate_srand_seed();
                        srand(seed);
 
-                       cpu_affinity(i);
+                       cpu_affinity(ctx.cpu_start + i);
                        main_loop(&ctx, confname, slow, i, invoke_cpp,
                                  cpp_argv, orig_num);
 
@@ -1323,7 +1346,7 @@
                }
        }
 
-       for (i = 0; i < ctx.cpus; i++) {
+       for (i = 0; i < ctx.cpu_num; i++) {
                int status;
 
                wait(&status);
@@ -1334,7 +1357,7 @@
        if (set_sock_mem)
                reset_system_socket_memory(vals, array_size(vals));
 
-       for (i = 0, tx_packets = tx_bytes = 0; i < ctx.cpus; i++) {
+       for (i = 0, tx_packets = tx_bytes = 0; i < ctx.cpu_num; i++) {
                while ((__get_state(i) & CPU_STATS_STATE_RES) == 0)
                        sched_yield();
 
@@ -1346,7 +1369,7 @@
        printf("\n");
        printf("\r%12llu packets outgoing\n", tx_packets);
        printf("\r%12llu bytes outgoing\n", tx_bytes);
-       for (i = 0; cpustats && i < ctx.cpus; i++) {
+       for (i = 0; cpustats && i < ctx.cpu_num; i++) {
                printf("\r%12lu sec, %lu usec on CPU%d (%llu packets)\n",
                       stats[i].tv_sec, stats[i].tv_usec, i,
                       stats[i].tx_packets);
@@ -1354,7 +1377,7 @@
 
 thread_out:
        xunlockme();
-       destroy_shared_var(stats, ctx.cpus);
+       destroy_shared_var(stats, ctx.cpu_num);
        if (dev_io_is_netdev(ctx.dev_out) && set_irq_aff)
                device_restore_irq_affinity_list();
 

Reply via email to