Skip to content

Commit

Permalink
[send/recv] improve dst_host_filter API to include more data to deter…
Browse files Browse the repository at this point in the history
…mine destination

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Dec 9, 2015
1 parent 7d75de6 commit 02eae82
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kronosnetd/etherfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ static inline int is_broadcast_ether_addr(const uint8_t *addr)

int ether_host_filter_fn (const unsigned char *outdata,
ssize_t outdata_len,
uint8_t tx_rx,
uint16_t this_host_id,
uint16_t src_host_id,
uint16_t *dst_host_ids,
size_t *dst_host_ids_entries)
Expand Down
2 changes: 2 additions & 0 deletions kronosnetd/etherfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

int ether_host_filter_fn (const unsigned char *outdata,
ssize_t outdata_len,
uint8_t tx_rx,
uint16_t this_host_id,
uint16_t src_host_id,
uint16_t *dst_host_ids,
size_t *dst_host_ids_entries);
Expand Down
2 changes: 2 additions & 0 deletions libknet/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,8 @@ int knet_handle_enable_filter(knet_handle_t knet_h,
int (*dst_host_filter_fn) (
const unsigned char *outdata,
ssize_t outdata_len,
uint8_t tx_rx,
uint16_t this_host_id,
uint16_t src_node_id,
uint16_t *dst_host_ids,
size_t *dst_host_ids_entries))
Expand Down
2 changes: 2 additions & 0 deletions libknet/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ struct knet_handle {
int (*dst_host_filter_fn) (
const unsigned char *outdata,
ssize_t outdata_len,
uint8_t tx_rx,
uint16_t this_host_id,
uint16_t src_node_id,
uint16_t *dst_host_ids,
size_t *dst_host_ids_entries);
Expand Down
8 changes: 8 additions & 0 deletions libknet/libknet.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ ssize_t knet_send(knet_handle_t knet_h,
* const unsigned char *outdata - is a pointer to the
* current packet
* ssize_t outdata_len - lenght of the above data
* uint8_t tx_rx - filter is called on tx or rx
* (see defines below)
* uint16_t this_host_id - host_id processing the packet
* uint16_t src_host_id - host_id that generated the
* packet
* uint16_t *dst_host_ids - array of KNET_MAX_HOST uint16_t
Expand All @@ -185,10 +188,15 @@ ssize_t knet_send(knet_handle_t knet_h,
* -1 on error and errno is set.
*/

#define KNET_DST_HOST_FILTER_TX 0
#define KNET_DST_HOST_FILTER_RX 1

int knet_handle_enable_filter(knet_handle_t knet_h,
int (*dst_host_filter_fn) (
const unsigned char *outdata,
ssize_t outdata_len,
uint8_t tx_rx,
uint16_t this_host_id,
uint16_t src_host_id,
uint16_t *dst_host_ids,
size_t *dst_host_ids_entries));
Expand Down
4 changes: 4 additions & 0 deletions libknet/threads_send_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ static void _handle_send_to_links(knet_handle_t knet_h, int sockfd)
bcast = knet_h->dst_host_filter_fn(
(const unsigned char *)knet_h->send_to_links_buf[0]->khp_data_userdata,
inlen,
KNET_DST_HOST_FILTER_TX,
knet_h->host_id,
knet_h->send_to_links_buf[0]->kh_node,
dst_host_ids,
&dst_host_ids_entries);
Expand Down Expand Up @@ -613,6 +615,8 @@ static void _parse_recv_from_links(knet_handle_t knet_h, struct sockaddr_storage
bcast = knet_h->dst_host_filter_fn(
(const unsigned char *)inbuf->khp_data_userdata,
len,
KNET_DST_HOST_FILTER_RX,
knet_h->host_id,
inbuf->kh_node,
dst_host_ids,
&dst_host_ids_entries);
Expand Down

0 comments on commit 02eae82

Please sign in to comment.