diff options
| author | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-01-15 23:19:58 +0100 | 
|---|---|---|
| committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-01-15 23:19:58 +0100 | 
| commit | e2af183ea7e5ea35a1582f40a01a7c49e83b31be (patch) | |
| tree | 5d5c5fabca580aa2851fb39c3e343b5bc324342e /include | |
| parent | 2cacd3a802510bde43e23cf4c7d39f51a2eaf460 (diff) | |
| download | conntrack-tools-e2af183ea7e5ea35a1582f40a01a7c49e83b31be.tar.gz conntrack-tools-e2af183ea7e5ea35a1582f40a01a7c49e83b31be.zip | |
sync: unify tx_list and tx_queue into one single tx_queue
This patch unifies the tx_list and the tx_queue to have only one
transmission queue. Since the tx_list hold state objects and
tx_queue control messages, I have introduced a queue node type
that can be used to differenciate the kind of information that
the node stores: object or control message.
This patch also reworks the existing queue class to include a
file descriptor that can be used to know if there are new data
added to the queue (see QUEUE_F_EVFD flag).
In this change, I have also modified the current evfd to make the
file descriptor to make read operations non-blocking. Moreover,
it keeps a counter that is used to know how many messages are
inserted in the queue.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/conntrackd.h | 1 | ||||
| -rw-r--r-- | include/queue.h | 51 | ||||
| -rw-r--r-- | include/sync.h | 6 | 
3 files changed, 43 insertions, 15 deletions
| diff --git a/include/conntrackd.h b/include/conntrackd.h index 67397b8..8cb520d 100644 --- a/include/conntrackd.h +++ b/include/conntrackd.h @@ -150,7 +150,6 @@ struct ct_sync_state {  	struct mcast_sock *mcast_server;  /* multicast socket: incoming */  	struct mcast_sock *mcast_client;  /* multicast socket: outgoing  */ -	struct evfd *evfd;		  /* event fd */  	struct sync_mode *sync;		/* sync mode */ diff --git a/include/queue.h b/include/queue.h index 5a9cf39..ef56323 100644 --- a/include/queue.h +++ b/include/queue.h @@ -1,28 +1,53 @@  #ifndef _QUEUE_H_  #define _QUEUE_H_ +#include <stdint.h>  #include "linux_list.h" -struct queue { -	size_t max_size; -	size_t cur_size; -	unsigned int num_elems; -	struct list_head head; +struct queue_node { +	struct list_head	head; +	uint32_t		type; +	struct queue		*owner; +	size_t 			size;  }; -struct queue_node { -	struct list_head head; -	size_t size; -	char data[0]; +enum { +	Q_ELEM_OBJ = 0, +	Q_ELEM_CTL = 1 +}; + +void queue_node_init(struct queue_node *n, int type); +void *queue_node_data(struct queue_node *n); + +struct queue_object { +	struct queue_node	qnode; +	char			data[0];  }; -struct queue *queue_create(size_t max_size); +struct queue_object *queue_object_new(int type, size_t size); +void queue_object_free(struct queue_object *obj); + +struct evfd; + +struct queue { +	unsigned int		max_elems; +	unsigned int		num_elems; +	uint32_t		flags; +	struct list_head	head; +	struct evfd		*evfd; +}; + +#define QUEUE_F_EVFD (1U << 0) + +struct queue *queue_create(int max_objects, unsigned int flags);  void queue_destroy(struct queue *b);  unsigned int queue_len(const struct queue *b); -int queue_add(struct queue *b, const void *data, size_t size); -void queue_del(struct queue *b, void *data); +int queue_add(struct queue *b, struct queue_node *n); +int queue_del(struct queue_node *n); +int queue_in(struct queue *b, struct queue_node *n);  void queue_iterate(struct queue *b,  		   const void *data, -		   int (*iterate)(void *data1, const void *data2)); +		   int (*iterate)(struct queue_node *n, const void *data2)); +int queue_get_eventfd(struct queue *b);  #endif diff --git a/include/sync.h b/include/sync.h index 60c9fae..9a9540c 100644 --- a/include/sync.h +++ b/include/sync.h @@ -1,8 +1,11 @@  #ifndef _SYNC_HOOKS_H_  #define _SYNC_HOOKS_H_ +#include <sys/select.h> +  struct nethdr;  struct cache_object; +struct fds;  struct sync_mode {  	int internal_cache_flags; @@ -15,7 +18,8 @@ struct sync_mode {  	int  (*local)(int fd, int type, void *data);  	int  (*recv)(const struct nethdr *net);  	void (*send)(struct nethdr *net, struct cache_object *obj); -	void (*run)(void); +	void (*run)(fd_set *readfds); +	int (*register_fds)(struct fds *fds);  };  extern struct sync_mode sync_alarm; | 
