diff options
| author | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:03:14 +0200 |
|---|---|---|
| committer | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:04:07 +0200 |
| commit | d62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch) | |
| tree | 3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /zebra/rib.h | |
| parent | 888ac268a0077fc9ebd1218cec6ae472af0bfc40 (diff) | |
*: reindentreindent-master-after
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'zebra/rib.h')
| -rw-r--r-- | zebra/rib.h | 439 |
1 files changed, 212 insertions, 227 deletions
diff --git a/zebra/rib.h b/zebra/rib.h index 999266241a..eca2be5eee 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -37,63 +37,62 @@ #define DISTANCE_INFINITY 255 #define ZEBRA_KERNEL_TABLE_MAX 252 /* support for no more than this rt tables */ -struct route_entry -{ - /* Link list. */ - struct route_entry *next; - struct route_entry *prev; - - /* Nexthop structure */ - struct nexthop *nexthop; - - /* Refrence count. */ - unsigned long refcnt; - - /* Tag */ - route_tag_t tag; - - /* Uptime. */ - time_t uptime; - - /* Type fo this route. */ - int type; - - /* Source protocol instance */ - u_short instance; - - /* VRF identifier. */ - vrf_id_t vrf_id; - - /* Which routing table */ - uint32_t table; - - /* Metric */ - u_int32_t metric; - - /* MTU */ - u_int32_t mtu; - u_int32_t nexthop_mtu; - - /* Distance. */ - u_char distance; - - /* Flags of this route. - * This flag's definition is in lib/zebra.h ZEBRA_FLAG_* and is exposed - * to clients via Zserv - */ - u_int32_t flags; - - /* RIB internal status */ - u_char status; +struct route_entry { + /* Link list. */ + struct route_entry *next; + struct route_entry *prev; + + /* Nexthop structure */ + struct nexthop *nexthop; + + /* Refrence count. */ + unsigned long refcnt; + + /* Tag */ + route_tag_t tag; + + /* Uptime. */ + time_t uptime; + + /* Type fo this route. */ + int type; + + /* Source protocol instance */ + u_short instance; + + /* VRF identifier. */ + vrf_id_t vrf_id; + + /* Which routing table */ + uint32_t table; + + /* Metric */ + u_int32_t metric; + + /* MTU */ + u_int32_t mtu; + u_int32_t nexthop_mtu; + + /* Distance. */ + u_char distance; + + /* Flags of this route. + * This flag's definition is in lib/zebra.h ZEBRA_FLAG_* and is exposed + * to clients via Zserv + */ + u_int32_t flags; + + /* RIB internal status */ + u_char status; #define ROUTE_ENTRY_REMOVED 0x1 - /* to simplify NHT logic when NHs change, instead of doing a NH by NH cmp */ +/* to simplify NHT logic when NHs change, instead of doing a NH by NH cmp */ #define ROUTE_ENTRY_NEXTHOPS_CHANGED 0x2 #define ROUTE_ENTRY_CHANGED 0x4 #define ROUTE_ENTRY_SELECTED_FIB 0x8 - /* Nexthop information. */ - u_char nexthop_num; - u_char nexthop_active_num; + /* Nexthop information. */ + u_char nexthop_num; + u_char nexthop_active_num; }; /* meta-queue structure: @@ -104,38 +103,36 @@ struct route_entry * sub-queue 4: any other origin (if any) */ #define MQ_SIZE 5 -struct meta_queue -{ - struct list *subq[MQ_SIZE]; - u_int32_t size; /* sum of lengths of all subqueues */ +struct meta_queue { + struct list *subq[MQ_SIZE]; + u_int32_t size; /* sum of lengths of all subqueues */ }; /* * Structure that represents a single destination (prefix). */ -typedef struct rib_dest_t_ -{ +typedef struct rib_dest_t_ { - /* - * Back pointer to the route node for this destination. This helps - * us get to the prefix that this structure is for. - */ - struct route_node *rnode; + /* + * Back pointer to the route node for this destination. This helps + * us get to the prefix that this structure is for. + */ + struct route_node *rnode; - /* - * Doubly-linked list of routes for this prefix. - */ - struct route_entry *routes; + /* + * Doubly-linked list of routes for this prefix. + */ + struct route_entry *routes; - /* - * Flags, see below. - */ - u_int32_t flags; + /* + * Flags, see below. + */ + u_int32_t flags; - /* - * Linkage to put dest on the FPM processing queue. - */ - TAILQ_ENTRY(rib_dest_t_) fpm_q_entries; + /* + * Linkage to put dest on the FPM processing queue. + */ + TAILQ_ENTRY(rib_dest_t_) fpm_q_entries; } rib_dest_t; @@ -161,34 +158,32 @@ typedef struct rib_dest_t_ /* * Macro to iterate over each route for a destination (prefix). */ -#define RE_DEST_FOREACH_ROUTE(dest, re) \ - for ((re) = (dest) ? (dest)->routes : NULL; (re); (re) = (re)->next) +#define RE_DEST_FOREACH_ROUTE(dest, re) \ + for ((re) = (dest) ? (dest)->routes : NULL; (re); (re) = (re)->next) /* * Same as above, but allows the current node to be unlinked. */ -#define RE_DEST_FOREACH_ROUTE_SAFE(dest, re, next) \ - for ((re) = (dest) ? (dest)->routes : NULL; \ - (re) && ((next) = (re)->next, 1); \ - (re) = (next)) +#define RE_DEST_FOREACH_ROUTE_SAFE(dest, re, next) \ + for ((re) = (dest) ? (dest)->routes : NULL; \ + (re) && ((next) = (re)->next, 1); (re) = (next)) -#define RNODE_FOREACH_RE(rn, re) \ - RE_DEST_FOREACH_ROUTE (rib_dest_from_rnode (rn), re) +#define RNODE_FOREACH_RE(rn, re) \ + RE_DEST_FOREACH_ROUTE(rib_dest_from_rnode(rn), re) -#define RNODE_FOREACH_RE_SAFE(rn, re, next) \ - RE_DEST_FOREACH_ROUTE_SAFE (rib_dest_from_rnode (rn), re, next) +#define RNODE_FOREACH_RE_SAFE(rn, re, next) \ + RE_DEST_FOREACH_ROUTE_SAFE(rib_dest_from_rnode(rn), re, next) -#if defined (HAVE_RTADV) +#if defined(HAVE_RTADV) /* Structure which hold status of router advertisement. */ -struct rtadv -{ - int sock; +struct rtadv { + int sock; - int adv_if_count; - int adv_msec_if_count; + int adv_if_count; + int adv_msec_if_count; - struct thread *ra_read; - struct thread *ra_timer; + struct thread *ra_read; + struct thread *ra_timer; }; #endif /* HAVE_RTADV */ @@ -198,142 +193,141 @@ struct rtadv * Structure that is hung off of a route_table that holds information about * the table. */ -typedef struct rib_table_info_t_ -{ +typedef struct rib_table_info_t_ { - /* - * Back pointer to zebra_vrf. - */ - struct zebra_vrf *zvrf; - afi_t afi; - safi_t safi; + /* + * Back pointer to zebra_vrf. + */ + struct zebra_vrf *zvrf; + afi_t afi; + safi_t safi; } rib_table_info_t; -typedef enum -{ - RIB_TABLES_ITER_S_INIT, - RIB_TABLES_ITER_S_ITERATING, - RIB_TABLES_ITER_S_DONE +typedef enum { + RIB_TABLES_ITER_S_INIT, + RIB_TABLES_ITER_S_ITERATING, + RIB_TABLES_ITER_S_DONE } rib_tables_iter_state_t; /* * Structure that holds state for iterating over all tables in the * Routing Information Base. */ -typedef struct rib_tables_iter_t_ -{ - vrf_id_t vrf_id; - int afi_safi_ix; +typedef struct rib_tables_iter_t_ { + vrf_id_t vrf_id; + int afi_safi_ix; - rib_tables_iter_state_t state; + rib_tables_iter_state_t state; } rib_tables_iter_t; /* Events/reasons triggering a RIB update. */ -typedef enum -{ - RIB_UPDATE_IF_CHANGE, - RIB_UPDATE_RMAP_CHANGE, - RIB_UPDATE_OTHER +typedef enum { + RIB_UPDATE_IF_CHANGE, + RIB_UPDATE_RMAP_CHANGE, + RIB_UPDATE_OTHER } rib_update_event_t; -extern struct nexthop *route_entry_nexthop_ifindex_add (struct route_entry *, ifindex_t); -extern struct nexthop *route_entry_nexthop_blackhole_add (struct route_entry *); -extern struct nexthop *route_entry_nexthop_ipv4_add (struct route_entry *, - struct in_addr *, - struct in_addr *); -extern struct nexthop *route_entry_nexthop_ipv4_ifindex_add (struct route_entry *, - struct in_addr *, - struct in_addr *, - ifindex_t); -extern void route_entry_nexthop_delete (struct route_entry *re, struct nexthop *nexthop); -extern struct nexthop *route_entry_nexthop_ipv6_add (struct route_entry *, - struct in6_addr *); -extern struct nexthop *route_entry_nexthop_ipv6_ifindex_add (struct route_entry *re, - struct in6_addr *ipv6, - ifindex_t ifindex); -extern void route_entry_nexthop_add (struct route_entry *re, struct nexthop *nexthop); -extern void route_entry_copy_nexthops (struct route_entry *re, struct nexthop *nh); +extern struct nexthop *route_entry_nexthop_ifindex_add(struct route_entry *, + ifindex_t); +extern struct nexthop *route_entry_nexthop_blackhole_add(struct route_entry *); +extern struct nexthop *route_entry_nexthop_ipv4_add(struct route_entry *, + struct in_addr *, + struct in_addr *); +extern struct nexthop * +route_entry_nexthop_ipv4_ifindex_add(struct route_entry *, struct in_addr *, + struct in_addr *, ifindex_t); +extern void route_entry_nexthop_delete(struct route_entry *re, + struct nexthop *nexthop); +extern struct nexthop *route_entry_nexthop_ipv6_add(struct route_entry *, + struct in6_addr *); +extern struct nexthop * +route_entry_nexthop_ipv6_ifindex_add(struct route_entry *re, + struct in6_addr *ipv6, ifindex_t ifindex); +extern void route_entry_nexthop_add(struct route_entry *re, + struct nexthop *nexthop); +extern void route_entry_copy_nexthops(struct route_entry *re, + struct nexthop *nh); #define route_entry_dump(prefix, src, re) _route_entry_dump(__func__, prefix, src, re) -extern void _route_entry_dump (const char *, - union prefixconstptr, - union prefixconstptr, const struct route_entry *); +extern void _route_entry_dump(const char *, union prefixconstptr, + union prefixconstptr, const struct route_entry *); /* RPF lookup behaviour */ -enum multicast_mode -{ - MCAST_NO_CONFIG = 0, /* MIX_MRIB_FIRST, but no show in config write */ - MCAST_MRIB_ONLY, /* MRIB only */ - MCAST_URIB_ONLY, /* URIB only */ - MCAST_MIX_MRIB_FIRST, /* MRIB, if nothing at all then URIB */ - MCAST_MIX_DISTANCE, /* MRIB & URIB, lower distance wins */ - MCAST_MIX_PFXLEN, /* MRIB & URIB, longer prefix wins */ - /* on equal value, MRIB wins for last 2 */ +enum multicast_mode { + MCAST_NO_CONFIG = 0, /* MIX_MRIB_FIRST, but no show in config write */ + MCAST_MRIB_ONLY, /* MRIB only */ + MCAST_URIB_ONLY, /* URIB only */ + MCAST_MIX_MRIB_FIRST, /* MRIB, if nothing at all then URIB */ + MCAST_MIX_DISTANCE, /* MRIB & URIB, lower distance wins */ + MCAST_MIX_PFXLEN, /* MRIB & URIB, longer prefix wins */ + /* on equal value, MRIB wins for last 2 */ }; -extern void multicast_mode_ipv4_set (enum multicast_mode mode); -extern enum multicast_mode multicast_mode_ipv4_get (void); +extern void multicast_mode_ipv4_set(enum multicast_mode mode); +extern enum multicast_mode multicast_mode_ipv4_get(void); -extern void rib_lookup_and_dump (struct prefix_ipv4 *, vrf_id_t); -extern void rib_lookup_and_pushup (struct prefix_ipv4 *, vrf_id_t); +extern void rib_lookup_and_dump(struct prefix_ipv4 *, vrf_id_t); +extern void rib_lookup_and_pushup(struct prefix_ipv4 *, vrf_id_t); -extern int rib_lookup_ipv4_route (struct prefix_ipv4 *, union sockunion *, - vrf_id_t); +extern int rib_lookup_ipv4_route(struct prefix_ipv4 *, union sockunion *, + vrf_id_t); #define ZEBRA_RIB_LOOKUP_ERROR -1 #define ZEBRA_RIB_FOUND_EXACT 0 #define ZEBRA_RIB_FOUND_NOGATE 1 #define ZEBRA_RIB_FOUND_CONNECTED 2 #define ZEBRA_RIB_NOTFOUND 3 - - extern int is_zebra_valid_kernel_table(u_int32_t table_id); extern int is_zebra_main_routing_table(u_int32_t table_id); -extern int zebra_check_addr (struct prefix *p); +extern int zebra_check_addr(struct prefix *p); -extern void rib_addnode (struct route_node *rn, struct route_entry *re, int process); -extern void rib_delnode (struct route_node *rn, struct route_entry *re); -extern int rib_install_kernel (struct route_node *rn, struct route_entry *re, struct route_entry *old); -extern int rib_uninstall_kernel (struct route_node *rn, struct route_entry *re); +extern void rib_addnode(struct route_node *rn, struct route_entry *re, + int process); +extern void rib_delnode(struct route_node *rn, struct route_entry *re); +extern int rib_install_kernel(struct route_node *rn, struct route_entry *re, + struct route_entry *old); +extern int rib_uninstall_kernel(struct route_node *rn, struct route_entry *re); /* NOTE: * All rib_add function will not just add prefix into RIB, but * also implicitly withdraw equal prefix of same type. */ -extern int rib_add (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, - u_short instance, int flags, struct prefix *p, - struct prefix_ipv6 *src_p, union g_addr *gate, union g_addr *src, - ifindex_t ifindex, u_int32_t table_id, - u_int32_t, u_int32_t, u_char); - -extern int rib_add_multipath (afi_t afi, safi_t safi, struct prefix *, - struct prefix_ipv6 *src_p, struct route_entry *); - -extern void rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, - u_short instance, int flags, struct prefix *p, - struct prefix_ipv6 *src_p, union g_addr *gate, - ifindex_t ifindex, u_int32_t table_id); - -extern struct route_entry *rib_match (afi_t afi, safi_t safi, vrf_id_t, union g_addr *, - struct route_node **rn_out); -extern struct route_entry *rib_match_ipv4_multicast (vrf_id_t vrf_id, struct in_addr addr, - struct route_node **rn_out); - -extern struct route_entry *rib_lookup_ipv4 (struct prefix_ipv4 *, vrf_id_t); - -extern void rib_update (vrf_id_t, rib_update_event_t); -extern void rib_weed_tables (void); -extern void rib_sweep_route (void); -extern void rib_close_table (struct route_table *); -extern void rib_init (void); -extern unsigned long rib_score_proto (u_char proto, u_short instance); -extern void rib_queue_add (struct route_node *rn); -extern void meta_queue_free (struct meta_queue *mq); -extern int zebra_rib_labeled_unicast (struct route_entry *re); +extern int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, + u_short instance, int flags, struct prefix *p, + struct prefix_ipv6 *src_p, union g_addr *gate, + union g_addr *src, ifindex_t ifindex, u_int32_t table_id, + u_int32_t, u_int32_t, u_char); + +extern int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *, + struct prefix_ipv6 *src_p, struct route_entry *); + +extern void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, + u_short instance, int flags, struct prefix *p, + struct prefix_ipv6 *src_p, union g_addr *gate, + ifindex_t ifindex, u_int32_t table_id); + +extern struct route_entry *rib_match(afi_t afi, safi_t safi, vrf_id_t, + union g_addr *, + struct route_node **rn_out); +extern struct route_entry *rib_match_ipv4_multicast(vrf_id_t vrf_id, + struct in_addr addr, + struct route_node **rn_out); + +extern struct route_entry *rib_lookup_ipv4(struct prefix_ipv4 *, vrf_id_t); + +extern void rib_update(vrf_id_t, rib_update_event_t); +extern void rib_weed_tables(void); +extern void rib_sweep_route(void); +extern void rib_close_table(struct route_table *); +extern void rib_init(void); +extern unsigned long rib_score_proto(u_char proto, u_short instance); +extern void rib_queue_add(struct route_node *rn); +extern void meta_queue_free(struct meta_queue *mq); +extern int zebra_rib_labeled_unicast(struct route_entry *re); extern struct route_table *rib_table_ipv6; -extern void rib_unlink (struct route_node *, struct route_entry *); -extern int rib_gc_dest (struct route_node *rn); -extern struct route_table *rib_tables_iter_next (rib_tables_iter_t *iter); +extern void rib_unlink(struct route_node *, struct route_entry *); +extern int rib_gc_dest(struct route_node *rn); +extern struct route_table *rib_tables_iter_next(rib_tables_iter_t *iter); extern u_char route_distance(int type); @@ -344,19 +338,17 @@ extern u_char route_distance(int type); /* * rib_table_info */ -static inline rib_table_info_t * -rib_table_info (struct route_table *table) +static inline rib_table_info_t *rib_table_info(struct route_table *table) { - return (rib_table_info_t *) table->info; + return (rib_table_info_t *)table->info; } /* * rib_dest_from_rnode */ -static inline rib_dest_t * -rib_dest_from_rnode (struct route_node *rn) +static inline rib_dest_t *rib_dest_from_rnode(struct route_node *rn) { - return (rib_dest_t *) rn->info; + return (rib_dest_t *)rn->info; } /* @@ -365,25 +357,23 @@ rib_dest_from_rnode (struct route_node *rn) * Returns a pointer to the list of routes corresponding to the given * route_node. */ -static inline struct route_entry * -rnode_to_ribs (struct route_node *rn) +static inline struct route_entry *rnode_to_ribs(struct route_node *rn) { - rib_dest_t *dest; + rib_dest_t *dest; - dest = rib_dest_from_rnode (rn); - if (!dest) - return NULL; + dest = rib_dest_from_rnode(rn); + if (!dest) + return NULL; - return dest->routes; + return dest->routes; } /* * rib_dest_prefix */ -static inline struct prefix * -rib_dest_prefix (rib_dest_t *dest) +static inline struct prefix *rib_dest_prefix(rib_dest_t *dest) { - return &dest->rnode->p; + return &dest->rnode->p; } /* @@ -391,39 +381,35 @@ rib_dest_prefix (rib_dest_t *dest) * * Returns the address family that the destination is for. */ -static inline u_char -rib_dest_af (rib_dest_t *dest) +static inline u_char rib_dest_af(rib_dest_t *dest) { - return dest->rnode->p.family; + return dest->rnode->p.family; } /* * rib_dest_table */ -static inline struct route_table * -rib_dest_table (rib_dest_t *dest) +static inline struct route_table *rib_dest_table(rib_dest_t *dest) { - return srcdest_rnode_table(dest->rnode); + return srcdest_rnode_table(dest->rnode); } /* * rib_dest_vrf */ -static inline struct zebra_vrf * -rib_dest_vrf (rib_dest_t *dest) +static inline struct zebra_vrf *rib_dest_vrf(rib_dest_t *dest) { - return rib_table_info (rib_dest_table (dest))->zvrf; + return rib_table_info(rib_dest_table(dest))->zvrf; } /* * rib_tables_iter_init */ -static inline void -rib_tables_iter_init (rib_tables_iter_t *iter) +static inline void rib_tables_iter_init(rib_tables_iter_t *iter) { - memset (iter, 0, sizeof (*iter)); - iter->state = RIB_TABLES_ITER_S_INIT; + memset(iter, 0, sizeof(*iter)); + iter->state = RIB_TABLES_ITER_S_INIT; } /* @@ -432,21 +418,20 @@ rib_tables_iter_init (rib_tables_iter_t *iter) * Returns TRUE if this iterator has started iterating over the set of * tables. */ -static inline int -rib_tables_iter_started (rib_tables_iter_t *iter) +static inline int rib_tables_iter_started(rib_tables_iter_t *iter) { - return iter->state != RIB_TABLES_ITER_S_INIT; + return iter->state != RIB_TABLES_ITER_S_INIT; } /* * rib_tables_iter_cleanup */ -static inline void -rib_tables_iter_cleanup (rib_tables_iter_t *iter) +static inline void rib_tables_iter_cleanup(rib_tables_iter_t *iter) { - iter->state = RIB_TABLES_ITER_S_DONE; + iter->state = RIB_TABLES_ITER_S_DONE; } -DECLARE_HOOK(rib_update, (struct route_node *rn, const char *reason), (rn, reason)) +DECLARE_HOOK(rib_update, (struct route_node * rn, const char *reason), + (rn, reason)) #endif /*_ZEBRA_RIB_H */ |
