OSPFv3: Fix some overlooked cases in IPv4 mode

Prefixes with max length (/32) were not handled properly.

Thanks to bauen1 for the bugreport.
This commit is contained in:
Ondrej Zajicek (work) 2019-04-12 14:11:23 +02:00
parent 4a50c8bd03
commit 6ff8119765

View file

@ -1424,6 +1424,7 @@ prepare_prefix_rt_lsa_body(struct ospf_proto *p, struct ospf_area *oa)
struct ospf_config *cf = (struct ospf_config *) (p->p.cf); struct ospf_config *cf = (struct ospf_config *) (p->p.cf);
struct ospf_iface *ifa; struct ospf_iface *ifa;
struct ospf_lsa_prefix *lp; struct ospf_lsa_prefix *lp;
uint max = ospf_is_ip4(p) ? IP4_MAX_PREFIX_LENGTH : IP6_MAX_PREFIX_LENGTH;
int host_addr = 0; int host_addr = 0;
int net_lsa; int net_lsa;
int i = 0; int i = 0;
@ -1457,7 +1458,7 @@ prepare_prefix_rt_lsa_body(struct ospf_proto *p, struct ospf_area *oa)
(a->scope <= SCOPE_LINK)) (a->scope <= SCOPE_LINK))
continue; continue;
if (((a->prefix.pxlen < IP6_MAX_PREFIX_LENGTH) && net_lsa) || if (((a->prefix.pxlen < max) && net_lsa) ||
configured_stubnet(oa, a)) configured_stubnet(oa, a))
continue; continue;
@ -1465,8 +1466,13 @@ prepare_prefix_rt_lsa_body(struct ospf_proto *p, struct ospf_area *oa)
(ifa->state == OSPF_IS_LOOP) || (ifa->state == OSPF_IS_LOOP) ||
(ifa->type == OSPF_IT_PTMP)) (ifa->type == OSPF_IT_PTMP))
{ {
net_addr_ip6 net = NET_ADDR_IP6(a->ip, IP6_MAX_PREFIX_LENGTH); net_addr net;
lsab_put_prefix(p, (net_addr *) &net, 0); if (a->prefix.type == NET_IP4)
net_fill_ip4(&net, ipa_to_ip4(a->ip), IP4_MAX_PREFIX_LENGTH);
else
net_fill_ip6(&net, ipa_to_ip6(a->ip), IP6_MAX_PREFIX_LENGTH);
lsab_put_prefix(p, &net, 0);
host_addr = 1; host_addr = 1;
} }
else else
@ -1482,7 +1488,7 @@ prepare_prefix_rt_lsa_body(struct ospf_proto *p, struct ospf_area *oa)
if (!sn->hidden) if (!sn->hidden)
{ {
lsab_put_prefix(p, &sn->prefix, sn->cost); lsab_put_prefix(p, &sn->prefix, sn->cost);
if (sn->prefix.pxlen == IP6_MAX_PREFIX_LENGTH) if (sn->prefix.pxlen == max)
host_addr = 1; host_addr = 1;
i++; i++;
} }