#include "lib/routemap.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_routemap_nb.h"
-#include "bgpd/bgp_ecommunity.h"
/* Add bgp route map rule. */
static int bgp_route_match_add(struct route_map_index *index,
char *argstr;
const char *condition;
route_map_event_t event;
+ int ret;
/* Add configuration. */
rhc = nb_running_get_entry(args->dnode, NULL, true);
rhc->rhc_event = RMAP_EVENT_ECLIST_DELETED;
}
- bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule, argstr, event,
- args->errmsg, args->errmsg_len);
+ ret = bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule, argstr, event,
+ args->errmsg, args->errmsg_len);
+ /*
+ * At this point if this is not a successful operation
+ * bgpd is about to crash. Let's just cut to the
+ * chase and do it.
+ */
+ assert(ret == RMAP_COMPILE_SUCCESS);
if (argstr != value)
XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
/* Set destroy information. */
rhc->rhc_mhook = bgp_route_match_delete;
- rhc->rhc_rule = "ipv6 next-hop";
+ rhc->rhc_rule = "ipv6 next-hop address";
rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
ret = bgp_route_match_add(rhc->rhc_rmi, rhc->rhc_rule,
const char *asn;
const char *addr;
char *argstr;
+ int ret;
/* Add configuration. */
rhc = nb_running_get_entry(args->dnode, NULL, true);
rhc->rhc_rule = "aggregator as";
rhc->rhc_event = RMAP_EVENT_SET_DELETED;
- generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, argstr,
- args->errmsg, args->errmsg_len);
+ ret = generic_set_add(rhc->rhc_rmi, rhc->rhc_rule, argstr, args->errmsg,
+ args->errmsg_len);
+ /*
+ * At this point if this is not a successful operation
+ * bgpd is about to crash. Let's just cut to the
+ * chase and do it.
+ */
+ assert(ret == CMD_SUCCESS);
+
XFREE(MTYPE_ROUTE_MAP_COMPILED, argstr);
}
/*
enum ecommunity_lb_type lb_type;
char str[VTY_BUFSIZ];
uint16_t bandwidth;
+ int ret;
/* Add configuration. */
rhc = nb_running_get_entry(args->dnode, NULL, true);
if (yang_dnode_get_bool(args->dnode, "./two-octet-as-specific"))
strlcat(str, " non-transitive", sizeof(str));
- generic_set_add(rhc->rhc_rmi,
- "extcommunity bandwidth", str,
- args->errmsg, args->errmsg_len);
+ ret = generic_set_add(rhc->rhc_rmi, "extcommunity bandwidth", str,
+ args->errmsg, args->errmsg_len);
+ /*
+ * At this point if this is not a successful operation
+ * bgpd is about to crash. Let's just cut to the
+ * chase and do it.
+ */
+ assert(ret == CMD_SUCCESS);
}
/*
return lib_route_map_entry_set_destroy(args);
}
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-none
+ */
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ bool none = false;
+ int rv;
+
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ none = yang_dnode_get_bool(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "extcommunity";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ if (none) {
+ rv = generic_set_add(rhc->rhc_rmi, "extcommunity",
+ "none", args->errmsg,
+ args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_shook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+ return NB_OK;
+ }
+
+ return NB_ERR_INCONSISTENCY;
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_extcommunity_none_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ switch (args->event) {
+ case NB_EV_VALIDATE:
+ case NB_EV_PREPARE:
+ case NB_EV_ABORT:
+ break;
+ case NB_EV_APPLY:
+ return lib_route_map_entry_set_destroy(args);
+ }
+
+ return NB_OK;
+}
+
/*
* XPath:
* /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv4