...
 
Commits (2)
......@@ -8,6 +8,12 @@
/* Define if accept() uses socklen_t. */
#undef HAVE_ACCEPT_SOCKLEN_T
/* Define if aligned_alloc is implemented */
#undef HAVE_ALIGNED_ALLOC
/* Define if the compiler supports aligned new (C++ 17) */
#undef HAVE_ALIGNED_NEW
/* Define if kqueue() may be used to wait for file descriptor events. */
#undef HAVE_ALLOW_KQUEUE
......
......@@ -1956,6 +1956,48 @@ fi
} # ac_fn_cxx_try_cpp
# ac_fn_cxx_try_run LINENO
# ------------------------
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
# that executables *can* be run.
ac_fn_cxx_try_run ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then :
ac_retval=0
else
$as_echo "$as_me: program exited with status $ac_status" >&5
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=$ac_status
fi
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_cxx_try_run
# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES
# ---------------------------------------------------------
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
......@@ -2202,48 +2244,6 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_func
# ac_fn_cxx_try_run LINENO
# ------------------------
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
# that executables *can* be run.
ac_fn_cxx_try_run ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then :
ac_retval=0
else
$as_echo "$as_me: program exited with status $ac_status" >&5
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=$ac_status
fi
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_cxx_try_run
# ac_fn_cxx_compute_int LINENO EXPR VAR INCLUDES
# ----------------------------------------------
# Tries to find the compile-time value of EXPR in a program that includes
......@@ -5824,6 +5824,32 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
if test "$cross_compiling" = yes; then :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run test program while cross compiling
See \`config.log' for more details" "$LINENO" 5; }
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <new>
int main() {
std::size_t sz = 8;
std::align_val_t al{64};
void* a = operator new(sz,al);
return (a == nullptr?1:0);
}
_ACEOF
if ac_fn_cxx_try_run "$LINENO"; then :
$as_echo "#define HAVE_ALIGNED_NEW 1" >>confdefs.h
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
test -z "$ac_user_kernel_cc" && \
......@@ -7679,7 +7705,7 @@ esac
fi
for ac_func in random snprintf strnlen strtof strtold strtoul tcgetpgrp vsnprintf
for ac_func in random snprintf strnlen strtof strtold strtoul tcgetpgrp vsnprintf aligned_alloc
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
......
......@@ -52,6 +52,15 @@ AC_C_INLINE
CLICK_PROG_CXX
AC_PROG_CXXCPP
AC_TRY_RUN([#include <new>
int main() {
std::size_t sz = 8;
std::align_val_t al{64};
void* a = operator new(sz,al);
return (a == nullptr?1:0);
}],AC_DEFINE([HAVE_ALIGNED_NEW]))
CLICK_PROG_KERNEL_CC
CLICK_PROG_KERNEL_CXX
......@@ -706,7 +715,7 @@ dnl
AC_LANG_C
AC_REPLACE_FUNCS(strerror)
AC_CHECK_FUNCS(random snprintf strnlen strtof strtold strtoul tcgetpgrp vsnprintf)
AC_CHECK_FUNCS(random snprintf strnlen strtof strtold strtoul tcgetpgrp vsnprintf aligned_alloc)
AC_LANG_CPLUSPLUS
......
......@@ -67,7 +67,7 @@ AverageBatchCounter::run_timer(Timer* t)
total.count_packets += last_tick.count_packets;
last_tick.count_batches = 0;
last_tick.count_packets = 0;
for (int i = 0; i < _stats.weight(); i++) {
for (unsigned i = 0; i < _stats.weight(); i++) {
last_tick.count_batches += _stats.get_value(i).count_batches;
last_tick.count_packets += _stats.get_value(i).count_packets;
_stats.get_value(i).count_batches = 0;
......
......@@ -47,7 +47,6 @@ int CheckNumberPacket::configure(Vector<String> &conf, ErrorHandler *errh) {
}
inline int CheckNumberPacket::smaction(Packet *p) {
WritablePacket *wp = nullptr;
if ((int)p->length() < _offset + 8) {
return 1;
}
......
......@@ -75,7 +75,7 @@ FromIPSummaryDump::configure(Vector<String> &conf, ErrorHandler *errh)
uint8_t default_proto = IP_PROTO_TCP;
_sampling_prob = (1 << SAMPLING_SHIFT);
String default_contents, default_flowid, data;
int burst = 1;
unsigned burst = 1;
if (Args(conf, this, errh)
.read_p("FILENAME", FilenameArg(), _ff.filename())
......@@ -755,12 +755,14 @@ FromIPSummaryDump::pull(int)
}
#if HAVE_BATCH
PacketBatch *
FromIPSummaryDump::pull_batch(int,int max)
FromIPSummaryDump::pull_batch(int,unsigned max)
{
if (!_active)
return 0;
PacketBatch* batch;
PacketBatch* batch = 0;
MAKE_BATCH(get_packet(), batch, max);
if (!batch)
return 0;
if (batch->count() == max) {
_notifier.wake();
}
......
......@@ -172,9 +172,9 @@ class FromIPSummaryDump : public BatchElement, public IPSummaryDumpInfo { public
bool run_task(Task *);
inline Packet *get_packet(bool push=false);
Packet *pull(int);
Packet *pull(int) override;
#if HAVE_BATCH
PacketBatch *pull_batch(int,int);
PacketBatch *pull_batch(int,unsigned) override;
#endif
void run_timer(Timer *timer);
......@@ -216,7 +216,7 @@ class FromIPSummaryDump : public BatchElement, public IPSummaryDumpInfo { public
int _minor_version;
IPFlowID _given_flowid;
int _burst;
unsigned _burst;
int read_binary(String &, ErrorHandler *);
......
......@@ -64,10 +64,10 @@ RecordTimestamp::smaction(Packet *p) {
uint64_t i;
if (_offset >= 0) {
i = _np ? _np->read_number_of_packet(p, _offset, _net_order) :
NumberPacket::read_number_of_packet(p, _offset, _net_order);
NumberPacket::read_number_of_packet(p, _offset, _net_order);
assert(i < ULLONG_MAX);
while (i >= _timestamps.size()) {
if (!_dynamic && i >= _timestamps.capacity()) {
while (i >= (unsigned)_timestamps.size()) {
if (!_dynamic && i >= (unsigned)_timestamps.capacity()) {
click_chatter("fatal error : DYNAMIC is not set and record timestamp reserved capacity is too small. Use N to augment the capacity.");
assert(false);
}
......
......@@ -83,7 +83,7 @@ private:
};
inline Timestamp RecordTimestamp::get(uint64_t i) {
if (i >= _timestamps.size())
if (i >= (unsigned)_timestamps.size())
return Timestamp::uninitialized_t();
Timestamp t = _timestamps[i];
if (t == Timestamp::uninitialized_t())
......
......@@ -23,8 +23,7 @@
#include <click/standard/scheduleinfo.hh>
CLICK_DECLS
ReplayBase::ReplayBase() : _active(true), _loaded(false), _burst(64), _stop(-1), _quick_clone(false), _task(this), _queue_head(0), _queue_current(0), _use_signal(false),_verbose(false),_freeonterminate(true), _limit(-1)
{
ReplayBase::ReplayBase() : _active(true), _loaded(false), _burst(64), _stop(-1), _quick_clone(false), _task(this), _limit(-1), _queue_head(0), _queue_current(0), _use_signal(false),_verbose(false),_freeonterminate(true) {
#if HAVE_BATCH
in_batch_mode = BATCH_MODE_YES;
#endif
......
......@@ -35,8 +35,6 @@ GTPDecap::~GTPDecap()
int
GTPDecap::configure(Vector<String> &conf, ErrorHandler *errh)
{
uint32_t eid;
if (Args(conf, this, errh)
.complete() < 0)
return -1;
......
......@@ -81,6 +81,7 @@ GTPEncap::simple_action_batch(PacketBatch* batch) {
String GTPEncap::read_handler(Element *e, void *thunk)
{
GTPEncap *u = static_cast<GTPEncap *>(e);
(void)u; //TODO
switch ((uintptr_t) thunk) {
default:
return String();
......
/*
* gtpfilter.{cc,hh} -- GTP Filtering element
* Tom Barbette
*
* Copyright (c) 2018 University of Liege
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, subject to the conditions
* listed in the Click LICENSE file. These conditions include: you must
* preserve this copyright notice, and you cannot mention the copyright
* holders in advertising related to the Software without their permission.
* The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
* notice is a summary of the Click LICENSE file; the license in that file is
* legally binding.
*/
#include <click/config.h>
#include <clicknet/ip.h>
#include <clicknet/udp.h>
#include <click/args.hh>
#include <click/error.hh>
#include <click/glue.hh>
#include "gtpfilter.hh"
CLICK_DECLS
GTPFilter::GTPFilter()
{
}
GTPFilter::~GTPFilter()
{
}
int
GTPFilter::configure(Vector<String> &conf, ErrorHandler *errh)
{
if (Args(conf, this, errh)
.complete() < 0)
return -1;
return 0;
}
Packet *
GTPFilter::simple_action(Packet *p_in)
{
Packet* p = p_in;
const click_ip *ip = reinterpret_cast<const click_ip *>(p->data());
const click_udp *udp = reinterpret_cast<const click_udp *>(p->data() + sizeof(click_ip));
const click_gtp *gtp = reinterpret_cast<const click_gtp *>(p->data() + sizeof(click_ip) + sizeof(click_udp));
//GTPTuple gtp_id(IP6Address(ip->ip_src), IPAddress(ip->ip_dst), ntohs(udp->uh_sport), ntohl(gtp->gtp_teid));
return p;
}
#if HAVE_BATCH
PacketBatch*
GTPFilter::simple_action_batch(PacketBatch* batch) {
EXECUTE_FOR_EACH_PACKET(GTPFilter::simple_action,batch);
return batch;
}
#endif
String GTPFilter::read_handler(Element *e, void *thunk)
{
GTPFilter *u = static_cast<GTPFilter *>(e);
switch ((uintptr_t) thunk) {
default:
return String();
}
}
void GTPFilter::add_handlers()
{
}
CLICK_ENDDECLS
EXPORT_ELEMENT(GTPFilter)
ELEMENT_MT_SAFE(GTPFilter)
#ifndef CLICK_GTPFilter_HH
#define CLICK_GTPFilter_HH
#include <click/batchelement.hh>
#include <click/glue.hh>
#include <clicknet/gtp.h>
CLICK_DECLS
/*
=c
GTPFilter(TEID eid)
=s gtp
=d
*/
class GTPFilter : public BatchElement { public:
GTPFilter() CLICK_COLD;
~GTPFilter() CLICK_COLD;
const char *class_name() const { return "GTPFilter"; }
const char *port_count() const { return PORTS_1_1; }
const char *flags() const { return "A"; }
int configure(Vector<String> &, ErrorHandler *) CLICK_COLD;
bool can_live_reconfigure() const { return true; }
void add_handlers() CLICK_COLD;
Packet *simple_action(Packet *);
#if HAVE_BATCH
PacketBatch* simple_action_batch(PacketBatch *);
#endif
private:
static String read_handler(Element *, void *) CLICK_COLD;
};
CLICK_ENDDECLS
#endif
......@@ -38,8 +38,6 @@ GTPTable::~GTPTable()
int
GTPTable::configure(Vector<String> &conf, ErrorHandler *errh)
{
uint32_t eid;
if (Args(conf, this, errh)
.read_mp("PING_DST",_ping_dst)
.complete() < 0)
......@@ -76,9 +74,8 @@ GTPTable::process(int port, Packet* p) {
uint32_t gen = click_random();
uint16_t icmp_id = gen + 3;
uint16_t icmp_seq = gen >> 16 + 3;
uint16_t icmp_seq = (gen >> 16) + 3;
//size_t hsz = sizeof(click_ip) + sizeof(click_icmp_echo);
size_t data_size = 60;
WritablePacket* q = Packet::make(sz + data_size);
if (q) {
......@@ -152,6 +149,8 @@ GTPTable::process(int port, Packet* p) {
}
(void)known; //TODO
//Pull packet to inner header
p->pull(sz);
......
......@@ -397,6 +397,8 @@ String QueueDevice::count_handler(Element *e, void *user_data)
switch (what) {
case h_count:
return String(tdd->n_count());
default:
return "<undefined>";
}
}
......
......@@ -199,7 +199,7 @@ private:
template <typename T, bool ZERO, int POOL_SIZE, int POOL_COUNT>
pool_allocator_mt<T,ZERO,POOL_SIZE,POOL_COUNT>::pool_allocator_mt() :_global_count(0),_global_pool(0),_pool(Pool()) {
pool_allocator_mt<T,ZERO,POOL_SIZE,POOL_COUNT>::pool_allocator_mt() : _pool(Pool()), _global_count(0),_global_pool(0) {
#if CLICK_DEBUG_ALLOCATOR
_released = 0;
_allocated = 0;
......@@ -222,7 +222,7 @@ pool_allocator_mt<T,ZERO,POOL_SIZE,POOL_COUNT>::~pool_allocator_mt() {
n_release++;
}
}
for (int i = 0 ; i < _pool.weight(); i++) {
for (unsigned i = 0 ; i < _pool.weight(); i++) {
Pool &pool = _pool.get_value(i);
item* p = pool.first;
item* next;
......
......@@ -134,6 +134,21 @@ void click_lfree(volatile void *p, size_t size);
# define CLICK_LFREE(p, size) delete[] ((void) (size), (uint8_t *)(p))
#endif
#if HAVE_ALIGNED_NEW
# define CLICK_ALIGNED_NEW(T,size) (new T[_size])
# define CLICK_ALIGNED_DELETE(p,T,size) (delete[] p)
#else
# if HAVE_ALIGNED_ALLOC
# define CLICK_ALIGNED_ALLOC(T,size) ((T*)(aligned_alloc(64, sizeof(T) * size)))
# define CLICK_ALIGNED_FREE(p,T,size) (free(p))
# else
# warning Using normal allocation instead of aligned one, please use a compiler that supports aligned_alloc
# define CLICK_ALIGNED_ALLOC(T,size) CLICK_LALLOC(sizeof(T) * size)
# define CLICK_ALIGNED_FREE(p,T,size) CLICK_LFREE(p,sizeof(T) * size);
# endif
# define CLICK_ALIGNED_NEW(T,size) ({T* v = CLICK_ALIGNED_ALLOC(T,size);for (unsigned i = 0; i < size; i++) {new(&v[i]) T();};v;})
# define CLICK_ALIGNED_DELETE(p,T,size) {for (unsigned i = 0; i < size; i++) p[i].~T();CLICK_ALIGNED_FREE(p,T,size);}
#endif
// RANDOMNESS
......
......@@ -361,7 +361,7 @@ class HashContainerMP { public:
void release_pending(bool force=false) {
ListItem* it;
ListItem* next;
for (int i = 0; i < _pending_release.weight() ; i++) {
for (unsigned i = 0; i < _pending_release.weight() ; i++) {
it = _pending_release.get_value(i);
while (it) {
next = it->_hashnext;
......@@ -396,14 +396,14 @@ void HashContainerMP<K,V,Item>::deinitialize()
template <typename K, typename V, typename Item>
HashContainerMP<K,V,Item>::HashContainerMP() :
_table(), _pending_release(0), _mt(true)
_mt(true), _table(), _pending_release(0)
{
initialize(initial_bucket_count);
}
template <typename K, typename V, typename Item>
HashContainerMP<K,V,Item>::HashContainerMP(size_type nb) :
_table(), _pending_release(0)
_mt(true), _table(), _pending_release(0)
{
size_type b = 1;
while (b < nb && b < max_bucket_count)
......@@ -517,7 +517,6 @@ retry:\
goto retry;\
}\
ListItem* e = allocate(ListItem(key,value));\
V* v = e->item.unprotected_ptr();\
click_hashmp_assert(e->item.refcnt() == 0);\
e->_hashnext = bucket.list->head;\
\
......
......@@ -1080,10 +1080,10 @@ protected:
template <typename T>
class fast_rcu { public:
#define N 2
fast_rcu() : _rcu_current(0), _write_epoch(1), _epochs(0) {
fast_rcu() : _rcu_current(0), _epochs(0), _write_epoch(1) {
}
fast_rcu(T v) : _rcu_current(0), _write_epoch(1), _epochs(0) {
fast_rcu(T v) : _rcu_current(0), _epochs(0), _write_epoch(1){
initialize(v);
}
......@@ -1123,7 +1123,7 @@ class fast_rcu { public:
int rcu_next = (rcu_current_local + 1) & 1;
int bad_epoch = (_write_epoch - N) + 1;
int i = 0;
unsigned i = 0;
loop:
for (; i < _epochs.weight(); i ++) {
int te = _epochs.get_value(i);
......
......@@ -230,7 +230,7 @@ CLICK_DECLS
Packet* last = head;\
if (head != NULL) {\
unsigned int count = 1;\
while (count < (max>0?max:BATCH_MAX_PULL)) {\
while (count < (unsigned)(max>0?max:BATCH_MAX_PULL)) {\
Packet* current = fnt;\
if (current == NULL)\
break;\
......
......@@ -62,7 +62,7 @@ private:
void initialize(unsigned int n, T v) {
_size = n;
storage = new AT[_size];
storage = CLICK_ALIGNED_NEW(AT,_size);
for (unsigned i = 0; i < n; i++) {
storage[i].v = v;
}
......@@ -73,7 +73,7 @@ private:
public:
explicit per_thread() {
_size = click_max_cpu_ids();
storage = new AT[_size];
storage = CLICK_ALIGNED_NEW(AT,_size);
}
explicit per_thread(T v) {
......@@ -90,13 +90,13 @@ public:
* This will destroy all data
*/
void resize(unsigned int max_cpu_id, T v) {
delete[] storage;
CLICK_ALIGNED_DELETE(storage, AT, _size);
initialize(max_cpu_id,v);
}
~per_thread() {
if (_size) {
delete[] storage;
CLICK_ALIGNED_DELETE(storage,AT,_size);
_size = 0;
}
}
......@@ -137,8 +137,8 @@ public:
inline void operator=(const per_thread<T>& pt) {
if (_size != pt._size) {
if (storage)
delete[] storage;
storage = new AT[_size];
CLICK_ALIGNED_DELETE(storage,AT, _size);
storage = CLICK_ALIGNED_NEW(AT, _size);
}
for (int i = 0; i < pt.weight(); i++) {
storage[i] = pt.storage[i];
......
......@@ -427,10 +427,11 @@ Element::Element()
in_batch_mode(BATCH_MODE_NO),
#endif
receives_batch(false),
_router(0), _eindex(-1)
#if HAVE_FULLPUSH_NONATOMIC
_is_fullpush(false),
,_is_fullpush(false)
#endif
_router(0), _eindex(-1)
{
nelements_allocated++;
_ports[0] = _ports[1] = &_inline_ports[0];
......