mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-02 18:56:53 +00:00

The rib_lookup_and_pushup function, from what I can tell, was used more when static route processing and connected routes were more closely integrated in zebra. The goal was when we were adding a new address to remove the connected route and then allow processing of the new address. With the re-org a few years ago to seperate out connected routes as well as static routes, I believe this is no longer needed. on BSD, without this code change we have this log: 2021/08/05 14:33:38 ZEBRA: [QEVVE-G3FQQ] rib_meta_queue_add: (0:0):10.40.30.0/24: queued rn 0x802022bb0 into sub-queue 4 2021/08/05 14:33:38 ZEBRA: [ZPR30-5G1FB] Kernel: Len: 200 Type: RTM_DELETE 2021/08/05 14:33:38 ZEBRA: [V3NSB-BPKBD] Kernel: GATEWAY DONE PROTO1 2021/08/05 14:33:38 ZEBRA: [HDTM1-ENZNM] Kernel: message seq 15 2021/08/05 14:33:38 ZEBRA: [MJD4M-0AAAR] Kernel: pid 53305, rtm_addrs {DST,GATEWAY,NETMASK} 2021/08/05 14:33:38 ZEBRA: [Y9Y5K-JJ7NT] rtm_read: got rtm of type 2 (RTM_DELETE) addrs {DST,GATEWAY,NETMASK} 2021/08/05 14:33:38 ZEBRA: [V17DT-1FJEN] kernel_rtm: 10.40.30.0/24: successfully did NH 9.8.6.7 2021/08/05 14:33:38 ZEBRA: [ZPR30-5G1FB] Kernel: Len: 164 Type: RTM_NEWADDR 2021/08/05 14:33:38 ZEBRA: [V3NSB-BPKBD] Kernel: 2021/08/05 14:33:38 ZEBRA: [HDTM1-ENZNM] Kernel: message seq 4664 2021/08/05 14:33:38 ZEBRA: [MJD4M-0AAAR] Kernel: pid 0, rtm_addrs {DST} 2021/08/05 14:33:38 ZEBRA: [M09CX-TKB4N] ifam_read_mesg: ifindex 1, ifname vtnet0, ifam_addrs {NETMASK,IFP,IFA,BRD}, ifam_flags 0x0, addr 10.40.30.1/24 broad 10.40.30.255 dst (unspec) gateway (unspec) 2021/08/05 14:33:38 ZEBRA: [MFYWV-KH3MC] rib_add_multipath_nhe: (0:0):10.40.30.0/24: Inserting route rn 0x802022bb0, re 0x8032973a0 (connected) existing 0x0, same_count 0 2021/08/05 14:33:38 ZEBRA: [Q4T2G-E2SQF] rib_add_multipath_nhe: dumping RE entry 0x8032973a0 for 10.40.30.0/24 vrf default(0) 2021/08/05 14:33:38 ZEBRA: [M5M58-9PD2R] 10.40.30.0/24: uptime == 1379355, type == 2, instance == 0, table == 0 2021/08/05 14:33:38 ZEBRA: [RVZMM-N7DME] 10.40.30.0/24: metric == 1, mtu == 0, distance == 0, flags == None status == None 2021/08/05 14:33:38 ZEBRA: [Q1NW5-NWY7P] 10.40.30.0/24: nexthop_num == 1, nexthop_active_num == 0 2021/08/05 14:33:38 ZEBRA: [TFHQ8-TC30H] 10.40.30.0/24: NH vtnet0[1] vrf default(0) with flags 2021/08/05 14:33:38 ZEBRA: [SCETK-GQ9E4] 10.40.30.0/24: dump complete 2021/08/05 14:33:38 ZEBRA: [QEVVE-G3FQQ] rib_meta_queue_add: (0:0):10.40.30.0/24: queued rn 0x802022bb0 into sub-queue 2 2021/08/05 14:33:38 ZEBRA: [MFYWV-KH3MC] rib_add_multipath_nhe: (0:?):10.40.30.0/24 (MRIB): Inserting route rn 0x802022f30, re 0x803297340 (connected) existing 0x0, same_count 0 2021/08/05 14:33:38 ZEBRA: [Q4T2G-E2SQF] rib_add_multipath_nhe: dumping RE entry 0x803297340 for 10.40.30.0/24 vrf default(0) 2021/08/05 14:33:38 ZEBRA: [M5M58-9PD2R] 10.40.30.0/24: uptime == 1379355, type == 2, instance == 0, table == 0 2021/08/05 14:33:38 ZEBRA: [RVZMM-N7DME] 10.40.30.0/24: metric == 1, mtu == 0, distance == 0, flags == None status == None 2021/08/05 14:33:38 ZEBRA: [Q1NW5-NWY7P] 10.40.30.0/24: nexthop_num == 1, nexthop_active_num == 0 2021/08/05 14:33:38 ZEBRA: [TFHQ8-TC30H] 10.40.30.0/24: NH vtnet0[1] vrf default(0) with flags 2021/08/05 14:33:38 ZEBRA: [SCETK-GQ9E4] 10.40.30.0/24: dump complete 2021/08/05 14:33:38 ZEBRA: [GCGMT-SQR82] rib_link: (0:?):10.40.30.0/24 (MRIB): rn 0x802022f30 adding dest 2021/08/05 14:33:38 ZEBRA: [QEVVE-G3FQQ] rib_meta_queue_add: (0:0):10.40.30.0/24 (MRIB): queued rn 0x802022f30 into sub-queue 2 2021/08/05 14:33:38 ZEBRA: [ZPR30-5G1FB] Kernel: Len: 240 Type: RTM_ADD 2021/08/05 14:33:38 ZEBRA: [V3NSB-BPKBD] Kernel: UP PINNED 2021/08/05 14:33:38 ZEBRA: [HDTM1-ENZNM] Kernel: message seq 0 2021/08/05 14:33:38 ZEBRA: [MJD4M-0AAAR] Kernel: pid 0, rtm_addrs {DST,GATEWAY,NETMASK} 2021/08/05 14:33:38 ZEBRA: [K0KVE-2GJA1] default(0:0):10.40.30.0/24: Processing rn 0x802022bb0 2021/08/05 14:33:38 ZEBRA: [RWCK7-TX4HT] default(0:0):10.40.30.0/24: Examine re 0x8032973a0 (connected) status: Changed flags: None dist 0 metric 1 2021/08/05 14:33:38 ZEBRA: [RWCK7-TX4HT] default(0:0):10.40.30.0/24: Examine re 0x8032970a0 (static) status: None flags: Recursion RR Distance dist 1 metric 0 2021/08/05 14:33:38 ZEBRA: [NYYJJ-0Q8QG] default(0:0):10.40.30.0/24: After processing: old_selected 0x0 new_selected 0x8032973a0 old_fib 0x0 new_fib 0x8032973a0 2021/08/05 14:33:38 ZEBRA: [RT9DY-ZS2KN] default(0:0):10.40.30.0/24: Adding route rn 0x802022bb0, re 0x8032973a0 (connected) 2021/08/05 14:33:38 ZEBRA: [PP3BZ-RABJN] default(0:0):10.40.30.0/24: rn 0x802022bb0 dequeued from sub-queue 2 2021/08/05 14:33:38 ZEBRA: [K0KVE-2GJA1] default(0:0):10.40.30.0/24: Processing rn 0x802022f30 2021/08/05 14:33:38 ZEBRA: [RWCK7-TX4HT] default(0:0):10.40.30.0/24: Examine re 0x803297340 (connected) status: Changed flags: None dist 0 metric 1 2021/08/05 14:33:38 ZEBRA: [NYYJJ-0Q8QG] default(0:0):10.40.30.0/24: After processing: old_selected 0x0 new_selected 0x803297340 old_fib 0x0 new_fib 0x803297340 2021/08/05 14:33:38 ZEBRA: [RT9DY-ZS2KN] default(0:0):10.40.30.0/24: Adding route rn 0x802022f30, re 0x803297340 (connected) 2021/08/05 14:33:38 ZEBRA: [PP3BZ-RABJN] default(0:0):10.40.30.0/24: rn 0x802022f30 dequeued from sub-queue 2 2021/08/05 14:33:38 ZEBRA: [K0KVE-2GJA1] default(0:0):10.40.30.0/24: Processing rn 0x802022bb0 2021/08/05 14:33:38 ZEBRA: [RWCK7-TX4HT] default(0:0):10.40.30.0/24: Examine re 0x8032973a0 (connected) status: Queued flags: Selected dist 0 metric 1 2021/08/05 14:33:38 ZEBRA: [RWCK7-TX4HT] default(0:0):10.40.30.0/24: Examine re 0x8032970a0 (static) status: None flags: Recursion RR Distance dist 1 metric 0 2021/08/05 14:33:38 ZEBRA: [NYYJJ-0Q8QG] default(0:0):10.40.30.0/24: After processing: old_selected 0x8032973a0 new_selected 0x8032973a0 old_fib 0x8032973a0 new_fib 0x8032973a0 2021/08/05 14:33:38 ZEBRA: [PP3BZ-RABJN] default(0:0):10.40.30.0/24: rn 0x802022bb0 dequeued from sub-queue 4 2021/08/05 14:33:38 ZEBRA: [GHWHS-ZKQM5] update_from_ctx: default(0:0):10.40.30.0/24: SELECTED, re 0x8032973a0 2021/08/05 14:33:38 ZEBRA: [TS3SH-1276M] default(0:0):10.40.30.0/24 update_from_ctx(): no fib nhg 2021/08/05 14:33:38 ZEBRA: [HKQXC-4STSK] default(0:0):10.40.30.0/24 update_from_ctx(): rib nhg matched, changed 'false' 2021/08/05 14:33:38 ZEBRA: [HBZNK-5H1X0] (0:0):10.40.30.0/24: Redist update re 0x8032973a0 (connected), old 0x0 (None) 2021/08/05 14:33:38 ZEBRA: [GHWHS-ZKQM5] update_from_ctx: default(0:0):10.40.30.0/24: SELECTED, re 0x8032973a0 2021/08/05 14:33:38 ZEBRA: [TS3SH-1276M] default(0:0):10.40.30.0/24 update_from_ctx(): no fib nhg 2021/08/05 14:33:38 ZEBRA: [HKQXC-4STSK] default(0:0):10.40.30.0/24 update_from_ctx(): rib nhg matched, changed 'false' 2021/08/05 14:33:38 ZEBRA: [HBZNK-5H1X0] (0:0):10.40.30.0/24: Redist update re 0x8032973a0 (connected), old 0x0 (None) With this code change: 2021/08/05 14:41:24 ZEBRA: [MFYWV-KH3MC] rib_add_multipath_nhe: (0:?):10.10.40.0/24: Inserting route rn 0x802022f30, re 0x8021cbe60 (static) existing 0x0, same_count 0 2021/08/05 14:41:24 ZEBRA: [RT9DY-ZS2KN] default(0:0):10.10.40.0/24: Adding route rn 0x802022f30, re 0x8021cbe60 (static) 2021/08/05 14:41:24 ZEBRA: [V17DT-1FJEN] kernel_rtm: 10.10.40.0/24: successfully did NH 9.8.6.7 2021/08/05 14:41:24 ZEBRA: [ZPR30-5G1FB] Kernel: Len: 200 Type: RTM_ADD 2021/08/05 14:41:24 ZEBRA: [V3NSB-BPKBD] Kernel: UP GATEWAY DONE PROTO1 2021/08/05 14:41:24 ZEBRA: [HDTM1-ENZNM] Kernel: message seq 0 2021/08/05 14:41:24 ZEBRA: [MJD4M-0AAAR] Kernel: pid 60818, rtm_addrs {DST,GATEWAY,NETMASK} 2021/08/05 14:41:24 ZEBRA: [Y9Y5K-JJ7NT] rtm_read: got rtm of type 1 (RTM_ADD) addrs {DST,GATEWAY,NETMASK} 2021/08/05 14:41:24 ZEBRA: [TS3SH-1276M] default(0:0):10.10.40.0/24 update_from_ctx(): no fib nhg 2021/08/05 14:41:24 ZEBRA: [HKQXC-4STSK] default(0:0):10.10.40.0/24 update_from_ctx(): rib nhg matched, changed 'true' 2021/08/05 14:41:24 ZEBRA: [HBZNK-5H1X0] (0:0):10.10.40.0/24: Redist update re 0x8021cbe60 (static), old 0x0 (None) 2021/08/05 14:42:06 ZEBRA: [ZJ4AV-JEMJ3] dplane_intf_addr_set 2021/08/05 14:42:06 ZEBRA: [ZPR30-5G1FB] Kernel: Len: 164 Type: RTM_NEWADDR 2021/08/05 14:42:06 ZEBRA: [V3NSB-BPKBD] Kernel: 2021/08/05 14:42:06 ZEBRA: [HDTM1-ENZNM] Kernel: message seq 4664 2021/08/05 14:42:06 ZEBRA: [MJD4M-0AAAR] Kernel: pid 0, rtm_addrs {DST} 2021/08/05 14:42:06 ZEBRA: [M09CX-TKB4N] ifam_read_mesg: ifindex 1, ifname vtnet0, ifam_addrs {NETMASK,IFP,IFA,BRD}, ifam_flags 0x0, addr 10.10.40.3/24 broad 10.10.40.255 dst (unspec) gateway (unspec) 2021/08/05 14:42:06 ZEBRA: [MFYWV-KH3MC] rib_add_multipath_nhe: (0:0):10.10.40.0/24: Inserting route rn 0x802022f30, re 0x80308c4c0 (connected) existing 0x0, same_count 0 2021/08/05 14:42:06 ZEBRA: [MFYWV-KH3MC] rib_add_multipath_nhe: (0:?):10.10.40.0/24 (MRIB): Inserting route rn 0x802023160, re 0x80308c460 (connected) existing 0x0, same_count 0 2021/08/05 14:42:06 ZEBRA: [ZPR30-5G1FB] Kernel: Len: 240 Type: RTM_ADD 2021/08/05 14:42:06 ZEBRA: [V3NSB-BPKBD] Kernel: UP PINNED 2021/08/05 14:42:06 ZEBRA: [HDTM1-ENZNM] Kernel: message seq 0 2021/08/05 14:42:06 ZEBRA: [MJD4M-0AAAR] Kernel: pid 0, rtm_addrs {DST,GATEWAY,NETMASK} 2021/08/05 14:42:06 ZEBRA: [RG9Y6-E93A0] default(0:0):10.10.40.0/24: Updating route rn 0x802022f30, re 0x80308c4c0 (connected) old 0x8021cbe60 (static) 2021/08/05 14:42:06 ZEBRA: [RT9DY-ZS2KN] default(0:0):10.10.40.0/24: Adding route rn 0x802023160, re 0x80308c460 (connected) 2021/08/05 14:42:06 ZEBRA: [THSYN-E2XFY][EC 100663299] rtm_write: write : Address already in use (48) 2021/08/05 14:42:06 ZEBRA: [RV5F2-MQGZG][EC 100663303] kernel_rtm: 10.10.40.0/24: rtm_write() unexpectedly returned -5 for command RTM_DELETE 2021/08/05 14:42:06 ZEBRA: [ZPR30-5G1FB] Kernel: Len: 200 Type: RTM_DELETE 2021/08/05 14:42:06 ZEBRA: [V3NSB-BPKBD] Kernel: UP PROTO1 2021/08/05 14:42:06 ZEBRA: [HDTM1-ENZNM] Kernel: message seq 1 2021/08/05 14:42:06 ZEBRA: [MJD4M-0AAAR] Kernel: pid 60818, rtm_addrs {DST,GATEWAY,NETMASK} 2021/08/05 14:42:06 ZEBRA: [XASXT-GF69Y] kernel_rtm: No useful nexthops were found in RIB prefix 10.10.40.0/24 2021/08/05 14:42:06 ZEBRA: [TS3SH-1276M] default(0:0):10.10.40.0/24 update_from_ctx(): no fib nhg 2021/08/05 14:42:06 ZEBRA: [HKQXC-4STSK] default(0:0):10.10.40.0/24 update_from_ctx(): rib nhg matched, changed 'false' 2021/08/05 14:42:06 ZEBRA: [HBZNK-5H1X0] (0:0):10.10.40.0/24: Redist update re 0x80308c4c0 (connected), old 0x8021cbe60 (static) netstat -rn: 10.10.40.0/24 link#1 U vtnet0 10.10.40.3 link#1 UHS lo0 show ip route: C>* 10.10.40.0/24 [0/1] is directly connected, vtnet0, 00:18:48 S 10.10.40.0/24 [1/0] via 9.8.6.7, vtnet0, weight 1, 00:19:30 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
635 lines
17 KiB
C
635 lines
17 KiB
C
/*
|
|
* Routing Information Base header
|
|
* Copyright (C) 1997 Kunihiro Ishiguro
|
|
*
|
|
* This file is part of GNU Zebra.
|
|
*
|
|
* GNU Zebra is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
* later version.
|
|
*
|
|
* GNU Zebra is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _ZEBRA_RIB_H
|
|
#define _ZEBRA_RIB_H
|
|
|
|
#include "zebra.h"
|
|
#include "memory.h"
|
|
#include "hook.h"
|
|
#include "typesafe.h"
|
|
#include "linklist.h"
|
|
#include "prefix.h"
|
|
#include "table.h"
|
|
#include "queue.h"
|
|
#include "nexthop.h"
|
|
#include "nexthop_group.h"
|
|
#include "vrf.h"
|
|
#include "if.h"
|
|
#include "mpls.h"
|
|
#include "srcdest_table.h"
|
|
#include "zebra/zebra_nhg.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
DECLARE_MGROUP(ZEBRA);
|
|
|
|
DECLARE_MTYPE(RE);
|
|
|
|
enum rnh_type { RNH_NEXTHOP_TYPE, RNH_IMPORT_CHECK_TYPE };
|
|
|
|
PREDECL_LIST(rnh_list);
|
|
|
|
/* Nexthop structure. */
|
|
struct rnh {
|
|
uint8_t flags;
|
|
|
|
#define ZEBRA_NHT_CONNECTED 0x1
|
|
#define ZEBRA_NHT_DELETED 0x2
|
|
#define ZEBRA_NHT_EXACT_MATCH 0x4
|
|
|
|
/* VRF identifier. */
|
|
vrf_id_t vrf_id;
|
|
|
|
afi_t afi;
|
|
|
|
enum rnh_type type;
|
|
|
|
uint32_t seqno;
|
|
|
|
struct route_entry *state;
|
|
struct prefix resolved_route;
|
|
struct list *client_list;
|
|
|
|
/* pseudowires dependent on this nh */
|
|
struct list *zebra_pseudowire_list;
|
|
|
|
struct route_node *node;
|
|
|
|
/*
|
|
* if this has been filtered for the client
|
|
*/
|
|
int filtered[ZEBRA_ROUTE_MAX];
|
|
|
|
struct rnh_list_item rnh_list_item;
|
|
};
|
|
|
|
#define DISTANCE_INFINITY 255
|
|
#define ZEBRA_KERNEL_TABLE_MAX 252 /* support for no more than this rt tables */
|
|
|
|
PREDECL_LIST(re_list);
|
|
|
|
struct opaque {
|
|
uint16_t length;
|
|
uint8_t data[];
|
|
};
|
|
|
|
struct route_entry {
|
|
/* Link list. */
|
|
struct re_list_item next;
|
|
|
|
/* Nexthop group, shared/refcounted, based on the nexthop(s)
|
|
* provided by the owner of the route
|
|
*/
|
|
struct nhg_hash_entry *nhe;
|
|
|
|
/* Nexthop group from FIB (optional), reflecting what is actually
|
|
* installed in the FIB if that differs. The 'backup' group is used
|
|
* when backup nexthops are present in the route's nhg.
|
|
*/
|
|
struct nexthop_group fib_ng;
|
|
struct nexthop_group fib_backup_ng;
|
|
|
|
/* Nexthop group hash entry ID */
|
|
uint32_t nhe_id;
|
|
|
|
/* Tag */
|
|
route_tag_t tag;
|
|
|
|
/* Uptime. */
|
|
time_t uptime;
|
|
|
|
/* Type of this route. */
|
|
int type;
|
|
|
|
/* VRF identifier. */
|
|
vrf_id_t vrf_id;
|
|
|
|
/* Which routing table */
|
|
uint32_t table;
|
|
|
|
/* Metric */
|
|
uint32_t metric;
|
|
|
|
/* MTU */
|
|
uint32_t mtu;
|
|
uint32_t nexthop_mtu;
|
|
|
|
/* Flags of this route.
|
|
* This flag's definition is in lib/zebra.h ZEBRA_FLAG_* and is exposed
|
|
* to clients via Zserv
|
|
*/
|
|
uint32_t flags;
|
|
|
|
/* RIB internal status */
|
|
uint32_t status;
|
|
#define ROUTE_ENTRY_REMOVED 0x1
|
|
/* The Route Entry has changed */
|
|
#define ROUTE_ENTRY_CHANGED 0x2
|
|
/* The Label has changed on the Route entry */
|
|
#define ROUTE_ENTRY_LABELS_CHANGED 0x4
|
|
/* Route is queued for Installation into the Data Plane */
|
|
#define ROUTE_ENTRY_QUEUED 0x8
|
|
/* Route is installed into the Data Plane */
|
|
#define ROUTE_ENTRY_INSTALLED 0x10
|
|
/* Route has Failed installation into the Data Plane in some manner */
|
|
#define ROUTE_ENTRY_FAILED 0x20
|
|
/* Route has a 'fib' set of nexthops, probably because the installed set
|
|
* differs from the rib/normal set of nexthops.
|
|
*/
|
|
#define ROUTE_ENTRY_USE_FIB_NHG 0x40
|
|
|
|
/* Sequence value incremented for each dataplane operation */
|
|
uint32_t dplane_sequence;
|
|
|
|
/* Source protocol instance */
|
|
uint16_t instance;
|
|
|
|
/* Distance. */
|
|
uint8_t distance;
|
|
|
|
struct opaque *opaque;
|
|
};
|
|
|
|
#define RIB_SYSTEM_ROUTE(R) RSYSTEM_ROUTE((R)->type)
|
|
|
|
#define RIB_KERNEL_ROUTE(R) RKERNEL_ROUTE((R)->type)
|
|
|
|
/* meta-queue structure:
|
|
* sub-queue 0: nexthop group objects
|
|
* sub-queue 1: EVPN/VxLAN objects
|
|
* sub-queue 2: connected
|
|
* sub-queue 3: kernel
|
|
* sub-queue 4: static
|
|
* sub-queue 5: RIP, RIPng, OSPF, OSPF6, IS-IS, EIGRP, NHRP
|
|
* sub-queue 6: iBGP, eBGP
|
|
* sub-queue 7: any other origin (if any) typically those that
|
|
* don't generate routes
|
|
*/
|
|
#define MQ_SIZE 8
|
|
struct meta_queue {
|
|
struct list *subq[MQ_SIZE];
|
|
uint32_t size; /* sum of lengths of all subqueues */
|
|
};
|
|
|
|
/*
|
|
* Structure that represents a single destination (prefix).
|
|
*/
|
|
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;
|
|
|
|
/*
|
|
* Doubly-linked list of routes for this prefix.
|
|
*/
|
|
struct re_list_head routes;
|
|
|
|
struct route_entry *selected_fib;
|
|
|
|
/*
|
|
* Flags, see below.
|
|
*/
|
|
uint32_t flags;
|
|
|
|
/*
|
|
* The list of nht prefixes that have ended up
|
|
* depending on this route node.
|
|
* After route processing is returned from
|
|
* the data plane we will run evaluate_rnh
|
|
* on these prefixes.
|
|
*/
|
|
struct rnh_list_head nht;
|
|
|
|
/*
|
|
* Linkage to put dest on the FPM processing queue.
|
|
*/
|
|
TAILQ_ENTRY(rib_dest_t_) fpm_q_entries;
|
|
|
|
} rib_dest_t;
|
|
|
|
DECLARE_LIST(rnh_list, struct rnh, rnh_list_item);
|
|
DECLARE_LIST(re_list, struct route_entry, next);
|
|
|
|
#define RIB_ROUTE_QUEUED(x) (1 << (x))
|
|
// If MQ_SIZE is modified this value needs to be updated.
|
|
#define RIB_ROUTE_ANY_QUEUED 0x3F
|
|
|
|
/*
|
|
* The maximum qindex that can be used.
|
|
*/
|
|
#define ZEBRA_MAX_QINDEX (MQ_SIZE - 1)
|
|
|
|
/*
|
|
* This flag indicates that a given prefix has been 'advertised' to
|
|
* the FPM to be installed in the forwarding plane.
|
|
*/
|
|
#define RIB_DEST_SENT_TO_FPM (1 << (ZEBRA_MAX_QINDEX + 1))
|
|
|
|
/*
|
|
* This flag is set when we need to send an update to the FPM about a
|
|
* dest.
|
|
*/
|
|
#define RIB_DEST_UPDATE_FPM (1 << (ZEBRA_MAX_QINDEX + 2))
|
|
|
|
#define RIB_DEST_UPDATE_LSPS (1 << (ZEBRA_MAX_QINDEX + 3))
|
|
|
|
/*
|
|
* Macro to iterate over each route for a destination (prefix).
|
|
*/
|
|
#define RE_DEST_FOREACH_ROUTE(dest, re) \
|
|
for ((re) = (dest) ? re_list_first(&((dest)->routes)) : NULL; (re); \
|
|
(re) = re_list_next(&((dest)->routes), (re)))
|
|
|
|
/*
|
|
* Same as above, but allows the current node to be unlinked.
|
|
*/
|
|
#define RE_DEST_FOREACH_ROUTE_SAFE(dest, re, next) \
|
|
for ((re) = (dest) ? re_list_first(&((dest)->routes)) : NULL; \
|
|
(re) && ((next) = re_list_next(&((dest)->routes), (re)), 1); \
|
|
(re) = (next))
|
|
|
|
#define RE_DEST_FIRST_ROUTE(dest, re) \
|
|
((re) = (dest) ? re_list_first(&((dest)->routes)) : NULL)
|
|
|
|
#define RE_DEST_NEXT_ROUTE(dest, re) \
|
|
((re) = (dest) ? re_list_next(&((dest)->routes), (re)) : NULL)
|
|
|
|
#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_FIRST_RE(rn, re) RE_DEST_FIRST_ROUTE(rib_dest_from_rnode(rn), re)
|
|
|
|
#define RNODE_NEXT_RE(rn, re) RE_DEST_NEXT_ROUTE(rib_dest_from_rnode(rn), re)
|
|
|
|
#if defined(HAVE_RTADV)
|
|
PREDECL_SORTLIST_UNIQ(adv_if_list);
|
|
/* Structure which hold status of router advertisement. */
|
|
struct rtadv {
|
|
int sock;
|
|
|
|
struct adv_if_list_head adv_if;
|
|
struct adv_if_list_head adv_msec_if;
|
|
|
|
struct thread *ra_read;
|
|
struct thread *ra_timer;
|
|
};
|
|
|
|
/* adv list node */
|
|
struct adv_if {
|
|
char name[INTERFACE_NAMSIZ];
|
|
struct adv_if_list_item list_item;
|
|
};
|
|
|
|
static int adv_if_cmp(const struct adv_if *a, const struct adv_if *b)
|
|
{
|
|
return if_cmp_name_func(a->name, b->name);
|
|
}
|
|
|
|
DECLARE_SORTLIST_UNIQ(adv_if_list, struct adv_if, list_item, adv_if_cmp);
|
|
#endif /* HAVE_RTADV */
|
|
|
|
/*
|
|
* rib_table_info_t
|
|
*
|
|
* Structure that is hung off of a route_table that holds information about
|
|
* the table.
|
|
*/
|
|
struct rib_table_info {
|
|
|
|
/*
|
|
* Back pointer to zebra_vrf.
|
|
*/
|
|
struct zebra_vrf *zvrf;
|
|
afi_t afi;
|
|
safi_t safi;
|
|
uint32_t table_id;
|
|
};
|
|
|
|
enum rib_tables_iter_state {
|
|
RIB_TABLES_ITER_S_INIT,
|
|
RIB_TABLES_ITER_S_ITERATING,
|
|
RIB_TABLES_ITER_S_DONE
|
|
};
|
|
|
|
/*
|
|
* 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;
|
|
|
|
enum rib_tables_iter_state state;
|
|
} rib_tables_iter_t;
|
|
|
|
/* Events/reasons triggering a RIB update. */
|
|
enum rib_update_event {
|
|
RIB_UPDATE_KERNEL,
|
|
RIB_UPDATE_RMAP_CHANGE,
|
|
RIB_UPDATE_OTHER,
|
|
RIB_UPDATE_MAX
|
|
};
|
|
|
|
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_nhghe);
|
|
|
|
/* NHG replace has happend, we have to update route_entry pointers to new one */
|
|
void rib_handle_nhg_replace(struct nhg_hash_entry *old_entry,
|
|
struct nhg_hash_entry *new_entry);
|
|
|
|
#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,
|
|
union prefixconstptr src_pp,
|
|
const struct route_entry *re);
|
|
|
|
extern void rib_lookup_and_dump(struct prefix_ipv4 *p, vrf_id_t vrf_id);
|
|
|
|
#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(uint32_t table_id);
|
|
extern int is_zebra_main_routing_table(uint32_t table_id);
|
|
extern int zebra_check_addr(const struct prefix *p);
|
|
|
|
extern void rib_delnode(struct route_node *rn, struct route_entry *re);
|
|
extern void rib_install_kernel(struct route_node *rn, struct route_entry *re,
|
|
struct route_entry *old);
|
|
extern void 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,
|
|
unsigned short instance, uint32_t flags, struct prefix *p,
|
|
struct prefix_ipv6 *src_p, const struct nexthop *nh,
|
|
uint32_t nhe_id, uint32_t table_id, uint32_t metric,
|
|
uint32_t mtu, uint8_t distance, route_tag_t tag);
|
|
/*
|
|
* Multipath route apis.
|
|
*/
|
|
extern int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
|
|
struct prefix_ipv6 *src_p, struct route_entry *re,
|
|
struct nexthop_group *ng);
|
|
extern int rib_add_multipath_nhe(afi_t afi, safi_t safi, struct prefix *p,
|
|
struct prefix_ipv6 *src_p,
|
|
struct route_entry *re,
|
|
struct nhg_hash_entry *nhe);
|
|
|
|
extern void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
|
|
unsigned short instance, uint32_t flags,
|
|
struct prefix *p, struct prefix_ipv6 *src_p,
|
|
const struct nexthop *nh, uint32_t nhe_id,
|
|
uint32_t table_id, uint32_t metric, uint8_t distance,
|
|
bool fromkernel);
|
|
|
|
extern struct route_entry *rib_match(afi_t afi, safi_t safi, vrf_id_t vrf_id,
|
|
const union g_addr *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 *p,
|
|
vrf_id_t vrf_id);
|
|
|
|
extern void rib_update(enum rib_update_event event);
|
|
extern void rib_update_table(struct route_table *table,
|
|
enum rib_update_event event, int rtype);
|
|
extern int rib_sweep_route(struct thread *t);
|
|
extern void rib_sweep_table(struct route_table *table);
|
|
extern void rib_close_table(struct route_table *table);
|
|
extern void rib_init(void);
|
|
extern unsigned long rib_score_proto(uint8_t proto, unsigned short instance);
|
|
extern unsigned long rib_score_proto_table(uint8_t proto,
|
|
unsigned short instance,
|
|
struct route_table *table);
|
|
|
|
extern int rib_queue_add(struct route_node *rn);
|
|
|
|
struct nhg_ctx; /* Forward declaration */
|
|
|
|
/* Enqueue incoming nhg from OS for processing */
|
|
extern int rib_queue_nhg_ctx_add(struct nhg_ctx *ctx);
|
|
|
|
/* Enqueue incoming nhg from proto daemon for processing */
|
|
extern int rib_queue_nhe_add(struct nhg_hash_entry *nhe);
|
|
|
|
/* Enqueue evpn route for processing */
|
|
int zebra_rib_queue_evpn_route_add(vrf_id_t vrf_id, const struct ethaddr *rmac,
|
|
const struct ipaddr *vtep_ip,
|
|
const struct prefix *host_prefix);
|
|
int zebra_rib_queue_evpn_route_del(vrf_id_t vrf_id,
|
|
const struct ipaddr *vtep_ip,
|
|
const struct prefix *host_prefix);
|
|
/* Enqueue EVPN remote ES for processing */
|
|
int zebra_rib_queue_evpn_rem_es_add(const esi_t *esi,
|
|
const struct in_addr *vtep_ip,
|
|
bool esr_rxed, uint8_t df_alg,
|
|
uint16_t df_pref);
|
|
int zebra_rib_queue_evpn_rem_es_del(const esi_t *esi,
|
|
const struct in_addr *vtep_ip);
|
|
/* Enqueue EVPN remote macip update for processing */
|
|
int zebra_rib_queue_evpn_rem_macip_del(vni_t vni, const struct ethaddr *macaddr,
|
|
const struct ipaddr *ip,
|
|
struct in_addr vtep_ip);
|
|
int zebra_rib_queue_evpn_rem_macip_add(vni_t vni, const struct ethaddr *macaddr,
|
|
const struct ipaddr *ipaddr,
|
|
uint8_t flags, uint32_t seq,
|
|
struct in_addr vtep_ip,
|
|
const esi_t *esi);
|
|
/* Enqueue VXLAN remote vtep update for processing */
|
|
int zebra_rib_queue_evpn_rem_vtep_add(vrf_id_t vrf_id, vni_t vni,
|
|
struct in_addr vtep_ip,
|
|
int flood_control);
|
|
int zebra_rib_queue_evpn_rem_vtep_del(vrf_id_t vrf_id, vni_t vni,
|
|
struct in_addr vtep_ip);
|
|
|
|
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 *rn, struct route_entry *re);
|
|
extern int rib_gc_dest(struct route_node *rn);
|
|
extern struct route_table *rib_tables_iter_next(rib_tables_iter_t *iter);
|
|
|
|
extern uint8_t route_distance(int type);
|
|
|
|
extern void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq);
|
|
|
|
/*
|
|
* Inline functions.
|
|
*/
|
|
|
|
/*
|
|
* rib_table_info
|
|
*/
|
|
static inline struct rib_table_info *rib_table_info(struct route_table *table)
|
|
{
|
|
return (struct rib_table_info *)route_table_get_info(table);
|
|
}
|
|
|
|
/*
|
|
* rib_dest_from_rnode
|
|
*/
|
|
static inline rib_dest_t *rib_dest_from_rnode(struct route_node *rn)
|
|
{
|
|
return (rib_dest_t *)rn->info;
|
|
}
|
|
|
|
/*
|
|
* rnode_to_ribs
|
|
*
|
|
* 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)
|
|
{
|
|
rib_dest_t *dest;
|
|
|
|
dest = rib_dest_from_rnode(rn);
|
|
if (!dest)
|
|
return NULL;
|
|
|
|
return re_list_first(&dest->routes);
|
|
}
|
|
|
|
/*
|
|
* rib_dest_prefix
|
|
*/
|
|
static inline struct prefix *rib_dest_prefix(rib_dest_t *dest)
|
|
{
|
|
return &dest->rnode->p;
|
|
}
|
|
|
|
/*
|
|
* rib_dest_af
|
|
*
|
|
* Returns the address family that the destination is for.
|
|
*/
|
|
static inline uint8_t rib_dest_af(rib_dest_t *dest)
|
|
{
|
|
return dest->rnode->p.family;
|
|
}
|
|
|
|
/*
|
|
* rib_dest_table
|
|
*/
|
|
static inline struct route_table *rib_dest_table(rib_dest_t *dest)
|
|
{
|
|
return srcdest_rnode_table(dest->rnode);
|
|
}
|
|
|
|
/*
|
|
* rib_dest_vrf
|
|
*/
|
|
static inline struct zebra_vrf *rib_dest_vrf(rib_dest_t *dest)
|
|
{
|
|
return rib_table_info(rib_dest_table(dest))->zvrf;
|
|
}
|
|
|
|
/*
|
|
* Create the rib_dest_t and attach it to the specified node
|
|
*/
|
|
extern rib_dest_t *zebra_rib_create_dest(struct route_node *rn);
|
|
|
|
/*
|
|
* rib_tables_iter_init
|
|
*/
|
|
static inline void rib_tables_iter_init(rib_tables_iter_t *iter)
|
|
|
|
{
|
|
memset(iter, 0, sizeof(*iter));
|
|
iter->state = RIB_TABLES_ITER_S_INIT;
|
|
}
|
|
|
|
/*
|
|
* rib_tables_iter_started
|
|
*
|
|
* 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)
|
|
{
|
|
return iter->state != RIB_TABLES_ITER_S_INIT;
|
|
}
|
|
|
|
/*
|
|
* rib_tables_iter_cleanup
|
|
*/
|
|
static inline void rib_tables_iter_cleanup(rib_tables_iter_t *iter)
|
|
{
|
|
iter->state = RIB_TABLES_ITER_S_DONE;
|
|
}
|
|
|
|
DECLARE_HOOK(rib_update, (struct route_node * rn, const char *reason),
|
|
(rn, reason));
|
|
|
|
/*
|
|
* Access installed/fib nexthops, which may be a subset of the
|
|
* rib nexthops.
|
|
*/
|
|
static inline struct nexthop_group *rib_get_fib_nhg(struct route_entry *re)
|
|
{
|
|
/* If the fib set is a subset of the active rib set,
|
|
* use the dedicated fib list.
|
|
*/
|
|
if (CHECK_FLAG(re->status, ROUTE_ENTRY_USE_FIB_NHG))
|
|
return &(re->fib_ng);
|
|
else
|
|
return &(re->nhe->nhg);
|
|
}
|
|
|
|
/*
|
|
* Access backup nexthop-group that represents the installed backup nexthops;
|
|
* any installed backup will be on the fib list.
|
|
*/
|
|
static inline struct nexthop_group *rib_get_fib_backup_nhg(
|
|
struct route_entry *re)
|
|
{
|
|
return &(re->fib_backup_ng);
|
|
}
|
|
|
|
extern void zebra_vty_init(void);
|
|
|
|
extern pid_t pid;
|
|
|
|
extern bool v6_rr_semantics;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /*_ZEBRA_RIB_H */
|