summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/ouroboros/ipcp-dev.h6
-rw-r--r--src/ipcpd/broadcast/main.c4
-rw-r--r--src/ipcpd/eth/eth.c6
-rw-r--r--src/ipcpd/local/main.c35
-rw-r--r--src/ipcpd/normal/fa.c3
-rw-r--r--src/ipcpd/normal/main.c4
-rw-r--r--src/ipcpd/udp/main.c35
-rw-r--r--src/lib/dev.c10
8 files changed, 48 insertions, 55 deletions
diff --git a/include/ouroboros/ipcp-dev.h b/include/ouroboros/ipcp-dev.h
index 923794d0..bdeb75d6 100644
--- a/include/ouroboros/ipcp-dev.h
+++ b/include/ouroboros/ipcp-dev.h
@@ -26,11 +26,9 @@
#ifndef OUROBOROS_IPCP_DEV_H
#define OUROBOROS_IPCP_DEV_H
-int ipcp_create_r(pid_t pid,
- int result);
+int ipcp_create_r(int result);
-int ipcp_flow_req_arr(pid_t pid,
- const uint8_t * dst,
+int ipcp_flow_req_arr(const uint8_t * dst,
size_t len,
qosspec_t qs);
diff --git a/src/ipcpd/broadcast/main.c b/src/ipcpd/broadcast/main.c
index c1e5d4ab..71d1ddaa 100644
--- a/src/ipcpd/broadcast/main.c
+++ b/src/ipcpd/broadcast/main.c
@@ -304,7 +304,7 @@ int main(int argc,
goto fail_boot;
}
- if (ipcp_create_r(getpid(), 0)) {
+ if (ipcp_create_r(0)) {
log_err("Failed to notify IRMd we are initialized.");
ipcp_set_state(IPCP_NULL);
goto fail_create_r;
@@ -342,6 +342,6 @@ int main(int argc,
fail_rib_init:
ipcp_fini();
fail_init:
- ipcp_create_r(getpid(), -1);
+ ipcp_create_r(-1);
exit(EXIT_FAILURE);
}
diff --git a/src/ipcpd/eth/eth.c b/src/ipcpd/eth/eth.c
index cceca42c..04130d6f 100644
--- a/src/ipcpd/eth/eth.c
+++ b/src/ipcpd/eth/eth.c
@@ -578,7 +578,7 @@ static int eth_ipcp_req(uint8_t * r_addr,
}
/* reply to IRM, called under lock to prevent race */
- fd = ipcp_flow_req_arr(getpid(), dst, ipcp_dir_hash_len(), qs);
+ fd = ipcp_flow_req_arr(dst, ipcp_dir_hash_len(), qs);
if (fd < 0) {
pthread_mutex_unlock(&ipcpi.alloc_lock);
log_err("Could not get new flow from IRMd.");
@@ -1804,7 +1804,7 @@ int main(int argc,
goto fail_boot;
}
- if (ipcp_create_r(getpid(), 0)) {
+ if (ipcp_create_r(0)) {
log_err("Failed to notify IRMd we are initialized.");
ipcp_set_state(IPCP_NULL);
goto fail_create_r;
@@ -1846,6 +1846,6 @@ int main(int argc,
fail_data_init:
ipcp_fini();
fail_init:
- ipcp_create_r(getpid(), -1);
+ ipcp_create_r(-1);
exit(EXIT_FAILURE);
}
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index cd90ab77..f40d0d26 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -212,7 +212,7 @@ static int ipcp_local_flow_alloc(int fd,
assert(ipcpi.alloc_id == -1);
- out_fd = ipcp_flow_req_arr(getpid(), dst, ipcp_dir_hash_len(), qs);
+ out_fd = ipcp_flow_req_arr(dst, ipcp_dir_hash_len(), qs);
if (out_fd < 0) {
pthread_mutex_unlock(&ipcpi.alloc_lock);
log_dbg("Flow allocation failed: %d", out_fd);
@@ -333,33 +333,22 @@ static struct ipcp_ops local_ops = {
int main(int argc,
char * argv[])
{
- if (ipcp_init(argc, argv, &local_ops) < 0) {
- ipcp_create_r(getpid(), -1);
- exit(EXIT_FAILURE);
- }
+ if (ipcp_init(argc, argv, &local_ops) < 0)
+ goto fail_init;
if (local_data_init() < 0) {
log_err("Failed to init local data.");
- ipcp_create_r(getpid(), -1);
- ipcp_fini();
- exit(EXIT_FAILURE);
+ goto fail_data_init;
}
if (ipcp_boot() < 0) {
log_err("Failed to boot IPCP.");
- ipcp_create_r(getpid(), -1);
- local_data_fini();
- ipcp_fini();
- exit(EXIT_FAILURE);
+ goto fail_boot;
}
- if (ipcp_create_r(getpid(), 0)) {
+ if (ipcp_create_r(0)) {
log_err("Failed to notify IRMd we are initialized.");
- ipcp_set_state(IPCP_NULL);
- ipcp_shutdown();
- local_data_fini();
- ipcp_fini();
- exit(EXIT_FAILURE);
+ goto fail_create_r;
}
ipcp_shutdown();
@@ -374,4 +363,14 @@ int main(int argc,
ipcp_fini();
exit(EXIT_SUCCESS);
+ fail_create_r:
+ ipcp_set_state(IPCP_NULL);
+ ipcp_shutdown();
+ fail_boot:
+ local_data_fini();
+ fail_data_init:
+ ipcp_fini();
+ fail_init:
+ ipcp_create_r(-1);
+ exit(EXIT_FAILURE);
}
diff --git a/src/ipcpd/normal/fa.c b/src/ipcpd/normal/fa.c
index 30d87df5..e03467c2 100644
--- a/src/ipcpd/normal/fa.c
+++ b/src/ipcpd/normal/fa.c
@@ -218,8 +218,7 @@ static void * fa_handle_packet(void * o)
qs.in_order = msg->in_order;
qs.max_gap = ntoh32(msg->max_gap);
- fd = ipcp_flow_req_arr(getpid(),
- (uint8_t *) (msg + 1),
+ fd = ipcp_flow_req_arr((uint8_t *) (msg + 1),
ipcp_dir_hash_len(),
qs);
if (fd < 0) {
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index 7a453a9e..28fc8c5a 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -334,7 +334,7 @@ int main(int argc,
goto fail_boot;
}
- if (ipcp_create_r(getpid(), 0)) {
+ if (ipcp_create_r(0)) {
log_err("Failed to notify IRMd we are initialized.");
ipcp_set_state(IPCP_NULL);
goto fail_create_r;
@@ -373,6 +373,6 @@ int main(int argc,
fail_rib_init:
ipcp_fini();
fail_init:
- ipcp_create_r(getpid(), -1);
+ ipcp_create_r(-1);
exit(EXIT_FAILURE);
}
diff --git a/src/ipcpd/udp/main.c b/src/ipcpd/udp/main.c
index 457dc789..f45a18cb 100644
--- a/src/ipcpd/udp/main.c
+++ b/src/ipcpd/udp/main.c
@@ -344,7 +344,7 @@ static int ipcp_udp_port_req(struct sockaddr_in * c_saddr,
}
/* reply to IRM */
- fd = ipcp_flow_req_arr(getpid(), dst, ipcp_dir_hash_len(), qs);
+ fd = ipcp_flow_req_arr(dst, ipcp_dir_hash_len(), qs);
if (fd < 0) {
pthread_mutex_unlock(&ipcpi.alloc_lock);
log_err("Could not get new flow from IRMd.");
@@ -1191,33 +1191,22 @@ static struct ipcp_ops udp_ops = {
int main(int argc,
char * argv[])
{
- if (ipcp_init(argc, argv, &udp_ops) < 0) {
- ipcp_create_r(getpid(), -1);
- exit(EXIT_FAILURE);
- }
+ if (ipcp_init(argc, argv, &udp_ops) < 0)
+ goto fail_init;
if (udp_data_init() < 0) {
log_err("Failed to init udp data.");
- ipcp_create_r(getpid(), -1);
- ipcp_fini();
- exit(EXIT_FAILURE);
+ goto fail_data_init;
}
if (ipcp_boot() < 0) {
log_err("Failed to boot IPCP.");
- ipcp_create_r(getpid(), -1);
- udp_data_fini();
- ipcp_fini();
- exit(EXIT_FAILURE);
+ goto fail_boot;
}
- if (ipcp_create_r(getpid(), 0)) {
+ if (ipcp_create_r(0)) {
log_err("Failed to notify IRMd we are initialized.");
- ipcp_set_state(IPCP_NULL);
- ipcp_shutdown();
- udp_data_fini();
- ipcp_fini();
- exit(EXIT_FAILURE);
+ goto fail_create_r;
}
ipcp_shutdown();
@@ -1237,4 +1226,14 @@ int main(int argc,
ipcp_fini();
exit(EXIT_SUCCESS);
+ fail_create_r:
+ ipcp_set_state(IPCP_NULL);
+ ipcp_shutdown();
+ fail_boot:
+ udp_data_fini();
+ fail_data_init:
+ ipcp_fini();
+ fail_init:
+ ipcp_create_r(-1);
+ exit(EXIT_FAILURE);
}
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 297c85f7..10b34e4e 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -1262,8 +1262,7 @@ int np1_flow_resp(int flow_id)
return fd;
}
-int ipcp_create_r(pid_t pid,
- int result)
+int ipcp_create_r(int result)
{
irm_msg_t msg = IRM_MSG__INIT;
irm_msg_t * recv_msg;
@@ -1271,7 +1270,7 @@ int ipcp_create_r(pid_t pid,
msg.code = IRM_MSG_CODE__IPCP_CREATE_R;
msg.has_pid = true;
- msg.pid = pid;
+ msg.pid = getpid();
msg.has_result = true;
msg.result = result;
@@ -1290,8 +1289,7 @@ int ipcp_create_r(pid_t pid,
return ret;
}
-int ipcp_flow_req_arr(pid_t pid,
- const uint8_t * dst,
+int ipcp_flow_req_arr(const uint8_t * dst,
size_t len,
qosspec_t qs)
{
@@ -1304,7 +1302,7 @@ int ipcp_flow_req_arr(pid_t pid,
msg.code = IRM_MSG_CODE__IPCP_FLOW_REQ_ARR;
msg.has_pid = true;
- msg.pid = pid;
+ msg.pid = getpid();
msg.has_hash = true;
msg.hash.len = len;
msg.hash.data = (uint8_t *) dst;