Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
U
udpdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ywj
udpdk
Commits
b53ab6ba
Commit
b53ab6ba
authored
Nov 05, 2020
by
Leonardo Lai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some renaming to prevent conflicts
parent
c650dabb
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
124 additions
and
124 deletions
+124
-124
udpdk/list/udpdk_list.c
udpdk/list/udpdk_list.c
+34
-34
udpdk/list/udpdk_list.h
udpdk/list/udpdk_list.h
+37
-37
udpdk/list/udpdk_list_globals.c
udpdk/list/udpdk_list_globals.c
+3
-3
udpdk/list/udpdk_list_init.c
udpdk/list/udpdk_list_init.c
+15
-15
udpdk/list/udpdk_list_iterator.c
udpdk/list/udpdk_list_iterator.c
+16
-16
udpdk/list/udpdk_list_node.c
udpdk/list/udpdk_list_node.c
+5
-5
udpdk/udpdk_bind_table.c
udpdk/udpdk_bind_table.c
+7
-7
udpdk/udpdk_bind_table.h
udpdk/udpdk_bind_table.h
+1
-1
udpdk/udpdk_init.c
udpdk/udpdk_init.c
+2
-2
udpdk/udpdk_poller.c
udpdk/udpdk_poller.c
+4
-4
No files found.
udpdk/list/udpdk_list.c
View file @
b53ab6ba
...
@@ -8,17 +8,17 @@
...
@@ -8,17 +8,17 @@
#include "udpdk_list.h"
#include "udpdk_list.h"
#include "udpdk_shmalloc.h"
#include "udpdk_shmalloc.h"
extern
const
void
*
list_t_alloc
;
extern
const
void
*
udpdk_
list_t_alloc
;
extern
const
void
*
list_node_t_alloc
;
extern
const
void
*
udpdk_
list_node_t_alloc
;
/*
/*
* Allocate a new list_t. NULL on failure.
* Allocate a new
udpdk_
list_t. NULL on failure.
*/
*/
list_t
*
udpdk_
list_t
*
list_new
(
void
)
{
list_new
(
void
)
{
list_t
*
self
;
udpdk_
list_t
*
self
;
if
(
!
(
self
=
udpdk_shmalloc
(
list_t_alloc
)))
if
(
!
(
self
=
udpdk_shmalloc
(
udpdk_
list_t_alloc
)))
return
NULL
;
return
NULL
;
self
->
head
=
NULL
;
self
->
head
=
NULL
;
self
->
tail
=
NULL
;
self
->
tail
=
NULL
;
...
@@ -33,19 +33,19 @@ list_new(void) {
...
@@ -33,19 +33,19 @@ list_new(void) {
*/
*/
void
void
list_destroy
(
list_t
*
self
)
{
list_destroy
(
udpdk_
list_t
*
self
)
{
unsigned
int
len
=
self
->
len
;
unsigned
int
len
=
self
->
len
;
list_node_t
*
next
;
udpdk_
list_node_t
*
next
;
list_node_t
*
curr
=
self
->
head
;
udpdk_
list_node_t
*
curr
=
self
->
head
;
while
(
len
--
)
{
while
(
len
--
)
{
next
=
curr
->
next
;
next
=
curr
->
next
;
if
(
self
->
free
)
self
->
free
(
curr
->
val
);
if
(
self
->
free
)
self
->
free
(
curr
->
val
);
udpdk_shfree
(
list_node_t_alloc
,
curr
);
udpdk_shfree
(
udpdk_
list_node_t_alloc
,
curr
);
curr
=
next
;
curr
=
next
;
}
}
udpdk_shfree
(
list_t_alloc
,
self
);
udpdk_shfree
(
udpdk_
list_t_alloc
,
self
);
}
}
/*
/*
...
@@ -53,8 +53,8 @@ list_destroy(list_t *self) {
...
@@ -53,8 +53,8 @@ list_destroy(list_t *self) {
* and return the node, NULL on failure.
* and return the node, NULL on failure.
*/
*/
list_node_t
*
udpdk_
list_node_t
*
list_rpush
(
list_t
*
self
,
list_node_t
*
node
)
{
list_rpush
(
udpdk_list_t
*
self
,
udpdk_
list_node_t
*
node
)
{
if
(
!
node
)
return
NULL
;
if
(
!
node
)
return
NULL
;
if
(
self
->
len
)
{
if
(
self
->
len
)
{
...
@@ -75,11 +75,11 @@ list_rpush(list_t *self, list_node_t *node) {
...
@@ -75,11 +75,11 @@ list_rpush(list_t *self, list_node_t *node) {
* Return / detach the last node in the list, or NULL.
* Return / detach the last node in the list, or NULL.
*/
*/
list_node_t
*
udpdk_
list_node_t
*
list_rpop
(
list_t
*
self
)
{
list_rpop
(
udpdk_
list_t
*
self
)
{
if
(
!
self
->
len
)
return
NULL
;
if
(
!
self
->
len
)
return
NULL
;
list_node_t
*
node
=
self
->
tail
;
udpdk_
list_node_t
*
node
=
self
->
tail
;
if
(
--
self
->
len
)
{
if
(
--
self
->
len
)
{
(
self
->
tail
=
node
->
prev
)
->
next
=
NULL
;
(
self
->
tail
=
node
->
prev
)
->
next
=
NULL
;
...
@@ -95,11 +95,11 @@ list_rpop(list_t *self) {
...
@@ -95,11 +95,11 @@ list_rpop(list_t *self) {
* Return / detach the first node in the list, or NULL.
* Return / detach the first node in the list, or NULL.
*/
*/
list_node_t
*
udpdk_
list_node_t
*
list_lpop
(
list_t
*
self
)
{
list_lpop
(
udpdk_
list_t
*
self
)
{
if
(
!
self
->
len
)
return
NULL
;
if
(
!
self
->
len
)
return
NULL
;
list_node_t
*
node
=
self
->
head
;
udpdk_
list_node_t
*
node
=
self
->
head
;
if
(
--
self
->
len
)
{
if
(
--
self
->
len
)
{
(
self
->
head
=
node
->
next
)
->
prev
=
NULL
;
(
self
->
head
=
node
->
next
)
->
prev
=
NULL
;
...
@@ -116,8 +116,8 @@ list_lpop(list_t *self) {
...
@@ -116,8 +116,8 @@ list_lpop(list_t *self) {
* and return the node, NULL on failure.
* and return the node, NULL on failure.
*/
*/
list_node_t
*
udpdk_
list_node_t
*
list_lpush
(
list_t
*
self
,
list_node_t
*
node
)
{
list_lpush
(
udpdk_list_t
*
self
,
udpdk_
list_node_t
*
node
)
{
if
(
!
node
)
return
NULL
;
if
(
!
node
)
return
NULL
;
if
(
self
->
len
)
{
if
(
self
->
len
)
{
...
@@ -139,8 +139,8 @@ list_lpush(list_t *self, list_node_t *node) {
...
@@ -139,8 +139,8 @@ list_lpush(list_t *self, list_node_t *node) {
* (or first if the only element)
* (or first if the only element)
* and return the node, NULL or failure
* and return the node, NULL or failure
*/
*/
list_node_t
*
udpdk_
list_node_t
*
list_spush
(
list_t
*
self
,
list_node_t
*
node
)
{
list_spush
(
udpdk_list_t
*
self
,
udpdk_
list_node_t
*
node
)
{
if
(
!
node
)
return
NULL
;
if
(
!
node
)
return
NULL
;
if
(
self
->
len
)
{
if
(
self
->
len
)
{
...
@@ -161,10 +161,10 @@ list_spush(list_t *self, list_node_t *node) {
...
@@ -161,10 +161,10 @@ list_spush(list_t *self, list_node_t *node) {
* Return the node associated to val or NULL.
* Return the node associated to val or NULL.
*/
*/
list_node_t
*
udpdk_
list_node_t
*
list_find
(
list_t
*
self
,
void
*
val
)
{
list_find
(
udpdk_
list_t
*
self
,
void
*
val
)
{
list_iterator_t
*
it
=
list_iterator_new
(
self
,
LIST_HEAD
);
udpdk_
list_iterator_t
*
it
=
list_iterator_new
(
self
,
LIST_HEAD
);
list_node_t
*
node
;
udpdk_
list_node_t
*
node
;
while
((
node
=
list_iterator_next
(
it
)))
{
while
((
node
=
list_iterator_next
(
it
)))
{
if
(
self
->
match
)
{
if
(
self
->
match
)
{
...
@@ -188,9 +188,9 @@ list_find(list_t *self, void *val) {
...
@@ -188,9 +188,9 @@ list_find(list_t *self, void *val) {
* Return the node at the given index or NULL.
* Return the node at the given index or NULL.
*/
*/
list_node_t
*
udpdk_
list_node_t
*
list_at
(
list_t
*
self
,
int
index
)
{
list_at
(
udpdk_
list_t
*
self
,
int
index
)
{
list_direction_t
direction
=
LIST_HEAD
;
udpdk_
list_direction_t
direction
=
LIST_HEAD
;
if
(
index
<
0
)
{
if
(
index
<
0
)
{
direction
=
LIST_TAIL
;
direction
=
LIST_TAIL
;
...
@@ -198,8 +198,8 @@ list_at(list_t *self, int index) {
...
@@ -198,8 +198,8 @@ list_at(list_t *self, int index) {
}
}
if
((
unsigned
)
index
<
self
->
len
)
{
if
((
unsigned
)
index
<
self
->
len
)
{
list_iterator_t
*
it
=
list_iterator_new
(
self
,
direction
);
udpdk_
list_iterator_t
*
it
=
list_iterator_new
(
self
,
direction
);
list_node_t
*
node
=
list_iterator_next
(
it
);
udpdk_
list_node_t
*
node
=
list_iterator_next
(
it
);
while
(
index
--
)
node
=
list_iterator_next
(
it
);
while
(
index
--
)
node
=
list_iterator_next
(
it
);
list_iterator_destroy
(
it
);
list_iterator_destroy
(
it
);
return
node
;
return
node
;
...
@@ -213,7 +213,7 @@ list_at(list_t *self, int index) {
...
@@ -213,7 +213,7 @@ list_at(list_t *self, int index) {
*/
*/
void
void
list_remove
(
list_t
*
self
,
list_node_t
*
node
)
{
list_remove
(
udpdk_list_t
*
self
,
udpdk_
list_node_t
*
node
)
{
node
->
prev
node
->
prev
?
(
node
->
prev
->
next
=
node
->
next
)
?
(
node
->
prev
->
next
=
node
->
next
)
:
(
self
->
head
=
node
->
next
);
:
(
self
->
head
=
node
->
next
);
...
@@ -224,6 +224,6 @@ list_remove(list_t *self, list_node_t *node) {
...
@@ -224,6 +224,6 @@ list_remove(list_t *self, list_node_t *node) {
if
(
self
->
free
)
self
->
free
(
node
->
val
);
if
(
self
->
free
)
self
->
free
(
node
->
val
);
udpdk_shfree
(
list_node_t_alloc
,
node
);
udpdk_shfree
(
udpdk_
list_node_t_alloc
,
node
);
--
self
->
len
;
--
self
->
len
;
}
}
udpdk/list/udpdk_list.h
View file @
b53ab6ba
...
@@ -29,92 +29,92 @@ extern "C" {
...
@@ -29,92 +29,92 @@ extern "C" {
#endif
#endif
/*
/*
* list_t iterator direction.
*
udpdk_
list_t iterator direction.
*/
*/
typedef
enum
{
typedef
enum
{
LIST_HEAD
LIST_HEAD
,
LIST_TAIL
,
LIST_TAIL
}
list_direction_t
;
}
udpdk_
list_direction_t
;
/*
/*
* list_t node struct.
*
udpdk_
list_t node struct.
*/
*/
typedef
struct
list_node
{
typedef
struct
list_node
{
struct
list_node
*
prev
;
struct
list_node
*
prev
;
struct
list_node
*
next
;
struct
list_node
*
next
;
void
*
val
;
void
*
val
;
}
list_node_t
;
}
udpdk_
list_node_t
;
/*
/*
* list_t struct.
*
udpdk_
list_t struct.
*/
*/
typedef
struct
{
typedef
struct
{
list_node_t
*
head
;
udpdk_
list_node_t
*
head
;
list_node_t
*
tail
;
udpdk_
list_node_t
*
tail
;
unsigned
int
len
;
unsigned
int
len
;
void
(
*
free
)(
void
*
val
);
void
(
*
free
)(
void
*
val
);
int
(
*
match
)(
void
*
a
,
void
*
b
);
int
(
*
match
)(
void
*
a
,
void
*
b
);
}
list_t
;
}
udpdk_
list_t
;
/*
/*
* list_t iterator struct.
*
udpdk_
list_t iterator struct.
*/
*/
typedef
struct
{
typedef
struct
{
list_node_t
*
next
;
udpdk_
list_node_t
*
next
;
list_direction_t
direction
;
udpdk_
list_direction_t
direction
;
}
list_iterator_t
;
}
udpdk_
list_iterator_t
;
// Node prototypes.
// Node prototypes.
list_node_t
*
udpdk_
list_node_t
*
list_node_new
(
void
*
val
);
list_node_new
(
void
*
val
);
// list_t prototypes.
//
udpdk_
list_t prototypes.
list_t
*
udpdk_
list_t
*
list_new
(
void
);
list_new
(
void
);
list_node_t
*
udpdk_
list_node_t
*
list_rpush
(
list_t
*
self
,
list_node_t
*
node
);
list_rpush
(
udpdk_list_t
*
self
,
udpdk_
list_node_t
*
node
);
list_node_t
*
udpdk_
list_node_t
*
list_lpush
(
list_t
*
self
,
list_node_t
*
node
);
list_lpush
(
udpdk_list_t
*
self
,
udpdk_
list_node_t
*
node
);
list_node_t
*
udpdk_
list_node_t
*
list_find
(
list_t
*
self
,
void
*
val
);
list_find
(
udpdk_
list_t
*
self
,
void
*
val
);
list_node_t
*
udpdk_
list_node_t
*
list_at
(
list_t
*
self
,
int
index
);
list_at
(
udpdk_
list_t
*
self
,
int
index
);
list_node_t
*
udpdk_
list_node_t
*
list_rpop
(
list_t
*
self
);
list_rpop
(
udpdk_
list_t
*
self
);
list_node_t
*
udpdk_
list_node_t
*
list_lpop
(
list_t
*
self
);
list_lpop
(
udpdk_
list_t
*
self
);
void
void
list_remove
(
list_t
*
self
,
list_node_t
*
node
);
list_remove
(
udpdk_list_t
*
self
,
udpdk_
list_node_t
*
node
);
void
void
list_destroy
(
list_t
*
self
);
list_destroy
(
udpdk_
list_t
*
self
);
// list_t iterator prototypes.
//
udpdk_
list_t iterator prototypes.
list_iterator_t
*
udpdk_
list_iterator_t
*
list_iterator_new
(
list_t
*
list
,
list_direction_t
direction
);
list_iterator_new
(
udpdk_list_t
*
list
,
udpdk_
list_direction_t
direction
);
list_iterator_t
*
udpdk_
list_iterator_t
*
list_iterator_new_from_node
(
list_node_t
*
node
,
list_direction_t
direction
);
list_iterator_new_from_node
(
udpdk_list_node_t
*
node
,
udpdk_
list_direction_t
direction
);
list_node_t
*
udpdk_
list_node_t
*
list_iterator_next
(
list_iterator_t
*
self
);
list_iterator_next
(
udpdk_
list_iterator_t
*
self
);
void
void
list_iterator_destroy
(
list_iterator_t
*
self
);
list_iterator_destroy
(
udpdk_
list_iterator_t
*
self
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
udpdk/list/udpdk_list_globals.c
View file @
b53ab6ba
#include "udpdk_list.h"
#include "udpdk_list.h"
const
void
*
list_t_alloc
=
NULL
;
const
void
*
udpdk_
list_t_alloc
=
NULL
;
const
void
*
list_node_t_alloc
=
NULL
;
const
void
*
udpdk_
list_node_t_alloc
=
NULL
;
const
void
*
list_iterator_t_alloc
=
NULL
;
const
void
*
udpdk_
list_iterator_t_alloc
=
NULL
;
udpdk/list/udpdk_list_init.c
View file @
b53ab6ba
#include "udpdk_list.h"
#include "udpdk_list.h"
#include "udpdk_shmalloc.h"
#include "udpdk_shmalloc.h"
extern
const
void
*
list_t_alloc
;
extern
const
void
*
udpdk_
list_t_alloc
;
extern
const
void
*
list_node_t_alloc
;
extern
const
void
*
udpdk_
list_node_t_alloc
;
extern
const
void
*
list_iterator_t_alloc
;
extern
const
void
*
udpdk_
list_iterator_t_alloc
;
void
udpdk_list_init
(
void
)
void
udpdk_list_init
(
void
)
{
{
list_t_alloc
=
udpdk_init_allocator
(
"list_t_alloc"
,
UDP_MAX_PORT
,
sizeof
(
list_t
));
udpdk_list_t_alloc
=
udpdk_init_allocator
(
"udpdk_list_t_alloc"
,
UDP_MAX_PORT
,
sizeof
(
udpdk_
list_t
));
list_node_t_alloc
=
udpdk_init_allocator
(
"list_node_t_alloc"
,
NUM_SOCKETS_MAX
,
sizeof
(
list_node_t
));
udpdk_list_node_t_alloc
=
udpdk_init_allocator
(
"udpdk_list_node_t_alloc"
,
NUM_SOCKETS_MAX
,
sizeof
(
udpdk_
list_node_t
));
list_iterator_t_alloc
=
udpdk_init_allocator
(
"list_iterator_t_alloc"
,
10
,
sizeof
(
list_iterator_t
));
udpdk_list_iterator_t_alloc
=
udpdk_init_allocator
(
"udpdk_list_iterator_t_alloc"
,
10
,
sizeof
(
udpdk_
list_iterator_t
));
}
}
int
udpdk_list_reinit
(
void
)
int
udpdk_list_reinit
(
void
)
{
{
list_t_alloc
=
udpdk_retrieve_allocator
(
"
list_t_alloc"
);
udpdk_list_t_alloc
=
udpdk_retrieve_allocator
(
"udpdk_
list_t_alloc"
);
if
(
list_t_alloc
==
NULL
)
{
if
(
udpdk_
list_t_alloc
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
list_node_t_alloc
=
udpdk_retrieve_allocator
(
"
list_node_t_alloc"
);
udpdk_list_node_t_alloc
=
udpdk_retrieve_allocator
(
"udpdk_
list_node_t_alloc"
);
if
(
list_node_t_alloc
==
NULL
)
{
if
(
udpdk_
list_node_t_alloc
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
list_iterator_t_alloc
=
udpdk_retrieve_allocator
(
"
list_iterator_t_alloc"
);
udpdk_list_iterator_t_alloc
=
udpdk_retrieve_allocator
(
"udpdk_
list_iterator_t_alloc"
);
if
(
list_iterator_t_alloc
==
NULL
)
{
if
(
udpdk_
list_iterator_t_alloc
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
...
@@ -31,7 +31,7 @@ int udpdk_list_reinit(void)
...
@@ -31,7 +31,7 @@ int udpdk_list_reinit(void)
void
udpdk_list_deinit
(
void
)
void
udpdk_list_deinit
(
void
)
{
{
udpdk_destroy_allocator
(
list_t_alloc
);
udpdk_destroy_allocator
(
udpdk_
list_t_alloc
);
udpdk_destroy_allocator
(
list_node_t_alloc
);
udpdk_destroy_allocator
(
udpdk_
list_node_t_alloc
);
udpdk_destroy_allocator
(
list_iterator_t_alloc
);
udpdk_destroy_allocator
(
udpdk_
list_iterator_t_alloc
);
}
}
udpdk/list/udpdk_list_iterator.c
View file @
b53ab6ba
...
@@ -8,30 +8,30 @@
...
@@ -8,30 +8,30 @@
#include "udpdk_list.h"
#include "udpdk_list.h"
#include "udpdk_shmalloc.h"
#include "udpdk_shmalloc.h"
extern
void
*
list_iterator_t_alloc
;
extern
void
*
udpdk_
list_iterator_t_alloc
;
/*
/*
* Allocate a new list_iterator_t. NULL on failure.
* Allocate a new
udpdk_
list_iterator_t. NULL on failure.
* Accepts a direction, which may be LIST_HEAD or LIST_TAIL.
* Accepts a direction, which may be LIST_HEAD or LIST_TAIL.
*/
*/
list_iterator_t
*
udpdk_
list_iterator_t
*
list_iterator_new
(
list_t
*
list
,
list_direction_t
direction
)
{
list_iterator_new
(
udpdk_list_t
*
list
,
udpdk_
list_direction_t
direction
)
{
list_node_t
*
node
=
direction
==
LIST_HEAD
udpdk_
list_node_t
*
node
=
direction
==
LIST_HEAD
?
list
->
head
?
list
->
head
:
list
->
tail
;
:
list
->
tail
;
return
list_iterator_new_from_node
(
node
,
direction
);
return
list_iterator_new_from_node
(
node
,
direction
);
}
}
/*
/*
* Allocate a new list_iterator_t with the given start
* Allocate a new
udpdk_
list_iterator_t with the given start
* node. NULL on failure.
* node. NULL on failure.
*/
*/
list_iterator_t
*
udpdk_
list_iterator_t
*
list_iterator_new_from_node
(
list_node_t
*
node
,
list_direction_t
direction
)
{
list_iterator_new_from_node
(
udpdk_list_node_t
*
node
,
udpdk_
list_direction_t
direction
)
{
list_iterator_t
*
self
;
udpdk_
list_iterator_t
*
self
;
if
(
!
(
self
=
udpdk_shmalloc
(
list_iterator_t_alloc
)))
if
(
!
(
self
=
udpdk_shmalloc
(
udpdk_
list_iterator_t_alloc
)))
return
NULL
;
return
NULL
;
self
->
next
=
node
;
self
->
next
=
node
;
self
->
direction
=
direction
;
self
->
direction
=
direction
;
...
@@ -39,13 +39,13 @@ list_iterator_new_from_node(list_node_t *node, list_direction_t direction) {
...
@@ -39,13 +39,13 @@ list_iterator_new_from_node(list_node_t *node, list_direction_t direction) {
}
}
/*
/*
* Return the next list_node_t or NULL when no more
* Return the next
udpdk_
list_node_t or NULL when no more
* nodes remain in the list.
* nodes remain in the list.
*/
*/
list_node_t
*
udpdk_
list_node_t
*
list_iterator_next
(
list_iterator_t
*
self
)
{
list_iterator_next
(
udpdk_
list_iterator_t
*
self
)
{
list_node_t
*
curr
=
self
->
next
;
udpdk_
list_node_t
*
curr
=
self
->
next
;
if
(
curr
)
{
if
(
curr
)
{
self
->
next
=
self
->
direction
==
LIST_HEAD
self
->
next
=
self
->
direction
==
LIST_HEAD
?
curr
->
next
?
curr
->
next
...
@@ -59,7 +59,7 @@ list_iterator_next(list_iterator_t *self) {
...
@@ -59,7 +59,7 @@ list_iterator_next(list_iterator_t *self) {
*/
*/
void
void
list_iterator_destroy
(
list_iterator_t
*
self
)
{
list_iterator_destroy
(
udpdk_
list_iterator_t
*
self
)
{
udpdk_shfree
(
list_iterator_t_alloc
,
self
);
udpdk_shfree
(
udpdk_
list_iterator_t_alloc
,
self
);
self
=
NULL
;
self
=
NULL
;
}
}
udpdk/list/udpdk_list_node.c
View file @
b53ab6ba
...
@@ -8,16 +8,16 @@
...
@@ -8,16 +8,16 @@
#include "udpdk_list.h"
#include "udpdk_list.h"
#include "udpdk_shmalloc.h"
#include "udpdk_shmalloc.h"
extern
void
*
list_node_t_alloc
;
extern
void
*
udpdk_
list_node_t_alloc
;
/*
/*
* Allocates a new list_node_t. NULL on failure.
* Allocates a new
udpdk_
list_node_t. NULL on failure.
*/
*/
list_node_t
*
udpdk_
list_node_t
*
list_node_new
(
void
*
val
)
{
list_node_new
(
void
*
val
)
{
list_node_t
*
self
;
udpdk_
list_node_t
*
self
;
if
(
!
(
self
=
udpdk_shmalloc
(
list_node_t_alloc
)))
if
(
!
(
self
=
udpdk_shmalloc
(
udpdk_
list_node_t_alloc
)))
return
NULL
;
return
NULL
;
self
->
prev
=
NULL
;
self
->
prev
=
NULL
;
self
->
next
=
NULL
;
self
->
next
=
NULL
;
...
...
udpdk/udpdk_bind_table.c
View file @
b53ab6ba
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#define RTE_LOGTYPE_BTABLE RTE_LOGTYPE_USER1
#define RTE_LOGTYPE_BTABLE RTE_LOGTYPE_USER1
const
void
*
bind_info_alloc
=
NULL
;
const
void
*
bind_info_alloc
=
NULL
;
list_t
**
sock_bind_table
;
udpdk_
list_t
**
sock_bind_table
;
/* Initialize the bindings table */
/* Initialize the bindings table */
void
btable_init
(
void
)
void
btable_init
(
void
)
...
@@ -49,8 +49,8 @@ static inline bool btable_can_bind(struct in_addr ip, int port, int opts)
...
@@ -49,8 +49,8 @@ static inline bool btable_can_bind(struct in_addr ip, int port, int opts)
bool
reuse_addr
=
opts
&
SO_REUSEADDR
;
bool
reuse_addr
=
opts
&
SO_REUSEADDR
;
bool
reuse_port
=
opts
&
SO_REUSEPORT
;
bool
reuse_port
=
opts
&
SO_REUSEPORT
;
bool
can_bind
=
true
;
bool
can_bind
=
true
;
list_iterator_t
*
it
;
udpdk_
list_iterator_t
*
it
;
list_node_t
*
node
;
udpdk_
list_node_t
*
node
;
unsigned
long
ip_oth
,
ip_new
;
unsigned
long
ip_oth
,
ip_new
;
// bool oth_reuseaddr;
// bool oth_reuseaddr;
bool
oth_reuseport
;
bool
oth_reuseport
;
...
@@ -92,7 +92,7 @@ static inline bool btable_can_bind(struct in_addr ip, int port, int opts)
...
@@ -92,7 +92,7 @@ static inline bool btable_can_bind(struct in_addr ip, int port, int opts)
int
btable_add_binding
(
int
s
,
struct
in_addr
ip
,
int
port
,
int
opts
)
int
btable_add_binding
(
int
s
,
struct
in_addr
ip
,
int
port
,
int
opts
)
{
{
struct
bind_info
*
b
;
struct
bind_info
*
b
;
list_node_t
*
ln
;
udpdk_
list_node_t
*
ln
;
// Check if binding this pair is allowed
// Check if binding this pair is allowed
if
(
!
btable_can_bind
(
ip
,
port
,
opts
))
{
if
(
!
btable_can_bind
(
ip
,
port
,
opts
))
{
...
@@ -127,8 +127,8 @@ int btable_add_binding(int s, struct in_addr ip, int port, int opts)
...
@@ -127,8 +127,8 @@ int btable_add_binding(int s, struct in_addr ip, int port, int opts)
/* Remove a binding from the port */
/* Remove a binding from the port */
void
btable_del_binding
(
int
s
,
int
port
)
{
void
btable_del_binding
(
int
s
,
int
port
)
{
list_node_t
*
node
;
udpdk_
list_node_t
*
node
;
list_iterator_t
*
it
;
udpdk_
list_iterator_t
*
it
;
// Remove the binding from the list
// Remove the binding from the list
it
=
list_iterator_new
(
sock_bind_table
[
port
],
LIST_HEAD
);
it
=
list_iterator_new
(
sock_bind_table
[
port
],
LIST_HEAD
);
...
@@ -149,7 +149,7 @@ void btable_del_binding(int s, int port) {
...
@@ -149,7 +149,7 @@ void btable_del_binding(int s, int port) {
}
}
/* Get all the bind_info descriptors of the sockets bound to the given port */
/* Get all the bind_info descriptors of the sockets bound to the given port */
list_t
*
btable_get_bindings
(
int
port
)
{
udpdk_
list_t
*
btable_get_bindings
(
int
port
)
{
return
sock_bind_table
[
port
];
return
sock_bind_table
[
port
];
}
}
...
...
udpdk/udpdk_bind_table.h
View file @
b53ab6ba
...
@@ -18,7 +18,7 @@ int btable_add_binding(int s, struct in_addr ip, int port, int opts);
...
@@ -18,7 +18,7 @@ int btable_add_binding(int s, struct in_addr ip, int port, int opts);
void
btable_del_binding
(
int
s
,
int
port
);
void
btable_del_binding
(
int
s
,
int
port
);
list_t
*
btable_get_bindings
(
int
port
);
udpdk_
list_t
*
btable_get_bindings
(
int
port
);
void
btable_destroy
(
void
);
void
btable_destroy
(
void
);
...
...
udpdk/udpdk_init.c
View file @
b53ab6ba
...
@@ -41,7 +41,7 @@ extern struct rte_mempool *rx_pktmbuf_pool;
...
@@ -41,7 +41,7 @@ extern struct rte_mempool *rx_pktmbuf_pool;
extern
struct
rte_mempool
*
tx_pktmbuf_pool
;
extern
struct
rte_mempool
*
tx_pktmbuf_pool
;
extern
struct
rte_mempool
*
tx_pktmbuf_direct_pool
;
extern
struct
rte_mempool
*
tx_pktmbuf_direct_pool
;
extern
struct
rte_mempool
*
tx_pktmbuf_indirect_pool
;
extern
struct
rte_mempool
*
tx_pktmbuf_indirect_pool
;
extern
list_t
**
sock_bind_table
;
extern
udpdk_
list_t
**
sock_bind_table
;
extern
int
primary_argc
;
extern
int
primary_argc
;
extern
int
secondary_argc
;
extern
int
secondary_argc
;
extern
char
*
primary_argv
[
MAX_ARGC
];
extern
char
*
primary_argv
[
MAX_ARGC
];
...
@@ -207,7 +207,7 @@ static int init_udp_bind_table(void)
...
@@ -207,7 +207,7 @@ static int init_udp_bind_table(void)
{
{
const
struct
rte_memzone
*
mz
;
const
struct
rte_memzone
*
mz
;
mz
=
rte_memzone_reserve
(
UDP_BIND_TABLE_NAME
,
UDP_MAX_PORT
*
sizeof
(
struct
list_t
*
),
rte_socket_id
(),
0
);
mz
=
rte_memzone_reserve
(
UDP_BIND_TABLE_NAME
,
UDP_MAX_PORT
*
sizeof
(
struct
udpdk_
list_t
*
),
rte_socket_id
(),
0
);
if
(
mz
==
NULL
)
{
if
(
mz
==
NULL
)
{
RTE_LOG
(
ERR
,
INIT
,
"Cannot allocate shared memory for L4 switching table
\n
"
);
RTE_LOG
(
ERR
,
INIT
,
"Cannot allocate shared memory for L4 switching table
\n
"
);
return
-
1
;
return
-
1
;
...
...
udpdk/udpdk_poller.c
View file @
b53ab6ba
...
@@ -37,7 +37,7 @@ static volatile int poller_alive = 1;
...
@@ -37,7 +37,7 @@ static volatile int poller_alive = 1;
extern
struct
exch_zone_info
*
exch_zone_desc
;
extern
struct
exch_zone_info
*
exch_zone_desc
;
extern
struct
exch_slot
*
exch_slots
;
extern
struct
exch_slot
*
exch_slots
;
extern
list_t
**
sock_bind_table
;
extern
udpdk_
list_t
**
sock_bind_table
;
extern
const
void
*
bind_info_alloc
;
extern
const
void
*
bind_info_alloc
;
/* Descriptor of a RX queue */
/* Descriptor of a RX queue */
...
@@ -350,13 +350,13 @@ static inline void reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queu
...
@@ -350,13 +350,13 @@ static inline void reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queu
ip_dst_addr
=
get_ipv4_dst_addr
(
ip_hdr
);
ip_dst_addr
=
get_ipv4_dst_addr
(
ip_hdr
);
// Find the sock_ids corresponding to the UDP dst port (L4 switching) and enqueue the packet to its queue
// Find the sock_ids corresponding to the UDP dst port (L4 switching) and enqueue the packet to its queue
list_t
*
binds
=
btable_get_bindings
(
udp_dst_port
);
udpdk_
list_t
*
binds
=
btable_get_bindings
(
udp_dst_port
);
if
(
binds
==
NULL
)
{
if
(
binds
==
NULL
)
{
RTE_LOG
(
WARNING
,
POLLBODY
,
"Dropping packet for port %d: no socket bound
\n
"
,
ntohs
(
udp_dst_port
));
RTE_LOG
(
WARNING
,
POLLBODY
,
"Dropping packet for port %d: no socket bound
\n
"
,
ntohs
(
udp_dst_port
));
return
;
return
;
}
}
list_iterator_t
*
it
=
list_iterator_new
(
binds
,
LIST_HEAD
);
udpdk_
list_iterator_t
*
it
=
list_iterator_new
(
binds
,
LIST_HEAD
);
list_node_t
*
node
;
udpdk_
list_node_t
*
node
;
while
((
node
=
list_iterator_next
(
it
)))
{
while
((
node
=
list_iterator_next
(
it
)))
{
unsigned
long
ip_oth
=
((
struct
bind_info
*
)(
node
->
val
))
->
ip_addr
.
s_addr
;
unsigned
long
ip_oth
=
((
struct
bind_info
*
)(
node
->
val
))
->
ip_addr
.
s_addr
;
bool
oth_reuseaddr
=
((
struct
bind_info
*
)(
node
->
val
))
->
reuse_addr
;
bool
oth_reuseaddr
=
((
struct
bind_info
*
)(
node
->
val
))
->
reuse_addr
;
...
...
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