version 1.1.1.1, 2012/02/21 17:26:11
|
version 1.1.1.4, 2016/11/02 10:09:10
|
Line 59 struct bgp_master
|
Line 59 struct bgp_master
|
#define BGP_OPT_NO_FIB (1 << 0) |
#define BGP_OPT_NO_FIB (1 << 0) |
#define BGP_OPT_MULTIPLE_INSTANCE (1 << 1) |
#define BGP_OPT_MULTIPLE_INSTANCE (1 << 1) |
#define BGP_OPT_CONFIG_CISCO (1 << 2) |
#define BGP_OPT_CONFIG_CISCO (1 << 2) |
|
#define BGP_OPT_NO_LISTEN (1 << 3) |
}; |
}; |
|
|
/* BGP instance structure. */ |
/* BGP instance structure. */ |
Line 103 struct bgp
|
Line 104 struct bgp
|
as_t *confed_peers; |
as_t *confed_peers; |
int confed_peers_cnt; |
int confed_peers_cnt; |
|
|
|
struct thread *t_startup; |
|
|
/* BGP flags. */ |
/* BGP flags. */ |
u_int16_t flags; |
u_int16_t flags; |
#define BGP_FLAG_ALWAYS_COMPARE_MED (1 << 0) |
#define BGP_FLAG_ALWAYS_COMPARE_MED (1 << 0) |
Line 119 struct bgp
|
Line 122 struct bgp
|
#define BGP_FLAG_LOG_NEIGHBOR_CHANGES (1 << 11) |
#define BGP_FLAG_LOG_NEIGHBOR_CHANGES (1 << 11) |
#define BGP_FLAG_GRACEFUL_RESTART (1 << 12) |
#define BGP_FLAG_GRACEFUL_RESTART (1 << 12) |
#define BGP_FLAG_ASPATH_CONFED (1 << 13) |
#define BGP_FLAG_ASPATH_CONFED (1 << 13) |
|
#define BGP_FLAG_ASPATH_MULTIPATH_RELAX (1 << 14) |
|
#define BGP_FLAG_DELETING (1 << 15) |
|
|
/* BGP Per AF flags */ |
/* BGP Per AF flags */ |
u_int16_t af_flags[AFI_MAX][SAFI_MAX]; |
u_int16_t af_flags[AFI_MAX][SAFI_MAX]; |
Line 162 struct bgp
|
Line 167 struct bgp
|
/* BGP graceful restart */ |
/* BGP graceful restart */ |
u_int32_t restart_time; |
u_int32_t restart_time; |
u_int32_t stalepath_time; |
u_int32_t stalepath_time; |
|
|
|
/* Maximum-paths configuration */ |
|
struct bgp_maxpaths_cfg { |
|
u_int16_t maxpaths_ebgp; |
|
u_int16_t maxpaths_ibgp; |
|
} maxpaths[AFI_MAX][SAFI_MAX]; |
}; |
}; |
|
|
/* BGP peer-group support. */ |
/* BGP peer-group support. */ |
Line 194 struct bgp_nexthop
|
Line 205 struct bgp_nexthop
|
{ |
{ |
struct interface *ifp; |
struct interface *ifp; |
struct in_addr v4; |
struct in_addr v4; |
#ifdef HAVE_IPV6 |
|
struct in6_addr v6_global; |
struct in6_addr v6_global; |
struct in6_addr v6_local; |
struct in6_addr v6_local; |
#endif /* HAVE_IPV6 */ |
|
}; |
}; |
|
|
/* BGP router distinguisher value. */ |
/* BGP router distinguisher value. */ |
Line 253 struct bgp_filter
|
Line 262 struct bgp_filter
|
} usmap; |
} usmap; |
}; |
}; |
|
|
|
/* IBGP/EBGP identifier. We also have a CONFED peer, which is to say, |
|
a peer who's AS is part of our Confederation. */ |
|
typedef enum |
|
{ |
|
BGP_PEER_IBGP = 1, |
|
BGP_PEER_EBGP, |
|
BGP_PEER_INTERNAL, |
|
BGP_PEER_CONFED, |
|
} bgp_peer_sort_t; |
|
|
/* BGP neighbor structure. */ |
/* BGP neighbor structure. */ |
struct peer |
struct peer |
{ |
{ |
Line 276 struct peer
|
Line 295 struct peer
|
/* Peer's local AS number. */ |
/* Peer's local AS number. */ |
as_t local_as; |
as_t local_as; |
|
|
|
bgp_peer_sort_t sort; |
|
|
/* Peer's Change local AS number. */ |
/* Peer's Change local AS number. */ |
as_t change_local_as; |
as_t change_local_as; |
|
|
Line 293 struct peer
|
Line 314 struct peer
|
struct stream_fifo *obuf; |
struct stream_fifo *obuf; |
struct stream *work; |
struct stream *work; |
|
|
|
/* We use a separate stream to encode MP_REACH_NLRI for efficient |
|
* NLRI packing. peer->work stores all the other attributes. The |
|
* actual packet is then constructed by concatenating the two. |
|
*/ |
|
struct stream *scratch; |
|
|
/* Status of the peer. */ |
/* Status of the peer. */ |
int status; |
int status; |
int ostatus; |
int ostatus; |
Line 303 struct peer
|
Line 330 struct peer
|
/* Peer information */ |
/* Peer information */ |
int fd; /* File descriptor */ |
int fd; /* File descriptor */ |
int ttl; /* TTL of TCP connection to the peer. */ |
int ttl; /* TTL of TCP connection to the peer. */ |
|
int rtt; /* Estimated round-trip-time from TCP_INFO */ |
int gtsm_hops; /* minimum hopcount to peer */ |
int gtsm_hops; /* minimum hopcount to peer */ |
char *desc; /* Description of the peer. */ |
char *desc; /* Description of the peer. */ |
unsigned short port; /* Destination port for peer */ |
unsigned short port; /* Destination port for peer */ |
Line 312 struct peer
|
Line 340 struct peer
|
time_t readtime; /* Last read time */ |
time_t readtime; /* Last read time */ |
time_t resettime; /* Last reset time */ |
time_t resettime; /* Last reset time */ |
|
|
unsigned int ifindex; /* ifindex of the BGP connection. */ | ifindex_t ifindex; /* ifindex of the BGP connection. */ |
char *ifname; /* bind interface name. */ |
char *ifname; /* bind interface name. */ |
char *update_if; |
char *update_if; |
union sockunion *update_source; |
union sockunion *update_source; |
Line 340 struct peer
|
Line 368 struct peer
|
#define PEER_CAP_RESTART_RCV (1 << 6) /* restart received */ |
#define PEER_CAP_RESTART_RCV (1 << 6) /* restart received */ |
#define PEER_CAP_AS4_ADV (1 << 7) /* as4 advertised */ |
#define PEER_CAP_AS4_ADV (1 << 7) /* as4 advertised */ |
#define PEER_CAP_AS4_RCV (1 << 8) /* as4 received */ |
#define PEER_CAP_AS4_RCV (1 << 8) /* as4 received */ |
|
#define PEER_CAP_RESTART_BIT_ADV (1 << 9) /* sent restart state */ |
|
#define PEER_CAP_RESTART_BIT_RCV (1 << 10) /* peer restart state */ |
|
|
/* Capability flags (reset in bgp_stop) */ |
/* Capability flags (reset in bgp_stop) */ |
u_int16_t af_cap[AFI_MAX][SAFI_MAX]; |
u_int16_t af_cap[AFI_MAX][SAFI_MAX]; |
Line 362 struct peer
|
Line 392 struct peer
|
#define PEER_FLAG_DYNAMIC_CAPABILITY (1 << 5) /* dynamic capability */ |
#define PEER_FLAG_DYNAMIC_CAPABILITY (1 << 5) /* dynamic capability */ |
#define PEER_FLAG_DISABLE_CONNECTED_CHECK (1 << 6) /* disable-connected-check */ |
#define PEER_FLAG_DISABLE_CONNECTED_CHECK (1 << 6) /* disable-connected-check */ |
#define PEER_FLAG_LOCAL_AS_NO_PREPEND (1 << 7) /* local-as no-prepend */ |
#define PEER_FLAG_LOCAL_AS_NO_PREPEND (1 << 7) /* local-as no-prepend */ |
|
#define PEER_FLAG_LOCAL_AS_REPLACE_AS (1 << 8) /* local-as no-prepend replace-as */ |
|
|
/* NSF mode (graceful restart) */ |
/* NSF mode (graceful restart) */ |
u_char nsf[AFI_MAX][SAFI_MAX]; |
u_char nsf[AFI_MAX][SAFI_MAX]; |
Line 385 struct peer
|
Line 416 struct peer
|
#define PEER_FLAG_MAX_PREFIX (1 << 14) /* maximum prefix */ |
#define PEER_FLAG_MAX_PREFIX (1 << 14) /* maximum prefix */ |
#define PEER_FLAG_MAX_PREFIX_WARNING (1 << 15) /* maximum prefix warning-only */ |
#define PEER_FLAG_MAX_PREFIX_WARNING (1 << 15) /* maximum prefix warning-only */ |
#define PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED (1 << 16) /* leave link-local nexthop unchanged */ |
#define PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED (1 << 16) /* leave link-local nexthop unchanged */ |
|
#define PEER_FLAG_NEXTHOP_SELF_ALL (1 << 17) /* next-hop-self all */ |
|
|
/* MD5 password */ |
/* MD5 password */ |
char *password; |
char *password; |
Line 433 struct peer
|
Line 465 struct peer
|
u_int32_t v_connect; |
u_int32_t v_connect; |
u_int32_t v_holdtime; |
u_int32_t v_holdtime; |
u_int32_t v_keepalive; |
u_int32_t v_keepalive; |
u_int32_t v_asorig; |
|
u_int32_t v_routeadv; |
u_int32_t v_routeadv; |
u_int32_t v_pmax_restart; |
u_int32_t v_pmax_restart; |
u_int32_t v_gr_restart; |
u_int32_t v_gr_restart; |
Line 445 struct peer
|
Line 476 struct peer
|
struct thread *t_connect; |
struct thread *t_connect; |
struct thread *t_holdtime; |
struct thread *t_holdtime; |
struct thread *t_keepalive; |
struct thread *t_keepalive; |
struct thread *t_asorig; |
|
struct thread *t_routeadv; |
struct thread *t_routeadv; |
struct thread *t_pmax_restart; |
struct thread *t_pmax_restart; |
struct thread *t_gr_restart; |
struct thread *t_gr_restart; |
Line 616 struct bgp_nlri
|
Line 646 struct bgp_nlri
|
#define BGP_ATTR_AS4_PATH 17 |
#define BGP_ATTR_AS4_PATH 17 |
#define BGP_ATTR_AS4_AGGREGATOR 18 |
#define BGP_ATTR_AS4_AGGREGATOR 18 |
#define BGP_ATTR_AS_PATHLIMIT 21 |
#define BGP_ATTR_AS_PATHLIMIT 21 |
|
#define BGP_ATTR_ENCAP 23 |
|
|
/* BGP update origin. */ |
/* BGP update origin. */ |
#define BGP_ORIGIN_IGP 0 |
#define BGP_ORIGIN_IGP 0 |
Line 641 struct bgp_nlri
|
Line 672 struct bgp_nlri
|
#define BGP_NOTIFY_HEADER_MAX 4 |
#define BGP_NOTIFY_HEADER_MAX 4 |
|
|
/* BGP_NOTIFY_OPEN_ERR sub codes. */ |
/* BGP_NOTIFY_OPEN_ERR sub codes. */ |
|
#define BGP_NOTIFY_OPEN_UNSPECIFIC 0 |
#define BGP_NOTIFY_OPEN_UNSUP_VERSION 1 |
#define BGP_NOTIFY_OPEN_UNSUP_VERSION 1 |
#define BGP_NOTIFY_OPEN_BAD_PEER_AS 2 |
#define BGP_NOTIFY_OPEN_BAD_PEER_AS 2 |
#define BGP_NOTIFY_OPEN_BAD_BGP_IDENT 3 |
#define BGP_NOTIFY_OPEN_BAD_BGP_IDENT 3 |
Line 711 struct bgp_nlri
|
Line 743 struct bgp_nlri
|
|
|
/* BGP timers default value. */ |
/* BGP timers default value. */ |
#define BGP_INIT_START_TIMER 5 |
#define BGP_INIT_START_TIMER 5 |
#define BGP_ERROR_START_TIMER 30 |
|
#define BGP_DEFAULT_HOLDTIME 180 |
#define BGP_DEFAULT_HOLDTIME 180 |
#define BGP_DEFAULT_KEEPALIVE 60 |
#define BGP_DEFAULT_KEEPALIVE 60 |
#define BGP_DEFAULT_ASORIGINATE 15 |
|
#define BGP_DEFAULT_EBGP_ROUTEADV 30 |
#define BGP_DEFAULT_EBGP_ROUTEADV 30 |
#define BGP_DEFAULT_IBGP_ROUTEADV 5 |
#define BGP_DEFAULT_IBGP_ROUTEADV 5 |
#define BGP_CLEAR_CONNECT_RETRY 20 |
#define BGP_CLEAR_CONNECT_RETRY 20 |
#define BGP_DEFAULT_CONNECT_RETRY 120 | #define BGP_DEFAULT_CONNECT_RETRY 10 |
|
|
/* BGP default local preference. */ |
/* BGP default local preference. */ |
#define BGP_DEFAULT_LOCAL_PREF 100 |
#define BGP_DEFAULT_LOCAL_PREF 100 |
Line 727 struct bgp_nlri
|
Line 757 struct bgp_nlri
|
#define BGP_DEFAULT_RESTART_TIME 120 |
#define BGP_DEFAULT_RESTART_TIME 120 |
#define BGP_DEFAULT_STALEPATH_TIME 360 |
#define BGP_DEFAULT_STALEPATH_TIME 360 |
|
|
/* SAFI which used in open capability negotiation. */ | /* RFC4364 */ |
#define BGP_SAFI_VPNV4 128 | #define SAFI_MPLS_LABELED_VPN 128 |
#define BGP_SAFI_VPNV6 129 | |
|
|
/* Max TTL value. */ |
/* Max TTL value. */ |
#define TTL_MAX 255 |
#define TTL_MAX 255 |
Line 744 struct bgp_nlri
|
Line 773 struct bgp_nlri
|
/* Check AS path loop when we send NLRI. */ |
/* Check AS path loop when we send NLRI. */ |
/* #define BGP_SEND_ASPATH_CHECK */ |
/* #define BGP_SEND_ASPATH_CHECK */ |
|
|
/* IBGP/EBGP identifier. We also have a CONFED peer, which is to say, |
|
a peer who's AS is part of our Confederation. */ |
|
enum |
|
{ |
|
BGP_PEER_IBGP, |
|
BGP_PEER_EBGP, |
|
BGP_PEER_INTERNAL, |
|
BGP_PEER_CONFED |
|
}; |
|
|
|
/* Flag for peer_clear_soft(). */ |
/* Flag for peer_clear_soft(). */ |
enum bgp_clear_type |
enum bgp_clear_type |
{ |
{ |
Line 768 enum bgp_clear_type
|
Line 787 enum bgp_clear_type
|
/* Macros. */ |
/* Macros. */ |
#define BGP_INPUT(P) ((P)->ibuf) |
#define BGP_INPUT(P) ((P)->ibuf) |
#define BGP_INPUT_PNT(P) (STREAM_PNT(BGP_INPUT(P))) |
#define BGP_INPUT_PNT(P) (STREAM_PNT(BGP_INPUT(P))) |
|
#define BGP_IS_VALID_STATE_FOR_NOTIF(S)\ |
|
(((S) == OpenSent) || ((S) == OpenConfirm) || ((S) == Established)) |
|
|
/* Count prefix size from mask length */ |
/* Count prefix size from mask length */ |
#define PSIZE(a) (((a) + 7) / (8)) |
#define PSIZE(a) (((a) + 7) / (8)) |
Line 806 enum bgp_clear_type
|
Line 827 enum bgp_clear_type
|
#define BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK -30 |
#define BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK -30 |
#define BGP_ERR_NO_IBGP_WITH_TTLHACK -31 |
#define BGP_ERR_NO_IBGP_WITH_TTLHACK -31 |
#define BGP_ERR_MAX -32 |
#define BGP_ERR_MAX -32 |
|
#define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS_REMOTE_AS -33 |
|
|
extern struct bgp_master *bm; |
extern struct bgp_master *bm; |
|
|
extern struct thread_master *master; |
|
|
|
/* Prototypes. */ |
/* Prototypes. */ |
extern void bgp_terminate (void); |
extern void bgp_terminate (void); |
extern void bgp_reset (void); |
extern void bgp_reset (void); |
Line 826 extern struct peer_group *peer_group_lookup (struct bg
|
Line 846 extern struct peer_group *peer_group_lookup (struct bg
|
extern struct peer_group *peer_group_get (struct bgp *, const char *); |
extern struct peer_group *peer_group_get (struct bgp *, const char *); |
extern struct peer *peer_lookup_with_open (union sockunion *, as_t, struct in_addr *, |
extern struct peer *peer_lookup_with_open (union sockunion *, as_t, struct in_addr *, |
int *); |
int *); |
extern struct peer *peer_lock (struct peer *); | |
extern struct peer *peer_unlock (struct peer *); | /* |
extern int peer_sort (struct peer *peer); | * Peers are incredibly easy to memory leak |
| * due to the various ways that they are actually used |
| * Provide some functionality to debug locks and unlocks |
| */ |
| extern struct peer *peer_lock_with_caller(const char *, struct peer *); |
| extern struct peer *peer_unlock_with_caller(const char *, struct peer *); |
| #define peer_unlock(A) peer_unlock_with_caller(__FUNCTION__, (A)) |
| #define peer_lock(B) peer_lock_with_caller(__FUNCTION__, (B)) |
| |
| extern bgp_peer_sort_t peer_sort (struct peer *peer); |
extern int peer_active (struct peer *); |
extern int peer_active (struct peer *); |
extern int peer_active_nego (struct peer *); |
extern int peer_active_nego (struct peer *); |
extern struct peer *peer_create_accept (struct bgp *); |
extern struct peer *peer_create_accept (struct bgp *); |
extern char *peer_uptime (time_t, char *, size_t); |
extern char *peer_uptime (time_t, char *, size_t); |
extern int bgp_config_write (struct vty *); |
extern int bgp_config_write (struct vty *); |
extern void bgp_config_write_family_header (struct vty *, afi_t, safi_t, int *); |
extern void bgp_config_write_family_header (struct vty *, afi_t, safi_t, int *); |
| |
extern void bgp_master_init (void); |
extern void bgp_master_init (void); |
|
|
extern void bgp_init (void); |
extern void bgp_init (void); |
Line 933 extern int peer_distribute_unset (struct peer *, afi_t
|
Line 962 extern int peer_distribute_unset (struct peer *, afi_t
|
extern int peer_allowas_in_set (struct peer *, afi_t, safi_t, int); |
extern int peer_allowas_in_set (struct peer *, afi_t, safi_t, int); |
extern int peer_allowas_in_unset (struct peer *, afi_t, safi_t); |
extern int peer_allowas_in_unset (struct peer *, afi_t, safi_t); |
|
|
extern int peer_local_as_set (struct peer *, as_t, int); | extern int peer_local_as_set (struct peer *, as_t, int, int); |
extern int peer_local_as_unset (struct peer *); |
extern int peer_local_as_unset (struct peer *); |
|
|
extern int peer_prefix_list_set (struct peer *, afi_t, safi_t, int, const char *); |
extern int peer_prefix_list_set (struct peer *, afi_t, safi_t, int, const char *); |