Re: [netsniff-ng] [Re: multiple instances of netsniff-ng with AF_PACKET hash fanout] Initial implementation of a multiprocess functionality.

2015-04-21 Thread Daniel Borkmann

Hi Michal,

On 04/14/2015 09:53 AM, Daniel Borkmann wrote:

Thanks Michal, looks almost ready to go in!


Okay, I just fixed everything up and pushed it out under your
authorship:

  
https://github.com/netsniff-ng/netsniff-ng/commit/f00d4d54f28c0374cc57e6ca07dd648d7684c69c

We can still fix things up later on if needed.

Cheers  thanks,
Daniel

--
You received this message because you are subscribed to the Google Groups 
netsniff-ng group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [netsniff-ng] [Re: multiple instances of netsniff-ng with AF_PACKET hash fanout] Initial implementation of a multiprocess functionality.

2015-04-21 Thread Daniel Borkmann

On 04/21/2015 01:13 PM, Michał Purzyński wrote:

Thanks a lot, I was trying to find a time for it over the weekend,
turned out to be difficult so decided to work on it next weekend :-)


No problem. ;) Thanks for looking into this!


I'll focus on some good documentation next, showing how to use it and when, etc.


I think that would be useful. If you think putting this into an extra
file e.g. called SCALING or somewhere appropriate into the netsniff-ng
man-page, I'm totally fine with it.

I think one option would be to make a description on all the tuning knobs
and the new fanout option to provide a small guide for users with such
demand.

Cheers  thanks,
Daniel

--
You received this message because you are subscribed to the Google Groups 
netsniff-ng group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [netsniff-ng] [Re: multiple instances of netsniff-ng with AF_PACKET hash fanout] Initial implementation of a multiprocess functionality.

2015-04-14 Thread Daniel Borkmann

Thanks Michal, looks almost ready to go in!

Other than Tobias' excellent feedback, some minor things from my side:
On 04/14/2015 01:10 AM, Michal Purzynski wrote:

---
  netsniff-ng.c | 28 +---
  ring_rx.c | 17 -
  ring_rx.h |  2 +-
  3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/netsniff-ng.c b/netsniff-ng.c
index dfb99bb..c603919 100644
--- a/netsniff-ng.c
+++ b/netsniff-ng.c
@@ -60,12 +60,13 @@ struct ctx {
bool randomize, promiscuous, enforce, jumbo, dump_bpf, hwtimestamp, 
verbose;
enum pcap_ops_groups pcap; enum dump_mode dump_mode;
uid_t uid; gid_t gid; uint32_t link_type, magic;
+uint32_t cluster_id, cluster_type;


I know you have changed the naming from the command line site,
but please also rename this internally, e.g. fanout_group, fanout_type.


  };

  static volatile sig_atomic_t sigint = 0;
  static volatile bool next_dump = false;

-static const char *short_options = 
d:i:o:rf:MNJt:S:k:n:b:HQmcsqXlvhF:RGAP:Vu:g:T:DBU;
+static const char *short_options = 
d:i:o:rf:MNJt:S:k:n:b:HQmcsqXlvhF:RGAP:Vu:g:T:DBU:C:K:;
  static const struct option long_options[] = {
{dev,   required_argument,  NULL, 'd'},
{in,required_argument,  NULL, 'i'},
@@ -81,6 +82,8 @@ static const struct option long_options[] = {
{user,  required_argument,  NULL, 'u'},
{group, required_argument,  NULL, 'g'},
{magic, required_argument,  NULL, 'T'},
+   {fanout-group,  required_argument,  NULL, 'C'},
+   {fanout-type,required_argument, NULL, 'K'},


Looks like we run out of short option chars, I guess C/K is fine.


{rand,  no_argument,NULL, 'r'},
{rfraw, no_argument,NULL, 'R'},
{mmap,  no_argument,NULL, 'm'},

...

diff --git a/ring_rx.c b/ring_rx.c
index 8ad64d1..c97dd2d 100644
--- a/ring_rx.c
+++ b/ring_rx.c
@@ -209,9 +209,23 @@ static void alloc_rx_ring_frames(int sock, struct ring 
*ring)
  rx_ring_get_size(ring, v3));
  }

+void create_cluster(int sock, uint32_t cluster_id, uint32_t cluster_mode)


create_fanout_instance() or something along that line.


+{
+uint32_t cluster_option = 0;
+int ret = 0;
+
+if (cluster_mode == PACKET_FANOUT_HASH)
+cluster_mode = PACKET_FANOUT_HASH | PACKET_FANOUT_FLAG_DEFRAG;
+else
+cluster_option = (cluster_id | (cluster_mode  16));
+ret = setsockopt(sock, SOL_PACKET, PACKET_FANOUT,(void *)cluster_option, 
sizeof(cluster_option));
+if (ret  0)
+panic(Cannot set fanout ring mode!\n);
+}
+
  void ring_rx_setup(struct ring *ring, int sock, size_t size, int ifindex,
   struct pollfd *poll, bool v3, bool jumbo_support,
-  bool verbose)
+  bool verbose, uint32_t cluster_id, uint32_t cluster_type)
  {
fmemset(ring, 0, sizeof(*ring));
setup_rx_ring_layout(sock, ring, size, jumbo_support, v3);
@@ -220,6 +234,7 @@ void ring_rx_setup(struct ring *ring, int sock, size_t 
size, int ifindex,
alloc_rx_ring_frames(sock, ring);
bind_ring_generic(sock, ring, ifindex, false);
prepare_polling(sock, poll);
+create_cluster(sock, cluster_id, cluster_type);


As Tobias mentioned, this should only be enabled if the user specifies
at least fanout_group over the command line. fanout_type, if not specified,
could be on default hash.


  }

  void sock_rx_net_stats(int sock, unsigned long seen)
diff --git a/ring_rx.h b/ring_rx.h
index edd0feb..ae2cd76 100644
--- a/ring_rx.h
+++ b/ring_rx.h
@@ -13,7 +13,7 @@

  extern void ring_rx_setup(struct ring *ring, int sock, size_t size, int 
ifindex,
  struct pollfd *poll, bool v3, bool jumbo_support,
- bool verbose);
+ bool verbose, uint32_t cluster_id, uint32_t 
cluster_type);
  extern void destroy_rx_ring(int sock, struct ring *ring);
  extern void sock_rx_net_stats(int sock, unsigned long seen);




--
You received this message because you are subscribed to the Google Groups 
netsniff-ng group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.