Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arne Øslebø
mapi
Commits
dfcc868b
Commit
dfcc868b
authored
Feb 21, 2006
by
Arne Øslebø
Browse files
fixed possible race condition
git-svn-id:
file:///home/svn/mapi/trunk@358
8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent
676a646c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Makefile.in
View file @
dfcc868b
...
...
@@ -10,30 +10,30 @@ LIB_DIR=-L/usr/local/lib
DEBUG
=
1
#DAG cards
WITH_DAG
=
0
WITH_DAG
=
1
#COMBO6 cards
WITH_COMBO6
=
0
#Distributed MAPI functionality
WITH_DIMAPI
=
1
WITH_DIMAPI
=
0
#MAPI function statistics
#With this pkt counters for each function is enabled
WITH_FUNCT_STATS
=
1
#Support for flow priorities
WITH_PRIORITIES
=
1
WITH_PRIORITIES
=
0
PRIORITIES
=
3
#Support for functions that modifies packets
WITH_MODIFY_PKTS
=
0
WITH_MODIFY_PKTS
=
1
#Support for anonymization
WITH_ANONYMIZATION
=
0
#Support for application-level filtering (mostly P2P traffic identification)
WITH_TRACKING
=
1
WITH_TRACKING
=
0
#Ipfix flow record generation
WITH_IPFIX
=
0
...
...
@@ -52,7 +52,7 @@ WITH_ETHEREAL=0
WITH_OPTIMIZED_BPF_FILTER
=
0
# ADMISSION CONTROL
WITH_ADMISSION_CONTROL
=
1
WITH_ADMISSION_CONTROL
=
0
WITH_RESOURCE_CONTROL
=
0
ifeq
($(WITH_DAG),1)
...
...
mapidagdrv.c
View file @
dfcc868b
...
...
@@ -41,6 +41,7 @@ typedef struct dag_instance {
mapi_offline_device_status_t
*
offline_status
;
mapid_hw_info_t
hwinfo
;
mapidlib_instance_t
mapidlib
;
int
active
;
//Workaround for possible race condition when deleting a driver
}
dag_instance_t
;
flist_t
*
devlist
;
...
...
@@ -72,6 +73,7 @@ int mapidrv_add_device(mapi_offline_device_status_t *olstatus,char *devname, int
i
->
hwinfo
.
offline
=
0
;
i
->
hwinfo
.
gflist
=
gflist
;
i
->
offline_status
=
olstatus
;
i
->
active
=
1
;
if
(
devid
<
0
)
i
->
hwinfo
.
offline
=
1
;
...
...
@@ -88,6 +90,7 @@ int mapidrv_delete_device(int devid)
if
(
i
!=
NULL
)
{
int
err
=
0
;
i
->
active
=
0
;
if
(
i
->
th_proc
&&
pthread_equal
(
i
->
th_proc
,
pthread_self
())
==
0
)
{
DEBUG_CMD
(
printf
(
"Calling thread != th_proc (%lu != %lu), canceling [%s:%d]
\n
"
,
i
->
th_proc
,
pthread_self
(),
__FILE__
,
__LINE__
));
...
...
@@ -100,7 +103,7 @@ int mapidrv_delete_device(int devid)
}
}
/* if ((err=pthread_join(i->th_proc,NULL))!=0) {
/*
if ((err=pthread_join(i->th_proc,NULL))!=0) {
if (!(i->hwinfo.offline==1 && err==ESRCH)) {
WARNING_CMD(printf("Could not join thread for devid %d (%s) [%s:%d]\n",devid,strerror(err),__FILE__,__LINE__));
fflush(stdout);
...
...
@@ -120,7 +123,7 @@ int mapidrv_delete_device(int devid)
DEBUG_CMD
(
printf
(
"Closed file [%s:%d]
\n
"
,
__FILE__
,
__LINE__
));
}
}
mapid_destroy
(
&
i
->
mapidlib
);
free
(
i
->
name
);
if
(
i
->
offline_status
!=
NULL
)
...
...
@@ -143,8 +146,11 @@ process_pkts(void *buf,unsigned len, dag_instance_t *i)
rec
=
(
dag_record_t
*
)
buf
;
rlen
=
ntohs
(
rec
->
rlen
);
if
(
!
i
->
active
)
return
len
;
mapid_lock
(
&
i
->
mapidlib
);
while
(
c
+
rlen
<
len
)
while
(
c
+
rlen
<
len
&&
i
->
active
)
{
char
*
p
=
buf
;
buf
=
p
+
rlen
;
...
...
mapidlib.c
View file @
dfcc868b
...
...
@@ -142,7 +142,7 @@ mapid_init(mapidlib_instance_t *i)
};
void
mapid_lock
(
mapidlib_instance_t
*
i
)
{
// printf("Lock..\n");
//
printf("Lock..\n");
pthread_spin_lock
(
i
->
shm_spinlock
);
//printf("Locked\n");
}
...
...
@@ -260,7 +260,8 @@ static void delete_flow(mapidlib_instance_t *i,struct mapidlibflow *flow) {
}
#ifdef WITH_MODIFY_PKTS
free
(
flow
->
mod_pkt
);
if
(
flow
->
mod_pkt
!=
NULL
)
free
(
flow
->
mod_pkt
);
#endif
lock
=&
flow
->
hwinfo
->
gflist
->
lock
;
...
...
@@ -456,6 +457,7 @@ mapid_add_flow(mapidlib_instance_t *i,
fl
->
shm_fname
[
0
]
=
'\0'
;
fl
->
adapterinfo
=
info
;
fl
->
funct_info_list
=
NULL
;
fl
->
mod_pkt
=
NULL
;
//Add new flow to the global function list
fl
->
functionlist
=
malloc
(
sizeof
(
flist_t
));
...
...
tests/runtests
View file @
dfcc868b
...
...
@@ -15,19 +15,19 @@ if [ $# -lt 1 ]; then
fi
#echo -n "testing bpf_filter: "
#./test_bpf_filter $1
> /dev/null
#./test_bpf_filter $1
#test $?
echo
-n
"testing byte_counter : "
./test_byte_counter
$1
>
/dev/null
./test_byte_counter
$1
test
$?
echo
-n
"testing close_flow : "
./test_close_flow
$1
>
/dev/null
./test_close_flow
$1
test
$?
echo
-n
"testing create_flow : "
./test_create_flow
$1
>
/dev/null
./test_create_flow
$1
test
$?
#echo
...
...
@@ -52,75 +52,75 @@ test $?
#echo
echo
-n
"testing mapi_apply_function : "
./test_mapi_apply_function
$1
>
/dev/null
./test_mapi_apply_function
$1
test
$?
echo
-n
"testing mapi_connect : "
./test_mapi_connect
$1
>
/dev/null
./test_mapi_connect
$1
test
$?
echo
-n
"testing mapi_read_results : "
./test_mapi_read_results
$1
>
/dev/null
./test_mapi_read_results
$1
test
$?
echo
-n
"testing offline_bpf_filter : "
./test_off_bpf_filter tracefile
>
/dev/null
./test_off_bpf_filter tracefile
test
$?
echo
-n
"testing offline_pkt_counter : "
./test_off_pkt_counter tracefile
>
/dev/null
./test_off_pkt_counter tracefile
test
$?
echo
-n
"testing offline_str_search : "
./test_off_str_search www.trace
>
/dev/null
./test_off_str_search www.trace
test
$?
echo
-n
"testing offline_to_buffer : "
./test_off_to_buffer tracefile tracefile
>
/dev/null
./test_off_to_buffer tracefile tracefile
test
$?
echo
-n
"testing offline_res2file : "
./test_off_res2file tracefile
>
/dev/null
./test_off_res2file tracefile
test
$?
echo
-n
"testing offline_stats : "
./test_off_stats tracefile
>
/dev/null
./test_off_stats tracefile
test
$?
echo
-n
"testing pkt_counter : "
./test_pkt_counter
$1
>
/dev/null
./test_pkt_counter
$1
test
$?
echo
-n
"testing sample_pkts : "
./test_sample_pkts
$1
>
/dev/null
./test_sample_pkts
$1
test
$?
echo
-n
"testing str_search : "
./test_str_search
$1
>
/dev/null
./test_str_search
$1
test
$?
echo
-n
"testing tcp_offline_flow : "
./test_tcp_offline_flow tracefile
>
/dev/null
./test_tcp_offline_flow tracefile
test
$?
echo
-n
"testing to_buffer : "
./test_to_buffer
$1
>
/dev/null
./test_to_buffer
$1
test
$?
echo
-n
"testing mapi_loop : "
./test_loop
>
/dev/null
./test_loop
test
$?
echo
-n
"testing error cases : "
./test_for_error_cases
$1
tracefile
>
/dev/null
./test_for_error_cases
$1
tracefile
test
$?
echo
-n
"testing get_flow_info : "
./test_get_flow_info
$1
>
/dev/null
./test_get_flow_info
$1
test
$?
echo
-n
"testing get_function_info : "
./test_mapi_get_function_info
$1
>
/dev/null
./test_mapi_get_function_info
$1
test
$?
#echo
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment