]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: register nb routing hook
authorChirag Shah <chirag@nvidia.com>
Mon, 17 Aug 2020 00:59:13 +0000 (17:59 -0700)
committerChirag Shah <chirag@nvidia.com>
Sat, 3 Oct 2020 18:25:37 +0000 (11:25 -0700)
On bgpd bootstrap register routing hook which ensures
only single bgp named instance created per vrf routing
hierarchy.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
bgpd/bgp_main.c
bgpd/bgp_nb.h
bgpd/bgp_nb_config.c

index 18f597f5390a72d0d0070872191f74d7dd347d67..d0a32ee408199c8aa2a4af9f144e79d5a9624452 100644 (file)
@@ -501,6 +501,10 @@ int main(int argc, char **argv)
        /* Initializations. */
        bgp_vrf_init();
 
+       hook_register(routing_conf_event,
+                     routing_control_plane_protocols_name_validate);
+
+
        /* BGP related initialization.  */
        bgp_init((unsigned short)instance);
 
index 2bed6bcfe6a8db0a2e4fb53343055e6349a3992a..ad7561b8ce2d0ceca5bdc3818320670775238781 100644 (file)
@@ -3407,6 +3407,13 @@ int routing_control_plane_protocols_control_plane_protocol_bgp_peer_groups_peer_
 int routing_control_plane_protocols_control_plane_protocol_bgp_peer_groups_peer_group_afi_safis_afi_safi_ipv6_flowspec_soft_reconfiguration_modify(
        struct nb_cb_modify_args *args);
 
+/*
+ * Callback registered with routing_nb lib to validate only
+ * one instance of bgp instance is allowed
+ */
+int routing_control_plane_protocols_name_validate(
+       struct nb_cb_create_args *args);
+
 /* Optional 'cli_show' callbacks. */
 void cli_show_router_bgp(struct vty *vty, struct lyd_node *dnode,
                         bool show_defaults);
index e3bb7ec295ebbffedf5a866717f253d277546623..8d94e3f97299a151aa2dd0e73667d772cb0f9868 100644 (file)
@@ -44,6 +44,20 @@ FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE,
         { .val_ulong = 60 },
 )
 
+int routing_control_plane_protocols_name_validate(
+       struct nb_cb_create_args *args)
+{
+       const char *name;
+
+       name = yang_dnode_get_string(args->dnode, "./name");
+       if (!strmatch(name, "bgp")) {
+               snprintf(args->errmsg, args->errmsg_len,
+                        "per vrf only one bgp instance is supported.");
+               return NB_ERR_VALIDATION;
+       }
+       return NB_OK;
+}
+
 /*
  * XPath:
  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-bgp:bgp/global