From d3393da62009e49b5724f8ff3d901c244ab8d557 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Sat, 25 Mar 2017 13:16:11 +0100 Subject: ipcpd: normal: Fix compilation issue --- src/ipcpd/normal/fmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ipcpd/normal/fmgr.c') diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index d2966d0c..a8a9ba58 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -494,7 +494,7 @@ int fmgr_np1_alloc(int fd, return -1; } - free(buf->data); + free(buf.data); fmgr.np1_fd_to_cep_id[fd] = cep_id; fmgr.np1_cep_id_to_fd[cep_id] = fd; -- cgit v1.2.3 From 9e3dffb25570fc12dd43f8fad721be40374ea35b Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Mon, 27 Mar 2017 11:53:20 +0200 Subject: ipcpd: normal: Fix locking of PFF This adds fixes the locking of the PFF which was externalized, but not yet correctly updated within the PFF component itself and within the flow manager. --- src/ipcpd/normal/fmgr.c | 9 +++++++++ src/ipcpd/normal/pff.c | 20 +------------------- 2 files changed, 10 insertions(+), 19 deletions(-) (limited to 'src/ipcpd/normal/fmgr.c') diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index a8a9ba58..f78d390a 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -198,13 +198,16 @@ void * fmgr_nm1_sdu_reader(void * o) continue; } + pff_lock(fmgr.pff[i]); fd = pff_nhop(fmgr.pff[i], pci.dst_addr); if (fd < 0) { + pff_unlock(fmgr.pff[i]); log_err("No next hop for %lu", pci.dst_addr); ipcp_flow_del(sdb); continue; } + pff_unlock(fmgr.pff[i]); if (ipcp_flow_write(fd, sdb)) { log_err("Failed to write SDU to fd %d.", @@ -689,12 +692,15 @@ int fmgr_nm1_write_sdu(struct pci * pci, if (pci == NULL || sdb == NULL) return -EINVAL; + pff_lock(fmgr.pff[pci->qos_id]); fd = pff_nhop(fmgr.pff[pci->qos_id], pci->dst_addr); if (fd < 0) { + pff_unlock(fmgr.pff[pci->qos_id]); log_err("Could not get nhop for address %lu", pci->dst_addr); ipcp_flow_del(sdb); return -1; } + pff_unlock(fmgr.pff[pci->qos_id]); if (shm_pci_ser(sdb, pci)) { log_err("Failed to serialize PDU."); @@ -720,11 +726,14 @@ int fmgr_nm1_write_buf(struct pci * pci, if (pci == NULL || buf == NULL || buf->data == NULL) return -EINVAL; + pff_lock(fmgr.pff[pci->qos_id]); fd = pff_nhop(fmgr.pff[pci->qos_id], pci->dst_addr); if (fd < 0) { + pff_unlock(fmgr.pff[pci->qos_id]); log_err("Could not get nhop for address %lu", pci->dst_addr); return -1; } + pff_unlock(fmgr.pff[pci->qos_id]); buffer = shm_pci_ser_buf(buf, pci); if (buffer == NULL) { diff --git a/src/ipcpd/normal/pff.c b/src/ipcpd/normal/pff.c index 77c2c551..c26c2263 100644 --- a/src/ipcpd/normal/pff.c +++ b/src/ipcpd/normal/pff.c @@ -60,9 +60,7 @@ void pff_destroy(struct pff * instance) { assert(instance); - pthread_mutex_lock(&instance->lock); htable_destroy(instance->table); - pthread_mutex_unlock(&instance->lock); pthread_mutex_destroy(&instance->lock); free(instance); @@ -89,13 +87,10 @@ int pff_add(struct pff * instance, uint64_t addr, int fd) return -ENOMEM; *val = fd; - pthread_mutex_lock(&instance->lock); if (htable_insert(instance->table, addr, val)) { - pthread_mutex_unlock(&instance->lock); free(val); return -1; } - pthread_mutex_unlock(&instance->lock); return 0; } @@ -111,19 +106,15 @@ int pff_update(struct pff * instance, uint64_t addr, int fd) return -ENOMEM; *val = fd; - pthread_mutex_lock(&instance->lock); if (htable_delete(instance->table, addr)) { - pthread_mutex_unlock(&instance->lock); free(val); return -1; } if (htable_insert(instance->table, addr, val)) { - pthread_mutex_unlock(&instance->lock); free(val); return -1; } - pthread_mutex_unlock(&instance->lock); return 0; } @@ -132,12 +123,8 @@ int pff_remove(struct pff * instance, uint64_t addr) { assert(instance); - pthread_mutex_lock(&instance->lock); - if (htable_delete(instance->table, addr)) { - pthread_mutex_unlock(&instance->lock); + if (htable_delete(instance->table, addr)) return -1; - } - pthread_mutex_unlock(&instance->lock); return 0; } @@ -146,9 +133,7 @@ void pff_flush(struct pff * instance) { assert(instance); - pthread_mutex_lock(&instance->lock); htable_flush(instance->table); - pthread_mutex_unlock(&instance->lock); } int pff_nhop(struct pff * instance, uint64_t addr) @@ -158,14 +143,11 @@ int pff_nhop(struct pff * instance, uint64_t addr) assert(instance); - pthread_mutex_lock(&instance->lock); j = (int *) htable_lookup(instance->table, addr); if (j == NULL) { - pthread_mutex_unlock(&instance->lock); return -1; } fd = *j; - pthread_mutex_unlock(&instance->lock); return fd; } -- cgit v1.2.3 From 48f12c6466c14f51bc3a2bba9b06772207e9ef33 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Mon, 27 Mar 2017 14:12:41 +0200 Subject: ipcpd: normal: Call shm_pci_init on fmgr init The shm PCI was never initialized during flow manager init. This commit will do that, and initialize the pdu length correctly as well, since it was not being written into the RIB, nor read in shm_pci_init. --- src/ipcpd/normal/fmgr.c | 6 ++++++ src/ipcpd/normal/main.c | 13 ++++++++++++- src/ipcpd/normal/shm_pci.c | 20 +++++++++++--------- 3 files changed, 29 insertions(+), 10 deletions(-) (limited to 'src/ipcpd/normal/fmgr.c') diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index f78d390a..5a1bd842 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -296,6 +296,12 @@ int fmgr_init(void) } } + if (shm_pci_init()) { + log_err("Failed to init shm pci."); + fmgr_destroy_flows(); + return -1; + } + memset(&info, 0, sizeof(info)); strcpy(info.ae_name, DT_AE); diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c index 41e0544d..ef7f07cf 100644 --- a/src/ipcpd/normal/main.c +++ b/src/ipcpd/normal/main.c @@ -85,6 +85,7 @@ static int boot_components(void) char buf[256]; ssize_t len; enum pol_addr_auth pa; + char path[RIB_MAX_PATH_LEN + 1]; len = rib_read(DIF_PATH, &buf, 256); if (len < 0) { @@ -108,7 +109,6 @@ static int boot_components(void) if (rib_read(BOOT_PATH "/addr_auth/type", &pa, sizeof(pa)) != sizeof(pa)) { log_err("Failed to read policy for address authority."); - connmgr_fini(); return -1; } @@ -124,6 +124,14 @@ static int boot_components(void) return -1; } + path[0] = '\0'; + rib_path_append(rib_path_append(path, MEMBERS_NAME), ipcpi.name); + if (rib_write(path, &ipcpi.dt_addr, sizeof(&ipcpi.dt_addr))) { + log_err("Failed to write address to member object."); + addr_auth_fini(); + return -1; + } + log_dbg("IPCP got address %" PRIu64 ".", ipcpi.dt_addr); log_dbg("Starting ribmgr."); @@ -342,6 +350,9 @@ static int normal_ipcp_bootstrap(struct dif_config * conf) rib_write(BOOT_PATH "/dt/const/seqno_size", &conf->seqno_size, sizeof(conf->seqno_size)) || + rib_write(BOOT_PATH "/dt/const/pdu_length_size", + &conf->pdu_length_size, + sizeof(conf->pdu_length_size)) || rib_write(BOOT_PATH "/dt/const/has_ttl", &conf->has_ttl, sizeof(conf->has_ttl)) || diff --git a/src/ipcpd/normal/shm_pci.c b/src/ipcpd/normal/shm_pci.c index 001463eb..e6cd1042 100644 --- a/src/ipcpd/normal/shm_pci.c +++ b/src/ipcpd/normal/shm_pci.c @@ -88,30 +88,32 @@ int shm_pci_init(void) /* read dt constants from the RIB */ if (rib_read(BOOT_PATH "/dt/const/addr_size", &pci_info.dtc.addr_size, - sizeof(pci_info.dtc.addr_size)) || + sizeof(pci_info.dtc.addr_size)) < 0 || rib_read(BOOT_PATH "/dt/const/cep_id_size", &pci_info.dtc.cep_id_size, - sizeof(pci_info.dtc.cep_id_size)) || + sizeof(pci_info.dtc.cep_id_size)) < 0 || rib_read(BOOT_PATH "/dt/const/seqno_size", &pci_info.dtc.seqno_size, - sizeof(pci_info.dtc.seqno_size)) || + sizeof(pci_info.dtc.seqno_size)) < 0 || + rib_read(BOOT_PATH "/dt/const/pdu_length_size", + &pci_info.dtc.pdu_length_size, + sizeof(pci_info.dtc.pdu_length_size)) < 0 || rib_read(BOOT_PATH "/dt/const/has_ttl", &pci_info.dtc.has_ttl, - sizeof(pci_info.dtc.has_ttl)) || + sizeof(pci_info.dtc.has_ttl)) < 0 || rib_read(BOOT_PATH "/dt/const/has_chk", &pci_info.dtc.has_chk, - sizeof(pci_info.dtc.has_chk)) || + sizeof(pci_info.dtc.has_chk)) < 0 || rib_read(BOOT_PATH "/dt/const/min_pdu_size", &pci_info.dtc.min_pdu_size, - sizeof(pci_info.dtc.min_pdu_size)) || + sizeof(pci_info.dtc.min_pdu_size)) < 0 || rib_read(BOOT_PATH "/dt/const/max_pdu_size", &pci_info.dtc.max_pdu_size, - sizeof(pci_info.dtc.max_pdu_size))) + sizeof(pci_info.dtc.max_pdu_size)) < 0) return -1; pci_info.dst_addr_o = PDU_TYPE_SIZE; pci_info.src_addr_o = pci_info.dst_addr_o + pci_info.dtc.addr_size; - pci_info.dst_cep_id_o = pci_info.dst_addr_o + pci_info.dtc.addr_size; pci_info.dst_cep_id_o = pci_info.src_addr_o + pci_info.dtc.addr_size; pci_info.src_cep_id_o = pci_info.dst_cep_id_o + pci_info.dtc.cep_id_size; @@ -132,7 +134,7 @@ int shm_pci_init(void) } void shm_pci_fini(void) { - return ; + return; } int shm_pci_ser(struct shm_du_buff * sdb, -- cgit v1.2.3