summaryrefslogtreecommitdiffstats
path: root/sharpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2020-08-06 15:43:12 +0200
committerGitHub <noreply@github.com>2020-08-06 15:43:12 +0200
commitcd97e9522dbe43973361b4257bc69e6ba4a4579d (patch)
treee157fc612eed0b3606a42daf0970389d2f03f3a3 /sharpd
parentMerge pull request #6859 from mjstapp/fix_dplane_sa_again (diff)
parentsharpd: support 'update lsp' zapi testing (diff)
downloadfrr-cd97e9522dbe43973361b4257bc69e6ba4a4579d.tar.xz
frr-cd97e9522dbe43973361b4257bc69e6ba4a4579d.zip
Merge pull request #6854 from mjstapp/sharp_lsp_update
sharpd: support 'update lsp' zapi testing
Diffstat (limited to 'sharpd')
-rw-r--r--sharpd/sharp_vty.c34
-rw-r--r--sharpd/sharp_zebra.c24
-rw-r--r--sharpd/sharp_zebra.h5
3 files changed, 38 insertions, 25 deletions
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c
index 1d2b87b9b..6a120c8ef 100644
--- a/sharpd/sharp_vty.c
+++ b/sharpd/sharp_vty.c
@@ -394,27 +394,31 @@ DEFUN_NOSH (show_debugging_sharpd,
return CMD_SUCCESS;
}
-DEFPY(sharp_lsp_prefix_v4, sharp_lsp_prefix_v4_cmd,
- "sharp lsp (0-100000)$inlabel\
+DEFPY (sharp_lsp_prefix_v4, sharp_lsp_prefix_v4_cmd,
+ "sharp lsp [update]$update (0-100000)$inlabel\
nexthop-group NHGNAME$nhgname\
[prefix A.B.C.D/M$pfx\
" FRR_IP_REDIST_STR_ZEBRA "$type_str [instance (0-255)$instance]]",
- "Sharp Routing Protocol\n"
- "Add an LSP\n"
- "The ingress label to use\n"
- "Use nexthops from a nexthop-group\n"
- "The nexthop-group name\n"
- "Label a prefix\n"
- "The v4 prefix to label\n"
- FRR_IP_REDIST_HELP_STR_ZEBRA
- "Instance to use\n"
- "Instance\n")
+ "Sharp Routing Protocol\n"
+ "Add an LSP\n"
+ "Update an LSP\n"
+ "The ingress label to use\n"
+ "Use nexthops from a nexthop-group\n"
+ "The nexthop-group name\n"
+ "Label a prefix\n"
+ "The v4 prefix to label\n"
+ FRR_IP_REDIST_HELP_STR_ZEBRA
+ "Instance to use\n"
+ "Instance\n")
{
struct nexthop_group_cmd *nhgc = NULL;
struct nexthop_group_cmd *backup_nhgc = NULL;
struct nexthop_group *backup_nhg = NULL;
struct prefix p = {};
int type = 0;
+ bool update_p;
+
+ update_p = (update != NULL);
/* We're offered a v4 prefix */
if (pfx->family > 0 && type_str) {
@@ -458,7 +462,8 @@ DEFPY(sharp_lsp_prefix_v4, sharp_lsp_prefix_v4_cmd,
backup_nhg = &(backup_nhgc->nhg);
}
- if (sharp_install_lsps_helper(true, pfx->family > 0 ? &p : NULL,
+ if (sharp_install_lsps_helper(true /*install*/, update_p,
+ pfx->family > 0 ? &p : NULL,
type, instance, inlabel,
&(nhgc->nhg), backup_nhg) == 0)
return CMD_SUCCESS;
@@ -523,7 +528,8 @@ DEFPY(sharp_remove_lsp_prefix_v4, sharp_remove_lsp_prefix_v4_cmd,
nhg = &(nhgc->nhg);
}
- if (sharp_install_lsps_helper(false, pfx->family > 0 ? &p : NULL,
+ if (sharp_install_lsps_helper(false /*!install*/, false,
+ pfx->family > 0 ? &p : NULL,
type, instance, inlabel, nhg, NULL) == 0)
return CMD_SUCCESS;
else {
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index 74e44014a..e0f16d71f 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -114,15 +114,16 @@ static int sharp_ifp_down(struct interface *ifp)
return 0;
}
-int sharp_install_lsps_helper(bool install_p, const struct prefix *p,
- uint8_t type, int instance, uint32_t in_label,
+int sharp_install_lsps_helper(bool install_p, bool update_p,
+ const struct prefix *p, uint8_t type,
+ int instance, uint32_t in_label,
const struct nexthop_group *nhg,
const struct nexthop_group *backup_nhg)
{
struct zapi_labels zl = {};
struct zapi_nexthop *znh;
const struct nexthop *nh;
- int i, ret;
+ int i, cmd, ret;
zl.type = ZEBRA_LSP_SHARP;
zl.local_label = in_label;
@@ -200,12 +201,17 @@ int sharp_install_lsps_helper(bool install_p, const struct prefix *p,
zl.backup_nexthop_num = i;
}
- if (install_p)
- ret = zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_ADD,
- &zl);
- else
- ret = zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_DELETE,
- &zl);
+
+ if (install_p) {
+ if (update_p)
+ cmd = ZEBRA_MPLS_LABELS_REPLACE;
+ else
+ cmd = ZEBRA_MPLS_LABELS_ADD;
+ } else {
+ cmd = ZEBRA_MPLS_LABELS_DELETE;
+ }
+
+ ret = zebra_send_mpls_labels(zclient, cmd, &zl);
return ret;
}
diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h
index cb2f38a6a..e40585aa6 100644
--- a/sharpd/sharp_zebra.h
+++ b/sharpd/sharp_zebra.h
@@ -44,8 +44,9 @@ extern void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id,
extern void sharp_remove_routes_helper(struct prefix *p, vrf_id_t vrf_id,
uint8_t instance, uint32_t routes);
-int sharp_install_lsps_helper(bool install_p, const struct prefix *p,
- uint8_t type, int instance, uint32_t in_label,
+int sharp_install_lsps_helper(bool install_p, bool update_p,
+ const struct prefix *p, uint8_t type,
+ int instance, uint32_t in_label,
const struct nexthop_group *nhg,
const struct nexthop_group *backup_nhg);