]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_routemap.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospfd / ospf_routemap.c
index d3b114840ee2e38a1d0cb5ce43a6bd836cbc53c3..3087008819275c7a97fa0040d083fc9c56a7dc4f 100644 (file)
@@ -1,24 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Route map function of ospfd.
  * Copyright (C) 2000 IP Infusion Inc.
  *
  * Written by Toshiaki Takada.
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -71,19 +56,14 @@ static void ospf_route_map_update(const char *name)
                                        /* Keep old route-map. */
                                        struct route_map *old = ROUTEMAP(red);
 
-                                       if (!old) {
-                                               /* Route-map creation */
-                                               /* Update route-map. */
-                                               ROUTEMAP(red) =
-                                                       route_map_lookup_by_name(
-                                                               ROUTEMAP_NAME(red));
-
-                                                       route_map_counter_increment(
-                                                               ROUTEMAP(red));
-                                       } else {
-                                               /* Route-map deletion */
-                                               ROUTEMAP(red) = NULL;
-                                       }
+                                       ROUTEMAP(red) =
+                                               route_map_lookup_by_name(
+                                                       ROUTEMAP_NAME(red));
+
+                                       if (!old)
+                                               route_map_counter_increment(
+                                                       ROUTEMAP(red));
+
                                        /* No update for this distribute type.
                                         */
                                        if (old == NULL
@@ -139,8 +119,13 @@ route_match_ip_nexthop(void *rule, const struct prefix *prefix, void *object)
        p.prefixlen = IPV4_MAX_BITLEN;
 
        alist = access_list_lookup(AFI_IP, (char *)rule);
-       if (alist == NULL)
+       if (alist == NULL) {
+               if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP_DETAIL))
+                       zlog_debug(
+                               "%s: Access-List Specified: %s does not exist defaulting to NO_MATCH",
+                               __func__, (char *)rule);
                return RMAP_NOMATCH;
+       }
 
        return (access_list_apply(alist, &p) == FILTER_DENY ? RMAP_NOMATCH
                                                            : RMAP_MATCH);
@@ -182,8 +167,13 @@ route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
        p.prefixlen = IPV4_MAX_BITLEN;
 
        plist = prefix_list_lookup(AFI_IP, (char *)rule);
-       if (plist == NULL)
+       if (plist == NULL) {
+               if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP_DETAIL))
+                       zlog_debug(
+                               "%s: Prefix List %s specified does not exist defaulting to NO_MATCH",
+                               __func__, (char *)rule);
                return RMAP_NOMATCH;
+       }
 
        return (prefix_list_apply(plist, &p) == PREFIX_DENY ? RMAP_NOMATCH
                                                            : RMAP_MATCH);
@@ -254,8 +244,13 @@ route_match_ip_address(void *rule, const struct prefix *prefix, void *object)
        /* struct prefix_ipv4 match; */
 
        alist = access_list_lookup(AFI_IP, (char *)rule);
-       if (alist == NULL)
+       if (alist == NULL) {
+               if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP_DETAIL))
+                       zlog_debug(
+                               "%s: Access-List Specified: %s does not exist defaulting to NO_MATCH",
+                               __func__, (char *)rule);
                return RMAP_NOMATCH;
+       }
 
        return (access_list_apply(alist, prefix) == FILTER_DENY ? RMAP_NOMATCH
                                                                : RMAP_MATCH);
@@ -290,8 +285,14 @@ route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
        struct prefix_list *plist;
 
        plist = prefix_list_lookup(AFI_IP, (char *)rule);
-       if (plist == NULL)
+       if (plist == NULL) {
+               if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP_DETAIL))
+                       zlog_debug(
+                               "%s: Prefix List %s specified does not exist defaulting to NO_MATCH",
+                               __func__, (char *)rule);
+
                return RMAP_NOMATCH;
+       }
 
        return (prefix_list_apply(plist, prefix) == PREFIX_DENY ? RMAP_NOMATCH
                                                                : RMAP_MATCH);
@@ -325,7 +326,7 @@ route_match_interface(void *rule, const struct prefix *prefix, void *object)
        struct external_info *ei;
 
        ei = object;
-       ifp = if_lookup_by_name_all_vrf((char *)rule);
+       ifp = if_lookup_by_name((char *)rule, ei->ospf->vrf_id);
 
        if (ifp == NULL || ifp->ifindex != ei->ifindex)
                return RMAP_NOMATCH;