Skip to content

Commit

Permalink
Merge pull request #325 from kronosnet/kill-hostinfo
Browse files Browse the repository at this point in the history
[cleanup] remove unused infrastructure to send HOSTINFO messages
  • Loading branch information
fabbione committed Sep 21, 2020
2 parents 4065ab3 + 2341b90 commit 9f56dbc
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 257 deletions.
21 changes: 0 additions & 21 deletions libknet/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,6 @@ static int _init_socks(knet_handle_t knet_h)
{
int savederrno = 0;

if (_init_socketpair(knet_h, knet_h->hostsockfd)) {
savederrno = errno;
log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize internal hostsockpair: %s",
strerror(savederrno));
goto exit_fail;
}

if (_init_socketpair(knet_h, knet_h->dstsockfd)) {
savederrno = errno;
log_err(knet_h, KNET_SUB_HANDLE, "Unable to initialize internal dstsockpair: %s",
Expand All @@ -191,7 +184,6 @@ static int _init_socks(knet_handle_t knet_h)
static void _close_socks(knet_handle_t knet_h)
{
_close_socketpair(knet_h, knet_h->dstsockfd);
_close_socketpair(knet_h, knet_h->hostsockfd);
}

static int _init_buffers(knet_handle_t knet_h)
Expand Down Expand Up @@ -406,18 +398,6 @@ static int _init_epolls(knet_handle_t knet_h)
goto exit_fail;
}

memset(&ev, 0, sizeof(struct epoll_event));
ev.events = EPOLLIN;
ev.data.fd = knet_h->hostsockfd[0];

if (epoll_ctl(knet_h->send_to_links_epollfd,
EPOLL_CTL_ADD, knet_h->hostsockfd[0], &ev)) {
savederrno = errno;
log_err(knet_h, KNET_SUB_HANDLE, "Unable to add hostsockfd[0] to epoll pool: %s",
strerror(savederrno));
goto exit_fail;
}

memset(&ev, 0, sizeof(struct epoll_event));
ev.events = EPOLLIN;
ev.data.fd = knet_h->dstsockfd[0];
Expand Down Expand Up @@ -453,7 +433,6 @@ static void _close_epolls(knet_handle_t knet_h)
}
}

epoll_ctl(knet_h->send_to_links_epollfd, EPOLL_CTL_DEL, knet_h->hostsockfd[0], &ev);
epoll_ctl(knet_h->dst_link_handler_epollfd, EPOLL_CTL_DEL, knet_h->dstsockfd[0], &ev);
close(knet_h->send_to_links_epollfd);
close(knet_h->recv_from_links_epollfd);
Expand Down
21 changes: 0 additions & 21 deletions libknet/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,27 +527,6 @@ int knet_host_enable_status_change_notify(knet_handle_t knet_h,
return 0;
}

int _send_host_info(knet_handle_t knet_h, const void *data, const size_t datalen)
{
ssize_t ret = 0;

if (knet_h->fini_in_progress) {
return 0;
}

ret = sendto(knet_h->hostsockfd[1], data, datalen, MSG_DONTWAIT | MSG_NOSIGNAL, NULL, 0);
if (ret < 0) {
log_debug(knet_h, KNET_SUB_HOST, "Unable to write data to hostpipe. Error: %s", strerror(errno));
return -1;
}
if ((size_t)ret != datalen) {
log_debug(knet_h, KNET_SUB_HOST, "Unable to write all data to hostpipe. Expected: %zu, Written: %zd.", datalen, ret);
return -1;
}

return 0;
}

static void _clear_cbuffers(struct knet_host *host, seq_num_t rx_seq_num)
{
int i;
Expand Down
1 change: 0 additions & 1 deletion libknet/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
int _seq_num_lookup(struct knet_host *host, seq_num_t seq_num, int defrag_buf, int clear_buf);
void _seq_num_set(struct knet_host *host, seq_num_t seq_num, int defrag_buf);

int _send_host_info(knet_handle_t knet_h, const void *data, const size_t datalen);
int _host_dstcache_update_async(knet_handle_t knet_h, struct knet_host *host);
int _host_dstcache_update_sync(knet_handle_t knet_h, struct knet_host *host);

Expand Down
3 changes: 0 additions & 3 deletions libknet/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

#define KNET_EPOLL_MAX_EVENTS KNET_DATAFD_MAX + 1

#define KNET_INTERNAL_DATA_CHANNEL KNET_DATAFD_MAX

/*
* Size of threads stack. Value is choosen by experimenting, how much is needed
* to sucesfully finish test suite, and at the time of writing patch it was
Expand Down Expand Up @@ -171,7 +169,6 @@ struct knet_handle {
struct knet_sock sockfd[KNET_DATAFD_MAX + 1];
int logfd;
uint8_t log_levels[KNET_MAX_SUBSYSTEMS];
int hostsockfd[2];
int dstsockfd[2];
int send_to_links_epollfd;
int recv_from_links_epollfd;
Expand Down
73 changes: 0 additions & 73 deletions libknet/onwire.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,78 +19,6 @@

#include "libknet.h"

#if 0

/*
* for future protocol extension (re-switching table calculation)
*/

struct knet_hinfo_link {
uint8_t khl_link_id;
uint8_t khl_link_dynamic;
uint8_t khl_link_priority;
uint64_t khl_link_latency;
char khl_link_dst_ipaddr[KNET_MAX_HOST_LEN];
char khl_link_dst_port[KNET_MAX_PORT_LEN];
} __attribute__((packed));

struct knet_hinfo_link_table {
knet_node_id_t khlt_node_id;
uint8_t khlt_local; /* we have this node connected locally */
struct knet_hinfo_link khlt_link[KNET_MAX_LINK]; /* info we send about each link in the node */
} __attribute__((packed));

struct link_table {
knet_node_id_t khdt_host_entries;
uint8_t khdt_host_maps[0]; /* array of knet_hinfo_link_table[khdt_host_entries] */
} __attribute__((packed));
#endif

#define KNET_HOSTINFO_LINK_STATUS_DOWN 0
#define KNET_HOSTINFO_LINK_STATUS_UP 1

struct knet_hostinfo_payload_link_status {
uint8_t khip_link_status_link_id; /* link id */
uint8_t khip_link_status_status; /* up/down status */
} __attribute__((packed));

/*
* union to reference possible individual payloads
*/

union knet_hostinfo_payload {
struct knet_hostinfo_payload_link_status knet_hostinfo_payload_link_status;
} __attribute__((packed));

/*
* due to the nature of knet_hostinfo, we are currently
* sending those data as part of knet_header_payload_data.khp_data_userdata
* and avoid a union that increses knet_header_payload_data size
* unnecessarely.
* This might change later on depending on how we implement
* host info exchange
*/

#define KNET_HOSTINFO_TYPE_LINK_UP_DOWN 0 // UNUSED
#define KNET_HOSTINFO_TYPE_LINK_TABLE 1 // NOT IMPLEMENTED

#define KNET_HOSTINFO_UCAST 0 /* send info to a specific host */
#define KNET_HOSTINFO_BCAST 1 /* send info to all known / connected hosts */

struct knet_hostinfo {
uint8_t khi_type; /* type of hostinfo we are sending */
uint8_t khi_bcast; /* hostinfo destination bcast/ucast */
knet_node_id_t khi_dst_node_id;/* used only if in ucast mode */
union knet_hostinfo_payload khi_payload;
} __attribute__((packed));

#define KNET_HOSTINFO_ALL_SIZE sizeof(struct knet_hostinfo)
#define KNET_HOSTINFO_SIZE (KNET_HOSTINFO_ALL_SIZE - sizeof(union knet_hostinfo_payload))
#define KNET_HOSTINFO_LINK_STATUS_SIZE (KNET_HOSTINFO_SIZE + sizeof(struct knet_hostinfo_payload_link_status))

#define khip_link_status_status khi_payload.knet_hostinfo_payload_link_status.khip_link_status_status
#define khip_link_status_link_id khi_payload.knet_hostinfo_payload_link_status.khip_link_status_link_id

/*
* typedef uint64_t seq_num_t;
* #define SEQ_MAX UINT64_MAX
Expand Down Expand Up @@ -152,7 +80,6 @@ union knet_header_payload {
#define KNET_HEADER_VERSION 0x01 /* we currently support only one version */

#define KNET_HEADER_TYPE_DATA 0x00 /* pure data packet */
#define KNET_HEADER_TYPE_HOST_INFO 0x01 /* host status information pckt */

#define KNET_HEADER_TYPE_PMSK 0x80 /* packet mask */
#define KNET_HEADER_TYPE_PING 0x81 /* heartbeat */
Expand Down
4 changes: 0 additions & 4 deletions libknet/tests/pckt_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ int main(void)
printf("KNET_HEADER_PING_SIZE: %zu (%zu)\n", KNET_HEADER_PING_SIZE, sizeof(struct knet_header_payload_ping));
printf("KNET_HEADER_PMTUD_SIZE: %zu (%zu)\n", KNET_HEADER_PMTUD_SIZE, sizeof(struct knet_header_payload_pmtud));
printf("KNET_HEADER_DATA_SIZE: %zu (%zu)\n", KNET_HEADER_DATA_SIZE, sizeof(struct knet_header_payload_data));
printf("\n");
printf("KNET_HOSTINFO_ALL_SIZE: %zu\n", KNET_HOSTINFO_ALL_SIZE);
printf("KNET_HOSTINFO_SIZE: %zu\n", KNET_HOSTINFO_SIZE);
printf("KNET_HOSTINFO_LINK_STATUS_SIZE: %zu (%zu)\n", KNET_HOSTINFO_LINK_STATUS_SIZE, sizeof(struct knet_hostinfo_payload_link_status));

return 0;
}

0 comments on commit 9f56dbc

Please sign in to comment.