From 6785ca65ab48f1a29914c1784a24009964ec4720 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 9 Feb 2017 16:49:56 +0100 Subject: ipcpd, lib: Report IPCP creation failure The IPCP will now respond with an ipcp_create_r message when it fails, informing the IRMd. Also adds some const qualifiers in the public headers and fixes some formatting in dev.c. --- src/ipcpd/local/main.c | 5 ++++- src/ipcpd/normal/main.c | 6 +++++- src/ipcpd/normal/pol/flat.c | 10 +--------- src/ipcpd/shim-eth-llc/main.c | 5 ++++- src/ipcpd/shim-udp/main.c | 5 ++++- 5 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src/ipcpd') diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index b49e1612..ccbd6acb 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -353,11 +353,13 @@ int main(int argc, if (ipcp_init(argc, argv, THIS_TYPE, &local_ops) < 0) { log_err("Failed to init IPCP."); + ipcp_create_r(getpid(), -1); exit(EXIT_FAILURE); } if (local_data_init() < 0) { log_err("Failed to init local data."); + ipcp_create_r(getpid(), -1); ipcp_fini(); exit(EXIT_FAILURE); } @@ -366,6 +368,7 @@ int main(int argc, if (ipcp_boot() < 0) { log_err("Failed to boot IPCP."); + ipcp_create_r(getpid(), -1); local_data_fini(); ipcp_fini(); exit(EXIT_FAILURE); @@ -373,7 +376,7 @@ int main(int argc, pthread_sigmask(SIG_UNBLOCK, &sigset, NULL); - if (ipcp_create_r(getpid())) { + if (ipcp_create_r(getpid(), 0)) { log_err("Failed to notify IRMd we are initialized."); ipcp_set_state(IPCP_NULL); ipcp_shutdown(); diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c index 2b30dba3..b69bfe28 100644 --- a/src/ipcpd/normal/main.c +++ b/src/ipcpd/normal/main.c @@ -459,17 +459,20 @@ int main(int argc, if (ipcp_init(argc, argv, THIS_TYPE, &normal_ops) < 0) { log_err("Failed to create instance."); + ipcp_create_r(getpid(), -1); exit(EXIT_FAILURE); } if (irm_bind_api(getpid(), ipcpi.name)) { log_err("Failed to bind AP name."); + ipcp_create_r(getpid(), -1); ipcp_fini(); exit(EXIT_FAILURE); } if (rib_init()) { log_err("Failed to initialize RIB."); + ipcp_create_r(getpid(), -1); irm_unbind_api(getpid(), ipcpi.name); ipcp_fini(); exit(EXIT_FAILURE); @@ -479,6 +482,7 @@ int main(int argc, if (ipcp_boot() < 0) { log_err("Failed to boot IPCP."); + ipcp_create_r(getpid(), -1); rib_fini(); irm_unbind_api(getpid(), ipcpi.name); ipcp_fini(); @@ -487,7 +491,7 @@ int main(int argc, pthread_sigmask(SIG_UNBLOCK, &sigset, NULL); - if (ipcp_create_r(getpid())) { + if (ipcp_create_r(getpid(), 0)) { log_err("Failed to notify IRMd we are initialized."); ipcp_set_state(IPCP_NULL); ipcp_shutdown(); diff --git a/src/ipcpd/normal/pol/flat.c b/src/ipcpd/normal/pol/flat.c index 9ffeb5c7..61b0110c 100644 --- a/src/ipcpd/normal/pol/flat.c +++ b/src/ipcpd/normal/pol/flat.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "ipcp.h" @@ -46,15 +47,6 @@ static void addr_name(char * name, sprintf(name, "%8x", (uint32_t) (addr)); } -#define freepp(type, ptr, len) \ - do { \ - if (len == 0) \ - break; \ - while (len > 0) \ - free(((type **) ptr)[--len]); \ - free(ptr); \ - } while (0); - static int addr_taken(char * name, char ** members, size_t len) diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index 35ec0297..15482f87 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -1129,11 +1129,13 @@ int main(int argc, if (ipcp_init(argc, argv, THIS_TYPE, ð_llc_ops) < 0) { log_err("Failed to init IPCP."); + ipcp_create_r(getpid(), -1); exit(EXIT_FAILURE); } if (eth_llc_data_init() < 0) { log_err("Failed to init shim-eth-llc data."); + ipcp_create_r(getpid(), -1); ipcp_fini(); exit(EXIT_FAILURE); } @@ -1143,6 +1145,7 @@ int main(int argc, if (ipcp_boot() < 0) { log_err("Failed to boot IPCP."); + ipcp_create_r(getpid(), -1); eth_llc_data_fini(); ipcp_fini(); exit(EXIT_FAILURE); @@ -1150,7 +1153,7 @@ int main(int argc, pthread_sigmask(SIG_UNBLOCK, &sigset, NULL); - if (ipcp_create_r(getpid())) { + if (ipcp_create_r(getpid(), 0)) { log_err("Failed to notify IRMd we are initialized."); ipcp_set_state(IPCP_NULL); ipcp_shutdown(); diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index 2a73077c..47628a3e 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -1196,11 +1196,13 @@ int main(int argc, if (ipcp_init(argc, argv, THIS_TYPE, &udp_ops) < 0) { log_err("Failed to init IPCP."); + ipcp_create_r(getpid(), -1); exit(EXIT_FAILURE); } if (udp_data_init() < 0) { log_err("Failed to init shim-udp data."); + ipcp_create_r(getpid(), -1); ipcp_fini(); exit(EXIT_FAILURE); } @@ -1210,6 +1212,7 @@ int main(int argc, if (ipcp_boot() < 0) { log_err("Failed to boot IPCP."); + ipcp_create_r(getpid(), -1); udp_data_fini(); ipcp_fini(); exit(EXIT_FAILURE); @@ -1217,7 +1220,7 @@ int main(int argc, pthread_sigmask(SIG_UNBLOCK, &sigset, NULL); - if (ipcp_create_r(getpid())) { + if (ipcp_create_r(getpid(), 0)) { log_err("Failed to notify IRMd we are initialized."); ipcp_set_state(IPCP_NULL); ipcp_shutdown(); -- cgit v1.2.3