]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_nhg.h
zebra: Pass is_kernel_nh to zebra_nhg_find()
[mirror_frr.git] / zebra / zebra_nhg.h
CommitLineData
ad28e79a
SW
1/* Zebra Nexthop Group header.
2 * Copyright (C) 2019 Cumulus Networks, Inc.
3 * Donald Sharp
4 * Stephen Worley
5 *
6 * This file is part of FRR.
7 *
8 * FRR is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * FRR is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with FRR; see the file COPYING. If not, write to the Free
20 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 * 02111-1307, USA.
22 */
23#ifndef __ZEBRA_NHG_H__
24#define __ZEBRA_NHG_H__
25
26#include "zebra/rib.h"
69171da2 27#include "lib/nexthop_group.h"
ad28e79a 28
5f3c9e52
SW
29#include "zebra/zebra_dplane.h"
30
69171da2 31struct nhg_hash_entry {
a95b8020 32 uint32_t id;
77b76fc9 33 afi_t afi;
69171da2 34 vrf_id_t vrf_id;
d9f5b2f5 35 bool is_kernel_nh;
69171da2 36
8e401b25 37 struct nexthop_group *nhg;
69171da2 38
2614bf87
SW
39 /* If this is not a group, it
40 * will be a single nexthop
41 * and must have an interface
42 * associated with it.
43 * Otherwise, this will be null.
44 */
45 struct interface *ifp;
46
69171da2
DS
47 uint32_t refcnt;
48 uint32_t dplane_ref;
c8ee3cdb
DS
49
50 uint32_t flags;
3119f6a1
SW
51
52 /* Dependency list for other entries.
53 * For instance a group with two
54 * nexthops will have two dependencies
55 * pointing to those nhg_hash_entries.
56 */
57 struct list *nhg_depends;
c8ee3cdb
DS
58/*
59 * Is this nexthop group valid, ie all nexthops are fully resolved.
60 * What is fully resolved? It's a nexthop that is either self contained
61 * and correct( ie no recursive pointer ) or a nexthop that is recursively
62 * resolved and correct.
63 */
64#define NEXTHOP_GROUP_VALID 0x1
65/*
66 * Has this nexthop group been installed? At this point in time, this
67 * means that the data-plane has been told about this nexthop group
68 * and it's possible usage by a route entry.
69 */
70#define NEXTHOP_GROUP_INSTALLED 0x2
7f6077d0
SW
71/*
72 * Has the nexthop group been queued to be send to the FIB?
73 * The NEXTHOP_GROUP_VALID flag should also be set by this point.
74 */
75#define NEXTHOP_GROUP_QUEUED 0x4
69171da2
DS
76};
77
3119f6a1
SW
78/* Struct for dependency nexthop */
79struct nhg_depend {
80 struct nhg_hash_entry *nhe;
81};
82
83
69171da2
DS
84void zebra_nhg_init(void);
85void zebra_nhg_terminate(void);
86
3119f6a1
SW
87extern struct nhg_depend *nhg_depend_add(struct list *nhg_depends,
88 struct nhg_hash_entry *depend);
89extern struct nhg_depend *nhg_depend_new(void);
90extern void nhg_depend_free(struct nhg_depend *depends);
91
92extern struct list *nhg_depend_new_list(void);
d6e0094f 93extern struct list *nhg_depend_dup_list(struct list *from);
3119f6a1 94
d9f5b2f5
SW
95extern struct nhg_hash_entry *zebra_nhg_lookup_id(uint32_t id);
96extern int zebra_nhg_insert_id(struct nhg_hash_entry *nhe);
97
69171da2 98extern uint32_t zebra_nhg_hash_key(const void *arg);
a95b8020 99extern uint32_t zebra_nhg_id_key(const void *arg);
69171da2
DS
100
101extern bool zebra_nhg_hash_equal(const void *arg1, const void *arg2);
d9f5b2f5 102extern bool zebra_nhg_hash_id_equal(const void *arg1, const void *arg2);
69171da2 103
85f5e761
SW
104extern struct nhg_hash_entry *
105zebra_nhg_find(struct nexthop_group *nhg, vrf_id_t vrf_id, afi_t afi,
9ed6c34a 106 uint32_t id, struct list *nhg_depends, bool is_kernel_nh);
85f5e761 107
b599cd2a
SW
108void zebra_nhg_free_group_depends(struct nexthop_group *nhg,
109 struct list *nhg_depends);
110void zebra_nhg_free_members(struct nhg_hash_entry *nhe);
d9f5b2f5
SW
111void zebra_nhg_free(void *arg);
112void zebra_nhg_release(struct nhg_hash_entry *nhe);
113void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe);
8b5bdc8b
SW
114
115extern int nexthop_active_update(struct route_node *rn, struct route_entry *re);
5be96a2d
SW
116
117void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe);
147bad16
SW
118void zebra_nhg_uninstall_kernel(struct nhg_hash_entry *nhe);
119
120void zebra_nhg_cleanup_tables(void);
5f3c9e52
SW
121
122void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx);
ad28e79a 123#endif