#include "if.h"
#include "mpls.h"
#include "srcdest_table.h"
+#include "zebra/zebra_nhg.h"
#ifdef __cplusplus
extern "C" {
struct nexthop *nexthop);
extern void route_entry_copy_nexthops(struct route_entry *re,
struct nexthop *nh);
+int route_entry_update_nhe(struct route_entry *re, struct nhg_hash_entry *new);
#define route_entry_dump(prefix, src, re) _route_entry_dump(__func__, prefix, src, re)
extern void _route_entry_dump(const char *func, union prefixconstptr pp,
nhe = zebra_nhg_rib_find(0, new_grp, afi);
- zebra_nhg_re_update_ref(re, nhe);
+ route_entry_update_nhe(re, nhe);
}
static bool mpls_ftn_update_nexthop(int add, struct nexthop *nexthop,
new_nhe = zebra_nhg_rib_find(0, &new_grp, rt_afi);
- zebra_nhg_re_update_ref(re, new_nhe);
+ route_entry_update_nhe(re, new_nhe);
}
if (curr_active) {
return curr_active;
}
-static void zebra_nhg_re_attach_ref(struct route_entry *re,
- struct nhg_hash_entry *new)
-{
- re->ng = new->nhg;
- re->nhe_id = new->id;
-
- zebra_nhg_increment_ref(new);
-}
-
-int zebra_nhg_re_update_ref(struct route_entry *re, struct nhg_hash_entry *new)
-{
- struct nhg_hash_entry *old = NULL;
- int ret = 0;
-
- if (new == NULL) {
- re->ng = NULL;
- goto done;
- }
-
- if (re->nhe_id != new->id) {
- old = zebra_nhg_lookup_id(re->nhe_id);
-
- zebra_nhg_re_attach_ref(re, new);
-
- if (old)
- zebra_nhg_decrement_ref(old);
- } else if (!re->ng)
- /* This is the first time it's being attached */
- zebra_nhg_re_attach_ref(re, new);
-
-done:
- return ret;
-}
-
/* Convert a nhe into a group array */
uint8_t zebra_nhg_nhe2grp(struct nh_grp *grp, struct nhg_hash_entry *nhe,
int max_num)
#ifndef __ZEBRA_NHG_H__
#define __ZEBRA_NHG_H__
-#include "zebra/rib.h"
+#include "lib/nexthop.h"
#include "lib/nexthop_group.h"
-#include "zebra/zebra_dplane.h"
-
/* This struct is used exclusively for dataplane
* interaction via a dataplane context.
*
/* Reference counter functions */
extern void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe);
extern void zebra_nhg_increment_ref(struct nhg_hash_entry *nhe);
-extern int zebra_nhg_re_update_ref(struct route_entry *re,
- struct nhg_hash_entry *nhe);
/* Check validity of nhe, if invalid will update dependents as well */
extern void zebra_nhg_check_valid(struct nhg_hash_entry *nhe);
extern void zebra_nhg_sweep_table(struct hash *hash);
/* Nexthop resolution processing */
+struct route_entry; /* Forward ref to avoid circular includes */
extern int nexthop_active_update(struct route_node *rn, struct route_entry *re);
#endif
return nexthop;
}
+static void route_entry_attach_ref(struct route_entry *re,
+ struct nhg_hash_entry *new)
+{
+ re->ng = new->nhg;
+ re->nhe_id = new->id;
+
+ zebra_nhg_increment_ref(new);
+}
+
+int route_entry_update_nhe(struct route_entry *re, struct nhg_hash_entry *new)
+{
+ struct nhg_hash_entry *old = NULL;
+ int ret = 0;
+
+ if (new == NULL) {
+ re->ng = NULL;
+ goto done;
+ }
+
+ if (re->nhe_id != new->id) {
+ old = zebra_nhg_lookup_id(re->nhe_id);
+
+ route_entry_attach_ref(re, new);
+
+ if (old)
+ zebra_nhg_decrement_ref(old);
+ } else if (!re->ng)
+ /* This is the first time it's being attached */
+ route_entry_attach_ref(re, new);
+
+done:
+ return ret;
+}
+
struct route_entry *rib_match(afi_t afi, safi_t safi, vrf_id_t vrf_id,
union g_addr *addr, struct route_node **rn_out)
{
* level protocols, as the refcnt might be wrong, since it checks
* if old_id != new_id.
*/
- zebra_nhg_re_update_ref(re, nhe);
+ route_entry_update_nhe(re, nhe);
/* Make it sure prefixlen is applied to the prefix. */
apply_mask(p);