summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2019-02-13 15:25:02 -0500
committerGitHub <noreply@github.com>2019-02-13 15:25:02 -0500
commit77a4dd9320d2cc78ab6b57f98ea09f879d9272c6 (patch)
treecd68f30ba7d49939353418dfa476bcb5dfabcc23
parentc919c6b6ef028d28643e978d55b4397fc749b79b (diff)
parent80d5ff338da6fecbef297db3eb42a98711205fb2 (diff)
Merge pull request #3794 from donaldsharp/sharp_import_check
Sharp import check
-rw-r--r--doc/user/sharp.rst7
-rw-r--r--sharpd/sharp_vty.c23
-rw-r--r--sharpd/sharp_zebra.c19
-rw-r--r--sharpd/sharp_zebra.h4
4 files changed, 42 insertions, 11 deletions
diff --git a/doc/user/sharp.rst b/doc/user/sharp.rst
index a78fac8fc1..ca8f1f512f 100644
--- a/doc/user/sharp.rst
+++ b/doc/user/sharp.rst
@@ -71,10 +71,15 @@ keyword. At present, no sharp commands will be preserved in the config.
be used for pop and forward operations when the specified label is seen.
.. index:: sharp watch
-.. clicmd:: sharp watch nexthop <A.B.C.D|X:X::X:X>
+.. clicmd:: [no] sharp watch <nexthop|import> <A.B.C.D|X:X::X:X> [connected]
Instruct zebra to monitor and notify sharp when the specified nexthop is
changed. The notification from zebra is written into the debug log.
+ The nexthop or import choice chooses the type of nexthop we are asking
+ zebra to watch for us. This choice affects zebra's decision on what
+ matches. Connected tells zebra whether or not that we want the route
+ matched against to be a static or connected route. The no form of
+ the command obviously turns this watching off.
.. index:: sharp data nexthop
.. clicmd:: sharp data nexthop
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c
index 0c02bd304d..9018cfb359 100644
--- a/sharpd/sharp_vty.c
+++ b/sharpd/sharp_vty.c
@@ -39,14 +39,22 @@
#endif
DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
- "sharp watch nexthop X:X::X:X$nhop [connected$connected]",
+ "sharp watch <nexthop$n|import$import> X:X::X:X$nhop [connected$connected]",
"Sharp routing Protocol\n"
"Watch for changes\n"
"Watch for nexthop changes\n"
+ "Watch for import check changes\n"
"The v6 nexthop to signal for watching\n"
"Should the route be connected\n")
{
struct prefix p;
+ bool type_import;
+
+
+ if (n)
+ type_import = false;
+ else
+ type_import = true;
memset(&p, 0, sizeof(p));
@@ -55,29 +63,36 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
p.family = AF_INET6;
sharp_nh_tracker_get(&p);
- sharp_zebra_nexthop_watch(&p, true, !!connected);
+ sharp_zebra_nexthop_watch(&p, type_import, true, !!connected);
return CMD_SUCCESS;
}
DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
- "sharp watch nexthop A.B.C.D$nhop [connected$connected]",
+ "sharp watch <nexthop$n|import$import> A.B.C.D$nhop [connected$connected]",
"Sharp routing Protocol\n"
"Watch for changes\n"
"Watch for nexthop changes\n"
+ "Watch for import check changes\n"
"The v4 nexthop to signal for watching\n"
"Should the route be connected\n")
{
struct prefix p;
+ bool type_import;
memset(&p, 0, sizeof(p));
+ if (n)
+ type_import = false;
+ else
+ type_import = true;
+
p.prefixlen = 32;
p.u.prefix4 = nhop;
p.family = AF_INET;
sharp_nh_tracker_get(&p);
- sharp_zebra_nexthop_watch(&p, true, !!connected);
+ sharp_zebra_nexthop_watch(&p, type_import, true, !!connected);
return CMD_SUCCESS;
}
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index 30e616a057..4682dbc73a 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -320,12 +320,22 @@ void route_delete(struct prefix *p, uint8_t instance)
return;
}
-void sharp_zebra_nexthop_watch(struct prefix *p, bool watch, bool connected)
+void sharp_zebra_nexthop_watch(struct prefix *p, bool import,
+ bool watch, bool connected)
{
- int command = ZEBRA_NEXTHOP_REGISTER;
+ int command;
- if (!watch)
- command = ZEBRA_NEXTHOP_UNREGISTER;
+ if (!import) {
+ command = ZEBRA_NEXTHOP_REGISTER;
+
+ if (!watch)
+ command = ZEBRA_NEXTHOP_UNREGISTER;
+ } else {
+ command = ZEBRA_IMPORT_ROUTE_REGISTER;
+
+ if (!watch)
+ command = ZEBRA_IMPORT_ROUTE_UNREGISTER;
+ }
if (zclient_send_rnh(zclient, command, p, connected, VRF_DEFAULT) < 0)
zlog_warn("%s: Failure to send nexthop to zebra",
@@ -405,4 +415,5 @@ void sharp_zebra_init(void)
zclient->interface_address_delete = interface_address_delete;
zclient->route_notify_owner = route_notify_owner;
zclient->nexthop_update = sharp_nexthop_update;
+ zclient->import_check_update = sharp_nexthop_update;
}
diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h
index 7e6ac7670b..b219022f02 100644
--- a/sharpd/sharp_zebra.h
+++ b/sharpd/sharp_zebra.h
@@ -28,8 +28,8 @@ extern void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label);
extern void route_add(struct prefix *p, uint8_t instance,
struct nexthop_group *nhg);
extern void route_delete(struct prefix *p, uint8_t instance);
-extern void sharp_zebra_nexthop_watch(struct prefix *p, bool watch,
- bool connected);
+extern void sharp_zebra_nexthop_watch(struct prefix *p, bool import,
+ bool watch, bool connected);
extern void sharp_install_routes_helper(struct prefix *p, uint8_t instance,
struct nexthop_group *nhg,