mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-05 19:33:11 +00:00

* bgpd/(general) refcount struct peer and bgp_info, hence allowing us add work_queues for bgp_process. * bgpd/bgp_route.h: (struct bgp_info) Add 'lock' field for refcount. Add bgp_info_{lock,unlock} helper functions. Add bgp_info_{add,delete} helpers, to remove need for users managing locking/freeing of bgp_info and bgp_node's. * bgpd/bgp_table.h: (struct bgp_node) Add a flags field, and BGP_NODE_PROCESS_SCHEDULED to merge redundant processing of nodes. * bgpd/bgp_fsm.h: Make the ON/OFF/ADD/REMOVE macros lock and unlock peer reference as appropriate. * bgpd/bgp_damp.c: Remove its internal prototypes for bgp_info_delete/free. Just use bgp_info_delete. * bgpd/bgpd.h: (struct bgp_master) Add work_queue pointers. (struct peer) Add reference count 'lock' (peer_lock,peer_unlock) New helpers to take/release reference on struct peer. * bgpd/bgp_advertise.c: (general) Add peer and bgp_info refcounting and balance how references are taken and released. (bgp_advertise_free) release bgp_info reference, if appropriate (bgp_adj_out_free) unlock peer (bgp_advertise_clean) leave the adv references alone, or else call bgp_advertise_free cant unlock them. (bgp_adj_out_set) lock the peer on new adj's, leave the reference alone otherwise. lock the new bgp_info reference. (bgp_adj_in_set) lock the peer reference (bgp_adj_in_remove) and unlock it here (bgp_sync_delete) make hash_free on peer conditional, just in case. * bgpd/bgp_fsm.c: (general) document that the timers depend on bgp_event to release a peer reference. (bgp_fsm_change_status) moved up the file, unchanged. (bgp_stop) Decrement peer lock as many times as cancel_event canceled - shouldnt be needed but just in case. stream_fifo_clean of obuf made conditional, just in case. (bgp_event) always unlock the peer, regardless of return value of bgp_fsm_change_status. * bgpd/bgp_packet.c: (general) change several bgp_stop's to BGP_EVENT's. (bgp_read) Add a mysterious extra peer_unlock for ACCEPT_PEERs along with a comment on it. * bgpd/bgp_route.c: (general) Add refcounting of bgp_info, cleanup some of the resource management around bgp_info. Refcount peer. Add workqueues for bgp_process and clear_table. (bgp_info_new) make static (bgp_info_free) Ditto, and unlock the peer reference. (bgp_info_lock,bgp_info_unlock) new exported functions (bgp_info_add) Add a bgp_info to a bgp_node in correct fashion, taking care of reference counts. (bgp_info_delete) do the opposite of bgp_info_add. (bgp_process_rsclient) Converted into a work_queue work function. (bgp_process_main) ditto. (bgp_processq_del) process work queue item deconstructor (bgp_process_queue_init) process work queue init (bgp_process) call init function if required, set up queue item and add to queue, rather than calling process functions directly. (bgp_rib_remove) let bgp_info_delete manage bgp_info refcounts (bgp_rib_withdraw) ditto (bgp_update_rsclient) let bgp_info_add manage refcounts (bgp_update_main) ditto (bgp_clear_route_node) clear_node_queue work function, does per-node aspects of what bgp_clear_route_table did previously (bgp_clear_node_queue_del) clear_node_queue item delete function (bgp_clear_node_complete) clear_node_queue completion function, it unplugs the process queues, which have to be blocked while clear_node_queue is being processed to prevent a race. (bgp_clear_node_queue_init) init function for clear_node_queue work queues (bgp_clear_route_table) Sets up items onto a workqueue now, rather than clearing each node directly. Plugs both process queues to avoid potential race. (bgp_static_withdraw_rsclient) let bgp_info_{add,delete} manage bgp_info refcounts. (bgp_static_update_rsclient) ditto (bgp_static_update_main) ditto (bgp_static_update_vpnv4) ditto, remove unneeded cast. (bgp_static_withdraw) see bgp_static_withdraw_rsclient (bgp_static_withdraw_vpnv4) ditto (bgp_aggregate_{route,add,delete}) ditto (bgp_redistribute_{add,delete,withdraw}) ditto * bgpd/bgp_vty.c: (peer_rsclient_set_vty) lock rsclient list peer reference (peer_rsclient_unset_vty) ditto, but unlock same reference * bgpd/bgpd.c: (peer_free) handle frees of info to be kept for lifetime of struct peer. (peer_lock,peer_unlock) peer refcount helpers (peer_new) add initial refcounts (peer_create,peer_create_accept) lock peer as appropriate (peer_delete) unlock as appropriate, move out some free's to peer_free. (peer_group_bind,peer_group_unbind) peer refcounting as appropriate. (bgp_create) check CALLOC return value. (bgp_terminate) free workqueues too. * lib/memtypes.c: Add MTYPE_BGP_PROCESS_QUEUE and MTYPE_BGP_CLEAR_NODE_QUEUE
191 lines
6.3 KiB
C
191 lines
6.3 KiB
C
/* BGP routing information base
|
|
Copyright (C) 1996, 97, 98, 2000 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 GNU Zebra; see the file COPYING. If not, write to the Free
|
|
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
02111-1307, USA. */
|
|
|
|
#ifndef _QUAGGA_BGP_ROUTE_H
|
|
#define _QUAGGA_BGP_ROUTE_H
|
|
|
|
#include "bgp_table.h"
|
|
|
|
struct bgp_info
|
|
{
|
|
/* For linked list. */
|
|
struct bgp_info *next;
|
|
struct bgp_info *prev;
|
|
|
|
/* reference count */
|
|
unsigned int lock;
|
|
|
|
/* BGP route type. This can be static, RIP, OSPF, BGP etc. */
|
|
u_char type;
|
|
|
|
/* When above type is BGP. This sub type specify BGP sub type
|
|
information. */
|
|
u_char sub_type;
|
|
#define BGP_ROUTE_NORMAL 0
|
|
#define BGP_ROUTE_STATIC 1
|
|
#define BGP_ROUTE_AGGREGATE 2
|
|
#define BGP_ROUTE_REDISTRIBUTE 3
|
|
|
|
/* BGP information status. */
|
|
u_int16_t flags;
|
|
#define BGP_INFO_IGP_CHANGED (1 << 0)
|
|
#define BGP_INFO_DAMPED (1 << 1)
|
|
#define BGP_INFO_HISTORY (1 << 2)
|
|
#define BGP_INFO_SELECTED (1 << 3)
|
|
#define BGP_INFO_VALID (1 << 4)
|
|
#define BGP_INFO_ATTR_CHANGED (1 << 5)
|
|
#define BGP_INFO_DMED_CHECK (1 << 6)
|
|
#define BGP_INFO_DMED_SELECTED (1 << 7)
|
|
#define BGP_INFO_STALE (1 << 8)
|
|
|
|
/* Peer structure. */
|
|
struct peer *peer;
|
|
|
|
/* Attribute structure. */
|
|
struct attr *attr;
|
|
|
|
/* This route is suppressed with aggregation. */
|
|
int suppress;
|
|
|
|
/* Nexthop reachability check. */
|
|
u_int32_t igpmetric;
|
|
|
|
/* Uptime. */
|
|
time_t uptime;
|
|
|
|
/* Pointer to dampening structure. */
|
|
struct bgp_damp_info *damp_info;
|
|
|
|
/* MPLS label. */
|
|
u_char tag[3];
|
|
};
|
|
|
|
/* BGP static route configuration. */
|
|
struct bgp_static
|
|
{
|
|
/* Backdoor configuration. */
|
|
int backdoor;
|
|
|
|
/* Import check status. */
|
|
u_char valid;
|
|
|
|
/* IGP metric. */
|
|
u_int32_t igpmetric;
|
|
|
|
/* IGP nexthop. */
|
|
struct in_addr igpnexthop;
|
|
|
|
/* BGP redistribute route-map. */
|
|
struct
|
|
{
|
|
char *name;
|
|
struct route_map *map;
|
|
} rmap;
|
|
|
|
/* MPLS label. */
|
|
u_char tag[3];
|
|
};
|
|
|
|
#define DISTRIBUTE_IN_NAME(F) ((F)->dlist[FILTER_IN].name)
|
|
#define DISTRIBUTE_IN(F) ((F)->dlist[FILTER_IN].alist)
|
|
#define DISTRIBUTE_OUT_NAME(F) ((F)->dlist[FILTER_OUT].name)
|
|
#define DISTRIBUTE_OUT(F) ((F)->dlist[FILTER_OUT].alist)
|
|
|
|
#define PREFIX_LIST_IN_NAME(F) ((F)->plist[FILTER_IN].name)
|
|
#define PREFIX_LIST_IN(F) ((F)->plist[FILTER_IN].plist)
|
|
#define PREFIX_LIST_OUT_NAME(F) ((F)->plist[FILTER_OUT].name)
|
|
#define PREFIX_LIST_OUT(F) ((F)->plist[FILTER_OUT].plist)
|
|
|
|
#define FILTER_LIST_IN_NAME(F) ((F)->aslist[FILTER_IN].name)
|
|
#define FILTER_LIST_IN(F) ((F)->aslist[FILTER_IN].aslist)
|
|
#define FILTER_LIST_OUT_NAME(F) ((F)->aslist[FILTER_OUT].name)
|
|
#define FILTER_LIST_OUT(F) ((F)->aslist[FILTER_OUT].aslist)
|
|
|
|
#define ROUTE_MAP_IN_NAME(F) ((F)->map[RMAP_IN].name)
|
|
#define ROUTE_MAP_IN(F) ((F)->map[RMAP_IN].map)
|
|
#define ROUTE_MAP_OUT_NAME(F) ((F)->map[RMAP_OUT].name)
|
|
#define ROUTE_MAP_OUT(F) ((F)->map[RMAP_OUT].map)
|
|
|
|
#define ROUTE_MAP_IMPORT_NAME(F) ((F)->map[RMAP_IMPORT].name)
|
|
#define ROUTE_MAP_IMPORT(F) ((F)->map[RMAP_IMPORT].map)
|
|
#define ROUTE_MAP_EXPORT_NAME(F) ((F)->map[RMAP_EXPORT].name)
|
|
#define ROUTE_MAP_EXPORT(F) ((F)->map[RMAP_EXPORT].map)
|
|
|
|
#define UNSUPPRESS_MAP_NAME(F) ((F)->usmap.name)
|
|
#define UNSUPPRESS_MAP(F) ((F)->usmap.map)
|
|
|
|
/* Prototypes. */
|
|
void bgp_route_init ();
|
|
void bgp_cleanup_routes (void);
|
|
void bgp_announce_route (struct peer *, afi_t, safi_t);
|
|
void bgp_announce_route_all (struct peer *);
|
|
void bgp_default_originate (struct peer *, afi_t, safi_t, int);
|
|
void bgp_soft_reconfig_in (struct peer *, afi_t, safi_t);
|
|
void bgp_soft_reconfig_rsclient (struct peer *, afi_t, safi_t);
|
|
void bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi);
|
|
void bgp_clear_route (struct peer *, afi_t, safi_t);
|
|
void bgp_clear_route_all (struct peer *);
|
|
void bgp_clear_adj_in (struct peer *, afi_t, safi_t);
|
|
void bgp_clear_stale_route (struct peer *, afi_t, safi_t);
|
|
|
|
extern struct bgp_info *bgp_info_lock (struct bgp_info *);
|
|
extern struct bgp_info *bgp_info_unlock (struct bgp_info *);
|
|
extern void bgp_info_add (struct bgp_node *rn, struct bgp_info *ri);
|
|
extern void bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri);
|
|
|
|
int bgp_nlri_sanity_check (struct peer *, int, u_char *, bgp_size_t);
|
|
int bgp_nlri_parse (struct peer *, struct attr *, struct bgp_nlri *);
|
|
|
|
int bgp_maximum_prefix_overflow (struct peer *, afi_t, safi_t, int);
|
|
|
|
void bgp_redistribute_add (struct prefix *, struct in_addr *, u_int32_t, u_char);
|
|
void bgp_redistribute_delete (struct prefix *, u_char);
|
|
void bgp_redistribute_withdraw (struct bgp *, afi_t, int);
|
|
|
|
void bgp_static_delete (struct bgp *);
|
|
void bgp_static_update (struct bgp *, struct prefix *, struct bgp_static *,
|
|
afi_t, safi_t);
|
|
void bgp_static_withdraw (struct bgp *, struct prefix *, afi_t, safi_t);
|
|
|
|
int bgp_static_set_vpnv4 (struct vty *vty, const char *,
|
|
const char *, const char *);
|
|
|
|
int bgp_static_unset_vpnv4 (struct vty *, const char *,
|
|
const char *, const char *);
|
|
|
|
int bgp_config_write_network (struct vty *, struct bgp *, afi_t, safi_t, int *);
|
|
int bgp_config_write_distance (struct vty *, struct bgp *);
|
|
|
|
void bgp_aggregate_increment (struct bgp *, struct prefix *, struct bgp_info *,
|
|
afi_t, safi_t);
|
|
void bgp_aggregate_decrement (struct bgp *, struct prefix *, struct bgp_info *,
|
|
afi_t, safi_t);
|
|
|
|
u_char bgp_distance_apply (struct prefix *, struct bgp_info *, struct bgp *);
|
|
|
|
afi_t bgp_node_afi (struct vty *);
|
|
safi_t bgp_node_safi (struct vty *);
|
|
|
|
void route_vty_out (struct vty *, struct prefix *, struct bgp_info *, int, safi_t);
|
|
void route_vty_out_tag (struct vty *, struct prefix *, struct bgp_info *, int, safi_t);
|
|
void route_vty_out_tmp (struct vty *, struct prefix *, struct attr *, safi_t);
|
|
|
|
#endif /* _QUAGGA_BGP_ROUTE_H */
|