diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-10-27 20:58:21 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-11-02 17:53:22 +0100 |
commit | 29239ba2bbee3e9ec7d17793b25936a1bfc795ca (patch) | |
tree | 3e0b5a6d76d9bc508a86b45fb222bcd57999a277 /proto/ospf/iface.c | |
parent | 390601f038b69d5de3841c691f92af0fcd088454 (diff) |
OSPF: Use message authentication interface
Based on former commit from Pavel Tvrdik
Diffstat (limited to 'proto/ospf/iface.c')
-rw-r--r-- | proto/ospf/iface.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c index 67ae094d..280fa4c1 100644 --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@ -9,6 +9,7 @@ */ #include "ospf.h" +#include "nest/password.h" const char *ospf_is_names[] = { @@ -52,6 +53,18 @@ ifa_tx_length(struct ospf_iface *ifa) } static inline uint +ifa_tx_hdrlen(struct ospf_iface *ifa) +{ + uint hlen = SIZE_OF_IP_HEADER; + + /* Relevant just for OSPFv2 */ + if (ifa->autype == OSPF_AUTH_CRYPT) + hlen += max_mac_length(ifa->passwords); + + return hlen; +} + +static inline uint ifa_bufsize(struct ospf_iface *ifa) { uint bsize = ifa->cf->rx_buffer ?: ifa->iface->mtu; @@ -67,11 +80,7 @@ ifa_flood_queue_size(struct ospf_iface *ifa) int ospf_iface_assure_bufsize(struct ospf_iface *ifa, uint plen) { - plen += SIZE_OF_IP_HEADER; - - /* This is relevant just for OSPFv2 */ - if (ifa->autype == OSPF_AUTH_CRYPT) - plen += OSPF_AUTH_CRYPT_SIZE; + plen += ifa->tx_hdrlen; if (plen <= ifa->sk->tbsize) return 0; @@ -574,6 +583,7 @@ ospf_iface_new(struct ospf_area *oa, struct ifa *addr, struct ospf_iface_patt *i ifa->stub = ospf_iface_stubby(ip, addr); ifa->ioprob = OSPF_I_OK; ifa->tx_length = ifa_tx_length(ifa); + ifa->tx_hdrlen = ifa_tx_hdrlen(ifa); ifa->check_link = ip->check_link; ifa->ecmp_weight = ip->ecmp_weight; ifa->check_ttl = (ip->ttl_security == 1); @@ -684,6 +694,7 @@ ospf_iface_new_vlink(struct ospf_proto *p, struct ospf_iface_patt *ip) ifa->deadint = ip->deadint; ifa->inftransdelay = ip->inftransdelay; ifa->tx_length = ospf_is_v2(p) ? IP4_MIN_MTU : IP6_MIN_MTU; + ifa->tx_hdrlen = ifa_tx_hdrlen(ifa); ifa->autype = ip->autype; ifa->passwords = ip->passwords; ifa->instance_id = ip->instance_id; @@ -824,6 +835,9 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new) /* Update passwords */ ifa->passwords = new->passwords; + /* Update header length */ + ifa->tx_hdrlen = ifa_tx_hdrlen(ifa); + /* Remaining options are just for proper interfaces */ if (ifa->type == OSPF_IT_VLINK) return 1; |