]> git.puffer.fish Git - mirror/frr.git/commitdiff
sharpd: add v4 redistribute watching 8619/head
authorDonald Sharp <sharpd@nvidia.com>
Mon, 3 May 2021 23:35:36 +0000 (19:35 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 3 May 2021 23:38:38 +0000 (19:38 -0400)
Add the ability for sharpd to watch v4 redistribution events

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
doc/user/sharp.rst
sharpd/sharp_vty.c
sharpd/sharp_zebra.c
sharpd/sharp_zebra.h

index bef2748afab5321c2a2bbcc6f975682b5a713ff9..0542a593aee3796ef69413418f6f7443c2306f1f 100644 (file)
@@ -83,6 +83,11 @@ keyword. At present, no sharp commands will be preserved in the config.
    Allow end user to dump associated data with the nexthop tracking that
    may have been turned on.
 
+.. clicmd:: sharp watch [vrf NAME] redistribute ROUTETYPE
+
+   Allow end user to monitor redistributed routes of ROUTETYPE
+   origin.
+
 .. clicmd:: sharp lsp [update] (0-100000) nexthop-group NAME [prefix A.B.C.D/M TYPE [instance (0-255)]]
 
    Install an LSP using the specified in-label, with nexthops as
index 8306aca9eeb622b14419de4025f2da62762e824a..1ff0591d5e390b88dab319bccf56dd6acfaf188d 100644 (file)
 #include "sharpd/sharp_vty_clippy.c"
 #endif
 
+DEFPY(watch_redistribute, watch_redistribute_cmd,
+      "sharp watch [vrf NAME$vrf_name] redistribute " FRR_REDIST_STR_SHARPD,
+      "Sharp routing Protocol\n"
+      "Watch for changes\n"
+      "The vrf we would like to watch if non-default\n"
+      "The NAME of the vrf\n"
+      "Redistribute into Sharp\n"
+      FRR_REDIST_HELP_STR_SHARPD)
+{
+       struct vrf *vrf;
+       int source;
+
+       if (!vrf_name)
+               vrf_name = VRF_DEFAULT_NAME;
+       vrf = vrf_lookup_by_name(vrf_name);
+       if (!vrf) {
+               vty_out(vty, "The vrf NAME specified: %s does not exist\n",
+                       vrf_name);
+               return CMD_WARNING;
+       }
+
+       source = proto_redistnum(AFI_IP, argv[argc-1]->text);
+       sharp_redistribute_vrf(vrf, source);
+
+       return CMD_SUCCESS;
+}
+
 DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
       "sharp watch [vrf NAME$vrf_name] <nexthop$n X:X::X:X$nhop|import$import X:X::X:X/M$inhop>  [connected$connected]",
       "Sharp routing Protocol\n"
@@ -844,6 +871,7 @@ void sharp_vty_init(void)
        install_element(ENABLE_NODE, &remove_routes_cmd);
        install_element(ENABLE_NODE, &vrf_label_cmd);
        install_element(ENABLE_NODE, &sharp_nht_data_dump_cmd);
+       install_element(ENABLE_NODE, &watch_redistribute_cmd);
        install_element(ENABLE_NODE, &watch_nexthop_v6_cmd);
        install_element(ENABLE_NODE, &watch_nexthop_v4_cmd);
        install_element(ENABLE_NODE, &sharp_lsp_prefix_v4_cmd);
index 0f2c6340498d513592ddbefa0f84537c503764c1..128cfe2de6bf9f7dbf8ea91b99de401151ff00ab 100644 (file)
@@ -714,6 +714,12 @@ static int sharp_redistribute_route(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
+void sharp_redistribute_vrf(struct vrf *vrf, int type)
+{
+       zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type,
+                               0, vrf->vrf_id);
+}
+
 /* Add a zclient with a specified session id, for testing. */
 int sharp_zclient_create(uint32_t session_id)
 {
index ffddb9e78041b7651f7c02b1f612928ae46f3972..4355f49a2f0ecd67883fd2497f1026b3d67e1f89 100644 (file)
@@ -63,4 +63,6 @@ extern void sharp_zebra_send_arp(const struct interface *ifp,
 /* Register Link State Opaque messages */
 extern void sharp_zebra_register_te(void);
 
+extern void sharp_redistribute_vrf(struct vrf *vrf, int source);
+
 #endif