Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Weibin Sun committed Dec 21, 2012
1 parent 1617c7f commit 653f2ba
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 33 deletions.
4 changes: 2 additions & 2 deletions elements/local/fromnmdevice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <click/userutils.hh>
#include <unistd.h>
#include <fcntl.h>
#include <click/master.hh>

# include <sys/socket.h>
# include <net/if.h>
Expand All @@ -35,7 +36,7 @@ CLICK_DECLS
FromNMDevice::FromNMDevice()
:
_task(this),
_datalink(-1), _count(0), _promisc(0), _snaplen(0)
_count(0), _promisc(0), _snaplen(0)
{
_fd = -1;
_ringid = -1;
Expand Down Expand Up @@ -107,7 +108,6 @@ FromNMDevice::initialize(ErrorHandler *errh)
else
_fd = _netmap.open(_ifname, true, errh);
if (_fd >= 0) {
_datalink = FAKE_DLT_EN10MB;
_netmap.initialize_rings_rx(0);//_timestamp);
}

Expand Down
18 changes: 7 additions & 11 deletions elements/local/fromnmdevice.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef CLICK_FROMDEVICE_USERLEVEL_HH
#define CLICK_FROMDEVICE_USERLEVEL_HH
#ifndef CLICK_FROMNMDEVICE_HH
#define CLICK_FROMNMDEVICE_HH
#include <click/element.hh>
#include "elements/userlevel/kernelfilter.hh"
#include "elements/userlevel/netmapinfo.hh"
Expand All @@ -13,16 +13,12 @@ class FromNMDevice : public Element { public:
FromNMDevice();
~FromNMDevice();

const char *class_name() const
{ return "FromNMDevice"; }
const char *port_count() const
{ return "0/1-2"; }
const char *processing() const
{ return PUSH; }
const char *class_name() const { return "FromNMDevice"; }
const char *port_count() const { return "0/1-2"; }
const char *processing() const { return PUSH; }

enum { default_snaplen = 2046 };
int configure_phase() const
{ return KernelFilter::CONFIGURE_PHASE_FROMDEVICE; }
int configure_phase() const { return KernelFilter::CONFIGURE_PHASE_FROMDEVICE; }
int configure(Vector<String> &, ErrorHandler *);
int initialize(ErrorHandler *);
void cleanup(CleanupStage);
Expand All @@ -36,7 +32,7 @@ class FromNMDevice : public Element { public:
void selected(int fd, int mask);

const NetmapInfo::ring *netmap() const
{ return _netmap; }
{ return &_netmap; }
inline int dev_ringid() { return _ringid; }

bool run_task(Task *task);
Expand Down
3 changes: 2 additions & 1 deletion elements/local/tonmdevice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <click/straccum.hh>
#include <stdio.h>
#include <unistd.h>
#include <click/master.hh>

# include <sys/socket.h>
# include <sys/ioctl.h>
Expand Down Expand Up @@ -55,7 +56,7 @@ ToNMDevice::configure(Vector<String> &conf, ErrorHandler *errh)
if (_burst <= 0)
return errh->error("bad BURST");

NetmapInfo::set_dev_dirs(_ifname.c_str(), NetmapInfo::dev_tx);
NetmapInfo::set_dev_dir(_ifname.c_str(), NetmapInfo::dev_tx);
return 0;
}

Expand Down
19 changes: 7 additions & 12 deletions elements/local/tonmdevice.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef CLICK_TODEVICE_USERLEVEL_HH
#define CLICK_TODEVICE_USERLEVEL_HH
#ifndef CLICK_TONMDEVICE_HH
#define CLICK_TONMDEVICE_HH
#include <click/element.hh>
#include <click/string.hh>
#include <click/task.hh>
Expand All @@ -14,17 +14,12 @@ class ToNMDevice : public Element { public:
ToNMDevice();
~ToNMDevice();

const char *class_name() const
{ return "ToNMDevice"; }
const char *port_count() const
{ return "1/0-2"; }
const char *processing() const
{ return "l/h"; }
const char *flags() const
{ return "S2"; }
const char *class_name() const { return "ToNMDevice"; }
const char *port_count() const { return "1/0-2"; }
const char *processing() const { return "l/h"; }
const char *flags() const { return "S2"; }

int configure_phase() const
{ return KernelFilter::CONFIGURE_PHASE_TODEVICE; }
int configure_phase() const { return KernelFilter::CONFIGURE_PHASE_TODEVICE; }
int configure(Vector<String> &, ErrorHandler *);
int initialize(ErrorHandler *);
void cleanup(CleanupStage);
Expand Down
5 changes: 3 additions & 2 deletions elements/userlevel/fromdevice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

#if FROMDEVICE_ALLOW_NETMAP
# include <sys/mman.h>
#include <click/master.hh>
#endif

CLICK_DECLS
Expand Down Expand Up @@ -165,9 +166,9 @@ FromDevice::configure(Vector<String> &conf, ErrorHandler *errh)
return errh->error("bad METHOD");

#if FROMDEVICE_ALLOW_NETMAP
if (_method == method_deafult || _method = method_netmap) {
if (_method == method_default || _method == method_netmap) {
NetmapInfo::register_buf_consumer();
NetmapInfo::set_dev_dirs(_ifname.c_str(), NetmapInfo::dev_rx);
NetmapInfo::set_dev_dir(_ifname.c_str(), NetmapInfo::dev_rx);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion elements/userlevel/netmapinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ NetmapInfo::initialize(int nthreads, ErrorHandler *errh)
if (!initialized) {
nr_threads = nthreads;

if (nr_threads == 1 || nr_buf_consumers = 1)
if (nr_threads == 1 || nr_buf_consumers == 1)
need_consumer_locking = false;
else
need_consumer_locking = true;
Expand Down
1 change: 1 addition & 0 deletions elements/userlevel/netmapinfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <click/packet.hh>
#include <click/error.hh>
#include <click/sync.hh>
#include <g4c.h>
#include <click/ring.hh>
#include <click/glue.hh>
#include <map>
Expand Down
5 changes: 3 additions & 2 deletions elements/userlevel/todevice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#endif
#if TODEVICE_ALLOW_NETMAP
# include <sys/mman.h>
# include <click/master.hh>
#endif

CLICK_DECLS
Expand Down Expand Up @@ -134,8 +135,8 @@ ToDevice::configure(Vector<String> &conf, ErrorHandler *errh)
return errh->error("bad METHOD");

#if FROMDEVICE_ALLOW_NETMAP
if (_method == method_deafult || _method = method_netmap) {
NetmapInfo::set_dev_dirs(_ifname.c_str(), NetmapInfo::dev_tx);
if (_method == method_default || _method == method_netmap) {
NetmapInfo::set_dev_dir(_ifname.c_str(), NetmapInfo::dev_tx);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion g4cnm
2 changes: 1 addition & 1 deletion hvpconfigure
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

./configure --prefix=$1 --enable-user-multithread --disable-linuxmodule --enable-local \
--enable-ipsec --enable-etherswitch --with-netmap --enable-nanotimestamp --enable-select=poll
--enable-ipsec --enable-etherswitch --with-netmap --enable-multithread --enable-select=poll

0 comments on commit 653f2ba

Please sign in to comment.