diff options
Diffstat (limited to 'ctrl')
-rw-r--r-- | ctrl/facemgr/src/interfaces/netlink/netlink.c | 24 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/api.c | 58 |
2 files changed, 54 insertions, 28 deletions
diff --git a/ctrl/facemgr/src/interfaces/netlink/netlink.c b/ctrl/facemgr/src/interfaces/netlink/netlink.c index b57a4e480..a1affd719 100644 --- a/ctrl/facemgr/src/interfaces/netlink/netlink.c +++ b/ctrl/facemgr/src/interfaces/netlink/netlink.c @@ -425,7 +425,7 @@ int nl_callback(interface_t * interface, int fd, void * unused) break; } - DEBUG("Interface %s: address was removed", interface_name); + DEBUG("[NETLINK] Interface %s: address was removed", interface_name); if (facelet) { facelet_set_event(facelet, FACELET_EVENT_SET_DOWN); facelet_set_attr_clean(facelet); @@ -446,7 +446,7 @@ int nl_callback(interface_t * interface, int fd, void * unused) break; } - DEBUG("Interface %s: new address was assigned: %s", interface_name, interface_address); + DEBUG("[NETLINK] Interface %s: new address was assigned: %s", interface_name, interface_address); if (facelet) { facelet_set_event(facelet, FACELET_EVENT_UPDATE); @@ -468,7 +468,7 @@ int nl_callback(interface_t * interface, int fd, void * unused) break; } - DEBUG("Network interface %s was removed", interface_name); + DEBUG("[NETLINK] Network interface %s was removed", interface_name); if (!facelet) break; @@ -495,7 +495,7 @@ int nl_callback(interface_t * interface, int fd, void * unused) // UP NOT RUNNING // DOWN NOT RUNNING #if 1 - DEBUG("New network interface %s, state: %s %s", interface_name, + DEBUG("[NETLINK] New network interface %s, state: %s %s", interface_name, up ? "UP" : "DOWN", running ? "RUNNING" : "NOT_RUNNING"); #endif @@ -517,14 +517,14 @@ int nl_callback(interface_t * interface, int fd, void * unused) facelet_set_family(facelet6, AF_INET6); interface_raise_event(interface, facelet6); #endif - } else { -#if 1 - facelet_set_event(facelet, FACELET_EVENT_SET_DOWN); - facelet_set_attr_clean(facelet); - interface_raise_event(interface, facelet); -#else - facelet_free(facelet); -#endif +// } else { +//#if 1 +// facelet_set_event(facelet, FACELET_EVENT_SET_DOWN); +// facelet_set_attr_clean(facelet); +// interface_raise_event(interface, facelet); +//#else +// facelet_free(facelet); +//#endif } break; } diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c index b836ef800..5e8536480 100644 --- a/ctrl/libhicnctrl/src/api.c +++ b/ctrl/libhicnctrl/src/api.c @@ -26,6 +26,12 @@ #include <sys/socket.h> // socket #include <unistd.h> // close, fcntl #include <fcntl.h> // fcntl +#include <sys/types.h> // getpid +#include <unistd.h> // getpid +#ifdef __linux__ +#include <sys/syscall.h> +#define gettid() syscall(SYS_gettid) +#endif /* __linux__ */ #include <hicn/ctrl/api.h> #include <hicn/ctrl/commands.h> @@ -435,7 +441,11 @@ hc_sock_parse_url(const char * url, struct sockaddr * sa) /* FIXME URL parsing is currently not implemented */ assert(!url); - srand(time(NULL)); +#ifdef __linux__ + srand(time(NULL) ^ getpid() ^ gettid()); +#else + srand(time(NULL) ^ getpid()); +#endif /* __linux__ */ /* * A temporary solution is to inspect the sa_family fields of the passed in @@ -704,16 +714,22 @@ hc_sock_process(hc_sock_t * s, hc_data_t ** data) } else { int rc; rc = hc_data_ensure_available(s->cur_request->data, num_chunks); - if (rc < 0) - return -99; + if (rc < 0) { + ERROR("[hc_sock_process] Error in hc_data_ensure_available"); + return -99; + } for (int i = 0; i < num_chunks; i++) { u8 * dst = hc_data_get_next(s->cur_request->data); - if (!dst) - return -99; + if (!dst) { + ERROR("[hc_sock_process] Error in hc_data_get_next"); + return -99; + } rc = s->cur_request->parse(s->buf + s->roff + i * s->cur_request->data->in_element_size, dst); - if (rc < 0) + if (rc < 0) { + ERROR("[hc_sock_process] Error in parse"); err = -99; /* FIXME we let the loop complete (?) */ + } s->cur_request->data->size++; } } @@ -757,9 +773,8 @@ hc_sock_callback(hc_sock_t * s, hc_data_t ** pdata) for (;;) { int n = hc_sock_recv(s); - if (n == 0) { + if (n == 0) goto ERR_EOF; - } if (n < 0) { switch(errno) { case ECONNRESET: @@ -858,7 +873,7 @@ hc_execute_command(hc_sock_t * s, hc_msg_t * msg, size_t msg_len, } int seq = hc_sock_get_next_seq(s); - + /* Create state used to process the request */ hc_sock_request_t * request = NULL; request = hc_sock_request_create(seq, data, params->parse); @@ -887,7 +902,10 @@ hc_execute_command(hc_sock_t * s, hc_msg_t * msg, size_t msg_len, * several times before success... shall we alternate between blocking * and non-blocking mode ? */ - if (hc_sock_recv(s) < 0) + int n = hc_sock_recv(s); + if (n == 0) + goto ERR_EOF; + if (n < 0) continue; //break; int rc = hc_sock_process(s, pdata); switch(rc) { @@ -898,15 +916,18 @@ hc_execute_command(hc_sock_t * s, hc_msg_t * msg, size_t msg_len, break; case -99: ERROR("[hc_execute_command] Error processing socket results"); - goto ERR_PROCESS; + goto ERR; break; default: ERROR("[hc_execute_command] Unexpected return value"); - goto ERR_PROCESS; + goto ERR; } } +ERR_EOF: ret = data->ret; + if (!data->complete) + return -1; if (!pdata) hc_data_free(data); @@ -915,6 +936,7 @@ hc_execute_command(hc_sock_t * s, hc_msg_t * msg, size_t msg_len, ERR_PROCESS: ERR_MAP: hc_sock_request_free(request); +ERR: ERR_REQUEST: hc_data_free(data); ERR_DATA: @@ -1939,12 +1961,16 @@ hc_route_parse(void * in, hc_route_t * route) { list_routes_command * cmd = (list_routes_command *) in; - if (!IS_VALID_ADDR_TYPE(cmd->addressType)) - return -1; + if (!IS_VALID_ADDR_TYPE(cmd->addressType)) { + ERROR("[hc_route_parse] Invalid address type"); + return -1; + } int family = map_from_addr_type[cmd->addressType]; - if (!IS_VALID_FAMILY(family)) - return -1; + if (!IS_VALID_FAMILY(family)) { + ERROR("[hc_route_parse] Invalid address family"); + return -1; + } *route = (hc_route_t) { .face_id = cmd->connid, |