back to topotato report
topotato coverage report
Current view: top level - bgpd - bgp_routemap_nb_config.c (source / functions) Hit Total Coverage
Test: test_exabgp_demo.py::ExaBGPDemo Lines: 0 1094 0.0 %
Date: 2023-02-24 18:37:55 Functions: 0 113 0.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2020        Vmware
       3             :  *                           Sarita Patra
       4             :  *
       5             :  * This program is free software; you can redistribute it and/or modify it
       6             :  * under the terms of the GNU General Public License as published by the Free
       7             :  * Software Foundation; either version 2 of the License, or (at your option)
       8             :  * any later version.
       9             :  *
      10             :  * This program is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             :  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
      13             :  * more details.
      14             :  *
      15             :  * You should have received a copy of the GNU General Public License along
      16             :  * with this program; see the file COPYING; if not, write to the Free Software
      17             :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
      18             :  */
      19             : 
      20             : #include <zebra.h>
      21             : 
      22             : #include "lib/command.h"
      23             : #include "lib/log.h"
      24             : #include "lib/northbound.h"
      25             : #include "lib/routemap.h"
      26             : #include "bgpd/bgpd.h"
      27             : #include "bgpd/bgp_routemap_nb.h"
      28             : 
      29             : /* Add bgp route map rule. */
      30           0 : static int bgp_route_match_add(struct route_map_index *index,
      31             :                 const char *command, const char *arg,
      32             :                 route_map_event_t type,
      33             :                 char *errmsg, size_t errmsg_len)
      34             : {
      35           0 :         int retval = CMD_SUCCESS;
      36           0 :         enum rmap_compile_rets ret;
      37             : 
      38           0 :         ret = route_map_add_match(index, command, arg, type);
      39           0 :         switch (ret) {
      40           0 :         case RMAP_RULE_MISSING:
      41           0 :                 snprintf(errmsg, errmsg_len, "%% BGP Can't find rule.");
      42           0 :                 retval = CMD_WARNING_CONFIG_FAILED;
      43           0 :                 break;
      44           0 :         case RMAP_COMPILE_ERROR:
      45           0 :                 snprintf(errmsg, errmsg_len, "%% BGP Argument is malformed.");
      46           0 :                 retval = CMD_WARNING_CONFIG_FAILED;
      47           0 :                 break;
      48             :         case RMAP_COMPILE_SUCCESS:
      49             :                 /*
      50             :                  * Intentionally doing nothing here.
      51             :                  */
      52             :                 break;
      53             :         }
      54             : 
      55           0 :         return retval;
      56             : }
      57             : 
      58             : /* Delete bgp route map rule. */
      59           0 : static int bgp_route_match_delete(struct route_map_index *index,
      60             :                 const char *command, const char *arg,
      61             :                 route_map_event_t type,
      62             :                 char *errmsg, size_t errmsg_len)
      63             : {
      64           0 :         enum rmap_compile_rets ret;
      65           0 :         int retval = CMD_SUCCESS;
      66           0 :         char *dep_name = NULL;
      67           0 :         const char *tmpstr;
      68           0 :         char *rmap_name = NULL;
      69             : 
      70           0 :         if (type != RMAP_EVENT_MATCH_DELETED) {
      71             :                 /* ignore the mundane, the types without any dependency */
      72           0 :                 if (arg == NULL) {
      73           0 :                         tmpstr = route_map_get_match_arg(index, command);
      74           0 :                         if (tmpstr != NULL)
      75           0 :                                 dep_name =
      76           0 :                                         XSTRDUP(MTYPE_ROUTE_MAP_RULE, tmpstr);
      77             :                 } else {
      78           0 :                         dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, arg);
      79             :                 }
      80           0 :                 rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, index->map->name);
      81             :         }
      82             : 
      83           0 :         ret = route_map_delete_match(index, command, dep_name, type);
      84           0 :         switch (ret) {
      85           0 :                 case RMAP_RULE_MISSING:
      86           0 :                         snprintf(errmsg, errmsg_len, "%% BGP Can't find rule.");
      87           0 :                         retval = CMD_WARNING_CONFIG_FAILED;
      88           0 :                         break;
      89           0 :                 case RMAP_COMPILE_ERROR:
      90           0 :                         snprintf(errmsg, errmsg_len,
      91             :                                  "%% BGP Argument is malformed.");
      92           0 :                         retval = CMD_WARNING_CONFIG_FAILED;
      93           0 :                         break;
      94             :                 case RMAP_COMPILE_SUCCESS:
      95             :                         /*
      96             :                          * Nothing to do here
      97             :                          */
      98             :                         break;
      99             :         }
     100             : 
     101           0 :         XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
     102           0 :         XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
     103             : 
     104           0 :         return retval;
     105             : }
     106             : 
     107             : /*
     108             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:local-preference
     109             :  */
     110             : int
     111           0 : lib_route_map_entry_match_condition_rmap_match_condition_local_preference_modify(
     112             :         struct nb_cb_modify_args *args)
     113             : {
     114           0 :         struct routemap_hook_context *rhc;
     115           0 :         const char *local_pref;
     116           0 :         enum rmap_compile_rets ret;
     117             : 
     118           0 :         switch (args->event) {
     119             :         case NB_EV_VALIDATE:
     120             :         case NB_EV_PREPARE:
     121             :         case NB_EV_ABORT:
     122             :                 break;
     123           0 :         case NB_EV_APPLY:
     124             :                 /* Add configuration. */
     125           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     126           0 :                 local_pref = yang_dnode_get_string(args->dnode, NULL);
     127             : 
     128             :                 /* Set destroy information. */
     129           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     130           0 :                 rhc->rhc_rule = "local-preference";
     131           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     132             : 
     133           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "local-preference",
     134             :                                 local_pref, RMAP_EVENT_MATCH_ADDED,
     135             :                                 args->errmsg, args->errmsg_len);
     136             : 
     137           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     138           0 :                         rhc->rhc_mhook = NULL;
     139           0 :                         return NB_ERR_INCONSISTENCY;
     140             :                 }
     141             :         }
     142             : 
     143             :                 return NB_OK;
     144             : }
     145             : 
     146             : int
     147           0 : lib_route_map_entry_match_condition_rmap_match_condition_local_preference_destroy(
     148             :         struct nb_cb_destroy_args *args)
     149             : {
     150           0 :         switch (args->event) {
     151             :         case NB_EV_VALIDATE:
     152             :         case NB_EV_PREPARE:
     153             :         case NB_EV_ABORT:
     154             :                 break;
     155           0 :         case NB_EV_APPLY:
     156           0 :                 return lib_route_map_entry_match_destroy(args);
     157             :         }
     158             : 
     159             :         return NB_OK;
     160             : }
     161             : 
     162             : /*
     163             :  * XPath:
     164             :  * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:alias
     165             :  */
     166           0 : int lib_route_map_entry_match_condition_rmap_match_condition_alias_modify(
     167             :         struct nb_cb_modify_args *args)
     168             : {
     169           0 :         struct routemap_hook_context *rhc;
     170           0 :         const char *alias;
     171           0 :         enum rmap_compile_rets ret;
     172             : 
     173           0 :         switch (args->event) {
     174             :         case NB_EV_VALIDATE:
     175             :         case NB_EV_PREPARE:
     176             :         case NB_EV_ABORT:
     177             :                 break;
     178           0 :         case NB_EV_APPLY:
     179             :                 /* Add configuration. */
     180           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     181           0 :                 alias = yang_dnode_get_string(args->dnode, NULL);
     182             : 
     183             :                 /* Set destroy information. */
     184           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     185           0 :                 rhc->rhc_rule = "alias";
     186           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     187             : 
     188           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "alias", alias,
     189             :                                           RMAP_EVENT_MATCH_ADDED, args->errmsg,
     190             :                                           args->errmsg_len);
     191             : 
     192           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     193           0 :                         rhc->rhc_mhook = NULL;
     194           0 :                         return NB_ERR_VALIDATION;
     195             :                 }
     196             : 
     197             :                 break;
     198             :         }
     199             : 
     200             :         return NB_OK;
     201             : }
     202             : 
     203           0 : int lib_route_map_entry_match_condition_rmap_match_condition_alias_destroy(
     204             :         struct nb_cb_destroy_args *args)
     205             : {
     206           0 :         switch (args->event) {
     207             :         case NB_EV_VALIDATE:
     208             :         case NB_EV_PREPARE:
     209             :         case NB_EV_ABORT:
     210             :                 break;
     211           0 :         case NB_EV_APPLY:
     212           0 :                 return lib_route_map_entry_match_destroy(args);
     213             :         }
     214             : 
     215             :         return NB_OK;
     216             : }
     217             : 
     218             : /*
     219             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:script
     220             :  */
     221             : int
     222           0 : lib_route_map_entry_match_condition_rmap_match_condition_script_modify(
     223             :         struct nb_cb_modify_args *args)
     224             : {
     225           0 :         struct routemap_hook_context *rhc;
     226           0 :         const char *script;
     227           0 :         enum rmap_compile_rets ret;
     228             : 
     229           0 :         switch (args->event) {
     230             :         case NB_EV_VALIDATE:
     231             :         case NB_EV_PREPARE:
     232             :         case NB_EV_ABORT:
     233             :                 break;
     234           0 :         case NB_EV_APPLY:
     235             :                 /* Add configuration. */
     236           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     237           0 :                 script = yang_dnode_get_string(args->dnode, NULL);
     238             : 
     239             :                 /* Set destroy information. */
     240           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     241           0 :                 rhc->rhc_rule = "script";
     242           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     243             : 
     244           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "script",
     245             :                                 script, RMAP_EVENT_MATCH_ADDED,
     246             :                                 args->errmsg, args->errmsg_len);
     247             : 
     248           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     249           0 :                         rhc->rhc_mhook = NULL;
     250           0 :                         return NB_ERR_INCONSISTENCY;
     251             :                 }
     252             :         }
     253             : 
     254             :         return NB_OK;
     255             : }
     256             : 
     257             : int
     258           0 : lib_route_map_entry_match_condition_rmap_match_condition_script_destroy(
     259             :         struct nb_cb_destroy_args *args)
     260             : {
     261           0 :         switch (args->event) {
     262             :         case NB_EV_VALIDATE:
     263             :         case NB_EV_PREPARE:
     264             :         case NB_EV_ABORT:
     265             :                 break;
     266           0 :         case NB_EV_APPLY:
     267           0 :                 return lib_route_map_entry_match_destroy(args);
     268             :         }
     269             : 
     270             :         return NB_OK;
     271             : }
     272             : 
     273             : /*
     274             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:origin
     275             :  */
     276             : int
     277           0 : lib_route_map_entry_match_condition_rmap_match_condition_origin_modify(
     278             :         struct nb_cb_modify_args *args)
     279             : {
     280           0 :         struct routemap_hook_context *rhc;
     281           0 :         const char *origin;
     282           0 :         enum rmap_compile_rets ret;
     283             : 
     284           0 :         switch (args->event) {
     285             :         case NB_EV_VALIDATE:
     286             :         case NB_EV_PREPARE:
     287             :         case NB_EV_ABORT:
     288             :                 break;
     289           0 :         case NB_EV_APPLY:
     290             :                 /* Add configuration. */
     291           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     292           0 :                 origin = yang_dnode_get_string(args->dnode, NULL);
     293             : 
     294             :                 /* Set destroy information. */
     295           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     296           0 :                 rhc->rhc_rule = "origin";
     297           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     298             : 
     299           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "origin", origin,
     300             :                                           RMAP_EVENT_MATCH_ADDED,
     301             :                                           args->errmsg, args->errmsg_len);
     302             : 
     303           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     304           0 :                         rhc->rhc_mhook = NULL;
     305           0 :                         return NB_ERR_INCONSISTENCY;
     306             :                 }
     307             :         }
     308             : 
     309             :         return NB_OK;
     310             : }
     311             : 
     312             : int
     313           0 : lib_route_map_entry_match_condition_rmap_match_condition_origin_destroy(
     314             :         struct nb_cb_destroy_args *args)
     315             : {
     316           0 :         switch (args->event) {
     317             :         case NB_EV_VALIDATE:
     318             :         case NB_EV_PREPARE:
     319             :         case NB_EV_ABORT:
     320             :                 break;
     321           0 :         case NB_EV_APPLY:
     322           0 :                 return lib_route_map_entry_match_destroy(args);
     323             :         }
     324             : 
     325             :         return NB_OK;
     326             : }
     327             : 
     328             : /*
     329             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki
     330             :  */
     331             : int
     332           0 : lib_route_map_entry_match_condition_rmap_match_condition_rpki_modify(
     333             :         struct nb_cb_modify_args *args)
     334             : {
     335           0 :         struct routemap_hook_context *rhc;
     336           0 :         const char *rpki;
     337           0 :         enum rmap_compile_rets ret;
     338             : 
     339           0 :         switch (args->event) {
     340             :         case NB_EV_VALIDATE:
     341             :         case NB_EV_PREPARE:
     342             :         case NB_EV_ABORT:
     343             :                 break;
     344           0 :         case NB_EV_APPLY:
     345             :                 /* Add configuration. */
     346           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     347           0 :                 rpki = yang_dnode_get_string(args->dnode, NULL);
     348             : 
     349             :                 /* Set destroy information. */
     350           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     351           0 :                 rhc->rhc_rule = "rpki";
     352           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     353             : 
     354           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "rpki", rpki,
     355             :                                 RMAP_EVENT_MATCH_ADDED,
     356             :                                 args->errmsg, args->errmsg_len);
     357             : 
     358           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     359           0 :                         rhc->rhc_mhook = NULL;
     360           0 :                         return NB_ERR_INCONSISTENCY;
     361             :                 }
     362             :         }
     363             : 
     364             :         return NB_OK;
     365             : }
     366             : 
     367             : int
     368           0 : lib_route_map_entry_match_condition_rmap_match_condition_rpki_destroy(
     369             :         struct nb_cb_destroy_args *args)
     370             : {
     371           0 :         switch (args->event) {
     372             :         case NB_EV_VALIDATE:
     373             :         case NB_EV_PREPARE:
     374             :         case NB_EV_ABORT:
     375             :                 break;
     376           0 :         case NB_EV_APPLY:
     377           0 :                 return lib_route_map_entry_match_destroy(args);
     378             :         }
     379             : 
     380             :         return NB_OK;
     381             : }
     382             : 
     383             : /*
     384             :  * XPath:
     385             :  * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:rpki-extcommunity
     386             :  */
     387           0 : int lib_route_map_entry_match_condition_rmap_match_condition_rpki_extcommunity_modify(
     388             :         struct nb_cb_modify_args *args)
     389             : {
     390           0 :         struct routemap_hook_context *rhc;
     391           0 :         const char *rpki;
     392           0 :         enum rmap_compile_rets ret;
     393             : 
     394           0 :         switch (args->event) {
     395             :         case NB_EV_VALIDATE:
     396             :         case NB_EV_PREPARE:
     397             :         case NB_EV_ABORT:
     398             :                 break;
     399           0 :         case NB_EV_APPLY:
     400             :                 /* Add configuration. */
     401           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     402           0 :                 rpki = yang_dnode_get_string(args->dnode, NULL);
     403             : 
     404             :                 /* Set destroy information. */
     405           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     406           0 :                 rhc->rhc_rule = "rpki-extcommunity";
     407           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     408             : 
     409           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "rpki-extcommunity",
     410             :                                           rpki, RMAP_EVENT_MATCH_ADDED,
     411             :                                           args->errmsg, args->errmsg_len);
     412             : 
     413           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     414           0 :                         rhc->rhc_mhook = NULL;
     415           0 :                         return NB_ERR_INCONSISTENCY;
     416             :                 }
     417             :         }
     418             : 
     419             :         return NB_OK;
     420             : }
     421             : 
     422           0 : int lib_route_map_entry_match_condition_rmap_match_condition_rpki_extcommunity_destroy(
     423             :         struct nb_cb_destroy_args *args)
     424             : {
     425           0 :         switch (args->event) {
     426             :         case NB_EV_VALIDATE:
     427             :         case NB_EV_PREPARE:
     428             :         case NB_EV_ABORT:
     429             :                 break;
     430           0 :         case NB_EV_APPLY:
     431           0 :                 return lib_route_map_entry_match_destroy(args);
     432             :         }
     433             : 
     434             :         return NB_OK;
     435             : }
     436             : 
     437             : /*
     438             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:probability
     439             :  */
     440             : int
     441           0 : lib_route_map_entry_match_condition_rmap_match_condition_probability_modify(
     442             :         struct nb_cb_modify_args *args)
     443             : {
     444           0 :         struct routemap_hook_context *rhc;
     445           0 :         const char *probability;
     446           0 :         enum rmap_compile_rets ret;
     447             : 
     448           0 :         switch (args->event) {
     449             :         case NB_EV_VALIDATE:
     450             :         case NB_EV_PREPARE:
     451             :         case NB_EV_ABORT:
     452             :                 break;
     453           0 :         case NB_EV_APPLY:
     454             :                 /* Add configuration. */
     455           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     456           0 :                 probability = yang_dnode_get_string(args->dnode, NULL);
     457             : 
     458             :                 /* Set destroy information. */
     459           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     460           0 :                 rhc->rhc_rule = "probability";
     461           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     462             : 
     463           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "probability",
     464             :                                           probability, RMAP_EVENT_MATCH_ADDED,
     465             :                                           args->errmsg, args->errmsg_len);
     466             : 
     467           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     468           0 :                         rhc->rhc_mhook = NULL;
     469           0 :                         return NB_ERR_INCONSISTENCY;
     470             :                 }
     471             :         }
     472             : 
     473             :         return NB_OK;
     474             : }
     475             : 
     476             : int
     477           0 : lib_route_map_entry_match_condition_rmap_match_condition_probability_destroy(
     478             :         struct nb_cb_destroy_args *args)
     479             : {
     480           0 :         switch (args->event) {
     481           0 :         case NB_EV_VALIDATE:
     482             :         case NB_EV_PREPARE:
     483             :         case NB_EV_ABORT:
     484             :         case NB_EV_APPLY:
     485           0 :                 return lib_route_map_entry_match_destroy(args);
     486             :         }
     487             : 
     488             :         return NB_OK;
     489             : }
     490             : 
     491             : /*
     492             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:source-vrf
     493             :  */
     494             : int
     495           0 : lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_modify(
     496             :         struct nb_cb_modify_args *args)
     497             : {
     498           0 :         struct routemap_hook_context *rhc;
     499           0 :         const char *vrf;
     500           0 :         enum rmap_compile_rets ret;
     501             : 
     502           0 :         switch (args->event) {
     503             :         case NB_EV_VALIDATE:
     504             :         case NB_EV_PREPARE:
     505             :         case NB_EV_ABORT:
     506             :                 break;
     507           0 :         case NB_EV_APPLY:
     508             :                 /* Add configuration. */
     509           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     510           0 :                 vrf = yang_dnode_get_string(args->dnode, NULL);
     511             : 
     512             :                 /* Set destroy information. */
     513           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     514           0 :                 rhc->rhc_rule = "source-vrf";
     515           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     516             : 
     517           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "source-vrf", vrf,
     518             :                                           RMAP_EVENT_MATCH_ADDED,
     519             :                                           args->errmsg, args->errmsg_len);
     520             : 
     521           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     522           0 :                         rhc->rhc_mhook = NULL;
     523           0 :                         return NB_ERR_INCONSISTENCY;
     524             :                 }
     525             :         }
     526             : 
     527             :         return NB_OK;
     528             : }
     529             : 
     530             : int
     531           0 : lib_route_map_entry_match_condition_rmap_match_condition_source_vrf_destroy(
     532             :         struct nb_cb_destroy_args *args)
     533             : {
     534           0 :         switch (args->event) {
     535             :         case NB_EV_VALIDATE:
     536             :         case NB_EV_PREPARE:
     537             :         case NB_EV_ABORT:
     538             :                 break;
     539           0 :         case NB_EV_APPLY:
     540           0 :                 return lib_route_map_entry_match_destroy(args);
     541             :         }
     542             : 
     543             :         return NB_OK;
     544             : }
     545             : 
     546             : /*
     547             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address
     548             :  */
     549             : int
     550           0 : lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_modify(
     551             :         struct nb_cb_modify_args *args)
     552             : {
     553           0 :         struct routemap_hook_context *rhc;
     554           0 :         const char *peer;
     555           0 :         enum rmap_compile_rets ret;
     556             : 
     557           0 :         switch (args->event) {
     558             :         case NB_EV_VALIDATE:
     559             :         case NB_EV_PREPARE:
     560             :         case NB_EV_ABORT:
     561             :                 break;
     562           0 :         case NB_EV_APPLY:
     563             :                 /* Add configuration. */
     564           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     565           0 :                 peer = yang_dnode_get_string(args->dnode, NULL);
     566             : 
     567             :                 /* Set destroy information. */
     568           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     569           0 :                 rhc->rhc_rule = "peer";
     570           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     571             : 
     572           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "peer", peer,
     573             :                                           RMAP_EVENT_MATCH_ADDED,
     574             :                                           args->errmsg, args->errmsg_len);
     575             : 
     576           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     577           0 :                         rhc->rhc_mhook = NULL;
     578           0 :                         return NB_ERR_INCONSISTENCY;
     579             :                 }
     580             :         }
     581             : 
     582             :         return NB_OK;
     583             : }
     584             : 
     585             : int
     586           0 : lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv4_address_destroy(
     587             :         struct nb_cb_destroy_args *args)
     588             : {
     589           0 :         switch (args->event) {
     590             :         case NB_EV_VALIDATE:
     591             :         case NB_EV_PREPARE:
     592             :         case NB_EV_ABORT:
     593             :                 break;
     594           0 :         case NB_EV_APPLY:
     595           0 :                 return lib_route_map_entry_match_destroy(args);
     596             :         }
     597             : 
     598             :         return NB_OK;
     599             : }
     600             : 
     601             : /*
     602             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-interface
     603             :  */
     604             : int
     605           0 : lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_modify(
     606             :         struct nb_cb_modify_args *args)
     607             : {
     608           0 :         struct routemap_hook_context *rhc;
     609           0 :         const char *peer;
     610           0 :         enum rmap_compile_rets ret;
     611             : 
     612           0 :         switch (args->event) {
     613             :         case NB_EV_VALIDATE:
     614             :         case NB_EV_PREPARE:
     615             :         case NB_EV_ABORT:
     616             :                 break;
     617           0 :         case NB_EV_APPLY:
     618             :                 /* Add configuration. */
     619           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     620           0 :                 peer = yang_dnode_get_string(args->dnode, NULL);
     621             : 
     622             :                 /* Set destroy information. */
     623           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     624           0 :                 rhc->rhc_rule = "peer";
     625           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     626             : 
     627           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "peer", peer,
     628             :                                 RMAP_EVENT_MATCH_ADDED,
     629             :                                 args->errmsg, args->errmsg_len);
     630             : 
     631           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     632           0 :                         rhc->rhc_mhook = NULL;
     633           0 :                         return NB_ERR_INCONSISTENCY;
     634             :                 }
     635             :         }
     636             : 
     637             :         return NB_OK;
     638             : }
     639             : 
     640             : int
     641           0 : lib_route_map_entry_match_condition_rmap_match_condition_peer_interface_destroy(
     642             :         struct nb_cb_destroy_args *args)
     643             : {
     644           0 :         switch (args->event) {
     645             :         case NB_EV_VALIDATE:
     646             :         case NB_EV_PREPARE:
     647             :         case NB_EV_ABORT:
     648             :                 break;
     649           0 :         case NB_EV_APPLY:
     650           0 :                 return lib_route_map_entry_match_destroy(args);
     651             :         }
     652             : 
     653             :         return NB_OK;
     654             : }
     655             : 
     656             : /*
     657             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address
     658             :  */
     659             : int
     660           0 : lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_modify(
     661             :         struct nb_cb_modify_args *args)
     662             : {
     663           0 :         struct routemap_hook_context *rhc;
     664           0 :         const char *peer;
     665           0 :         enum rmap_compile_rets ret;
     666             : 
     667           0 :         switch (args->event) {
     668             :         case NB_EV_VALIDATE:
     669             :         case NB_EV_PREPARE:
     670             :         case NB_EV_ABORT:
     671             :                 break;
     672           0 :         case NB_EV_APPLY:
     673             :                 /* Add configuration. */
     674           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     675           0 :                 peer = yang_dnode_get_string(args->dnode, NULL);
     676             : 
     677             :                 /* Set destroy information. */
     678           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     679           0 :                 rhc->rhc_rule = "peer";
     680           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     681             : 
     682           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "peer", peer,
     683             :                                 RMAP_EVENT_MATCH_ADDED,
     684             :                                 args->errmsg, args->errmsg_len);
     685             : 
     686           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     687           0 :                         rhc->rhc_mhook = NULL;
     688           0 :                         return NB_ERR_INCONSISTENCY;
     689             :                 }
     690             :         }
     691             : 
     692             :         return NB_OK;
     693             : }
     694             : 
     695             : int
     696           0 : lib_route_map_entry_match_condition_rmap_match_condition_peer_ipv6_address_destroy(
     697             :         struct nb_cb_destroy_args *args)
     698             : {
     699           0 :         switch (args->event) {
     700             :         case NB_EV_VALIDATE:
     701             :         case NB_EV_PREPARE:
     702             :         case NB_EV_ABORT:
     703             :                 break;
     704           0 :         case NB_EV_APPLY:
     705           0 :                 return lib_route_map_entry_match_destroy(args);
     706             :         }
     707             : 
     708             :         return NB_OK;
     709             : }
     710             : 
     711             : /*
     712             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:peer-local
     713             :  */
     714             : int
     715           0 : lib_route_map_entry_match_condition_rmap_match_condition_peer_local_modify(
     716             :         struct nb_cb_modify_args *args)
     717             : {
     718           0 :         struct routemap_hook_context *rhc;
     719           0 :         bool value;
     720           0 :         enum rmap_compile_rets ret;
     721             : 
     722           0 :         switch (args->event) {
     723             :         case NB_EV_VALIDATE:
     724             :         case NB_EV_PREPARE:
     725             :         case NB_EV_ABORT:
     726             :                 break;
     727           0 :         case NB_EV_APPLY:
     728             :                 /* Add configuration. */
     729           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     730           0 :                 value = yang_dnode_get_bool(args->dnode, NULL);
     731             : 
     732             :                 /* Set destroy information. */
     733           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     734           0 :                 rhc->rhc_rule = "peer";
     735           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     736             : 
     737           0 :                 if (value) {
     738           0 :                         ret = bgp_route_match_add(rhc->rhc_rmi, "peer",
     739             :                                                 "local",
     740             :                                                 RMAP_EVENT_MATCH_ADDED,
     741             :                                                 args->errmsg, args->errmsg_len);
     742             : 
     743           0 :                         if (ret != RMAP_COMPILE_SUCCESS) {
     744           0 :                                 rhc->rhc_mhook = NULL;
     745           0 :                                 return NB_ERR_INCONSISTENCY;
     746             :                         }
     747             :                 }
     748             :         }
     749             : 
     750             :         return NB_OK;
     751             : }
     752             : 
     753             : int
     754           0 : lib_route_map_entry_match_condition_rmap_match_condition_peer_local_destroy(
     755             :         struct nb_cb_destroy_args *args)
     756             : {
     757           0 :         switch (args->event) {
     758             :         case NB_EV_VALIDATE:
     759             :         case NB_EV_PREPARE:
     760             :         case NB_EV_ABORT:
     761             :                 break;
     762           0 :         case NB_EV_APPLY:
     763           0 :                 return lib_route_map_entry_match_destroy(args);
     764             :         }
     765             : 
     766             :         return NB_OK;
     767             : }
     768             : 
     769             : /*
     770             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:list-name
     771             :  */
     772             : int
     773           0 : lib_route_map_entry_match_condition_rmap_match_condition_list_name_modify(
     774             :         struct nb_cb_modify_args *args)
     775             : {
     776           0 :         struct routemap_hook_context *rhc;
     777           0 :         const char *list_name;
     778           0 :         enum rmap_compile_rets ret = RMAP_COMPILE_SUCCESS;
     779           0 :         const char *condition;
     780             : 
     781           0 :         switch (args->event) {
     782             :         case NB_EV_VALIDATE:
     783             :         case NB_EV_PREPARE:
     784             :         case NB_EV_ABORT:
     785             :                 break;
     786           0 :         case NB_EV_APPLY:
     787             :                 /* Add configuration. */
     788           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     789           0 :                 list_name = yang_dnode_get_string(args->dnode, NULL);
     790           0 :                 condition = yang_dnode_get_string(args->dnode,
     791             :                                 "../../frr-route-map:condition");
     792             : 
     793           0 :                 if (IS_MATCH_AS_LIST(condition)) {
     794             :                         /* Set destroy information. */
     795           0 :                         rhc->rhc_mhook = bgp_route_match_delete;
     796           0 :                         rhc->rhc_rule = "as-path";
     797           0 :                         rhc->rhc_event = RMAP_EVENT_ASLIST_DELETED;
     798             : 
     799           0 :                         ret = bgp_route_match_add(rhc->rhc_rmi, "as-path",
     800             :                                         list_name, RMAP_EVENT_ASLIST_ADDED,
     801             :                                         args->errmsg, args->errmsg_len);
     802           0 :                 } else if (IS_MATCH_MAC_LIST(condition)) {
     803             :                         /* Set destroy information. */
     804           0 :                         rhc->rhc_mhook = bgp_route_match_delete;
     805           0 :                         rhc->rhc_rule = "mac address";
     806           0 :                         rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
     807             : 
     808           0 :                         ret = bgp_route_match_add(rhc->rhc_rmi,
     809             :                                                   "mac address",
     810             :                                                   list_name,
     811             :                                                   RMAP_EVENT_FILTER_ADDED,
     812             :                                                   args->errmsg, args->errmsg_len);
     813           0 :                 } else if (IS_MATCH_ROUTE_SRC(condition)) {
     814             :                         /* Set destroy information. */
     815           0 :                         rhc->rhc_mhook = bgp_route_match_delete;
     816           0 :                         rhc->rhc_rule = "ip route-source";
     817           0 :                         rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
     818             : 
     819           0 :                         ret = bgp_route_match_add(rhc->rhc_rmi,
     820             :                                         "ip route-source",
     821             :                                         list_name, RMAP_EVENT_FILTER_ADDED,
     822             :                                         args->errmsg, args->errmsg_len);
     823           0 :                 } else if (IS_MATCH_ROUTE_SRC_PL(condition)) {
     824             :                         /* Set destroy information. */
     825           0 :                         rhc->rhc_mhook = bgp_route_match_delete;
     826           0 :                         rhc->rhc_rule = "ip route-source prefix-list";
     827           0 :                         rhc->rhc_event = RMAP_EVENT_PLIST_DELETED;
     828             : 
     829           0 :                         ret = bgp_route_match_add(rhc->rhc_rmi,
     830             :                                         "ip route-source prefix-list",
     831             :                                         list_name, RMAP_EVENT_PLIST_ADDED,
     832             :                                         args->errmsg, args->errmsg_len);
     833             :                 }
     834             : 
     835           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     836           0 :                         rhc->rhc_mhook = NULL;
     837           0 :                         return NB_ERR_INCONSISTENCY;
     838             :                 }
     839             :         }
     840             : 
     841             :         return NB_OK;
     842             : }
     843             : 
     844             : int
     845           0 : lib_route_map_entry_match_condition_rmap_match_condition_list_name_destroy(
     846             :         struct nb_cb_destroy_args *args)
     847             : {
     848           0 :         switch (args->event) {
     849             :         case NB_EV_VALIDATE:
     850             :         case NB_EV_PREPARE:
     851             :         case NB_EV_ABORT:
     852             :                 break;
     853           0 :         case NB_EV_APPLY:
     854           0 :                 return lib_route_map_entry_match_destroy(args);
     855             :         }
     856             : 
     857             :         return NB_OK;
     858             : }
     859             : 
     860             : /*
     861             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-default-route
     862             :  */
     863             : int
     864           0 : lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_create(
     865             :         struct nb_cb_create_args *args)
     866             : {
     867           0 :         struct routemap_hook_context *rhc;
     868           0 :         enum rmap_compile_rets ret;
     869             : 
     870           0 :         switch (args->event) {
     871             :         case NB_EV_VALIDATE:
     872             :         case NB_EV_PREPARE:
     873             :         case NB_EV_ABORT:
     874             :                 break;
     875           0 :         case NB_EV_APPLY:
     876             :                 /* Add configuration. */
     877           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     878             : 
     879             :                 /* Set destroy information. */
     880           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     881           0 :                 rhc->rhc_rule = "evpn default-route";
     882           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     883             : 
     884           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "evpn default-route",
     885             :                                           NULL, RMAP_EVENT_MATCH_ADDED,
     886             :                                           args->errmsg, args->errmsg_len);
     887             : 
     888           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     889           0 :                         rhc->rhc_mhook = NULL;
     890           0 :                         return NB_ERR_INCONSISTENCY;
     891             :                 }
     892             :         }
     893             : 
     894             :         return NB_OK;
     895             : }
     896             : 
     897             : int
     898           0 : lib_route_map_entry_match_condition_rmap_match_condition_evpn_default_route_destroy(
     899             :         struct nb_cb_destroy_args *args)
     900             : {
     901           0 :         switch (args->event) {
     902             :         case NB_EV_VALIDATE:
     903             :         case NB_EV_PREPARE:
     904             :         case NB_EV_ABORT:
     905             :                 break;
     906           0 :         case NB_EV_APPLY:
     907           0 :                 return lib_route_map_entry_match_destroy(args);
     908             :         }
     909             : 
     910             :         return NB_OK;
     911             : }
     912             : 
     913             : /*
     914             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-vni
     915             :  */
     916             : int
     917           0 : lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_modify(
     918             :         struct nb_cb_modify_args *args)
     919             : {
     920           0 :         struct routemap_hook_context *rhc;
     921           0 :         const char *vni;
     922           0 :         enum rmap_compile_rets ret;
     923             : 
     924           0 :         switch (args->event) {
     925             :         case NB_EV_VALIDATE:
     926             :         case NB_EV_PREPARE:
     927             :         case NB_EV_ABORT:
     928             :                 break;
     929           0 :         case NB_EV_APPLY:
     930             :                 /* Add configuration. */
     931           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     932           0 :                 vni = yang_dnode_get_string(args->dnode, NULL);
     933             : 
     934             :                 /* Set destroy information. */
     935           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     936           0 :                 rhc->rhc_rule = "evpn vni";
     937           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     938             : 
     939           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "evpn vni", vni,
     940             :                                 RMAP_EVENT_MATCH_ADDED,
     941             :                                 args->errmsg, args->errmsg_len);
     942             : 
     943           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
     944           0 :                         rhc->rhc_mhook = NULL;
     945           0 :                         return NB_ERR_INCONSISTENCY;
     946             :                 }
     947             :         }
     948             : 
     949             :         return NB_OK;
     950             : }
     951             : 
     952             : int
     953           0 : lib_route_map_entry_match_condition_rmap_match_condition_evpn_vni_destroy(
     954             :         struct nb_cb_destroy_args *args)
     955             : {
     956           0 :         switch (args->event) {
     957             :         case NB_EV_VALIDATE:
     958             :         case NB_EV_PREPARE:
     959             :         case NB_EV_ABORT:
     960             :                 break;
     961           0 :         case NB_EV_APPLY:
     962           0 :                 return lib_route_map_entry_match_destroy(args);
     963             :         }
     964             : 
     965             :         return NB_OK;
     966             : }
     967             : 
     968             : /*
     969             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:evpn-route-type
     970             :  */
     971             : int
     972           0 : lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_modify(
     973             :         struct nb_cb_modify_args *args)
     974             : {
     975           0 :         struct routemap_hook_context *rhc;
     976           0 :         const char *type;
     977           0 :         enum rmap_compile_rets ret;
     978             : 
     979           0 :         switch (args->event) {
     980             :         case NB_EV_VALIDATE:
     981             :         case NB_EV_PREPARE:
     982             :         case NB_EV_ABORT:
     983             :                 break;
     984           0 :         case NB_EV_APPLY:
     985             :                 /* Add configuration. */
     986           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
     987           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
     988             : 
     989             :                 /* Set destroy information. */
     990           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
     991           0 :                 rhc->rhc_rule = "evpn route-type";
     992           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
     993             : 
     994           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "evpn route-type",
     995             :                                           type,
     996             :                                           RMAP_EVENT_MATCH_ADDED,
     997             :                                           args->errmsg, args->errmsg_len);
     998             : 
     999           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
    1000           0 :                         rhc->rhc_mhook = NULL;
    1001           0 :                         return NB_ERR_INCONSISTENCY;
    1002             :                 }
    1003             :         }
    1004             : 
    1005             :         return NB_OK;
    1006             : }
    1007             : 
    1008             : int
    1009           0 : lib_route_map_entry_match_condition_rmap_match_condition_evpn_route_type_destroy(
    1010             :         struct nb_cb_destroy_args *args)
    1011             : {
    1012           0 :         switch (args->event) {
    1013             :         case NB_EV_VALIDATE:
    1014             :         case NB_EV_PREPARE:
    1015             :         case NB_EV_ABORT:
    1016             :                 break;
    1017           0 :         case NB_EV_APPLY:
    1018           0 :                 return lib_route_map_entry_match_destroy(args);
    1019             :         }
    1020             : 
    1021             :         return NB_OK;
    1022             : }
    1023             : 
    1024             : /*
    1025             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:route-distinguisher
    1026             :  */
    1027             : int
    1028           0 : lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_modify(
    1029             :         struct nb_cb_modify_args *args)
    1030             : {
    1031           0 :         struct routemap_hook_context *rhc;
    1032           0 :         const char *rd;
    1033           0 :         enum rmap_compile_rets ret;
    1034             : 
    1035           0 :         switch (args->event) {
    1036             :         case NB_EV_VALIDATE:
    1037             :         case NB_EV_PREPARE:
    1038             :         case NB_EV_ABORT:
    1039             :                 break;
    1040           0 :         case NB_EV_APPLY:
    1041             :                 /* Add configuration. */
    1042           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1043           0 :                 rd = yang_dnode_get_string(args->dnode, NULL);
    1044             : 
    1045             :                 /* Set destroy information. */
    1046           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
    1047           0 :                 rhc->rhc_rule = "evpn rd";
    1048           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
    1049             : 
    1050           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, "evpn rd", rd,
    1051             :                                 RMAP_EVENT_MATCH_ADDED,
    1052             :                                 args->errmsg, args->errmsg_len);
    1053             : 
    1054           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
    1055           0 :                         rhc->rhc_mhook = NULL;
    1056           0 :                         return NB_ERR_INCONSISTENCY;
    1057             :                 }
    1058             :         }
    1059             : 
    1060             :         return NB_OK;
    1061             : }
    1062             : 
    1063             : int
    1064           0 : lib_route_map_entry_match_condition_rmap_match_condition_route_distinguisher_destroy(
    1065             :         struct nb_cb_destroy_args *args)
    1066             : {
    1067           0 :         switch (args->event) {
    1068             :         case NB_EV_VALIDATE:
    1069             :         case NB_EV_PREPARE:
    1070             :         case NB_EV_ABORT:
    1071             :                 break;
    1072           0 :         case NB_EV_APPLY:
    1073           0 :                 return lib_route_map_entry_match_destroy(args);
    1074             :         }
    1075             : 
    1076             :         return NB_OK;
    1077             : }
    1078             : 
    1079             : /*
    1080             :  * XPath = /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list
    1081             :  */
    1082             : void
    1083           0 : lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish(
    1084             :         struct nb_cb_apply_finish_args *args)
    1085             : {
    1086           0 :         struct routemap_hook_context *rhc;
    1087           0 :         const char *value;
    1088           0 :         bool exact_match = false;
    1089           0 :         char *argstr;
    1090           0 :         const char *condition;
    1091           0 :         route_map_event_t event;
    1092           0 :         int ret;
    1093             : 
    1094             :         /* Add configuration. */
    1095           0 :         rhc = nb_running_get_entry(args->dnode, NULL, true);
    1096           0 :         value = yang_dnode_get_string(args->dnode, "./comm-list-name");
    1097             : 
    1098           0 :         if (yang_dnode_exists(args->dnode, "./comm-list-name-exact-match"))
    1099           0 :                 exact_match = yang_dnode_get_bool(
    1100             :                         args->dnode, "./comm-list-name-exact-match");
    1101             : 
    1102           0 :         if (exact_match) {
    1103           0 :                 argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED,
    1104             :                                  strlen(value) + strlen("exact-match") + 2);
    1105             : 
    1106           0 :                 snprintf(argstr, (strlen(value) + strlen("exact-match") + 2),
    1107             :                          "%s exact-match", value);
    1108             :         } else
    1109             :                 argstr = (char *)value;
    1110             : 
    1111             :         /* Set destroy information. */
    1112           0 :         rhc->rhc_mhook = bgp_route_match_delete;
    1113             : 
    1114           0 :         condition = yang_dnode_get_string(args->dnode,
    1115             :                                           "../../frr-route-map:condition");
    1116           0 :         if (IS_MATCH_COMMUNITY(condition)) {
    1117           0 :                 rhc->rhc_rule = "community";
    1118           0 :                 event = RMAP_EVENT_CLIST_ADDED;
    1119           0 :                 rhc->rhc_event = RMAP_EVENT_CLIST_DELETED;
    1120           0 :         } else if (IS_MATCH_LCOMMUNITY(condition)) {
    1121           0 :                 rhc->rhc_rule = "large-community";
    1122           0 :                 event = RMAP_EVENT_LLIST_ADDED;
    1123           0 :                 rhc->rhc_event = RMAP_EVENT_LLIST_DELETED;
    1124             :         } else {
    1125           0 :                 rhc->rhc_rule = "extcommunity";
    1126           0 :                 event = RMAP_EVENT_ECLIST_ADDED;
    1127           0 :                 rhc->rhc_event = RMAP_EVENT_ECLIST_DELETED;
    1128             :         }
    1129             : 
    1130           0 :         ret = bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule, argstr, event,
    1131             :                                   args->errmsg, args->errmsg_len);
    1132             :         /*
    1133             :          * At this point if this is not a successful operation
    1134             :          * bgpd is about to crash.  Let's just cut to the
    1135             :          * chase and do it.
    1136             :          */
    1137           0 :         assert(ret == RMAP_COMPILE_SUCCESS);
    1138             : 
    1139           0 :         if (argstr != value)
    1140           0 :                 XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
    1141           0 : }
    1142             : 
    1143             : /*
    1144             :  * XPath:
    1145             :  * /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name
    1146             :  */
    1147             : int
    1148           0 : lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_modify(
    1149             :         struct nb_cb_modify_args *args)
    1150             : {
    1151           0 :         switch (args->event) {
    1152             :         case NB_EV_VALIDATE:
    1153             :         case NB_EV_PREPARE:
    1154             :         case NB_EV_ABORT:
    1155             :         case NB_EV_APPLY:
    1156             :                 break;
    1157             :         }
    1158             : 
    1159           0 :         return NB_OK;
    1160             : }
    1161             : 
    1162             : int
    1163           0 : lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_destroy(
    1164             :         struct nb_cb_destroy_args *args)
    1165             : {
    1166           0 :         switch (args->event) {
    1167             :         case NB_EV_VALIDATE:
    1168             :         case NB_EV_PREPARE:
    1169             :         case NB_EV_ABORT:
    1170             :                 break;
    1171           0 :         case NB_EV_APPLY:
    1172           0 :                 return lib_route_map_entry_match_destroy(args);
    1173             :         }
    1174             : 
    1175             :         return NB_OK;
    1176             : 
    1177             : }
    1178             : 
    1179             : /*
    1180             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match
    1181             :  */
    1182             : int
    1183           0 : lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_modify(
    1184             :         struct nb_cb_modify_args *args)
    1185             : {
    1186           0 :         switch (args->event) {
    1187             :         case NB_EV_VALIDATE:
    1188             :         case NB_EV_PREPARE:
    1189             :         case NB_EV_ABORT:
    1190             :         case NB_EV_APPLY:
    1191             :                 break;
    1192             :         }
    1193             : 
    1194           0 :         return NB_OK;
    1195             : }
    1196             : 
    1197             : int
    1198           0 : lib_route_map_entry_match_condition_rmap_match_condition_comm_list_comm_list_name_exact_match_destroy(
    1199             :         struct nb_cb_destroy_args *args)
    1200             : {
    1201           0 :         switch (args->event) {
    1202             :         case NB_EV_VALIDATE:
    1203             :         case NB_EV_PREPARE:
    1204             :         case NB_EV_ABORT:
    1205             :                 break;
    1206           0 :         case NB_EV_APPLY:
    1207           0 :                 return lib_route_map_entry_match_destroy(args);
    1208             :         }
    1209             : 
    1210             :         return NB_OK;
    1211             : }
    1212             : 
    1213             : /*
    1214             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv4-address
    1215             :  */
    1216             : int
    1217           0 : lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_modify(
    1218             :         struct nb_cb_modify_args *args)
    1219             : {
    1220           0 :         struct routemap_hook_context *rhc;
    1221           0 :         const char *peer;
    1222           0 :         enum rmap_compile_rets ret;
    1223             : 
    1224           0 :         switch (args->event) {
    1225             :         case NB_EV_VALIDATE:
    1226             :         case NB_EV_PREPARE:
    1227             :         case NB_EV_ABORT:
    1228             :                 break;
    1229           0 :         case NB_EV_APPLY:
    1230             :                 /* Add configuration. */
    1231           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1232           0 :                 peer = yang_dnode_get_string(args->dnode, NULL);
    1233             : 
    1234             :                 /* Set destroy information. */
    1235           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
    1236           0 :                 rhc->rhc_rule = "ip next-hop address";
    1237           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
    1238             : 
    1239           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule,
    1240             :                                           peer, RMAP_EVENT_MATCH_ADDED,
    1241             :                                           args->errmsg, args->errmsg_len);
    1242             : 
    1243           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
    1244           0 :                         rhc->rhc_mhook = NULL;
    1245           0 :                         return NB_ERR_INCONSISTENCY;
    1246             :                 }
    1247             :         }
    1248             : 
    1249             :         return NB_OK;
    1250             : }
    1251             : 
    1252             : int
    1253           0 : lib_route_map_entry_match_condition_rmap_match_condition_ipv4_address_destroy(
    1254             :         struct nb_cb_destroy_args *args)
    1255             : {
    1256           0 :         switch (args->event) {
    1257             :         case NB_EV_VALIDATE:
    1258             :         case NB_EV_PREPARE:
    1259             :         case NB_EV_ABORT:
    1260             :                 break;
    1261           0 :         case NB_EV_APPLY:
    1262           0 :                 return lib_route_map_entry_match_destroy(args);
    1263             :         }
    1264             : 
    1265             :         return NB_OK;
    1266             : }
    1267             : 
    1268             : /*
    1269             :  * XPath: /frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/frr-bgp-route-map:ipv6-address
    1270             :  */
    1271             : int
    1272           0 : lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_modify(
    1273             :         struct nb_cb_modify_args *args)
    1274             : {
    1275           0 :         struct routemap_hook_context *rhc;
    1276           0 :         const char *peer;
    1277           0 :         enum rmap_compile_rets ret;
    1278             : 
    1279           0 :         switch (args->event) {
    1280             :         case NB_EV_VALIDATE:
    1281             :         case NB_EV_PREPARE:
    1282             :         case NB_EV_ABORT:
    1283             :                 break;
    1284           0 :         case NB_EV_APPLY:
    1285             :                 /* Add configuration. */
    1286           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1287           0 :                 peer = yang_dnode_get_string(args->dnode, NULL);
    1288             : 
    1289             :                 /* Set destroy information. */
    1290           0 :                 rhc->rhc_mhook = bgp_route_match_delete;
    1291           0 :                 rhc->rhc_rule = "ipv6 next-hop address";
    1292           0 :                 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
    1293             : 
    1294           0 :                 ret = bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule,
    1295             :                                           peer, RMAP_EVENT_MATCH_ADDED,
    1296             :                                           args->errmsg, args->errmsg_len);
    1297             : 
    1298           0 :                 if (ret != RMAP_COMPILE_SUCCESS) {
    1299           0 :                         rhc->rhc_mhook = NULL;
    1300           0 :                         return NB_ERR_INCONSISTENCY;
    1301             :                 }
    1302             :         }
    1303             : 
    1304             :         return NB_OK;
    1305             : }
    1306             : 
    1307             : int
    1308           0 : lib_route_map_entry_match_condition_rmap_match_condition_ipv6_address_destroy(
    1309             :         struct nb_cb_destroy_args *args)
    1310             : {
    1311           0 :         switch (args->event) {
    1312             :         case NB_EV_VALIDATE:
    1313             :         case NB_EV_PREPARE:
    1314             :         case NB_EV_ABORT:
    1315             :                 break;
    1316           0 :         case NB_EV_APPLY:
    1317           0 :                 return lib_route_map_entry_match_destroy(args);
    1318             :         }
    1319             : 
    1320             :         return NB_OK;
    1321             : }
    1322             : 
    1323             : /*
    1324             :  * XPath:
    1325             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:distance
    1326             :  */
    1327           0 : int lib_route_map_entry_set_action_rmap_set_action_distance_modify(
    1328             :         struct nb_cb_modify_args *args)
    1329             : {
    1330           0 :         struct routemap_hook_context *rhc;
    1331           0 :         const char *type;
    1332           0 :         int rv;
    1333             : 
    1334           0 :         switch (args->event) {
    1335             :         case NB_EV_VALIDATE:
    1336             :         case NB_EV_PREPARE:
    1337             :         case NB_EV_ABORT:
    1338             :                 break;
    1339           0 :         case NB_EV_APPLY:
    1340             :                 /* Add configuration. */
    1341           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1342           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    1343             : 
    1344             :                 /* Set destroy information. */
    1345           0 :                 rhc->rhc_shook = generic_set_delete;
    1346           0 :                 rhc->rhc_rule = "distance";
    1347           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1348             : 
    1349           0 :                 rv = generic_set_add(rhc->rhc_rmi, "distance", type,
    1350             :                                      args->errmsg, args->errmsg_len);
    1351           0 :                 if (rv != CMD_SUCCESS) {
    1352           0 :                         rhc->rhc_shook = NULL;
    1353           0 :                         return NB_ERR_INCONSISTENCY;
    1354             :                 }
    1355             :         }
    1356             : 
    1357             :         return NB_OK;
    1358             : }
    1359             : 
    1360           0 : int lib_route_map_entry_set_action_rmap_set_action_distance_destroy(
    1361             :         struct nb_cb_destroy_args *args)
    1362             : {
    1363           0 :         switch (args->event) {
    1364             :         case NB_EV_VALIDATE:
    1365             :         case NB_EV_PREPARE:
    1366             :         case NB_EV_ABORT:
    1367             :                 break;
    1368           0 :         case NB_EV_APPLY:
    1369           0 :                 return lib_route_map_entry_match_destroy(args);
    1370             :         }
    1371             : 
    1372             :         return NB_OK;
    1373             : }
    1374             : 
    1375             : /*
    1376             :  * XPath:
    1377             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-rt
    1378             :  */
    1379             : int
    1380           0 : lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_modify(
    1381             :         struct nb_cb_modify_args *args)
    1382             : {
    1383           0 :         struct routemap_hook_context *rhc;
    1384           0 :         const char *type;
    1385           0 :         int rv;
    1386             : 
    1387           0 :         switch (args->event) {
    1388             :         case NB_EV_VALIDATE:
    1389             :         case NB_EV_PREPARE:
    1390             :         case NB_EV_ABORT:
    1391             :                 break;
    1392           0 :         case NB_EV_APPLY:
    1393             :                 /* Add configuration. */
    1394           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1395           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    1396             : 
    1397             :                 /* Set destroy information. */
    1398           0 :                 rhc->rhc_shook = generic_set_delete;
    1399           0 :                 rhc->rhc_rule = "extcommunity rt";
    1400           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1401             : 
    1402           0 :                 rv = generic_set_add(rhc->rhc_rmi, "extcommunity rt", type,
    1403             :                                      args->errmsg, args->errmsg_len);
    1404           0 :                 if (rv != CMD_SUCCESS) {
    1405           0 :                         rhc->rhc_shook = NULL;
    1406           0 :                         return NB_ERR_INCONSISTENCY;
    1407             :                 }
    1408             :         }
    1409             : 
    1410             :         return NB_OK;
    1411             : }
    1412             : 
    1413             : int
    1414           0 : lib_route_map_entry_set_action_rmap_set_action_extcommunity_rt_destroy(
    1415             :         struct nb_cb_destroy_args *args)
    1416             : {
    1417           0 :         switch (args->event) {
    1418             :         case NB_EV_VALIDATE:
    1419             :         case NB_EV_PREPARE:
    1420             :         case NB_EV_ABORT:
    1421             :                 break;
    1422           0 :         case NB_EV_APPLY:
    1423           0 :                 return lib_route_map_entry_match_destroy(args);
    1424             :         }
    1425             : 
    1426             :         return NB_OK;
    1427             : }
    1428             : 
    1429             : /*
    1430             :  * XPath:
    1431             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-soo
    1432             :  */
    1433             : int
    1434           0 : lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_modify(
    1435             :         struct nb_cb_modify_args *args)
    1436             : {
    1437           0 :         struct routemap_hook_context *rhc;
    1438           0 :         const char *type;
    1439           0 :         int rv;
    1440             : 
    1441           0 :         switch (args->event) {
    1442             :         case NB_EV_VALIDATE:
    1443             :         case NB_EV_PREPARE:
    1444             :         case NB_EV_ABORT:
    1445             :                 break;
    1446           0 :         case NB_EV_APPLY:
    1447             :                 /* Add configuration. */
    1448           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1449           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    1450             : 
    1451             :                 /* Set destroy information. */
    1452           0 :                 rhc->rhc_shook = generic_set_delete;
    1453           0 :                 rhc->rhc_rule = "extcommunity soo";
    1454           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1455             : 
    1456           0 :                 rv = generic_set_add(rhc->rhc_rmi, "extcommunity soo",
    1457             :                                      type,
    1458             :                                      args->errmsg, args->errmsg_len);
    1459           0 :                 if (rv != CMD_SUCCESS) {
    1460           0 :                         rhc->rhc_shook = NULL;
    1461           0 :                         return NB_ERR_INCONSISTENCY;
    1462             :                 }
    1463             :         }
    1464             : 
    1465             :         return NB_OK;
    1466             : }
    1467             : 
    1468             : int
    1469           0 : lib_route_map_entry_set_action_rmap_set_action_extcommunity_soo_destroy(
    1470             :         struct nb_cb_destroy_args *args)
    1471             : {
    1472           0 :         switch (args->event) {
    1473             :         case NB_EV_VALIDATE:
    1474             :         case NB_EV_PREPARE:
    1475             :         case NB_EV_ABORT:
    1476             :                 break;
    1477           0 :         case NB_EV_APPLY:
    1478           0 :                 return lib_route_map_entry_match_destroy(args);
    1479             :         }
    1480             : 
    1481             :         return NB_OK;
    1482             : }
    1483             : 
    1484             : /*
    1485             :  * XPath:
    1486             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-address
    1487             :  */
    1488           0 : int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_modify(
    1489             :         struct nb_cb_modify_args *args)
    1490             : {
    1491           0 :         struct routemap_hook_context *rhc;
    1492           0 :         const char *addr;
    1493           0 :         int rv = CMD_SUCCESS;
    1494             : 
    1495           0 :         switch (args->event) {
    1496             :         case NB_EV_VALIDATE:
    1497             :         case NB_EV_PREPARE:
    1498             :         case NB_EV_ABORT:
    1499             :                 break;
    1500           0 :         case NB_EV_APPLY:
    1501             :                 /* Add configuration. */
    1502           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1503           0 :                 addr = yang_dnode_get_string(args->dnode, NULL);
    1504             : 
    1505           0 :                 rhc->rhc_shook = generic_set_delete;
    1506           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1507           0 :                 rhc->rhc_rule = "ipv4 vpn next-hop";
    1508             : 
    1509           0 :                 rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, addr,
    1510             :                                      args->errmsg, args->errmsg_len);
    1511             : 
    1512           0 :                 if (rv != CMD_SUCCESS) {
    1513           0 :                         rhc->rhc_shook = NULL;
    1514           0 :                         return NB_ERR_INCONSISTENCY;
    1515             :                 }
    1516             :         }
    1517             : 
    1518             :         return NB_OK;
    1519             : }
    1520             : 
    1521           0 : int lib_route_map_entry_set_action_rmap_set_action_ipv4_address_destroy(
    1522             :         struct nb_cb_destroy_args *args)
    1523             : {
    1524           0 :         switch (args->event) {
    1525             :         case NB_EV_VALIDATE:
    1526             :         case NB_EV_PREPARE:
    1527             :         case NB_EV_ABORT:
    1528             :                 break;
    1529           0 :         case NB_EV_APPLY:
    1530           0 :                 return lib_route_map_entry_set_destroy(args);
    1531             :         }
    1532             : 
    1533             :         return NB_OK;
    1534             : }
    1535             : 
    1536             : /*
    1537             :  * XPath:
    1538             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv4-nexthop
    1539             :  */
    1540           0 : int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_modify(
    1541             :         struct nb_cb_modify_args *args)
    1542             : {
    1543           0 :         struct routemap_hook_context *rhc;
    1544           0 :         const char *type;
    1545           0 :         int rv;
    1546             : 
    1547           0 :         switch (args->event) {
    1548             :         case NB_EV_VALIDATE:
    1549             :         case NB_EV_PREPARE:
    1550             :         case NB_EV_ABORT:
    1551             :                 break;
    1552           0 :         case NB_EV_APPLY:
    1553             :                 /* Add configuration. */
    1554           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1555           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    1556             : 
    1557             :                 /* Set destroy information. */
    1558           0 :                 rhc->rhc_shook = generic_set_delete;
    1559           0 :                 rhc->rhc_rule = "ip next-hop";
    1560           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1561             : 
    1562           0 :                 rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, type,
    1563             :                                     args->errmsg, args->errmsg_len);
    1564             : 
    1565           0 :                 if (rv != CMD_SUCCESS) {
    1566           0 :                         rhc->rhc_shook = NULL;
    1567           0 :                         return NB_ERR_INCONSISTENCY;
    1568             :                 }
    1569             :         }
    1570             : 
    1571             :         return NB_OK;
    1572             : }
    1573             : 
    1574           0 : int lib_route_map_entry_set_action_rmap_set_action_ipv4_nexthop_destroy(
    1575             :         struct nb_cb_destroy_args *args)
    1576             : {
    1577           0 :         switch (args->event) {
    1578             :         case NB_EV_VALIDATE:
    1579             :         case NB_EV_PREPARE:
    1580             :         case NB_EV_ABORT:
    1581             :                 break;
    1582           0 :         case NB_EV_APPLY:
    1583           0 :                 return lib_route_map_entry_set_destroy(args);
    1584             :         }
    1585             : 
    1586             :         return NB_OK;
    1587             : }
    1588             : 
    1589             : /*
    1590             :  * XPath:
    1591             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:ipv6-address
    1592             :  */
    1593           0 : int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify(
    1594             :         struct nb_cb_modify_args *args)
    1595             : {
    1596           0 :         struct routemap_hook_context *rhc;
    1597           0 :         const char *addr;
    1598           0 :         int rv = CMD_SUCCESS;
    1599           0 :         const char *action = NULL;
    1600           0 :         struct in6_addr i6a;
    1601             : 
    1602           0 :         action = yang_dnode_get_string(args->dnode,
    1603             :                                        "../../frr-route-map:action");
    1604           0 :         switch (args->event) {
    1605           0 :         case NB_EV_VALIDATE:
    1606           0 :                 if (action && IS_SET_IPV6_NH_GLOBAL(action)) {
    1607           0 :                         yang_dnode_get_ipv6(&i6a, args->dnode, NULL);
    1608           0 :                         if (IN6_IS_ADDR_UNSPECIFIED(&i6a)
    1609           0 :                             || IN6_IS_ADDR_LOOPBACK(&i6a)
    1610           0 :                             || IN6_IS_ADDR_MULTICAST(&i6a)
    1611           0 :                             || IN6_IS_ADDR_LINKLOCAL(&i6a))
    1612             :                                 return NB_ERR_VALIDATION;
    1613             :                 }
    1614             :         /* FALLTHROUGH */
    1615             :         case NB_EV_PREPARE:
    1616             :         case NB_EV_ABORT:
    1617             :                 return NB_OK;
    1618             :         case NB_EV_APPLY:
    1619             :                 break;
    1620             :         }
    1621             : 
    1622             :         /* Add configuration. */
    1623           0 :         rhc = nb_running_get_entry(args->dnode, NULL, true);
    1624           0 :         addr = yang_dnode_get_string(args->dnode, NULL);
    1625             : 
    1626           0 :         rhc->rhc_shook = generic_set_delete;
    1627           0 :         rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1628             : 
    1629           0 :         if (IS_SET_IPV6_NH_GLOBAL(action))
    1630             :                 /* Set destroy information. */
    1631           0 :                 rhc->rhc_rule = "ipv6 next-hop global";
    1632             :         else
    1633           0 :                 rhc->rhc_rule = "ipv6 vpn next-hop";
    1634             : 
    1635           0 :         rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, addr,
    1636             :                              args->errmsg, args->errmsg_len);
    1637             : 
    1638           0 :         if (rv != CMD_SUCCESS) {
    1639           0 :                 rhc->rhc_shook = NULL;
    1640           0 :                 return NB_ERR_INCONSISTENCY;
    1641             :         }
    1642             : 
    1643             :         return NB_OK;
    1644             : }
    1645             : 
    1646           0 : int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy(
    1647             :         struct nb_cb_destroy_args *args)
    1648             : {
    1649           0 :         switch (args->event) {
    1650             :         case NB_EV_VALIDATE:
    1651             :         case NB_EV_PREPARE:
    1652             :         case NB_EV_ABORT:
    1653             :                 break;
    1654           0 :         case NB_EV_APPLY:
    1655           0 :                 return lib_route_map_entry_set_destroy(args);
    1656             :         }
    1657             : 
    1658             :         return NB_OK;
    1659             : }
    1660             : 
    1661             : /*
    1662             :  * XPath:
    1663             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:preference
    1664             :  */
    1665           0 : int lib_route_map_entry_set_action_rmap_set_action_preference_modify(
    1666             :         struct nb_cb_modify_args *args)
    1667             : {
    1668           0 :         struct routemap_hook_context *rhc;
    1669           0 :         int rv = CMD_SUCCESS;
    1670           0 :         const char *action = NULL;
    1671           0 :         bool value;
    1672             : 
    1673           0 :         switch (args->event) {
    1674             :         case NB_EV_VALIDATE:
    1675             :         case NB_EV_PREPARE:
    1676             :         case NB_EV_ABORT:
    1677             :                 break;
    1678           0 :         case NB_EV_APPLY:
    1679             :                 /* Add configuration. */
    1680           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1681           0 :                 value = yang_dnode_get_bool(args->dnode, NULL);
    1682             : 
    1683           0 :                 rhc->rhc_shook = generic_set_delete;
    1684           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1685             : 
    1686           0 :                 action = yang_dnode_get_string(args->dnode,
    1687             :                                 "../../frr-route-map:action");
    1688             : 
    1689           0 :                 if (value) {
    1690           0 :                         if (IS_SET_IPV6_PEER_ADDR(action))
    1691             :                                 /* Set destroy information. */
    1692           0 :                                 rhc->rhc_rule = "ipv6 next-hop peer-address";
    1693             :                         else
    1694           0 :                                 rhc->rhc_rule = "ipv6 next-hop prefer-global";
    1695             : 
    1696           0 :                         rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule,
    1697             :                                              NULL,
    1698             :                                              args->errmsg, args->errmsg_len);
    1699             :                 }
    1700             : 
    1701           0 :                 if (rv != CMD_SUCCESS) {
    1702           0 :                         rhc->rhc_shook = NULL;
    1703           0 :                         return NB_ERR_INCONSISTENCY;
    1704             :                 }
    1705             :         }
    1706             : 
    1707             :         return NB_OK;
    1708             : }
    1709             : 
    1710           0 : int lib_route_map_entry_set_action_rmap_set_action_preference_destroy(
    1711             :         struct nb_cb_destroy_args *args)
    1712             : {
    1713           0 :         switch (args->event) {
    1714             :         case NB_EV_VALIDATE:
    1715             :         case NB_EV_PREPARE:
    1716             :         case NB_EV_ABORT:
    1717             :                 break;
    1718           0 :         case NB_EV_APPLY:
    1719           0 :                 return lib_route_map_entry_set_destroy(args);
    1720             :         }
    1721             : 
    1722             :         return NB_OK;
    1723             : }
    1724             : 
    1725             : /*
    1726             :  * XPath:
    1727             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:label-index
    1728             :  */
    1729           0 : int lib_route_map_entry_set_action_rmap_set_action_label_index_modify(
    1730             :         struct nb_cb_modify_args *args)
    1731             : {
    1732           0 :         struct routemap_hook_context *rhc;
    1733           0 :         const char *type;
    1734           0 :         int rv;
    1735             : 
    1736           0 :         switch (args->event) {
    1737             :         case NB_EV_VALIDATE:
    1738             :         case NB_EV_PREPARE:
    1739             :         case NB_EV_ABORT:
    1740             :                 break;
    1741           0 :         case NB_EV_APPLY:
    1742             :                 /* Add configuration. */
    1743           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1744           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    1745             : 
    1746             :                 /* Set destroy information. */
    1747           0 :                 rhc->rhc_shook = generic_set_delete;
    1748           0 :                 rhc->rhc_rule = "label-index";
    1749           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1750             : 
    1751           0 :                 rv = generic_set_add(rhc->rhc_rmi, "label-index", type,
    1752             :                                      args->errmsg, args->errmsg_len);
    1753           0 :                 if (rv != CMD_SUCCESS) {
    1754           0 :                         rhc->rhc_shook = NULL;
    1755           0 :                         return NB_ERR_INCONSISTENCY;
    1756             :                 }
    1757             :         }
    1758             : 
    1759             :         return NB_OK;
    1760             : }
    1761             : 
    1762           0 : int lib_route_map_entry_set_action_rmap_set_action_label_index_destroy(
    1763             :         struct nb_cb_destroy_args *args)
    1764             : {
    1765           0 :         switch (args->event) {
    1766             :         case NB_EV_VALIDATE:
    1767             :         case NB_EV_PREPARE:
    1768             :         case NB_EV_ABORT:
    1769             :                 break;
    1770           0 :         case NB_EV_APPLY:
    1771           0 :                 return lib_route_map_entry_set_destroy(args);
    1772             :         }
    1773             : 
    1774             :         return NB_OK;
    1775             : }
    1776             : 
    1777             : /*
    1778             :  * XPath:
    1779             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:local-pref
    1780             :  */
    1781           0 : int lib_route_map_entry_set_action_rmap_set_action_local_pref_modify(
    1782             :         struct nb_cb_modify_args *args)
    1783             : {
    1784           0 :         struct routemap_hook_context *rhc;
    1785           0 :         const char *type;
    1786           0 :         int rv;
    1787             : 
    1788           0 :         switch (args->event) {
    1789             :         case NB_EV_VALIDATE:
    1790             :         case NB_EV_PREPARE:
    1791             :         case NB_EV_ABORT:
    1792             :                 break;
    1793           0 :         case NB_EV_APPLY:
    1794             :                 /* Add configuration. */
    1795           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1796           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    1797             : 
    1798             :                 /* Set destroy information. */
    1799           0 :                 rhc->rhc_shook = generic_set_delete;
    1800           0 :                 rhc->rhc_rule = "local-preference";
    1801           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1802             : 
    1803           0 :                 rv = generic_set_add(rhc->rhc_rmi, "local-preference",
    1804             :                                      type,
    1805             :                                      args->errmsg, args->errmsg_len);
    1806           0 :                 if (rv != CMD_SUCCESS) {
    1807           0 :                         rhc->rhc_shook = NULL;
    1808           0 :                         return NB_ERR_INCONSISTENCY;
    1809             :                 }
    1810             :         }
    1811             : 
    1812             :         return NB_OK;
    1813             : }
    1814             : 
    1815           0 : int lib_route_map_entry_set_action_rmap_set_action_local_pref_destroy(
    1816             :         struct nb_cb_destroy_args *args)
    1817             : {
    1818           0 :         switch (args->event) {
    1819             :         case NB_EV_VALIDATE:
    1820             :         case NB_EV_PREPARE:
    1821             :         case NB_EV_ABORT:
    1822             :                 break;
    1823           0 :         case NB_EV_APPLY:
    1824           0 :                 return lib_route_map_entry_set_destroy(args);
    1825             :         }
    1826             : 
    1827             :         return NB_OK;
    1828             : }
    1829             : 
    1830             : /*
    1831             :  * XPath:
    1832             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:weight
    1833             :  */
    1834           0 : int lib_route_map_entry_set_action_rmap_set_action_weight_modify(
    1835             :         struct nb_cb_modify_args *args)
    1836             : {
    1837           0 :         struct routemap_hook_context *rhc;
    1838           0 :         const char *type;
    1839           0 :         int rv;
    1840             : 
    1841           0 :         switch (args->event) {
    1842             :         case NB_EV_VALIDATE:
    1843             :         case NB_EV_PREPARE:
    1844             :         case NB_EV_ABORT:
    1845             :                 break;
    1846           0 :         case NB_EV_APPLY:
    1847             :                 /* Add configuration. */
    1848           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1849           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    1850             : 
    1851             :                 /* Set destroy information. */
    1852           0 :                 rhc->rhc_shook = generic_set_delete;
    1853           0 :                 rhc->rhc_rule = "weight";
    1854           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1855             : 
    1856           0 :                 rv = generic_set_add(rhc->rhc_rmi, "weight", type,
    1857             :                                      args->errmsg, args->errmsg_len);
    1858           0 :                 if (rv != CMD_SUCCESS) {
    1859           0 :                         rhc->rhc_shook = NULL;
    1860           0 :                         return NB_ERR_INCONSISTENCY;
    1861             :                 }
    1862             :         }
    1863             : 
    1864             :         return NB_OK;
    1865             : }
    1866             : 
    1867           0 : int lib_route_map_entry_set_action_rmap_set_action_weight_destroy(
    1868             :         struct nb_cb_destroy_args *args)
    1869             : {
    1870           0 :         switch (args->event) {
    1871             :         case NB_EV_VALIDATE:
    1872             :         case NB_EV_PREPARE:
    1873             :         case NB_EV_ABORT:
    1874             :                 break;
    1875           0 :         case NB_EV_APPLY:
    1876           0 :                 return lib_route_map_entry_set_destroy(args);
    1877             :         }
    1878             : 
    1879             :         return NB_OK;
    1880             : }
    1881             : 
    1882             : /*
    1883             :  * XPath:
    1884             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:origin
    1885             :  */
    1886           0 : int lib_route_map_entry_set_action_rmap_set_action_origin_modify(
    1887             :         struct nb_cb_modify_args *args)
    1888             : {
    1889           0 :         struct routemap_hook_context *rhc;
    1890           0 :         const char *type;
    1891           0 :         int rv;
    1892             : 
    1893           0 :         switch (args->event) {
    1894             :         case NB_EV_VALIDATE:
    1895             :         case NB_EV_PREPARE:
    1896             :         case NB_EV_ABORT:
    1897             :                 break;
    1898           0 :         case NB_EV_APPLY:
    1899             :                 /* Add configuration. */
    1900           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1901           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    1902             : 
    1903             :                 /* Set destroy information. */
    1904           0 :                 rhc->rhc_shook = generic_set_delete;
    1905           0 :                 rhc->rhc_rule = "origin";
    1906           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1907             : 
    1908           0 :                 rv = generic_set_add(rhc->rhc_rmi, "origin", type,
    1909             :                                      args->errmsg, args->errmsg_len);
    1910           0 :                 if (rv != CMD_SUCCESS) {
    1911           0 :                         rhc->rhc_shook = NULL;
    1912           0 :                         return NB_ERR_INCONSISTENCY;
    1913             :                 }
    1914             :         }
    1915             : 
    1916             :         return NB_OK;
    1917             : }
    1918             : 
    1919           0 : int lib_route_map_entry_set_action_rmap_set_action_origin_destroy(
    1920             :         struct nb_cb_destroy_args *args)
    1921             : {
    1922           0 :         switch (args->event) {
    1923             :         case NB_EV_VALIDATE:
    1924             :         case NB_EV_PREPARE:
    1925             :         case NB_EV_ABORT:
    1926             :                 break;
    1927           0 :         case NB_EV_APPLY:
    1928           0 :                 return lib_route_map_entry_set_destroy(args);
    1929             : 
    1930             :         }
    1931             : 
    1932             :         return NB_OK;
    1933             : }
    1934             : 
    1935             : /*
    1936             :  * XPath:
    1937             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:originator-id
    1938             :  */
    1939           0 : int lib_route_map_entry_set_action_rmap_set_action_originator_id_modify(
    1940             :         struct nb_cb_modify_args *args)
    1941             : {
    1942           0 :         struct routemap_hook_context *rhc;
    1943           0 :         const char *type;
    1944           0 :         int rv;
    1945             : 
    1946           0 :         switch (args->event) {
    1947             :         case NB_EV_VALIDATE:
    1948             :         case NB_EV_PREPARE:
    1949             :         case NB_EV_ABORT:
    1950             :                 break;
    1951           0 :         case NB_EV_APPLY:
    1952             :                 /* Add configuration. */
    1953           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    1954           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    1955             : 
    1956             :                 /* Set destroy information. */
    1957           0 :                 rhc->rhc_shook = generic_set_delete;
    1958           0 :                 rhc->rhc_rule = "originator-id";
    1959           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    1960             : 
    1961           0 :                 rv = generic_set_add(rhc->rhc_rmi, "originator-id", type,
    1962             :                                      args->errmsg, args->errmsg_len);
    1963           0 :                 if (rv != CMD_SUCCESS) {
    1964           0 :                         rhc->rhc_shook = NULL;
    1965           0 :                         return NB_ERR_INCONSISTENCY;
    1966             :                 }
    1967             :         }
    1968             : 
    1969             :         return NB_OK;
    1970             : }
    1971             : 
    1972           0 : int lib_route_map_entry_set_action_rmap_set_action_originator_id_destroy(
    1973             :         struct nb_cb_destroy_args *args)
    1974             : {
    1975           0 :         switch (args->event) {
    1976             :         case NB_EV_VALIDATE:
    1977             :         case NB_EV_PREPARE:
    1978             :         case NB_EV_ABORT:
    1979             :                 break;
    1980           0 :         case NB_EV_APPLY:
    1981           0 :                 return lib_route_map_entry_set_destroy(args);
    1982             :         }
    1983             : 
    1984             :         return NB_OK;
    1985             : }
    1986             : 
    1987             : /*
    1988             :  * XPath:
    1989             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:table
    1990             :  */
    1991           0 : int lib_route_map_entry_set_action_rmap_set_action_table_modify(
    1992             :         struct nb_cb_modify_args *args)
    1993             : {
    1994           0 :         struct routemap_hook_context *rhc;
    1995           0 :         const char *type;
    1996           0 :         int rv;
    1997             : 
    1998           0 :         switch (args->event) {
    1999             :         case NB_EV_VALIDATE:
    2000             :         case NB_EV_PREPARE:
    2001             :         case NB_EV_ABORT:
    2002             :                 break;
    2003           0 :         case NB_EV_APPLY:
    2004             :                 /* Add configuration. */
    2005           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2006           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    2007             : 
    2008             :                 /* Set destroy information. */
    2009           0 :                 rhc->rhc_shook = generic_set_delete;
    2010           0 :                 rhc->rhc_rule = "table";
    2011           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2012             : 
    2013           0 :                 rv = generic_set_add(rhc->rhc_rmi, "table", type,
    2014             :                                      args->errmsg, args->errmsg_len);
    2015           0 :                 if (rv != CMD_SUCCESS) {
    2016           0 :                         rhc->rhc_shook = NULL;
    2017           0 :                         return NB_ERR_INCONSISTENCY;
    2018             :                 }
    2019             :         }
    2020             : 
    2021             :         return NB_OK;
    2022             : }
    2023             : 
    2024           0 : int lib_route_map_entry_set_action_rmap_set_action_table_destroy(
    2025             :         struct nb_cb_destroy_args *args)
    2026             : {
    2027           0 :         switch (args->event) {
    2028             :         case NB_EV_VALIDATE:
    2029             :         case NB_EV_PREPARE:
    2030             :         case NB_EV_ABORT:
    2031             :                 break;
    2032           0 :         case NB_EV_APPLY:
    2033           0 :                 return lib_route_map_entry_set_destroy(args);
    2034             :         }
    2035             : 
    2036             :         return NB_OK;
    2037             : }
    2038             : 
    2039             : /*
    2040             :  * XPath:
    2041             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:atomic-aggregate
    2042             :  */
    2043             : int
    2044           0 : lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_create(
    2045             :         struct nb_cb_create_args *args)
    2046             : {
    2047           0 :         struct routemap_hook_context *rhc;
    2048           0 :         int rv;
    2049             : 
    2050           0 :         switch (args->event) {
    2051             :         case NB_EV_VALIDATE:
    2052             :         case NB_EV_PREPARE:
    2053             :         case NB_EV_ABORT:
    2054             :                 break;
    2055           0 :         case NB_EV_APPLY:
    2056             :                 /* Add configuration. */
    2057           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2058             : 
    2059             :                 /* Set destroy information. */
    2060           0 :                 rhc->rhc_shook = generic_set_delete;
    2061           0 :                 rhc->rhc_rule = "atomic-aggregate";
    2062           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2063             : 
    2064           0 :                 rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, NULL,
    2065             :                                      args->errmsg, args->errmsg_len);
    2066           0 :                 if (rv != CMD_SUCCESS) {
    2067           0 :                         rhc->rhc_shook = NULL;
    2068           0 :                         return NB_ERR_INCONSISTENCY;
    2069             :                 }
    2070             :         }
    2071             : 
    2072             :         return NB_OK;
    2073             : }
    2074             : 
    2075             : int
    2076           0 : lib_route_map_entry_set_action_rmap_set_action_atomic_aggregate_destroy(
    2077             :         struct nb_cb_destroy_args *args)
    2078             : {
    2079           0 :         switch (args->event) {
    2080             :         case NB_EV_VALIDATE:
    2081             :         case NB_EV_PREPARE:
    2082             :         case NB_EV_ABORT:
    2083             :                 break;
    2084           0 :         case NB_EV_APPLY:
    2085           0 :                 return lib_route_map_entry_set_destroy(args);
    2086             :         }
    2087             : 
    2088             :         return NB_OK;
    2089             : }
    2090             : 
    2091             : /*
    2092             :  * XPath:
    2093             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aigp-metric
    2094             :  */
    2095           0 : int lib_route_map_entry_set_action_rmap_set_action_aigp_metric_modify(
    2096             :         struct nb_cb_modify_args *args)
    2097             : {
    2098           0 :         struct routemap_hook_context *rhc;
    2099           0 :         const char *aigp;
    2100           0 :         int rv;
    2101             : 
    2102           0 :         switch (args->event) {
    2103             :         case NB_EV_VALIDATE:
    2104             :         case NB_EV_PREPARE:
    2105             :         case NB_EV_ABORT:
    2106             :                 break;
    2107           0 :         case NB_EV_APPLY:
    2108             :                 /* Add configuration. */
    2109           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2110           0 :                 aigp = yang_dnode_get_string(args->dnode, NULL);
    2111             : 
    2112             :                 /* Set destroy information. */
    2113           0 :                 rhc->rhc_shook = generic_set_delete;
    2114           0 :                 rhc->rhc_rule = "aigp-metric";
    2115           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2116             : 
    2117           0 :                 rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, aigp,
    2118             :                                      args->errmsg, args->errmsg_len);
    2119           0 :                 if (rv != CMD_SUCCESS) {
    2120           0 :                         rhc->rhc_shook = NULL;
    2121           0 :                         return NB_ERR_INCONSISTENCY;
    2122             :                 }
    2123             :         }
    2124             : 
    2125             :         return NB_OK;
    2126             : }
    2127             : 
    2128           0 : int lib_route_map_entry_set_action_rmap_set_action_aigp_metric_destroy(
    2129             :         struct nb_cb_destroy_args *args)
    2130             : {
    2131           0 :         switch (args->event) {
    2132             :         case NB_EV_VALIDATE:
    2133             :         case NB_EV_PREPARE:
    2134             :         case NB_EV_ABORT:
    2135             :                 break;
    2136           0 :         case NB_EV_APPLY:
    2137           0 :                 return lib_route_map_entry_set_destroy(args);
    2138             :         }
    2139             : 
    2140             :         return NB_OK;
    2141             : }
    2142             : 
    2143             : /*
    2144             :  * XPath:
    2145             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:prepend-as-path
    2146             :  */
    2147             : int
    2148           0 : lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_modify(
    2149             :         struct nb_cb_modify_args *args)
    2150             : {
    2151           0 :         struct routemap_hook_context *rhc;
    2152           0 :         const char *type;
    2153           0 :         int rv;
    2154             : 
    2155           0 :         switch (args->event) {
    2156             :         case NB_EV_VALIDATE:
    2157             :         case NB_EV_PREPARE:
    2158             :         case NB_EV_ABORT:
    2159             :                 break;
    2160           0 :         case NB_EV_APPLY:
    2161             :                 /* Add configuration. */
    2162           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2163           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    2164             : 
    2165             :                 /* Set destroy information. */
    2166           0 :                 rhc->rhc_shook = generic_set_delete;
    2167           0 :                 rhc->rhc_rule = "as-path prepend";
    2168           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2169             : 
    2170           0 :                 rv = generic_set_add(rhc->rhc_rmi, "as-path prepend",
    2171             :                                      type,
    2172             :                                      args->errmsg, args->errmsg_len);
    2173           0 :                 if (rv != CMD_SUCCESS) {
    2174           0 :                         rhc->rhc_shook = NULL;
    2175           0 :                         return NB_ERR_INCONSISTENCY;
    2176             :                 }
    2177             :         }
    2178             : 
    2179             :         return NB_OK;
    2180             : }
    2181             : 
    2182             : int
    2183           0 : lib_route_map_entry_set_action_rmap_set_action_prepend_as_path_destroy(
    2184             :         struct nb_cb_destroy_args *args)
    2185             : {
    2186           0 :         switch (args->event) {
    2187             :         case NB_EV_VALIDATE:
    2188             :         case NB_EV_PREPARE:
    2189             :         case NB_EV_ABORT:
    2190             :                 break;
    2191           0 :         case NB_EV_APPLY:
    2192           0 :                 return lib_route_map_entry_set_destroy(args);
    2193             :         }
    2194             : 
    2195             :         return NB_OK;
    2196             : }
    2197             : 
    2198             : /*
    2199             :  * XPath:
    2200             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:last-as
    2201             :  */
    2202           0 : int lib_route_map_entry_set_action_rmap_set_action_last_as_modify(
    2203             :         struct nb_cb_modify_args *args)
    2204             : {
    2205           0 :         struct routemap_hook_context *rhc;
    2206           0 :         const char *value;
    2207           0 :         char *argstr;
    2208           0 :         int rv;
    2209             : 
    2210           0 :         switch (args->event) {
    2211             :         case NB_EV_VALIDATE:
    2212             :         case NB_EV_PREPARE:
    2213             :         case NB_EV_ABORT:
    2214             :                 break;
    2215           0 :         case NB_EV_APPLY:
    2216             :                 /* Add configuration. */
    2217           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2218           0 :                 value = yang_dnode_get_string(args->dnode, NULL);
    2219             : 
    2220             :                 /* Set destroy information. */
    2221           0 :                 rhc->rhc_shook = generic_set_delete;
    2222           0 :                 rhc->rhc_rule = "as-path prepend";
    2223           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2224             : 
    2225           0 :                 argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED,
    2226             :                                 strlen(value) + strlen("last-as") + 2);
    2227             : 
    2228           0 :                 snprintf(argstr, (strlen(value) + strlen("last-as") + 2),
    2229             :                          "last-as %s", value);
    2230             : 
    2231           0 :                 rv = generic_set_add(rhc->rhc_rmi, "as-path prepend",
    2232             :                                      argstr,
    2233             :                                      args->errmsg, args->errmsg_len);
    2234           0 :                 if (rv != CMD_SUCCESS) {
    2235           0 :                         rhc->rhc_shook = NULL;
    2236           0 :                         XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
    2237           0 :                         return NB_ERR_INCONSISTENCY;
    2238             :                 }
    2239             : 
    2240           0 :                 XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
    2241             :         }
    2242             : 
    2243             :         return NB_OK;
    2244             : }
    2245             : 
    2246           0 : int lib_route_map_entry_set_action_rmap_set_action_last_as_destroy(
    2247             :         struct nb_cb_destroy_args *args)
    2248             : {
    2249           0 :         switch (args->event) {
    2250             :         case NB_EV_VALIDATE:
    2251             :         case NB_EV_PREPARE:
    2252             :         case NB_EV_ABORT:
    2253             :                 break;
    2254           0 :         case NB_EV_APPLY:
    2255           0 :                 return lib_route_map_entry_set_destroy(args);
    2256             :         }
    2257             : 
    2258             :         return NB_OK;
    2259             : }
    2260             : 
    2261             : /*
    2262             :  * XPath:
    2263             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:exclude-as-path
    2264             :  */
    2265             : int
    2266           0 : lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_modify(
    2267             :         struct nb_cb_modify_args *args)
    2268             : {
    2269           0 :         struct routemap_hook_context *rhc;
    2270           0 :         const char *type;
    2271           0 :         int rv;
    2272             : 
    2273           0 :         switch (args->event) {
    2274             :         case NB_EV_VALIDATE:
    2275             :         case NB_EV_PREPARE:
    2276             :         case NB_EV_ABORT:
    2277             :                 break;
    2278           0 :         case NB_EV_APPLY:
    2279             :                 /* Add configuration. */
    2280           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2281           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    2282             : 
    2283             :                 /* Set destroy information. */
    2284           0 :                 rhc->rhc_shook = generic_set_delete;
    2285           0 :                 rhc->rhc_rule = "as-path exclude";
    2286           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2287             : 
    2288           0 :                 rv = generic_set_add(rhc->rhc_rmi, "as-path exclude",
    2289             :                                      type,
    2290             :                                      args->errmsg, args->errmsg_len);
    2291           0 :                 if (rv != CMD_SUCCESS) {
    2292           0 :                         rhc->rhc_shook = NULL;
    2293           0 :                         return NB_ERR_INCONSISTENCY;
    2294             :                 }
    2295             :         }
    2296             : 
    2297             :         return NB_OK;
    2298             : }
    2299             : 
    2300             : int
    2301           0 : lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy(
    2302             :         struct nb_cb_destroy_args *args)
    2303             : {
    2304           0 :         switch (args->event) {
    2305             :         case NB_EV_VALIDATE:
    2306             :         case NB_EV_PREPARE:
    2307             :         case NB_EV_ABORT:
    2308             :                 break;
    2309           0 :         case NB_EV_APPLY:
    2310           0 :                 return lib_route_map_entry_set_destroy(args);
    2311             :         }
    2312             : 
    2313             :         return NB_OK;
    2314             : }
    2315             : 
    2316             : /*
    2317             :  * XPath:
    2318             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:replace-as-path
    2319             :  */
    2320           0 : int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_modify(
    2321             :         struct nb_cb_modify_args *args)
    2322             : {
    2323           0 :         struct routemap_hook_context *rhc;
    2324           0 :         const char *type;
    2325           0 :         int rv;
    2326             : 
    2327           0 :         switch (args->event) {
    2328             :         case NB_EV_VALIDATE:
    2329             :         case NB_EV_PREPARE:
    2330             :         case NB_EV_ABORT:
    2331             :                 break;
    2332           0 :         case NB_EV_APPLY:
    2333             :                 /* Add configuration. */
    2334           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2335           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    2336             : 
    2337             :                 /* Set destroy information. */
    2338           0 :                 rhc->rhc_shook = generic_set_delete;
    2339           0 :                 rhc->rhc_rule = "as-path replace";
    2340           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2341             : 
    2342           0 :                 rv = generic_set_add(rhc->rhc_rmi, "as-path replace", type,
    2343             :                                      args->errmsg, args->errmsg_len);
    2344           0 :                 if (rv != CMD_SUCCESS) {
    2345           0 :                         rhc->rhc_shook = NULL;
    2346           0 :                         return NB_ERR_INCONSISTENCY;
    2347             :                 }
    2348             :         }
    2349             : 
    2350             :         return NB_OK;
    2351             : }
    2352             : 
    2353           0 : int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_destroy(
    2354             :         struct nb_cb_destroy_args *args)
    2355             : {
    2356           0 :         switch (args->event) {
    2357             :         case NB_EV_VALIDATE:
    2358             :         case NB_EV_PREPARE:
    2359             :         case NB_EV_ABORT:
    2360             :                 break;
    2361           0 :         case NB_EV_APPLY:
    2362           0 :                 return lib_route_map_entry_set_destroy(args);
    2363             :         }
    2364             : 
    2365             :         return NB_OK;
    2366             : }
    2367             : 
    2368             : /*
    2369             :  * XPath:
    2370             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-none
    2371             :  */
    2372           0 : int lib_route_map_entry_set_action_rmap_set_action_community_none_modify(
    2373             :         struct nb_cb_modify_args *args)
    2374             : {
    2375           0 :         struct routemap_hook_context *rhc;
    2376           0 :         bool none = false;
    2377           0 :         int rv;
    2378             : 
    2379           0 :         switch (args->event) {
    2380             :         case NB_EV_VALIDATE:
    2381             :         case NB_EV_PREPARE:
    2382             :         case NB_EV_ABORT:
    2383             :                 break;
    2384           0 :         case NB_EV_APPLY:
    2385             :                 /* Add configuration. */
    2386           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2387           0 :                 none = yang_dnode_get_bool(args->dnode, NULL);
    2388             : 
    2389             :                 /* Set destroy information. */
    2390           0 :                 rhc->rhc_shook = generic_set_delete;
    2391           0 :                 rhc->rhc_rule = "community";
    2392           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2393             : 
    2394           0 :                 if (none) {
    2395           0 :                         rv = generic_set_add(rhc->rhc_rmi, "community",
    2396             :                                              "none",
    2397             :                                              args->errmsg, args->errmsg_len);
    2398           0 :                         if (rv != CMD_SUCCESS) {
    2399           0 :                                 rhc->rhc_shook = NULL;
    2400           0 :                                 return NB_ERR_INCONSISTENCY;
    2401             :                         }
    2402             :                         return NB_OK;
    2403             :                 }
    2404             : 
    2405             :                 return NB_ERR_INCONSISTENCY;
    2406             :         }
    2407             : 
    2408             :         return NB_OK;
    2409             : }
    2410             : 
    2411             : int
    2412           0 : lib_route_map_entry_set_action_rmap_set_action_community_none_destroy(
    2413             :         struct nb_cb_destroy_args *args)
    2414             : {
    2415           0 :         switch (args->event) {
    2416             :         case NB_EV_VALIDATE:
    2417             :         case NB_EV_PREPARE:
    2418             :         case NB_EV_ABORT:
    2419             :                 break;
    2420           0 :         case NB_EV_APPLY:
    2421           0 :                 return lib_route_map_entry_set_destroy(args);
    2422             :         }
    2423             : 
    2424             :         return NB_OK;
    2425             : }
    2426             : 
    2427             : /*
    2428             :  * XPath:
    2429             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-string
    2430             :  */
    2431             : int
    2432           0 : lib_route_map_entry_set_action_rmap_set_action_community_string_modify(
    2433             :         struct nb_cb_modify_args *args)
    2434             : {
    2435           0 :         struct routemap_hook_context *rhc;
    2436           0 :         const char *type;
    2437           0 :         int rv;
    2438             : 
    2439           0 :         switch (args->event) {
    2440             :         case NB_EV_VALIDATE:
    2441             :         case NB_EV_PREPARE:
    2442             :         case NB_EV_ABORT:
    2443             :                 break;
    2444           0 :         case NB_EV_APPLY:
    2445             :                 /* Add configuration. */
    2446           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2447           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    2448             : 
    2449             :                 /* Set destroy information. */
    2450           0 :                 rhc->rhc_shook = generic_set_delete;
    2451           0 :                 rhc->rhc_rule = "community";
    2452           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2453             : 
    2454           0 :                 rv = generic_set_add(rhc->rhc_rmi, "community", type,
    2455             :                                      args->errmsg, args->errmsg_len);
    2456           0 :                 if (rv != CMD_SUCCESS) {
    2457           0 :                         rhc->rhc_shook = NULL;
    2458           0 :                         return NB_ERR_INCONSISTENCY;
    2459             :                 }
    2460             :         }
    2461             : 
    2462             :         return NB_OK;
    2463             : }
    2464             : 
    2465             : int
    2466           0 : lib_route_map_entry_set_action_rmap_set_action_community_string_destroy(
    2467             :         struct nb_cb_destroy_args *args)
    2468             : {
    2469           0 :         switch (args->event) {
    2470             :         case NB_EV_VALIDATE:
    2471             :         case NB_EV_PREPARE:
    2472             :         case NB_EV_ABORT:
    2473             :                 break;
    2474           0 :         case NB_EV_APPLY:
    2475           0 :                 return lib_route_map_entry_set_destroy(args);
    2476             :         }
    2477             : 
    2478             :         return NB_OK;
    2479             : }
    2480             : 
    2481             : /*
    2482             :  * XPath:
    2483             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-none
    2484             :  */
    2485             : int
    2486           0 : lib_route_map_entry_set_action_rmap_set_action_large_community_none_modify(
    2487             :         struct nb_cb_modify_args *args)
    2488             : {
    2489           0 :         struct routemap_hook_context *rhc;
    2490           0 :         bool none = false;
    2491           0 :         int rv;
    2492             : 
    2493           0 :         switch (args->event) {
    2494             :         case NB_EV_VALIDATE:
    2495             :         case NB_EV_PREPARE:
    2496             :         case NB_EV_ABORT:
    2497             :                 break;
    2498           0 :         case NB_EV_APPLY:
    2499             :                 /* Add configuration. */
    2500           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2501           0 :                 none = yang_dnode_get_bool(args->dnode, NULL);
    2502             : 
    2503             :                 /* Set destroy information. */
    2504           0 :                 rhc->rhc_shook = generic_set_delete;
    2505           0 :                 rhc->rhc_rule = "large-community";
    2506           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2507             : 
    2508           0 :                 if (none) {
    2509           0 :                         rv = generic_set_add(rhc->rhc_rmi,
    2510             :                                              "large-community",
    2511             :                                              "none",
    2512             :                                               args->errmsg, args->errmsg_len);
    2513           0 :                         if (rv != CMD_SUCCESS) {
    2514           0 :                                 rhc->rhc_shook = NULL;
    2515           0 :                                 return NB_ERR_INCONSISTENCY;
    2516             :                         }
    2517             :                 return NB_OK;
    2518             :                 }
    2519             : 
    2520             :                 return NB_ERR_INCONSISTENCY;
    2521             :         }
    2522             : 
    2523             :         return NB_OK;
    2524             : }
    2525             : 
    2526             : int
    2527           0 : lib_route_map_entry_set_action_rmap_set_action_large_community_none_destroy(
    2528             :         struct nb_cb_destroy_args *args)
    2529             : {
    2530           0 :         switch (args->event) {
    2531             :         case NB_EV_VALIDATE:
    2532             :         case NB_EV_PREPARE:
    2533             :         case NB_EV_ABORT:
    2534             :                 break;
    2535           0 :         case NB_EV_APPLY:
    2536           0 :                 return lib_route_map_entry_set_destroy(args);
    2537             :         }
    2538             : 
    2539             :         return NB_OK;
    2540             : }
    2541             : 
    2542             : /*
    2543             :  * XPath:
    2544             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:large-community-string
    2545             :  */
    2546             : int
    2547           0 : lib_route_map_entry_set_action_rmap_set_action_large_community_string_modify(
    2548             :         struct nb_cb_modify_args *args)
    2549             : {
    2550           0 :         struct routemap_hook_context *rhc;
    2551           0 :         const char *type;
    2552           0 :         int rv;
    2553             : 
    2554           0 :         switch (args->event) {
    2555             :         case NB_EV_VALIDATE:
    2556             :         case NB_EV_PREPARE:
    2557             :         case NB_EV_ABORT:
    2558             :                 break;
    2559           0 :         case NB_EV_APPLY:
    2560             :                 /* Add configuration. */
    2561           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2562           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    2563             : 
    2564             :                 /* Set destroy information. */
    2565           0 :                 rhc->rhc_shook = generic_set_delete;
    2566           0 :                 rhc->rhc_rule = "large-community";
    2567           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2568             : 
    2569           0 :                 rv = generic_set_add(rhc->rhc_rmi, "large-community",
    2570             :                                      type,
    2571             :                                      args->errmsg, args->errmsg_len);
    2572           0 :                 if (rv != CMD_SUCCESS) {
    2573           0 :                         rhc->rhc_shook = NULL;
    2574           0 :                         return NB_ERR_INCONSISTENCY;
    2575             :                 }
    2576             :         }
    2577             : 
    2578             :         return NB_OK;
    2579             : }
    2580             : 
    2581             : int
    2582           0 : lib_route_map_entry_set_action_rmap_set_action_large_community_string_destroy(
    2583             :         struct nb_cb_destroy_args *args)
    2584             : {
    2585           0 :         switch (args->event) {
    2586             :         case NB_EV_VALIDATE:
    2587             :         case NB_EV_PREPARE:
    2588             :         case NB_EV_ABORT:
    2589             :                 break;
    2590           0 :         case NB_EV_APPLY:
    2591           0 :                 return lib_route_map_entry_set_destroy(args);
    2592             :         }
    2593             : 
    2594             :         return NB_OK;
    2595             : }
    2596             : 
    2597             : /*
    2598             :  * xpath =
    2599             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator
    2600             :  */
    2601           0 : void lib_route_map_entry_set_action_rmap_set_action_aggregator_finish(
    2602             :         struct nb_cb_apply_finish_args *args)
    2603             : {
    2604           0 :         struct routemap_hook_context *rhc;
    2605           0 :         const char *asn;
    2606           0 :         const char *addr;
    2607           0 :         char *argstr;
    2608           0 :         int ret;
    2609             : 
    2610             :         /* Add configuration. */
    2611           0 :         rhc = nb_running_get_entry(args->dnode, NULL, true);
    2612           0 :         asn = yang_dnode_get_string(args->dnode, "./aggregator-asn");
    2613           0 :         addr = yang_dnode_get_string(args->dnode, "./aggregator-address");
    2614             : 
    2615           0 :         argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED,
    2616             :                          strlen(asn) + strlen(addr) + 2);
    2617             : 
    2618           0 :         snprintf(argstr, (strlen(asn) + strlen(addr) + 2), "%s %s", asn, addr);
    2619             : 
    2620             :         /* Set destroy information. */
    2621           0 :         rhc->rhc_shook = generic_set_delete;
    2622           0 :         rhc->rhc_rule = "aggregator as";
    2623           0 :         rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2624             : 
    2625           0 :         ret = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, argstr, args->errmsg,
    2626             :                               args->errmsg_len);
    2627             :         /*
    2628             :          * At this point if this is not a successful operation
    2629             :          * bgpd is about to crash.  Let's just cut to the
    2630             :          * chase and do it.
    2631             :          */
    2632           0 :         assert(ret == CMD_SUCCESS);
    2633             : 
    2634           0 :         XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
    2635           0 : }
    2636             : /*
    2637             :  * XPath:
    2638             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn
    2639             :  */
    2640             : int
    2641           0 : lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_modify(
    2642             :         struct nb_cb_modify_args *args)
    2643             : {
    2644           0 :         switch (args->event) {
    2645             :         case NB_EV_VALIDATE:
    2646             :         case NB_EV_PREPARE:
    2647             :         case NB_EV_ABORT:
    2648             :         case NB_EV_APPLY:
    2649             :                 break;
    2650             :         }
    2651             : 
    2652           0 :         return NB_OK;
    2653             : }
    2654             : 
    2655             : int
    2656           0 : lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_asn_destroy(
    2657             :         struct nb_cb_destroy_args *args)
    2658             : {
    2659           0 :         switch (args->event) {
    2660             :         case NB_EV_VALIDATE:
    2661             :         case NB_EV_PREPARE:
    2662             :         case NB_EV_ABORT:
    2663             :                 break;
    2664           0 :         case NB_EV_APPLY:
    2665           0 :                 return lib_route_map_entry_set_destroy(args);
    2666             :         }
    2667             : 
    2668             :         return NB_OK;
    2669             : }
    2670             : 
    2671             : /*
    2672             :  * XPath:
    2673             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address
    2674             :  */
    2675             : int
    2676           0 : lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_modify(
    2677             :         struct nb_cb_modify_args *args)
    2678             : {
    2679           0 :         switch (args->event) {
    2680             :         case NB_EV_VALIDATE:
    2681             :         case NB_EV_PREPARE:
    2682             :         case NB_EV_ABORT:
    2683             :         case NB_EV_APPLY:
    2684             :                 break;
    2685             :         }
    2686             : 
    2687           0 :         return NB_OK;
    2688             : }
    2689             : 
    2690             : int
    2691           0 : lib_route_map_entry_set_action_rmap_set_action_aggregator_aggregator_address_destroy(
    2692             :         struct nb_cb_destroy_args *args)
    2693             : {
    2694           0 :         switch (args->event) {
    2695             :         case NB_EV_VALIDATE:
    2696             :         case NB_EV_PREPARE:
    2697             :         case NB_EV_ABORT:
    2698             :                 break;
    2699           0 :         case NB_EV_APPLY:
    2700           0 :                 return lib_route_map_entry_set_destroy(args);
    2701             :         }
    2702             : 
    2703             :         return NB_OK;
    2704             : }
    2705             : 
    2706             : /*
    2707             :  * XPath:
    2708             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:comm-list-name
    2709             :  */
    2710           0 : int lib_route_map_entry_set_action_rmap_set_action_comm_list_name_modify(
    2711             :         struct nb_cb_modify_args *args)
    2712             : {
    2713           0 :         struct routemap_hook_context *rhc;
    2714           0 :         const char *value;
    2715           0 :         const char *action;
    2716           0 :         int rv = CMD_SUCCESS;
    2717             : 
    2718           0 :         switch (args->event) {
    2719             :         case NB_EV_VALIDATE:
    2720             :         case NB_EV_PREPARE:
    2721             :         case NB_EV_ABORT:
    2722             :                 break;
    2723           0 :         case NB_EV_APPLY:
    2724             :                 /* Add configuration. */
    2725           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2726           0 :                 value = yang_dnode_get_string(args->dnode, NULL);
    2727             : 
    2728             :                 /* Set destroy information. */
    2729           0 :                 rhc->rhc_shook = generic_set_delete;
    2730             : 
    2731           0 :                 action = yang_dnode_get_string(args->dnode,
    2732             :                                 "../../frr-route-map:action");
    2733           0 :                 if (IS_SET_COMM_LIST_DEL(action))
    2734           0 :                         rhc->rhc_rule = "comm-list";
    2735             :                 else
    2736           0 :                         rhc->rhc_rule = "large-comm-list";
    2737             : 
    2738           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2739             : 
    2740           0 :                 rv = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, value,
    2741             :                                      args->errmsg, args->errmsg_len);
    2742             : 
    2743           0 :                 if (rv != CMD_SUCCESS) {
    2744           0 :                         rhc->rhc_shook = NULL;
    2745           0 :                         return NB_ERR_INCONSISTENCY;
    2746             :                 }
    2747             :         }
    2748             : 
    2749             :         return NB_OK;
    2750             : }
    2751             : 
    2752             : int
    2753           0 : lib_route_map_entry_set_action_rmap_set_action_comm_list_name_destroy(
    2754             :         struct nb_cb_destroy_args *args)
    2755             : {
    2756           0 :         switch (args->event) {
    2757             :         case NB_EV_VALIDATE:
    2758             :         case NB_EV_PREPARE:
    2759             :         case NB_EV_ABORT:
    2760             :                 break;
    2761           0 :         case NB_EV_APPLY:
    2762           0 :                 return lib_route_map_entry_set_destroy(args);
    2763             :         }
    2764             : 
    2765             :         return NB_OK;
    2766             : }
    2767             : 
    2768             : /*
    2769             :  * XPath:
    2770             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb
    2771             :  */
    2772             : void
    2773           0 : lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish(
    2774             :         struct nb_cb_apply_finish_args *args)
    2775             : {
    2776           0 :         struct routemap_hook_context *rhc;
    2777           0 :         enum ecommunity_lb_type lb_type;
    2778           0 :         char str[VTY_BUFSIZ];
    2779           0 :         uint16_t bandwidth;
    2780           0 :         int ret;
    2781             : 
    2782             :         /* Add configuration. */
    2783           0 :         rhc = nb_running_get_entry(args->dnode, NULL, true);
    2784           0 :         lb_type = yang_dnode_get_enum(args->dnode, "./lb-type");
    2785             : 
    2786             :         /* Set destroy information. */
    2787           0 :         rhc->rhc_shook = generic_set_delete;
    2788           0 :         rhc->rhc_rule = "extcommunity bandwidth";
    2789           0 :         rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2790             : 
    2791           0 :         switch (lb_type) {
    2792           0 :         case EXPLICIT_BANDWIDTH:
    2793           0 :                 bandwidth = yang_dnode_get_uint16(args->dnode, "./bandwidth");
    2794           0 :                 snprintf(str, sizeof(str), "%d", bandwidth);
    2795           0 :                 break;
    2796           0 :         case CUMULATIVE_BANDWIDTH:
    2797           0 :                 snprintf(str, sizeof(str), "%s", "cumulative");
    2798           0 :                 break;
    2799           0 :         case COMPUTED_BANDWIDTH:
    2800           0 :                 snprintf(str, sizeof(str), "%s", "num-multipaths");
    2801             :         }
    2802             : 
    2803           0 :         if (yang_dnode_get_bool(args->dnode, "./two-octet-as-specific"))
    2804           0 :                 strlcat(str, " non-transitive", sizeof(str));
    2805             : 
    2806           0 :         ret = generic_set_add(rhc->rhc_rmi, "extcommunity bandwidth", str,
    2807             :                               args->errmsg, args->errmsg_len);
    2808             :         /*
    2809             :          * At this point if this is not a successful operation
    2810             :          * bgpd is about to crash.  Let's just cut to the
    2811             :          * chase and do it.
    2812             :          */
    2813           0 :         assert(ret == CMD_SUCCESS);
    2814           0 : }
    2815             : 
    2816             : /*
    2817             :  * XPath:
    2818             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type
    2819             :  */
    2820             : int
    2821           0 : lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_modify(
    2822             :                 struct nb_cb_modify_args *args)
    2823             : {
    2824           0 :         return NB_OK;
    2825             : }
    2826             : 
    2827             : int
    2828           0 : lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_lb_type_destroy(
    2829             :                 struct nb_cb_destroy_args *args)
    2830             : {
    2831           0 :         return lib_route_map_entry_set_destroy(args);
    2832             : }
    2833             : 
    2834             : /*
    2835             :  * XPath:
    2836             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth
    2837             :  */
    2838             : int
    2839           0 : lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_modify(
    2840             :                 struct nb_cb_modify_args *args)
    2841             : {
    2842           0 :         return NB_OK;
    2843             : }
    2844             : 
    2845             : int
    2846           0 : lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_bandwidth_destroy(
    2847             :                 struct nb_cb_destroy_args *args)
    2848             : {
    2849           0 :         return lib_route_map_entry_set_destroy(args);
    2850             : }
    2851             : 
    2852             : /*
    2853             :  * XPath:
    2854             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific
    2855             :  */
    2856             : int
    2857           0 : lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_modify(
    2858             :         struct nb_cb_modify_args *args)
    2859             : {
    2860           0 :         return NB_OK;
    2861             : }
    2862             : 
    2863             : int
    2864           0 : lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_two_octet_as_specific_destroy(
    2865             :         struct nb_cb_destroy_args *args)
    2866             : {
    2867           0 :         return lib_route_map_entry_set_destroy(args);
    2868             : }
    2869             : 
    2870             : /*
    2871             :  * XPath:
    2872             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-none
    2873             :  */
    2874           0 : int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_modify(
    2875             :         struct nb_cb_modify_args *args)
    2876             : {
    2877           0 :         struct routemap_hook_context *rhc;
    2878           0 :         bool none = false;
    2879           0 :         int rv;
    2880             : 
    2881           0 :         switch (args->event) {
    2882             :         case NB_EV_VALIDATE:
    2883             :         case NB_EV_PREPARE:
    2884             :         case NB_EV_ABORT:
    2885             :                 break;
    2886           0 :         case NB_EV_APPLY:
    2887             :                 /* Add configuration. */
    2888           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2889           0 :                 none = yang_dnode_get_bool(args->dnode, NULL);
    2890             : 
    2891             :                 /* Set destroy information. */
    2892           0 :                 rhc->rhc_shook = generic_set_delete;
    2893           0 :                 rhc->rhc_rule = "extcommunity";
    2894           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2895             : 
    2896           0 :                 if (none) {
    2897           0 :                         rv = generic_set_add(rhc->rhc_rmi, "extcommunity",
    2898             :                                              "none", args->errmsg,
    2899             :                                              args->errmsg_len);
    2900           0 :                         if (rv != CMD_SUCCESS) {
    2901           0 :                                 rhc->rhc_shook = NULL;
    2902           0 :                                 return NB_ERR_INCONSISTENCY;
    2903             :                         }
    2904             :                         return NB_OK;
    2905             :                 }
    2906             : 
    2907             :                 return NB_ERR_INCONSISTENCY;
    2908             :         }
    2909             : 
    2910             :         return NB_OK;
    2911             : }
    2912             : 
    2913           0 : int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_destroy(
    2914             :         struct nb_cb_destroy_args *args)
    2915             : {
    2916           0 :         switch (args->event) {
    2917             :         case NB_EV_VALIDATE:
    2918             :         case NB_EV_PREPARE:
    2919             :         case NB_EV_ABORT:
    2920             :                 break;
    2921           0 :         case NB_EV_APPLY:
    2922           0 :                 return lib_route_map_entry_set_destroy(args);
    2923             :         }
    2924             : 
    2925             :         return NB_OK;
    2926             : }
    2927             : 
    2928             : /*
    2929             :  * XPath:
    2930             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv4
    2931             :  */
    2932           0 : int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_modify(
    2933             :         struct nb_cb_modify_args *args)
    2934             : {
    2935           0 :         struct routemap_hook_context *rhc;
    2936           0 :         const char *type;
    2937           0 :         int rv;
    2938             : 
    2939           0 :         switch (args->event) {
    2940             :         case NB_EV_VALIDATE:
    2941             :         case NB_EV_PREPARE:
    2942             :         case NB_EV_ABORT:
    2943             :                 break;
    2944           0 :         case NB_EV_APPLY:
    2945             :                 /* Add configuration. */
    2946           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2947           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    2948             : 
    2949             :                 /* Set destroy information. */
    2950           0 :                 rhc->rhc_shook = generic_set_delete;
    2951           0 :                 rhc->rhc_rule = "evpn gateway-ip ipv4";
    2952           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    2953             : 
    2954           0 :                 rv = generic_set_add(rhc->rhc_rmi, "evpn gateway-ip ipv4", type,
    2955             :                                      args->errmsg, args->errmsg_len);
    2956           0 :                 if (rv != CMD_SUCCESS) {
    2957           0 :                         rhc->rhc_shook = NULL;
    2958           0 :                         return NB_ERR_INCONSISTENCY;
    2959             :                 }
    2960             :         }
    2961             : 
    2962             :         return NB_OK;
    2963             : }
    2964             : 
    2965           0 : int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv4_destroy(
    2966             :         struct nb_cb_destroy_args *args)
    2967             : {
    2968           0 :         switch (args->event) {
    2969             :         case NB_EV_VALIDATE:
    2970             :         case NB_EV_PREPARE:
    2971             :         case NB_EV_ABORT:
    2972             :                 break;
    2973           0 :         case NB_EV_APPLY:
    2974           0 :                 return lib_route_map_entry_set_destroy(args);
    2975             :         }
    2976             : 
    2977             :         return NB_OK;
    2978             : }
    2979             : 
    2980             : /*
    2981             :  * XPath:
    2982             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv6
    2983             :  */
    2984           0 : int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_modify(
    2985             :         struct nb_cb_modify_args *args)
    2986             : {
    2987           0 :         struct routemap_hook_context *rhc;
    2988           0 :         const char *type;
    2989           0 :         int rv;
    2990             : 
    2991           0 :         switch (args->event) {
    2992             :         case NB_EV_VALIDATE:
    2993             :         case NB_EV_PREPARE:
    2994             :         case NB_EV_ABORT:
    2995             :                 break;
    2996           0 :         case NB_EV_APPLY:
    2997             :                 /* Add configuration. */
    2998           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    2999           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    3000             : 
    3001             :                 /* Set destroy information. */
    3002           0 :                 rhc->rhc_shook = generic_set_delete;
    3003           0 :                 rhc->rhc_rule = "evpn gateway-ip ipv6";
    3004           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    3005             : 
    3006           0 :                 rv = generic_set_add(rhc->rhc_rmi, "evpn gateway-ip ipv6", type,
    3007             :                                      args->errmsg, args->errmsg_len);
    3008           0 :                 if (rv != CMD_SUCCESS) {
    3009           0 :                         rhc->rhc_shook = NULL;
    3010           0 :                         return NB_ERR_INCONSISTENCY;
    3011             :                 }
    3012             :         }
    3013             : 
    3014             :         return NB_OK;
    3015             : }
    3016             : 
    3017           0 : int lib_route_map_entry_set_action_rmap_set_action_evpn_gateway_ip_ipv6_destroy(
    3018             :         struct nb_cb_destroy_args *args)
    3019             : {
    3020           0 :         switch (args->event) {
    3021             :         case NB_EV_VALIDATE:
    3022             :         case NB_EV_PREPARE:
    3023             :         case NB_EV_ABORT:
    3024             :                 break;
    3025           0 :         case NB_EV_APPLY:
    3026           0 :                 return lib_route_map_entry_set_destroy(args);
    3027             :         }
    3028             : 
    3029             :         return NB_OK;
    3030             : }
    3031             : 
    3032             : /*
    3033             :  * XPath:
    3034             :  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/l3vpn-nexthop-encapsulation
    3035             :  */
    3036           0 : int lib_route_map_entry_set_action_rmap_set_action_l3vpn_nexthop_encapsulation_modify(
    3037             :         struct nb_cb_modify_args *args)
    3038             : {
    3039           0 :         struct routemap_hook_context *rhc;
    3040           0 :         const char *type;
    3041           0 :         int rv;
    3042             : 
    3043           0 :         switch (args->event) {
    3044             :         case NB_EV_VALIDATE:
    3045             :         case NB_EV_PREPARE:
    3046             :         case NB_EV_ABORT:
    3047             :                 break;
    3048           0 :         case NB_EV_APPLY:
    3049             :                 /* Add configuration. */
    3050           0 :                 rhc = nb_running_get_entry(args->dnode, NULL, true);
    3051           0 :                 type = yang_dnode_get_string(args->dnode, NULL);
    3052             : 
    3053             :                 /* Set destroy information. */
    3054           0 :                 rhc->rhc_shook = generic_set_delete;
    3055           0 :                 rhc->rhc_rule = "l3vpn next-hop encapsulation";
    3056           0 :                 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
    3057             : 
    3058           0 :                 rv = generic_set_add(rhc->rhc_rmi,
    3059             :                                      "l3vpn next-hop encapsulation", type,
    3060             :                                      args->errmsg, args->errmsg_len);
    3061           0 :                 if (rv != CMD_SUCCESS) {
    3062           0 :                         rhc->rhc_shook = NULL;
    3063           0 :                         return NB_ERR_INCONSISTENCY;
    3064             :                 }
    3065             :         }
    3066             : 
    3067             :         return NB_OK;
    3068             : }
    3069             : 
    3070           0 : int lib_route_map_entry_set_action_rmap_set_action_l3vpn_nexthop_encapsulation_destroy(
    3071             :         struct nb_cb_destroy_args *args)
    3072             : {
    3073           0 :         switch (args->event) {
    3074             :         case NB_EV_VALIDATE:
    3075             :         case NB_EV_PREPARE:
    3076             :         case NB_EV_ABORT:
    3077             :                 break;
    3078           0 :         case NB_EV_APPLY:
    3079           0 :                 return lib_route_map_entry_set_destroy(args);
    3080             :         }
    3081             : 
    3082             :         return NB_OK;
    3083             : }

Generated by: LCOV version v1.16-topotato