mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-31 14:11:54 +00:00
Fix BGP identifier values in BGP4-MIB
This commit is contained in:
parent
5f936b4442
commit
c6bcdf8687
@ -59,6 +59,7 @@ snmp_bgp_register(struct snmp_proto *p)
|
||||
|
||||
{ /* registering whole BGP4-MIB subtree */
|
||||
//snmp_log("snmp_proto %p (%p)", p, p->p.pool);
|
||||
|
||||
struct snmp_register *registering = snmp_register_create(p, SNMP_BGP4_MIB);
|
||||
|
||||
struct oid *oid = mb_alloc(p->p.pool, snmp_oid_sizeof(2));
|
||||
@ -71,6 +72,7 @@ snmp_bgp_register(struct snmp_proto *p)
|
||||
add_tail(&p->register_queue, ®istering->n);
|
||||
p->register_to_ack++;
|
||||
|
||||
/* snmp_register(struct snmp_proto *p, struct oid *oid, uint index, uint len, u8 is_instance) */
|
||||
snmp_register(p, oid, 0, 1, 0);
|
||||
}
|
||||
|
||||
@ -229,7 +231,6 @@ print_bgp_record(struct bgp_config *config)
|
||||
snmp_log(" local port: %u", config->local_port);
|
||||
snmp_log(" remote port: %u", config->remote_port);
|
||||
|
||||
// crashes ?
|
||||
if (conn) {
|
||||
snmp_log(" state: %u", conn->state);
|
||||
snmp_log(" remote as: %u", conn->remote_caps->as4_number);
|
||||
@ -243,15 +244,13 @@ print_bgp_record(struct bgp_config *config)
|
||||
snmp_log(" fsm transitions: %u",
|
||||
bgp_proto->stats.fsm_established_transitions);
|
||||
|
||||
// not supported yet
|
||||
snmp_log(" fsm total time: --");
|
||||
snmp_log(" fsm total time: -- (0)"); // not supported by bird
|
||||
snmp_log(" retry interval: %u", config->connect_retry_time);
|
||||
|
||||
snmp_log(" hold configurated: %u", config->hold_time );
|
||||
snmp_log(" keep alive config: %u", config->keepalive_time );
|
||||
|
||||
// unknown
|
||||
snmp_log(" min AS origin. int.: --");
|
||||
snmp_log(" min AS origin. int.: -- (0)"); // not supported by bird
|
||||
snmp_log(" min route advertisement: %u", 0 );
|
||||
snmp_log(" in update elapsed time: %u", 0 );
|
||||
|
||||
@ -320,7 +319,7 @@ snmp_bgp_state(const struct oid *oid)
|
||||
/* fall through */
|
||||
|
||||
case 4:
|
||||
if (oid->ids[3] == BGP4_PEER_ENTRY)
|
||||
if (oid->ids[3] == SNMP_BGP_PEER_ENTRY)
|
||||
state = (state == BGP_INTERNAL_NO_VALUE) ?
|
||||
BGP_INTERNAL_PEER_ENTRY : state;
|
||||
else
|
||||
@ -441,11 +440,11 @@ snmp_bgp_is_supported(struct oid *o)
|
||||
/* most likely not functioning */
|
||||
if (o->prefix == 2 && o->n_subid > 0 && o->ids[0] == 1)
|
||||
{
|
||||
if (o->n_subid == 2 && (o->ids[1] == BGP4_MIB_VERSION ||
|
||||
o->ids[1] == BGP4_MIB_LOCAL_AS))
|
||||
if (o->n_subid == 2 && (o->ids[1] == SNMP_BGP4_MIB ||
|
||||
o->ids[1] == SNMP_BGP_LOCAL_AS))
|
||||
return 1;
|
||||
else if (o->n_subid > 2 && o->ids[1] == BGP4_PEER_TABLE &&
|
||||
o->ids[2] == BGP4_PEER_ENTRY)
|
||||
else if (o->n_subid > 2 && o->ids[1] == SNMP_BGP_PEER_TABLE &&
|
||||
o->ids[2] == SNMP_BGP_PEER_ENTRY)
|
||||
{
|
||||
if (o->n_subid == 3)
|
||||
return 1;
|
||||
@ -774,7 +773,7 @@ snmp_bgp_find_next_oid(struct snmp_proto *p, struct oid *oid, uint UNUSED contid
|
||||
/* We skip the first match as we should not include ip address in oid */
|
||||
if (match)
|
||||
{
|
||||
snmp_log("continue");
|
||||
snmp_log("continue");
|
||||
trie_walk_next(&ws, &net);
|
||||
}
|
||||
|
||||
@ -1084,7 +1083,7 @@ bgp_fill_dynamic(struct snmp_proto UNUSED *p, struct agentx_varbind *vb,
|
||||
{
|
||||
case BGP_INTERNAL_IDENTIFIER:
|
||||
if (bgp_state == BS_OPENCONFIRM || bgp_state == BS_ESTABLISHED)
|
||||
pkt = snmp_varbind_ip4(vb, size, ipa_to_ip4(bgp_proto->remote_ip));
|
||||
pkt = snmp_varbind_ip4(vb, size, ip4_from_u32(bgp_proto->remote_id));
|
||||
else
|
||||
pkt = snmp_varbind_ip4(vb, size, IP4_NONE);
|
||||
break;
|
||||
@ -1155,7 +1154,6 @@ bgp_fill_dynamic(struct snmp_proto UNUSED *p, struct agentx_varbind *vb,
|
||||
pkt = snmp_varbind_nstr(vb, size, last_error, 2);
|
||||
break;
|
||||
|
||||
// TODO finish me here
|
||||
case BGP_INTERNAL_FSM_TRANSITIONS:
|
||||
pkt = snmp_varbind_counter32(vb, size,
|
||||
bgp_stats->fsm_established_transitions);
|
||||
@ -1173,11 +1171,15 @@ bgp_fill_dynamic(struct snmp_proto UNUSED *p, struct agentx_varbind *vb,
|
||||
|
||||
case BGP_INTERNAL_HOLD_TIME:
|
||||
// (0, 3..65535)
|
||||
pkt = snmp_varbind_int(vb, size, bgp_conn->hold_time);
|
||||
pkt = snmp_varbind_int(vb, size, (bgp_conn) ? bgp_conn->hold_time : 0);
|
||||
break;
|
||||
|
||||
case BGP_INTERNAL_KEEPALIVE:
|
||||
pkt = snmp_varbind_int(vb, size, bgp_conn->keepalive_time);
|
||||
if (!bgp_conf->hold_time)
|
||||
pkt = snmp_varbind_int(vb, size, 0);
|
||||
else
|
||||
pkt = snmp_varbind_int(vb, size,
|
||||
(bgp_conn) ? bgp_conn->keepalive_time : 0);
|
||||
break;
|
||||
|
||||
case BGP_INTERNAL_HOLD_TIME_CONFIGURED:
|
||||
@ -1185,7 +1187,11 @@ bgp_fill_dynamic(struct snmp_proto UNUSED *p, struct agentx_varbind *vb,
|
||||
break;
|
||||
|
||||
case BGP_INTERNAL_KEEPALIVE_CONFIGURED:
|
||||
pkt = snmp_varbind_int(vb, size, bgp_conf->keepalive_time);
|
||||
if (!bgp_conf->keepalive_time)
|
||||
pkt = snmp_varbind_int(vb, size, 0);
|
||||
else
|
||||
pkt = snmp_varbind_int(vb, size,
|
||||
(bgp_conn) ? bgp_conn->keepalive_time : 0);
|
||||
break;
|
||||
|
||||
case BGP_INTERNAL_ORIGINATION_INTERVAL:
|
||||
@ -1199,8 +1205,9 @@ bgp_fill_dynamic(struct snmp_proto UNUSED *p, struct agentx_varbind *vb,
|
||||
break;
|
||||
|
||||
case BGP_INTERNAL_IN_UPDATE_ELAPSED_TIME:
|
||||
pkt = snmp_varbind_gauge32(vb, size, (current_time()
|
||||
- bgp_proto->last_rx_update) TO_S);
|
||||
pkt = snmp_varbind_gauge32(vb, size,
|
||||
(current_time() - bgp_proto->last_rx_update) TO_S
|
||||
);
|
||||
break;
|
||||
|
||||
case BGP_INTERNAL_END:
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "subagent.h"
|
||||
|
||||
/* peers attributes */
|
||||
enum BGP4_MIB {
|
||||
enum BGP4_MIB_PEER_TABLE {
|
||||
SNMP_BGP_IDENTIFIER = 1,
|
||||
SNMP_BGP_STATE = 2,
|
||||
SNMP_BGP_ADMIN_STATUS = 3, /* in read-only mode */
|
||||
@ -21,7 +21,7 @@ enum BGP4_MIB {
|
||||
SNMP_BGP_TX_MESSAGES = 13, /* out total messages */
|
||||
SNMP_BGP_LAST_ERROR = 14,
|
||||
SNMP_BGP_FSM_TRANSITIONS = 15, /* FSM established transitions */
|
||||
SNMP_BGP_FSM_ESTABLISHED_TIME = 16, /* UNSUPPORTED FSM established time */
|
||||
SNMP_BGP_FSM_ESTABLISHED_TIME = 16,
|
||||
SNMP_BGP_RETRY_INTERVAL = 17,
|
||||
SNMP_BGP_HOLD_TIME = 18,
|
||||
SNMP_BGP_KEEPALIVE = 19,
|
||||
@ -29,36 +29,24 @@ enum BGP4_MIB {
|
||||
SNMP_BGP_KEEPALIVE_CONFIGURED = 21,
|
||||
SNMP_BGP_ORIGINATION_INTERVAL = 22, /* UNSUPPORTED - 0 */
|
||||
SNMP_BGP_MIN_ROUTE_ADVERTISEMENT = 23, /* UNSUPPORTED - 0 */
|
||||
SNMP_BGP_IN_UPDATE_ELAPSED_TIME = 24, /* UNSUPPORTED */
|
||||
SNMP_BGP_IN_UPDATE_ELAPSED_TIME = 24,
|
||||
} PACKED;
|
||||
|
||||
/* version of BGP, here BGP-4 */
|
||||
#define SNMP_BGP_NEGOTIATED_VER_VALUE 4
|
||||
#define SNMP_BGP_NEGOTIATED_VER_NO_VALUE 0
|
||||
|
||||
//void snmp_init_bgp_table(void);
|
||||
//void snmp_del_bgp_table(void);
|
||||
|
||||
struct oid;
|
||||
|
||||
void snmp_bgp_register(struct snmp_proto *p);
|
||||
// - int snmp_bgp_is_supported(struct oid *o);
|
||||
|
||||
//int snmp_bgp_valid_ip4(struct oid *o);
|
||||
//u8 snmp_bgp_state(const struct oid *o);
|
||||
u8 snmp_bgp_get_valid(u8 state);
|
||||
u8 snmp_bgp_getnext_valid(u8 state);
|
||||
|
||||
struct oid *snmp_bgp_search(struct snmp_proto *p, struct oid *o_start, struct oid *o_end, uint contid);
|
||||
enum snmp_search_res snmp_bgp_search2(struct snmp_proto *p, struct oid **searched, const struct oid *o_end, uint contid);
|
||||
//byte * snmp_bgp_fill(struct snmp_proto *p, struct agentx_varbind *vb, byte *buf, uint size, uint contid UNUSED, int byte_ord);
|
||||
void snmp_bgp_fill(struct snmp_proto *p, struct agentx_varbind *vb, struct snmp_pdu_context *c);
|
||||
|
||||
#define BGP4_MIB_VERSION 1
|
||||
#define BGP4_MIB_LOCAL_AS 2
|
||||
#define BGP4_PEER_TABLE 3
|
||||
#define BGP4_PEER_ENTRY 1
|
||||
|
||||
#define SNMP_BGP_VERSION 1
|
||||
#define SNMP_BGP_LOCAL_AS 2
|
||||
#define SNMP_BGP_PEER_TABLE 3
|
||||
@ -67,7 +55,8 @@ void snmp_bgp_fill(struct snmp_proto *p, struct agentx_varbind *vb, struct snmp_
|
||||
/* BGP linearized state */
|
||||
enum BGP_INTERNAL_STATES {
|
||||
BGP_INTERNAL_INVALID = 0,
|
||||
BGP_INTERNAL_BGP = 1,
|
||||
BGP_INTERNAL_START = 1,
|
||||
BGP_INTERNAL_BGP,
|
||||
BGP_INTERNAL_VERSION,
|
||||
BGP_INTERNAL_LOCAL_AS,
|
||||
BGP_INTERNAL_PEER_TABLE,
|
||||
@ -96,6 +85,7 @@ enum BGP_INTERNAL_STATES {
|
||||
BGP_INTERNAL_ORIGINATION_INTERVAL,
|
||||
BGP_INTERNAL_MIN_ROUTE_ADVERTISEMENT,
|
||||
BGP_INTERNAL_IN_UPDATE_ELAPSED_TIME,
|
||||
BGP_INTERNAL_PEER_TABLE_END,
|
||||
BGP_INTERNAL_END,
|
||||
BGP_INTERNAL_NO_VALUE = 255,
|
||||
} PACKED;
|
||||
|
@ -313,16 +313,15 @@ snmp_show_proto_info(struct proto *P)
|
||||
|
||||
cli_msg(-1006, " name: %s", cf->name);
|
||||
cli_msg(-1006, "");
|
||||
cli_msg(-1006, " rem. identifier: %u", bp->remote_id);
|
||||
// learn more !!
|
||||
cli_msg(-1006, " loc. identifier: %I4", bp->local_id);
|
||||
cli_msg(-1006, " rem. identifier: %I4", bp->remote_id);
|
||||
cli_msg(-1006, " admin status: %s", (p->disabled) ? "stop" :
|
||||
"start");
|
||||
// version ?
|
||||
cli_msg(-1006, " version: 4");
|
||||
cli_msg(-1006, " local ip: %u", bcf->local_ip);
|
||||
cli_msg(-1006, " remote ip: %u", bcf->remote_ip);
|
||||
cli_msg(-1006, " local port: %u", bcf->local_port);
|
||||
cli_msg(-1006, " remote port: %u", bcf->remote_port);
|
||||
cli_msg(-1006, " local ip: %I4", bcf->local_ip);
|
||||
cli_msg(-1006, " remote ip: %I4", bcf->remote_ip);
|
||||
cli_msg(-1006, " local port: %I4", bcf->local_port);
|
||||
cli_msg(-1006, " remote port: %I4", bcf->remote_port);
|
||||
/*
|
||||
if (conn) {
|
||||
cli_msg(-1006, " state: %u", conn->state);
|
||||
@ -336,8 +335,7 @@ snmp_show_proto_info(struct proto *P)
|
||||
cli_msg(-1006, " fsm transitions: %u",
|
||||
bp->stats.fsm_established_transitions);
|
||||
|
||||
// not supported yet
|
||||
cli_msg(-1006, " fsm total time: --");
|
||||
cli_msg(-1006, " fsm total time: -- (0)");
|
||||
cli_msg(-1006, " retry interval: %u", bcf->connect_retry_time);
|
||||
|
||||
/*
|
||||
@ -350,8 +348,7 @@ bp->stats.fsm_established_transitions);
|
||||
cli_msg(-1006, " hold configurated: %u", bcf->hold_time );
|
||||
cli_msg(-1006, " keep alive config: %u", bcf->keepalive_time );
|
||||
|
||||
// unknown
|
||||
cli_msg(-1006, " min AS origin. int.: --");
|
||||
cli_msg(-1006, " min AS origin. int.: -- (0)");
|
||||
cli_msg(-1006, " min route advertisement: %u", 0 );
|
||||
cli_msg(-1006, " in update elapsed time: %u", 0 );
|
||||
|
||||
@ -394,15 +391,16 @@ snmp_shutdown(struct proto *P)
|
||||
|
||||
tm_stop(p->ping_timer);
|
||||
|
||||
/* connection established => close the connection */
|
||||
if (p->state == SNMP_CONN)
|
||||
/* connection established -> close the connection */
|
||||
if (p->state == SNMP_CONN ||
|
||||
p->state == SNMP_REGISTER)
|
||||
{
|
||||
p->state = SNMP_STOP;
|
||||
|
||||
/* startup time is reused for connection closing */
|
||||
p->startup_timer->hook = snmp_stop_timeout;
|
||||
|
||||
// TODO timeout duration ??
|
||||
// TODO timeout option
|
||||
tm_set(p->startup_timer, 15 S);
|
||||
|
||||
snmp_stop_subagent(p);
|
||||
|
Loading…
Reference in New Issue
Block a user