diff options
| author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2021-07-08 14:09:20 -0300 |
|---|---|---|
| committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2021-07-09 07:55:25 -0300 |
| commit | 1fe59b44fc94337f0b508bc762a401a9dbe9c1a3 (patch) | |
| tree | 8a525db11e5c2b61c3b8cb29b9eb55c4ed9bd6f5 /ospfd/ospf_zebra.c | |
| parent | f45f6a22b052988a6ca3399fde66249e8b6e00cc (diff) | |
lib,ospfd,ospf6d: remove duplicated function
Move `is_default_prefix` variations to `lib/prefix.h` and make the code
use the library version instead of implementing it again.
NOTE
----
The function was split into per family versions to cover all types.
Using `union prefixconstptr` is not possible due to static analyzer
warnings which cause CI to fail.
The specific cases that would cause this failure were:
- Caller used `struct prefix_ipv4` and called the generic function.
- `is_default_prefix` with signature using `const struct prefix *` or
`union prefixconstptr`.
The compiler would complain about reading bytes outside of the memory
bounds even though it did not take into account the `prefix->family`
part.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'ospfd/ospf_zebra.c')
| -rw-r--r-- | ospfd/ospf_zebra.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 017915e0ee..387bbc0ce9 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -933,7 +933,7 @@ static int ospf_external_lsa_originate_check(struct ospf *ospf, } /* Take care of default-originate. */ - if (is_prefix_default(&ei->p)) + if (is_default_prefix4(&ei->p)) if (ospf->default_originate == DEFAULT_ORIGINATE_NONE) { zlog_info( "LSA[Type5:0.0.0.0]: Not originate AS-external-LSA for default"); @@ -1089,8 +1089,8 @@ int ospf_redistribute_check(struct ospf *ospf, struct external_info *ei, struct route_map_set_values save_values; struct prefix_ipv4 *p = &ei->p; struct ospf_redist *red; - uint8_t type = is_prefix_default(&ei->p) ? DEFAULT_ROUTE : ei->type; - unsigned short instance = is_prefix_default(&ei->p) ? 0 : ei->instance; + uint8_t type = is_default_prefix4(&ei->p) ? DEFAULT_ROUTE : ei->type; + unsigned short instance = is_default_prefix4(&ei->p) ? 0 : ei->instance; route_tag_t saved_tag = 0; /* Default is handled differently. */ @@ -1213,7 +1213,7 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS) * originate)ZEBRA_ROUTE_MAX is used to delete the ex-info. * Resolved this inconsistency by maintaining same route type. */ - if (is_prefix_default(&p)) + if (is_default_prefix4(&p)) rt_type = DEFAULT_ROUTE; if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) @@ -1252,7 +1252,7 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS) return 0; } if (ospf->router_id.s_addr != INADDR_ANY) { - if (is_prefix_default(&p)) + if (is_default_prefix4(&p)) ospf_external_lsa_refresh_default(ospf); else { struct ospf_external_aggr_rt *aggr; @@ -1374,7 +1374,7 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS) ospf_external_info_delete(ospf, rt_type, api.instance, p); - if (is_prefix_default(&p)) + if (is_default_prefix4(&p)) ospf_external_lsa_refresh_default(ospf); else ospf_external_lsa_flush(ospf, rt_type, &p, @@ -1471,7 +1471,7 @@ static int ospf_distribute_list_update_timer(struct thread *thread) if (!ei) continue; - if (is_prefix_default(&ei->p)) + if (is_default_prefix4(&ei->p)) default_refresh = 1; else { struct ospf_external_aggr_rt *aggr; |
