summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/pol
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2018-03-17 14:55:46 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2018-03-19 10:29:21 +0100
commit4230103ff633904c69cc18d861bf42781f57bb64 (patch)
tree9b21ca4a648456863af30e21ea4c7b55ba3ddf77 /src/ipcpd/normal/pol
parentc9747304271f63064687178938bf2a4060ef0180 (diff)
downloadouroboros-4230103ff633904c69cc18d861bf42781f57bb64.tar.gz
ouroboros-4230103ff633904c69cc18d861bf42781f57bb64.zip
lib: Allow disabling partial read
This allows disabling partial reads. It adds a flag FLOWFRNOPART that disables partial reads. Partial read is different from partial delivery (FRCTFPARTIAL), which allows delivery of fragments of an incomplete packet and thus potentially corrupted data. FLOWFRNOPART will never deliver corrupted data (unless FRCTFPARTIAL is also set). If FLOWFRNOPART is set and the buffer provided to flow_read is too small for the SDU, that SDU will be discarded and -EMSGSIZE is returned; Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/ipcpd/normal/pol')
-rw-r--r--src/ipcpd/normal/pol/link_state.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ipcpd/normal/pol/link_state.c b/src/ipcpd/normal/pol/link_state.c
index 7aa7faf7..cfe4faff 100644
--- a/src/ipcpd/normal/pol/link_state.c
+++ b/src/ipcpd/normal/pol/link_state.c
@@ -29,6 +29,7 @@
#include <ouroboros/endian.h>
#include <ouroboros/dev.h>
#include <ouroboros/errno.h>
+#include <ouroboros/fccntl.h>
#include <ouroboros/fqueue.h>
#include <ouroboros/list.h>
#include <ouroboros/logs.h>
@@ -655,7 +656,7 @@ static void * lsreader(void * o)
{
fqueue_t * fq;
int ret;
- uint8_t buf[sizeof(struct lsa) + 1];
+ uint8_t buf[sizeof(struct lsa)];
int fd;
qosspec_t qs;
struct lsa * msg;
@@ -680,7 +681,7 @@ static void * lsreader(void * o)
}
while ((fd = fqueue_next(fq)) >= 0) {
- len = flow_read(fd, buf, sizeof(*msg) + 1);
+ len = flow_read(fd, buf, sizeof(*msg));
if (len <= 0 || len != sizeof(*msg))
continue;
@@ -724,6 +725,7 @@ static void handle_event(void * self,
/* FIXME: Apply correct QoS on graph */
struct conn * c;
qosspec_t qs;
+ int flags;
(void) self;
@@ -759,6 +761,8 @@ static void handle_event(void * self,
flow_event(c->flow_info.fd, false);
break;
case NOTIFY_MGMT_CONN_ADD:
+ fccntl(c->flow_info.fd, FLOWGFLAGS, &flags);
+ fccntl(c->flow_info.fd, FLOWSFLAGS, flags | FLOWFRNOPART);
fset_add(ls.mgmt_set, c->flow_info.fd);
if (lsdb_add_nb(c->conn_info.addr, c->flow_info.fd, NB_MGMT))
log_warn("Failed to add mgmt neighbor to LSDB.");