Skip to content

Commit

Permalink
libknet: export function to allow dst cache update on link removal
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Oct 3, 2012
1 parent 8bafe7d commit f7f44e1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 0 additions & 2 deletions TODO
Expand Up @@ -26,8 +26,6 @@ Look into link status changes notification (maybe a signal to a thread? or write

* add priority/weight to link config struct

we might need to update the cache on link removal...

ring:

* support 8 listener per node.
Expand Down
2 changes: 2 additions & 0 deletions kronosnetd/vty_cli_cmds.c
Expand Up @@ -692,6 +692,8 @@ static int knet_cmd_no_link(struct knet_vty *vty)
}

host->link[j].configured = 0;
if (knet_host_dst_cache_update(knet_iface->cfg_ring.knet_h, host->node_id))
knet_vty_write(vty, "Error: unable to update switching cache%s", telnet_newline);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions libknet/handle.c
Expand Up @@ -456,7 +456,7 @@ static void _handle_recv_from_links(knet_handle_t knet_h, int sockfd)
try_again:
if (write(knet_h->pipefd[1], &src_host->node_id,
sizeof(src_host->node_id)) != sizeof(src_host->node_id)) {
if (write_retry < 10) {
if ((write_retry < 10) && ((errno = EAGAIN) || (errno = EWOULDBLOCK))) {
write_retry++;
goto try_again;
} /* define what to do if we can't add a link */
Expand Down Expand Up @@ -566,7 +566,7 @@ static void _handle_check_each(knet_handle_t knet_h, struct knet_host *dst_host,
dst_link->connected = 0;
try_again:
if (write(knet_h->pipefd[1], &dst_host->node_id, sizeof(dst_host->node_id)) != sizeof(dst_host->node_id)) {
if (write_retry < 10) {
if ((write_retry < 10) && ((errno = EAGAIN) || (errno = EWOULDBLOCK))) {
write_retry++;
goto try_again;
} /* define what to do if we can't deactivate a link */
Expand Down
17 changes: 17 additions & 0 deletions libknet/host.c
Expand Up @@ -4,6 +4,7 @@
#include <string.h>
#include <errno.h>
#include <pthread.h>
#include <unistd.h>

#include "libknet-private.h"

Expand Down Expand Up @@ -149,6 +150,22 @@ int knet_host_remove(knet_handle_t knet_h, uint16_t node_id)
return ret;
}

int knet_host_dst_cache_update(knet_handle_t knet_h, uint16_t node_id)
{
int write_retry = 0;

try_again:
if (write(knet_h->pipefd[1], &node_id, sizeof(node_id)) != sizeof(node_id)) {
if ((write_retry < 10) && ((errno = EAGAIN) || (errno = EWOULDBLOCK))) {
write_retry++;
goto try_again;
} else {
return -1;
}
}
return 0;
}

/* bcast = 0 -> unicast packet | 1 -> broadcast|mcast */

/* make this bcast/ucast aware */
Expand Down
1 change: 1 addition & 0 deletions libknet/libknet.h
Expand Up @@ -145,6 +145,7 @@ int knet_host_acquire(knet_handle_t knet_h, struct knet_host **host);
int knet_host_get(knet_handle_t knet_h, uint16_t node_id, struct knet_host **host);
int knet_host_release(knet_handle_t knet_h, struct knet_host **host);
int knet_host_remove(knet_handle_t knet_h, uint16_t node_id);
int knet_host_dst_cache_update(knet_handle_t knet_h, uint16_t node_id);

void knet_link_timeout(struct knet_link *lnk, time_t interval, time_t timeout, int precision);

Expand Down

0 comments on commit f7f44e1

Please sign in to comment.