+// 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>
#include "plist.h"
#include "vrf.h"
#include "frrstr.h"
+#include "northbound_cli.h"
#include "ospfd/ospfd.h"
#include "ospfd/ospf_asbr.h"
/* 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
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);
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);
/* 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);
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);
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;
route_map_rule_tag_free,
};
-DEFUN (set_metric_type,
+DEFUN_YANG (set_metric_type,
set_metric_type_cmd,
"set metric-type <type-1|type-2>",
SET_STR
"OSPF[6] external type 2 metric\n")
{
char *ext = argv[2]->text;
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "metric-type", ext);
+
+ const char *xpath =
+ "./set-action[action='frr-ospf-route-map:metric-type']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-ospf-route-map:metric-type", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, ext);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_metric_type,
+DEFUN_YANG (no_set_metric_type,
no_set_metric_type_cmd,
"no set metric-type [<type-1|type-2>]",
NO_STR
"OSPF[6] external type 1 metric\n"
"OSPF[6] external type 2 metric\n")
{
- char *ext = (argc == 4) ? argv[3]->text : NULL;
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "metric-type", ext);
+ const char *xpath =
+ "./set-action[action='frr-ospf-route-map:metric-type']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
/* Route-map init */