diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2014-11-03 10:42:55 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2014-11-03 10:42:55 +0100 |
commit | 6f8bbaa10bbd21729d0b62a5878febcbee2c0811 (patch) | |
tree | 5b20f464388a529084e53b24406b99df2210264d /proto/ospf/iface.c | |
parent | 88a183c6c9a2b86b52f67e87bbc8b7edd32670c6 (diff) |
Fininshing integrated OSPF.
Diffstat (limited to 'proto/ospf/iface.c')
-rw-r--r-- | proto/ospf/iface.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c index e14f09cb..4dfb74fb 100644 --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@ -58,6 +58,12 @@ ifa_bufsize(struct ospf_iface *ifa) return MAX(bsize, ifa->tx_length); } +static inline uint +ifa_flood_queue_size(struct ospf_iface *ifa) +{ + return ifa->tx_length / 24; +} + int ospf_iface_assure_bufsize(struct ospf_iface *ifa, uint plen) { @@ -476,6 +482,9 @@ ospf_iface_add(struct object_lock *lock) if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_NBMA)) ifa->wait_timer = tm_new_set(ifa->pool, wait_timer_hook, ifa, 0, 0); + + ifa->flood_queue_size = ifa_flood_queue_size(ifa); + ifa->flood_queue = mb_allocz(ifa->pool, ifa->flood_queue_size * sizeof(void *)); } /* Do iface UP, unless there is no link and we use link detection */ @@ -679,6 +688,9 @@ ospf_iface_new_vlink(struct ospf_proto *p, struct ospf_iface_patt *ip) add_tail(&p->iface_list, NODE ifa); ifa->hello_timer = tm_new_set(ifa->pool, hello_timer_hook, ifa, 0, ifa->helloint); + + ifa->flood_queue_size = ifa_flood_queue_size(ifa); + ifa->flood_queue = mb_allocz(ifa->pool, ifa->flood_queue_size * sizeof(void *)); } static void @@ -693,6 +705,20 @@ ospf_iface_change_timer(timer *tm, uint val) tm_start(tm, val); } +static inline void +ospf_iface_update_flood_queue_size(struct ospf_iface *ifa) +{ + uint old_size = ifa->flood_queue_size; + uint new_size = ifa_flood_queue_size(ifa); + + if (new_size <= old_size) + return; + + ifa->flood_queue_size = new_size; + ifa->flood_queue = mb_realloc(ifa->flood_queue, new_size * sizeof(void *)); + bzero(ifa->flood_queue + old_size, (new_size - old_size) * sizeof(void *)); +} + int ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new) { @@ -739,6 +765,7 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new) ifname, ifa->rxmtint, new->rxmtint); ifa->rxmtint = new->rxmtint; + /* FIXME: Update neighbors' timers */ } /* POLL TIMER */ @@ -874,6 +901,9 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new) /* ifa cannot be vlink */ ifa->tx_length = ifa_tx_length(ifa); update_buffers = 1; + + if (!ifa->stub) + ospf_iface_update_flood_queue_size(ifa); } /* RX BUFFER */ @@ -1211,6 +1241,9 @@ ospf_iface_change_mtu(struct ospf_proto *p, struct ospf_iface *ifa) sk_set_rbsize(ifa->sk, bsize); if (bsize > ifa->sk->tbsize) sk_set_tbsize(ifa->sk, bsize); + + if (!ifa->stub) + ospf_iface_update_flood_queue_size(ifa); } static void |