summaryrefslogtreecommitdiff
path: root/bfdd/bfd.h
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@opensourcerouting.org>2020-05-15 17:38:04 -0300
committerRafael Zalamena <rzalamena@opensourcerouting.org>2020-05-20 15:18:00 -0300
commitccc9ada8681471ab6093502686ddd9122058dcbe (patch)
treed7cc49e01ae2843eac3e56dc83b3dd219d2322ef /bfdd/bfd.h
parentd40d6c2274b7d05b4facd70228aaa8a1866d7efa (diff)
bfdd: implement BFD session configuration profiles
Allow user to pre-configure peers with a profile. If a peer is using a profile any configuration made to the peer will take precedence over the profile configuration. In order to track the peer configuration we have now an extra copy of the peer configuration in `peer_profile` inside `struct bfd_session`. This information will help the profile functions to detect user configurations and avoid overriding what the user configured. This is especially important for peers created via other protocols where the default `shutdown` state is disabled (peers created manually are `shutdown` by default). Profiles can be used before they exist: if no profile exists then it will use the default configuration. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'bfdd/bfd.h')
-rw-r--r--bfdd/bfd.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/bfdd/bfd.h b/bfdd/bfd.h
index 5a81d80424..5984662a01 100644
--- a/bfdd/bfd.h
+++ b/bfdd/bfd.h
@@ -192,6 +192,34 @@ struct bfd_session_stats {
uint64_t znotification;
};
+/**
+ * BFD session profile to override default configurations.
+ */
+struct bfd_profile {
+ /** Profile name. */
+ char name[64];
+
+ /** Session detection multiplier. */
+ uint8_t detection_multiplier;
+ /** Desired transmission interval (in microseconds). */
+ uint32_t min_tx;
+ /** Minimum required receive interval (in microseconds). */
+ uint32_t min_rx;
+ /** Administrative state. */
+ bool admin_shutdown;
+
+ /** Echo mode (only applies to single hop). */
+ bool echo_mode;
+ /** Minimum required echo receive interval (in microseconds). */
+ uint32_t min_echo_rx;
+
+ /** Profile list entry. */
+ TAILQ_ENTRY(bfd_profile) entry;
+};
+
+/** Profile list type. */
+TAILQ_HEAD(bfdproflist, bfd_profile);
+
/* bfd_session shortcut label forwarding. */
struct peer_label;
@@ -210,6 +238,13 @@ struct bfd_session {
uint8_t mh_ttl;
uint8_t remote_cbit;
+ /** BFD profile name. */
+ char *profile_name;
+ /** BFD pre configured profile. */
+ struct bfd_profile *profile;
+ /** BFD peer configuration (without profile). */
+ struct bfd_profile peer_profile;
+
/* Timers */
struct bfd_timers timers;
struct bfd_timers cur_timers;
@@ -597,6 +632,57 @@ int bfd_echo_xmt_cb(struct thread *t);
extern struct in6_addr zero_addr;
+/**
+ * Creates a new profile entry and insert into the global list.
+ *
+ * \param name the BFD profile name.
+ *
+ * \returns `NULL` if it already exists otherwise the new entry.
+ */
+struct bfd_profile *bfd_profile_new(const char *name);
+
+/**
+ * Search for configured BFD profiles (profile name is case insensitive).
+ *
+ * \param name the BFD profile name.
+ *
+ * \returns `NULL` if it doesn't exist otherwise the entry.
+ */
+struct bfd_profile *bfd_profile_lookup(const char *name);
+
+/**
+ * Removes profile from list and free memory.
+ *
+ * \param bp the BFD profile.
+ */
+void bfd_profile_free(struct bfd_profile *bp);
+
+/**
+ * Apply a profile configuration to an existing BFD session. The non default
+ * values will not be overriden.
+ *
+ * NOTE: if the profile doesn't exist yet, then the profile will be applied
+ * once it begins to exist.
+ *
+ * \param profile_name the BFD profile name.
+ * \param bs the BFD session.
+ */
+void bfd_profile_apply(const char *profname, struct bfd_session *bs);
+
+/**
+ * Remove any applied profile from session and revert the session
+ * configuration.
+ *
+ * \param bs the BFD session.
+ */
+void bfd_profile_remove(struct bfd_session *bs);
+
+/**
+ * Apply new profile values to sessions using it.
+ *
+ * \param[in] bp the BFD profile that got updated.
+ */
+void bfd_profile_update(struct bfd_profile *bp);
/*
* bfdd_vty.c