mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
BMP: Minor cleanups
Remove redundant 'disable' option, simplify IP address serialization, and remove useless macros.
This commit is contained in:
parent
a995ed4386
commit
4adebdf198
@ -869,7 +869,7 @@ bgp_graceful_restart_timeout(timer *t)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bgp_stop(p, 0, NULL, 0);
|
bgp_stop(p, 0, NULL, 0);
|
||||||
bmp_peer_down(p, BE_NONE, NULL, BMP_PEER_DOWN_NULL_PKT_SIZE);
|
bmp_peer_down(p, BE_NONE, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -996,7 +996,7 @@ bgp_sock_err(sock *sk, int err)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
BGP_TRACE(D_EVENTS, "Connection closed");
|
BGP_TRACE(D_EVENTS, "Connection closed");
|
||||||
bmp_peer_down(p, BE_SOCKET, NULL, BMP_PEER_DOWN_NULL_PKT_SIZE);
|
bmp_peer_down(p, BE_SOCKET, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((conn->state == BS_ESTABLISHED) && p->gr_ready)
|
if ((conn->state == BS_ESTABLISHED) && p->gr_ready)
|
||||||
@ -1322,7 +1322,7 @@ bgp_neigh_notify(neighbor *n)
|
|||||||
bgp_store_error(p, NULL, BE_MISC, BEM_NEIGHBOR_LOST);
|
bgp_store_error(p, NULL, BE_MISC, BEM_NEIGHBOR_LOST);
|
||||||
/* Perhaps also run bgp_update_startup_delay(p)? */
|
/* Perhaps also run bgp_update_startup_delay(p)? */
|
||||||
bgp_stop(p, 0, NULL, 0);
|
bgp_stop(p, 0, NULL, 0);
|
||||||
bmp_peer_down(p, BE_MISC, NULL, BMP_PEER_DOWN_NULL_PKT_SIZE);
|
bmp_peer_down(p, BE_MISC, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (p->cf->check_link && !(n->iface->flags & IF_LINK_UP))
|
else if (p->cf->check_link && !(n->iface->flags & IF_LINK_UP))
|
||||||
@ -1334,7 +1334,7 @@ bgp_neigh_notify(neighbor *n)
|
|||||||
if (ps == PS_UP)
|
if (ps == PS_UP)
|
||||||
bgp_update_startup_delay(p);
|
bgp_update_startup_delay(p);
|
||||||
bgp_stop(p, 0, NULL, 0);
|
bgp_stop(p, 0, NULL, 0);
|
||||||
bmp_peer_down(p, BE_MISC, NULL, BMP_PEER_DOWN_NULL_PKT_SIZE);
|
bmp_peer_down(p, BE_MISC, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1376,7 +1376,7 @@ bgp_bfd_notify(struct bfd_request *req)
|
|||||||
if (ps == PS_UP)
|
if (ps == PS_UP)
|
||||||
bgp_update_startup_delay(p);
|
bgp_update_startup_delay(p);
|
||||||
bgp_stop(p, 0, NULL, 0);
|
bgp_stop(p, 0, NULL, 0);
|
||||||
bmp_peer_down(p, BE_MISC, NULL, BMP_PEER_DOWN_NULL_PKT_SIZE);
|
bmp_peer_down(p, BE_MISC, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,7 +671,6 @@ byte * bgp_create_end_mark(struct bgp_channel *c, byte *buf);
|
|||||||
#define PKT_ROUTE_REFRESH 0x05 /* [RFC2918] */
|
#define PKT_ROUTE_REFRESH 0x05 /* [RFC2918] */
|
||||||
#define PKT_BEGIN_REFRESH 0x1e /* Dummy type for BoRR packet [RFC7313] */
|
#define PKT_BEGIN_REFRESH 0x1e /* Dummy type for BoRR packet [RFC7313] */
|
||||||
#define PKT_SCHEDULE_CLOSE 0x1f /* Used internally to schedule socket close */
|
#define PKT_SCHEDULE_CLOSE 0x1f /* Used internally to schedule socket close */
|
||||||
#define PKT_BMP_MSG 0x20 /* BGP Monitoring Protocol message [RFC7854] */
|
|
||||||
|
|
||||||
/* Attributes */
|
/* Attributes */
|
||||||
|
|
||||||
|
@ -377,12 +377,12 @@ bmp_sock_err(sock *sk, int err)
|
|||||||
log(L_WARN "[BMP:%s] Socket error: %M", conn->bmp->p.name, err);
|
log(L_WARN "[BMP:%s] Socket error: %M", conn->bmp->p.name, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
bmp_put_ip4_addr_with_padding(buffer *stream, const ip4_addr addr)
|
bmp_put_ipa(buffer *stream, const ip_addr addr)
|
||||||
{
|
{
|
||||||
byte padding[BMP_PADDING_IP4_ADDR_SIZE] = { 0x00 };
|
bmp_put_ip6(stream, ipa_is_ip4(addr) ?
|
||||||
bmp_put_data(stream, padding, BMP_PADDING_IP4_ADDR_SIZE);
|
ip6_build(0,0,0, ipa_to_u32(addr)) :
|
||||||
bmp_put_ip4(stream, addr);
|
ipa_to_ip6(addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -434,15 +434,7 @@ bmp_per_peer_hdr_serialize(buffer *stream, const bool is_global_instance_peer,
|
|||||||
bmp_put_u8(stream, peer_flags);
|
bmp_put_u8(stream, peer_flags);
|
||||||
// TODO: Provide appropriate peer Route Distinguisher if applicable
|
// TODO: Provide appropriate peer Route Distinguisher if applicable
|
||||||
bmp_put_u64(stream, 0x00); // 0x00 - Not supported peer distinguisher
|
bmp_put_u64(stream, 0x00); // 0x00 - Not supported peer distinguisher
|
||||||
if (ipa_is_ip4(peer_addr))
|
bmp_put_ipa(stream, peer_addr);
|
||||||
{
|
|
||||||
bmp_put_ip4_addr_with_padding(stream, ipa_to_ip4(peer_addr));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bmp_put_ip6(stream, ipa_to_ip6(peer_addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bmp_put_u32(stream, peer_as);
|
bmp_put_u32(stream, peer_as);
|
||||||
bmp_put_u32(stream, peer_bgp_id);
|
bmp_put_u32(stream, peer_bgp_id);
|
||||||
bmp_put_u32(stream, ts_sec);
|
bmp_put_u32(stream, ts_sec);
|
||||||
@ -478,15 +470,7 @@ bmp_peer_up_notif_msg_serialize(buffer *stream, const bool is_peer_global,
|
|||||||
bmp_per_peer_hdr_serialize(stream, is_peer_global,
|
bmp_per_peer_hdr_serialize(stream, is_peer_global,
|
||||||
true /* TODO: Hardcoded pre-policy Adj-RIB-In */, as4_support, remote_addr,
|
true /* TODO: Hardcoded pre-policy Adj-RIB-In */, as4_support, remote_addr,
|
||||||
peer_as, peer_bgp_id, 0, 0); // 0, 0 - No timestamp provided
|
peer_as, peer_bgp_id, 0, 0); // 0, 0 - No timestamp provided
|
||||||
if (ipa_is_ip4(local_addr))
|
bmp_put_ipa(stream, local_addr);
|
||||||
{
|
|
||||||
bmp_put_ip4_addr_with_padding(stream, ipa_to_ip4(local_addr));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bmp_put_ip6(stream, ipa_to_ip6(local_addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bmp_put_u16(stream, local_port);
|
bmp_put_u16(stream, local_port);
|
||||||
bmp_put_u16(stream, remote_port);
|
bmp_put_u16(stream, remote_port);
|
||||||
bmp_set_initial_bgp_hdr(stream, sent_msg_size, PKT_OPEN);
|
bmp_set_initial_bgp_hdr(stream, sent_msg_size, PKT_OPEN);
|
||||||
@ -1115,7 +1099,6 @@ bmp_init(struct proto_config *CF)
|
|||||||
p->station_port = cf->station_port;
|
p->station_port = cf->station_port;
|
||||||
strcpy(p->sys_descr, cf->sys_descr);
|
strcpy(p->sys_descr, cf->sys_descr);
|
||||||
strcpy(p->sys_name, cf->sys_name);
|
strcpy(p->sys_name, cf->sys_name);
|
||||||
p->disabled = cf->disabled;
|
|
||||||
p->monitoring_rib.in_pre_policy = cf->monitoring_rib_in_pre_policy;
|
p->monitoring_rib.in_pre_policy = cf->monitoring_rib_in_pre_policy;
|
||||||
p->monitoring_rib.in_post_policy = cf->monitoring_rib_in_post_policy;
|
p->monitoring_rib.in_post_policy = cf->monitoring_rib_in_post_policy;
|
||||||
p->monitoring_rib.local = cf->monitoring_rib_local;
|
p->monitoring_rib.local = cf->monitoring_rib_local;
|
||||||
@ -1128,17 +1111,6 @@ bmp_start(struct proto *P)
|
|||||||
{
|
{
|
||||||
struct bmp_proto *p = (void *) P;
|
struct bmp_proto *p = (void *) P;
|
||||||
|
|
||||||
if (p->disabled)
|
|
||||||
{
|
|
||||||
g_bmp = NULL;
|
|
||||||
return PS_DOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p->disabled)
|
|
||||||
{
|
|
||||||
return PS_DOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
p->conn = mb_allocz(P->pool, sizeof (struct bmp_conn));
|
p->conn = mb_allocz(P->pool, sizeof (struct bmp_conn));
|
||||||
p->conn->bmp = p;
|
p->conn->bmp = p;
|
||||||
bmp_setup_socket(p->conn);
|
bmp_setup_socket(p->conn);
|
||||||
|
@ -23,12 +23,6 @@
|
|||||||
// Max length of MIB-II description object
|
// Max length of MIB-II description object
|
||||||
#define MIB_II_STR_LEN 255
|
#define MIB_II_STR_LEN 255
|
||||||
|
|
||||||
enum bmp_peer_down {
|
|
||||||
// Value of packet size of 'pkt_size' argument of bmp_peer_down() function
|
|
||||||
// used for pointing out that there was not any packet to pass
|
|
||||||
BMP_PEER_DOWN_NULL_PKT_SIZE = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
// The following fields of this structure controls whether there will be put
|
// The following fields of this structure controls whether there will be put
|
||||||
// specific routes into Route Monitoring message and send to BMP collector
|
// specific routes into Route Monitoring message and send to BMP collector
|
||||||
struct monitoring_rib {
|
struct monitoring_rib {
|
||||||
@ -43,7 +37,6 @@ struct bmp_config {
|
|||||||
const char *sys_name; // sysName MIB-II [RFC1213] object
|
const char *sys_name; // sysName MIB-II [RFC1213] object
|
||||||
ip_addr station_ip; // Monitoring station address
|
ip_addr station_ip; // Monitoring station address
|
||||||
u16 station_port; // Monitoring station TCP port
|
u16 station_port; // Monitoring station TCP port
|
||||||
bool disabled; // Manually disabled
|
|
||||||
bool monitoring_rib_in_pre_policy; // Route monitoring pre-policy Adj-Rib-In
|
bool monitoring_rib_in_pre_policy; // Route monitoring pre-policy Adj-Rib-In
|
||||||
bool monitoring_rib_in_post_policy; // Route monitoring post-policy Adj-Rib-In
|
bool monitoring_rib_in_post_policy; // Route monitoring post-policy Adj-Rib-In
|
||||||
bool monitoring_rib_local; // Route monitoring Local Rib
|
bool monitoring_rib_local; // Route monitoring Local Rib
|
||||||
@ -82,10 +75,8 @@ struct bmp_proto {
|
|||||||
char sys_name[MIB_II_STR_LEN]; // sysName MIB-II [RFC1213] object
|
char sys_name[MIB_II_STR_LEN]; // sysName MIB-II [RFC1213] object
|
||||||
ip_addr station_ip; // Monitoring station IP address
|
ip_addr station_ip; // Monitoring station IP address
|
||||||
u16 station_port; // Monitoring station TCP port
|
u16 station_port; // Monitoring station TCP port
|
||||||
bool disabled; // Manually disabled
|
|
||||||
struct monitoring_rib monitoring_rib;
|
struct monitoring_rib monitoring_rib;
|
||||||
// Below fields are for internal use
|
// Below fields are for internal use
|
||||||
int station_socket; // Socket associated with the BMP collector
|
|
||||||
struct bmp_peer_map bgp_peers; // Stores 'bgp_proto' structure per BGP peer
|
struct bmp_peer_map bgp_peers; // Stores 'bgp_proto' structure per BGP peer
|
||||||
struct bmp_peer_open_msg peer_open_msg; // Stores sent and received BGP OPEN MSG per BGP peer
|
struct bmp_peer_open_msg peer_open_msg; // Stores sent and received BGP OPEN MSG per BGP peer
|
||||||
pool *buffer_mpool; // Memory pool used for BMP buffer allocations
|
pool *buffer_mpool; // Memory pool used for BMP buffer allocations
|
||||||
|
@ -25,7 +25,6 @@ proto: bmp_proto '}' ;
|
|||||||
|
|
||||||
bmp_proto_start: proto_start BMP {
|
bmp_proto_start: proto_start BMP {
|
||||||
this_proto = proto_config_new(&proto_bmp, $1);
|
this_proto = proto_config_new(&proto_bmp, $1);
|
||||||
BMP_CFG->disabled = false;
|
|
||||||
BMP_CFG->station_ip = IPA_NONE4;
|
BMP_CFG->station_ip = IPA_NONE4;
|
||||||
BMP_CFG->station_port = 0;
|
BMP_CFG->station_port = 0;
|
||||||
BMP_CFG->sys_descr = "Not defined";
|
BMP_CFG->sys_descr = "Not defined";
|
||||||
@ -39,7 +38,6 @@ bmp_proto_start: proto_start BMP {
|
|||||||
bmp_station_address:
|
bmp_station_address:
|
||||||
/* empty */
|
/* empty */
|
||||||
| bmp_station_address IP ipa {
|
| bmp_station_address IP ipa {
|
||||||
if (!BMP_CFG->disabled)
|
|
||||||
if (ipa_zero($3))
|
if (ipa_zero($3))
|
||||||
cf_error("Invalid BMP monitoring station IP address");
|
cf_error("Invalid BMP monitoring station IP address");
|
||||||
BMP_CFG->station_ip = $3;
|
BMP_CFG->station_ip = $3;
|
||||||
@ -54,9 +52,6 @@ bmp_station_address:
|
|||||||
bmp_proto:
|
bmp_proto:
|
||||||
bmp_proto_start proto_name '{'
|
bmp_proto_start proto_name '{'
|
||||||
| bmp_proto proto_item ';'
|
| bmp_proto proto_item ';'
|
||||||
| bmp_proto ENABLED bool ';' {
|
|
||||||
BMP_CFG->disabled = $3;
|
|
||||||
}
|
|
||||||
| bmp_proto STATION ADDRESS bmp_station_address ';'
|
| bmp_proto STATION ADDRESS bmp_station_address ';'
|
||||||
| bmp_proto SYSTEM DESCRIPTION text ';' {
|
| bmp_proto SYSTEM DESCRIPTION text ';' {
|
||||||
if (!$4 || (strlen($4) == 0))
|
if (!$4 || (strlen($4) == 0))
|
||||||
@ -81,8 +76,6 @@ bmp_proto:
|
|||||||
| bmp_proto MONITORING RIB LOCAL bool ';' {
|
| bmp_proto MONITORING RIB LOCAL bool ';' {
|
||||||
BMP_CFG->monitoring_rib_local = $5;
|
BMP_CFG->monitoring_rib_local = $5;
|
||||||
}
|
}
|
||||||
| bmp_proto DISABLED bool ';' {
|
|
||||||
BMP_CFG->disabled = $3; }
|
|
||||||
;
|
;
|
||||||
|
|
||||||
CF_CODE
|
CF_CODE
|
||||||
|
Loading…
Reference in New Issue
Block a user