summaryrefslogtreecommitdiffstats
path: root/ripd/ripd.h
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-01-04 22:08:10 +0100
committerRenato Westphal <renato@opensourcerouting.org>2019-01-18 19:15:41 +0100
commitae7b826a2338aa1cc61019fa74391da1c3ceb542 (patch)
tree6a2456b96aad0aeb182525e14c865ca9f6ba13dd /ripd/ripd.h
parentripd: failure to create a socket shouldn't be a fatal error (diff)
downloadfrr-ae7b826a2338aa1cc61019fa74391da1c3ceb542.tar.xz
frr-ae7b826a2338aa1cc61019fa74391da1c3ceb542.zip
ripd: add VRF support
* Turn the "instance" YANG presence-container into a YANG list keyed by the new "vrf" leaf. This is a backward incompatible change but this should be ok for now. * RIP VRF instances can be configured even when the corresponding VRF doesn't exist. And a RIP VRF instance isn't deleted when the corresponding VRF is deleted. For this to work, implement the rip_instance_enable() and rip_instance_disable() functions that are called to enable/disable RIP routing instances when necessary. A RIP routing instance can be enabled only when the corresponding VRF is enabled (this information comes from zebra and depends on the underlying VRF backend). Routing instances are stored in the new rip_instances rb-tree (global variable). * Add a vrf pointer to the rip structure instead of storing vrf_id only. This is much more convenient than using vrf_lookup_by_id() every time we need to get the vrf pointer from the VRF ID. The rip->vrf pointer is updated whenever the VRF enable/disable hooks are called. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripd/ripd.h')
-rw-r--r--ripd/ripd.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/ripd/ripd.h b/ripd/ripd.h
index a18a74157..268ba74b9 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -99,8 +99,16 @@
/* RIP structure. */
struct rip {
- /* VRF ID. */
- vrf_id_t vrf_id;
+ RB_ENTRY(rip) entry;
+
+ /* VRF this routing instance is associated with. */
+ char *vrf_name;
+
+ /* VRF backpointer (might be NULL if the VRF doesn't exist). */
+ struct vrf *vrf;
+
+ /* Status of the routing instance. */
+ bool enabled;
/* RIP socket. */
int sock;
@@ -182,6 +190,8 @@ struct rip {
long queries;
} counters;
};
+RB_HEAD(rip_instance_head, rip);
+RB_PROTOTYPE(rip_instance_head, rip, entry, rip_instance_compare)
/* RIP routing table entry which belong to rip_packet. */
struct rte {
@@ -416,11 +426,15 @@ extern int rip_passive_nondefault_unset(struct rip *rip, const char *ifname);
extern void rip_passive_nondefault_clean(struct rip *rip);
extern void rip_if_init(void);
extern void rip_route_map_init(void);
+extern void rip_zebra_vrf_register(struct vrf *vrf);
+extern void rip_zebra_vrf_deregister(struct vrf *vrf);
extern void rip_zclient_init(struct thread_master *);
extern void rip_zclient_stop(void);
extern int if_check_address(struct rip *rip, struct in_addr addr);
extern struct rip *rip_lookup_by_vrf_id(vrf_id_t vrf_id);
-extern struct rip *rip_create(struct vrf *vrf, int socket);
+extern struct rip *rip_lookup_by_vrf_name(const char *vrf_name);
+extern struct rip *rip_create(const char *vrf_name, struct vrf *vrf,
+ int socket);
extern int rip_request_send(struct sockaddr_in *, struct interface *, uint8_t,
struct connected *);
@@ -436,7 +450,7 @@ extern int rip_enable_if_delete(struct rip *rip, const char *ifname);
extern void rip_event(struct rip *rip, enum rip_event event, int sock);
extern void rip_ecmp_disable(struct rip *rip);
-extern int rip_create_socket(void);
+extern int rip_create_socket(struct vrf *vrf);
extern int rip_redistribute_check(struct rip *rip, int type);
extern void rip_redistribute_conf_update(struct rip *rip, int type);
@@ -495,6 +509,9 @@ extern int rip_offset_list_apply_out(struct prefix_ipv4 *, struct interface *,
extern int offset_list_cmp(struct rip_offset_list *o1,
struct rip_offset_list *o2);
+extern void rip_vrf_init(void);
+extern void rip_vrf_terminate(void);
+
/* YANG notifications */
extern void ripd_notif_send_auth_type_failure(const char *ifname);
extern void ripd_notif_send_auth_failure(const char *ifname);