diff options
| author | vdhingra <vdhingra@vmware.com> | 2020-04-24 05:38:43 -0700 |
|---|---|---|
| committer | vdhingra <vdhingra@vmware.com> | 2020-07-16 08:33:00 -0700 |
| commit | 88fa5104a04af60b7d1107f02ee84fb9c0a15abe (patch) | |
| tree | c2bbeecd9a5c384b7a615032c5fe13a1ff495c36 /staticd/static_routes.h | |
| parent | 7441ea1afd4400ca74f97138e20e4ffb9f0b125e (diff) | |
staticd : Configuration northbound implementation
1. Modifies the data structs to make the distance, tag and table-id
property of a route, i.e created a hireachical data struct to save
route and nexthop information.
2. Backend northbound implementation
Signed-off-by: VishalDhingra <vdhingra@vmware.com>
Diffstat (limited to 'staticd/static_routes.h')
| -rw-r--r-- | staticd/static_routes.h | 112 |
1 files changed, 82 insertions, 30 deletions
diff --git a/staticd/static_routes.h b/staticd/static_routes.h index 6414947b16..89ef544023 100644 --- a/staticd/static_routes.h +++ b/staticd/static_routes.h @@ -21,6 +21,7 @@ #define __STATIC_ROUTES_H__ #include "lib/mpls.h" +#include "table.h" /* Static route label information */ struct static_nh_label { @@ -35,13 +36,17 @@ enum static_blackhole_type { STATIC_BLACKHOLE_REJECT }; +/* + * The order for below macros should be in sync with + * yang model typedef nexthop-type + */ typedef enum { - STATIC_IFNAME, + STATIC_IFNAME = 1, STATIC_IPV4_GATEWAY, STATIC_IPV4_GATEWAY_IFNAME, - STATIC_BLACKHOLE, STATIC_IPV6_GATEWAY, STATIC_IPV6_GATEWAY_IFNAME, + STATIC_BLACKHOLE, } static_types; /* @@ -64,14 +69,37 @@ enum static_install_states { STATIC_NOT_INSTALLED, }; +PREDECL_DLIST(static_path_list); +PREDECL_DLIST(static_nexthop_list); + +/* Static route information */ +struct static_route_info { + /* path list */ + struct static_path_list_head path_list; +}; + +/* Static path information */ +struct static_path { + /* Linkage for static path lists */ + struct static_path_list_item list; + /* Administrative distance. */ + uint8_t distance; + /* Tag */ + route_tag_t tag; + /* Table-id */ + uint32_t table_id; + /* Nexthop list */ + struct static_nexthop_list_head nexthop_list; +}; + +DECLARE_DLIST(static_path_list, struct static_path, list); + /* Static route information. */ -struct static_route { +struct static_nexthop { /* For linked list. */ - struct static_route *prev; - struct static_route *next; + struct static_nexthop_list_item list; /* VRF identifier. */ - vrf_id_t vrf_id; vrf_id_t nh_vrf_id; char nh_vrfname[VRF_NAMSIZ + 1]; @@ -81,12 +109,6 @@ struct static_route { */ enum static_install_states state; - /* Administrative distance. */ - uint8_t distance; - - /* Tag */ - route_tag_t tag; - /* Flag for this static route's type. */ static_types type; @@ -104,8 +126,6 @@ struct static_route { /* Label information */ struct static_nh_label snh_label; - uint32_t table_id; - /* * Whether to pretend the nexthop is directly attached to the specified * link. Only meaningful when both a gateway address and interface name @@ -114,32 +134,64 @@ struct static_route { bool onlink; }; +DECLARE_DLIST(static_nexthop_list, struct static_nexthop, list); + + +/* + * rib_dest_from_rnode + */ +static inline struct static_route_info * +static_route_info_from_rnode(struct route_node *rn) +{ + return (struct static_route_info *)(rn->info); +} + extern bool mpls_enabled; extern struct zebra_privs_t static_privs; void static_fixup_vrf_ids(struct static_vrf *svrf); -extern int static_add_route(afi_t afi, safi_t safi, uint8_t type, - struct prefix *p, struct prefix_ipv6 *src_p, - union g_addr *gate, const char *ifname, - enum static_blackhole_type bh_type, route_tag_t tag, - uint8_t distance, struct static_vrf *svrf, - struct static_vrf *nh_svrf, - struct static_nh_label *snh_label, - uint32_t table_id, bool onlink); - -extern int static_delete_route(afi_t afi, safi_t safi, uint8_t type, - struct prefix *p, struct prefix_ipv6 *src_p, - union g_addr *gate, const char *ifname, - route_tag_t tag, uint8_t distance, - struct static_vrf *svrf, - struct static_nh_label *snh_label, - uint32_t table_id); +extern struct static_nexthop * +static_add_nexthop(struct route_node *rn, struct static_path *pn, safi_t safi, + struct static_vrf *svrf, static_types type, + struct ipaddr *ipaddr, const char *ifname, + const char *nh_vrf); +extern void static_install_nexthop(struct route_node *rn, + struct static_path *pn, + struct static_nexthop *nh, safi_t safi, + struct static_vrf *svrf, const char *ifname, + static_types type, const char *nh_vrf); + +extern int static_delete_nexthop(struct route_node *rn, struct static_path *pn, + safi_t safi, struct static_vrf *svrf, + struct static_nexthop *nh); extern void static_cleanup_vrf_ids(struct static_vrf *disable_svrf); extern void static_install_intf_nh(struct interface *ifp); extern void static_ifindex_update(struct interface *ifp, bool up); + +extern void static_install_path(struct route_node *rn, struct static_path *pn, + safi_t safi, struct static_vrf *svrf); + +extern struct route_node *static_add_route(afi_t afi, safi_t safi, + struct prefix *p, + struct prefix_ipv6 *src_p, + struct static_vrf *svrf); +extern void static_del_route(struct route_node *rn, safi_t safi, + struct static_vrf *svrf); + +extern struct static_path *static_add_path(struct route_node *rn, + uint8_t distance); +extern void static_del_path(struct route_node *rn, struct static_path *pn, + safi_t safi, struct static_vrf *svrf); + +extern void static_get_nh_type(static_types stype, char *type, size_t size); +extern bool static_add_nexthop_validate(struct static_vrf *svrf, + static_types type, + struct ipaddr *ipaddr); +extern struct stable_info *static_get_stable_info(struct route_node *rn); +extern void static_route_info_init(struct static_route_info *si); #endif |
