]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_routemap.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / zebra / zebra_routemap.c
index 4f43cea4930df0794d96f96c342d90b673e50c24..c5bccd05a6c3952d2cc1b3a0f297379a32572f3b 100644 (file)
@@ -1,21 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* zebra routemap.
  * Copyright (C) 2006 IBM Corporation
- *
- * 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>
@@ -1049,12 +1034,19 @@ route_match_ip_next_hop(void *rule, const struct prefix *prefix, void *object)
                p.prefix = nh_data->nexthop->gate.ipv4;
                p.prefixlen = IPV4_MAX_BITLEN;
                break;
-       default:
+       case NEXTHOP_TYPE_IPV6:
+       case NEXTHOP_TYPE_IPV6_IFINDEX:
+       case NEXTHOP_TYPE_BLACKHOLE:
                return RMAP_NOMATCH;
        }
        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);
@@ -1105,12 +1097,19 @@ route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
                p.prefix = nh_data->nexthop->gate.ipv4;
                p.prefixlen = IPV4_MAX_BITLEN;
                break;
-       default:
+       case NEXTHOP_TYPE_IPV6:
+       case NEXTHOP_TYPE_IPV6_IFINDEX:
+       case NEXTHOP_TYPE_BLACKHOLE:
                return RMAP_NOMATCH;
        }
        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);
@@ -1145,8 +1144,13 @@ route_match_address(afi_t afi, void *rule, const struct prefix *prefix,
        struct access_list *alist;
 
        alist = access_list_lookup(afi, (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);
@@ -1202,8 +1206,13 @@ route_match_address_prefix_list(void *rule, const struct prefix *prefix,
        struct prefix_list *plist;
 
        plist = prefix_list_lookup(afi, (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);
@@ -1364,7 +1373,9 @@ route_match_ip_nexthop_prefix_len(void *rule, const struct prefix *prefix,
                p.prefix = nh_data->nexthop->gate.ipv4;
                p.prefixlen = IPV4_MAX_BITLEN;
                break;
-       default:
+       case NEXTHOP_TYPE_IPV6:
+       case NEXTHOP_TYPE_IPV6_IFINDEX:
+       case NEXTHOP_TYPE_BLACKHOLE:
                return RMAP_NOMATCH;
        }
        return ((p.prefixlen == *prefixlen) ? RMAP_MATCH : RMAP_NOMATCH);