0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-17 08:38:42 +00:00

OSPF: Fix bad initialization of tx_hdrlen field

Function ifa_tx_hdrlen() uses fields autype and passwords, so it must be
called after these are set.

Thanks to Kenth Eriksson for the bugreport.
This commit is contained in:
Ondrej Zajicek (work) 2020-01-09 02:59:59 +01:00
parent 7d767c5a3d
commit 9f2670277c

View File

@ -586,8 +586,6 @@ ospf_iface_new(struct ospf_area *oa, struct ifa *addr, struct ospf_iface_patt *i
ifa->deadint = ip->deadint; ifa->deadint = ip->deadint;
ifa->stub = ospf_iface_stubby(ip, addr); ifa->stub = ospf_iface_stubby(ip, addr);
ifa->ioprob = OSPF_I_OK; 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->check_link = ip->check_link;
ifa->ecmp_weight = ip->ecmp_weight; ifa->ecmp_weight = ip->ecmp_weight;
ifa->check_ttl = (ip->ttl_security == 1); ifa->check_ttl = (ip->ttl_security == 1);
@ -596,6 +594,10 @@ ospf_iface_new(struct ospf_area *oa, struct ifa *addr, struct ospf_iface_patt *i
ifa->passwords = ip->passwords; ifa->passwords = ip->passwords;
ifa->instance_id = ip->instance_id; ifa->instance_id = ip->instance_id;
/* This must be done after relevant fields are set */
ifa->tx_length = ifa_tx_length(ifa);
ifa->tx_hdrlen = ifa_tx_hdrlen(ifa);
ifa->ptp_netmask = !(addr->flags & IA_PEER); ifa->ptp_netmask = !(addr->flags & IA_PEER);
if (ip->ptp_netmask < 2) if (ip->ptp_netmask < 2)
ifa->ptp_netmask = ip->ptp_netmask; ifa->ptp_netmask = ip->ptp_netmask;
@ -698,12 +700,14 @@ ospf_iface_new_vlink(struct ospf_proto *p, struct ospf_iface_patt *ip)
ifa->waitint = ip->waitint; ifa->waitint = ip->waitint;
ifa->deadint = ip->deadint; ifa->deadint = ip->deadint;
ifa->inftransdelay = ip->inftransdelay; 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->autype = ip->autype;
ifa->passwords = ip->passwords; ifa->passwords = ip->passwords;
ifa->instance_id = ip->instance_id; ifa->instance_id = ip->instance_id;
/* This must be done after relevant fields are set */
ifa->tx_length = ospf_is_v2(p) ? IP4_MIN_MTU : IP6_MIN_MTU;
ifa->tx_hdrlen = ifa_tx_hdrlen(ifa);
ifa->type = OSPF_IT_VLINK; ifa->type = OSPF_IT_VLINK;
ifa->state = OSPF_IS_DOWN; ifa->state = OSPF_IS_DOWN;