]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospf6d: handle redistributed routes without nexthop addresses
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 2 Mar 2023 23:20:39 +0000 (20:20 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Thu, 2 Mar 2023 22:38:03 +0000 (19:38 -0300)
Do not assume that all redistributed routes have a nexthop address,
otherwise blackhole nexthops can be misinterpreted as IPv6 addresses,
leading to inconsistencies.

Also, change the signature of a few functions to allow const nexthop
addresses, such that in6addr_any can be used without type casts.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ospf6d/ospf6_asbr.c
ospf6d/ospf6_asbr.h
ospf6d/ospf6_route.c
ospf6d/ospf6_route.h
ospf6d/ospf6_zebra.c

index 7ee22e05c78e1a0e96f8501e052758de2a8116db..b2cdbc9b57ee2c9a0656a151c5cf20bae089b191 100644 (file)
@@ -1380,8 +1380,8 @@ ospf6_external_aggr_match(struct ospf6 *ospf6, struct prefix *p)
 void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
                                 struct prefix *prefix,
                                 unsigned int nexthop_num,
-                                struct in6_addr *nexthop, route_tag_t tag,
-                                struct ospf6 *ospf6)
+                                const struct in6_addr *nexthop,
+                                route_tag_t tag, struct ospf6 *ospf6)
 {
        route_map_result_t ret;
        struct ospf6_route troute;
index 15982ca64c9e4994d62831a15557963186f95655..d63e467278903457e2ef7f39613cff988c96b445 100644 (file)
@@ -114,7 +114,7 @@ extern int ospf6_asbr_is_asbr(struct ospf6 *o);
 extern void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
                                        struct prefix *prefix,
                                        unsigned int nexthop_num,
-                                       struct in6_addr *nexthop,
+                                       const struct in6_addr *nexthop,
                                        route_tag_t tag, struct ospf6 *ospf6);
 extern void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex,
                                           struct prefix *prefix,
index 72dfa240afded489202d3804700cb89dcc442e01..443032933d0f378d9cc047714976b4e6e8a99d16 100644 (file)
@@ -267,7 +267,8 @@ int ospf6_num_nexthops(struct list *nh_list)
        return (listcount(nh_list));
 }
 
-void ospf6_add_nexthop(struct list *nh_list, int ifindex, struct in6_addr *addr)
+void ospf6_add_nexthop(struct list *nh_list, int ifindex,
+                      const struct in6_addr *addr)
 {
        struct ospf6_nexthop *nh;
        struct ospf6_nexthop nh_match;
index 2d4fcc930ece401d3959ca84f9c11044f96c03d3..c2125951ec52a3ab87e0a1816f2dea32e58207e2 100644 (file)
@@ -312,7 +312,7 @@ extern int ospf6_num_nexthops(struct list *nh_list);
 extern void ospf6_copy_nexthops(struct list *dst, struct list *src);
 extern void ospf6_merge_nexthops(struct list *dst, struct list *src);
 extern void ospf6_add_nexthop(struct list *nh_list, int ifindex,
-                             struct in6_addr *addr);
+                             const struct in6_addr *addr);
 extern void ospf6_add_route_nexthop_blackhole(struct ospf6_route *route);
 extern int ospf6_num_nexthops(struct list *nh_list);
 extern bool ospf6_route_cmp_nexthops(struct ospf6_route *a,
index 6fe0a24926738c190d54040ef7f732d0c343b9c1..0ccbb4d65d7da15e768eb16fb3a8f20182696df3 100644 (file)
@@ -252,7 +252,7 @@ static int ospf6_zebra_read_route(ZAPI_CALLBACK_ARGS)
 {
        struct zapi_route api;
        unsigned long ifindex;
-       struct in6_addr *nexthop;
+       const struct in6_addr *nexthop = &in6addr_any;
        struct ospf6 *ospf6;
        struct prefix_ipv6 p;
 
@@ -272,7 +272,9 @@ static int ospf6_zebra_read_route(ZAPI_CALLBACK_ARGS)
                return 0;
 
        ifindex = api.nexthops[0].ifindex;
-       nexthop = &api.nexthops[0].gate.ipv6;
+       if (api.nexthops[0].type == NEXTHOP_TYPE_IPV6
+           || api.nexthops[0].type == NEXTHOP_TYPE_IPV6_IFINDEX)
+               nexthop = &api.nexthops[0].gate.ipv6;
 
        if (IS_OSPF6_DEBUG_ZEBRA(RECV))
                zlog_debug(