2022-08-02 14:04:25 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- Simple Network Management Protocol (SNMP)
|
|
|
|
* BGP4-MIB bgpPeerTable
|
|
|
|
*
|
|
|
|
* (c) 2022 Vojtech Vilimek <vojtech.vilimek@nic.cz>
|
|
|
|
* (c) 2022 CZ.NIC z.s.p.o
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
2022-08-10 15:31:32 +00:00
|
|
|
#include "snmp.h"
|
2022-11-15 15:29:03 +00:00
|
|
|
#include "snmp_utils.h"
|
2022-09-30 07:36:09 +00:00
|
|
|
#include "subagent.h"
|
2024-07-04 14:33:44 +00:00
|
|
|
#include "bgp4_mib.h"
|
|
|
|
#include "mib_tree.h"
|
2022-08-02 14:04:25 +00:00
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
/* hash table macros */
|
|
|
|
#define SNMP_HASH_KEY(n) n->peer_ip
|
|
|
|
#define SNMP_HASH_NEXT(n) n->next
|
|
|
|
#define SNMP_HASH_EQ(ip1, ip2) ip4_equal(ip1, ip2)
|
|
|
|
#define SNMP_HASH_FN(ip) ip4_hash(ip)
|
|
|
|
|
|
|
|
#define SNMP_HASH_LESS4(ip1, ip2) ip4_less(ip1, ip2)
|
|
|
|
#define SNMP_HASH_LESS6(ip1, ip2) ip6_less(ip1, ip2)
|
|
|
|
|
|
|
|
/* hash table only store ip4 addresses */
|
|
|
|
#define SNMP_HASH_LESS(ip1, ip2) SNMP_HASH_LESS4(ip1,ip2)
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
// delete me
|
2024-05-24 13:20:30 +00:00
|
|
|
#define SNMP_MANAGE_TBUF(...) (void)0
|
2024-04-22 10:55:33 +00:00
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
#define DECLARE_BGP4(addr, proto, conn, stats, config) \
|
|
|
|
ip4_addr addr; \
|
2024-07-04 14:33:44 +00:00
|
|
|
const struct bgp_proto UNUSED *proto; \
|
|
|
|
const struct bgp_conn UNUSED *conn; \
|
|
|
|
const struct bgp_stats UNUSED *stats; \
|
|
|
|
const struct bgp_config UNUSED *config
|
2023-09-11 11:06:20 +00:00
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
#define POPULATE_BGP4(addr, proto, conn, stats, config) populate_bgp4(d, &(addr), &(proto), &(conn), &(stats), &(config))
|
2024-01-10 11:21:46 +00:00
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
static inline void ip4_to_oid(struct oid *oid, ip4_addr addr);
|
|
|
|
|
2024-01-10 11:21:46 +00:00
|
|
|
static inline void
|
|
|
|
snmp_hash_add_peer(struct snmp_proto *p, struct snmp_bgp_peer *peer)
|
|
|
|
{
|
|
|
|
HASH_INSERT(p->bgp_hash, SNMP_HASH, peer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct snmp_bgp_peer *
|
|
|
|
snmp_hash_find(struct snmp_proto *p, ip4_addr key)
|
|
|
|
{
|
|
|
|
return HASH_FIND(p->bgp_hash, SNMP_HASH, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
snmp_bgp_last_error(const struct bgp_proto *bgp, char err[2])
|
|
|
|
{
|
|
|
|
err[0] = bgp->last_error_code & 0x00FF0000 >> 16;
|
|
|
|
err[1] = bgp->last_error_code & 0x000000FF;
|
|
|
|
}
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2023-10-25 14:44:08 +00:00
|
|
|
static u8
|
|
|
|
bgp_get_candidate(u32 field)
|
|
|
|
{
|
|
|
|
const u8 translation_table[] = {
|
2024-01-23 23:23:31 +00:00
|
|
|
[BGP4_MIB_PEER_IDENTIFIER] = BGP4_MIB_S_PEER_IDENTIFIER,
|
|
|
|
[BGP4_MIB_STATE] = BGP4_MIB_S_STATE,
|
|
|
|
[BGP4_MIB_ADMIN_STATUS] = BGP4_MIB_S_ADMIN_STATUS,
|
|
|
|
[BGP4_MIB_NEGOTIATED_VERSION] = BGP4_MIB_S_NEGOTIATED_VERSION,
|
|
|
|
[BGP4_MIB_LOCAL_ADDR] = BGP4_MIB_S_LOCAL_ADDR,
|
|
|
|
[BGP4_MIB_LOCAL_PORT] = BGP4_MIB_S_LOCAL_PORT,
|
|
|
|
[BGP4_MIB_REMOTE_ADDR] = BGP4_MIB_S_REMOTE_ADDR,
|
|
|
|
[BGP4_MIB_REMOTE_PORT] = BGP4_MIB_S_REMOTE_PORT,
|
|
|
|
[BGP4_MIB_REMOTE_AS] = BGP4_MIB_S_REMOTE_AS,
|
|
|
|
[BGP4_MIB_RX_UPDATES] = BGP4_MIB_S_RX_UPDATES,
|
|
|
|
[BGP4_MIB_TX_UPDATES] = BGP4_MIB_S_TX_UPDATES,
|
|
|
|
[BGP4_MIB_RX_MESSAGES] = BGP4_MIB_S_RX_MESSAGES,
|
|
|
|
[BGP4_MIB_TX_MESSAGES] = BGP4_MIB_S_TX_MESSAGES,
|
|
|
|
[BGP4_MIB_LAST_ERROR] = BGP4_MIB_S_LAST_ERROR,
|
|
|
|
[BGP4_MIB_FSM_TRANSITIONS] = BGP4_MIB_S_FSM_TRANSITIONS,
|
|
|
|
[BGP4_MIB_FSM_ESTABLISHED_TIME] = BGP4_MIB_S_FSM_ESTABLISHED_TIME,
|
|
|
|
[BGP4_MIB_RETRY_INTERVAL] = BGP4_MIB_S_RETRY_INTERVAL,
|
|
|
|
[BGP4_MIB_HOLD_TIME] = BGP4_MIB_S_HOLD_TIME,
|
|
|
|
[BGP4_MIB_KEEPALIVE] = BGP4_MIB_S_KEEPALIVE,
|
|
|
|
[BGP4_MIB_HOLD_TIME_CONFIGURED] = BGP4_MIB_S_HOLD_TIME_CONFIGURED,
|
|
|
|
[BGP4_MIB_KEEPALIVE_CONFIGURED] = BGP4_MIB_S_KEEPALIVE_CONFIGURED,
|
|
|
|
[BGP4_MIB_ORIGINATION_INTERVAL] = BGP4_MIB_S_ORIGINATION_INTERVAL,
|
|
|
|
[BGP4_MIB_MIN_ROUTE_ADVERTISEMENT] = BGP4_MIB_S_MIN_ROUTE_ADVERTISEMENT,
|
|
|
|
[BGP4_MIB_IN_UPDATE_ELAPSED_TIME] = BGP4_MIB_S_IN_UPDATE_ELAPSED_TIME,
|
2023-10-25 14:44:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First value is in secord cell of array translation_table, as the
|
2024-05-24 13:20:30 +00:00
|
|
|
* SNMP_BGP_IDENTIFIER == 1
|
2023-10-25 14:44:08 +00:00
|
|
|
*/
|
|
|
|
if (field > 0 && field <= ARRAY_SIZE(translation_table)- 1)
|
|
|
|
return translation_table[field];
|
2024-01-23 23:23:31 +00:00
|
|
|
else if (field == 0)
|
|
|
|
return BGP4_MIB_S_PEER_ENTRY;
|
2023-10-25 14:44:08 +00:00
|
|
|
else
|
2024-01-23 23:23:31 +00:00
|
|
|
return BGP4_MIB_S_PEER_TABLE_END;
|
2023-10-25 14:44:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snmp_bgp_state - linearize oid from BGP4-MIB
|
|
|
|
* @oid: prefixed object identifier from BGP4-MIB::bgp subtree
|
|
|
|
*
|
|
|
|
* Returns linearized state for Get-PDU, GetNext-PDU and GetBulk-PDU packets.
|
|
|
|
*/
|
|
|
|
static u8
|
|
|
|
snmp_bgp_state(const struct oid *oid)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Ids of Object Identifier that are already checked:
|
|
|
|
* internet oid.prefix
|
|
|
|
* v...... v
|
|
|
|
* (*oid): .1.3.6.1.2.1.15
|
|
|
|
* -> BGP4-MIB::bgp (root)
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (snmp_is_oid_empty(oid))
|
2024-01-23 23:23:31 +00:00
|
|
|
return BGP4_MIB_S_END;
|
2023-10-25 14:44:08 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
u8 state = BGP4_MIB_S_NO_VALUE;
|
2023-10-25 14:44:08 +00:00
|
|
|
|
|
|
|
u8 candidate;
|
|
|
|
switch (oid->n_subid)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
if (oid->n_subid < 2)
|
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
state = BGP4_MIB_S_INVALID;
|
2023-10-25 14:44:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fall through */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Between ids[5] and ids[8] (n_subid == 9) should be IP address.
|
|
|
|
* Validity is checked later in execution because
|
|
|
|
* this field also could mean a query boundry (upper or lower).
|
|
|
|
*/
|
|
|
|
case 9:
|
|
|
|
case 8:
|
|
|
|
case 7:
|
|
|
|
case 6:
|
|
|
|
case 5:
|
|
|
|
state = bgp_get_candidate(oid->ids[4]);
|
|
|
|
|
|
|
|
/* fall through */
|
|
|
|
|
|
|
|
case 4:
|
2024-01-23 23:23:31 +00:00
|
|
|
if (oid->ids[3] == BGP4_MIB_PEER_ENTRY)
|
|
|
|
state = (state == BGP4_MIB_S_NO_VALUE) ?
|
|
|
|
BGP4_MIB_S_PEER_ENTRY : state;
|
2023-10-25 14:44:08 +00:00
|
|
|
else
|
2024-01-23 23:23:31 +00:00
|
|
|
state = BGP4_MIB_S_NO_VALUE;
|
2023-10-25 14:44:08 +00:00
|
|
|
|
|
|
|
/* fall through */
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
/* u8 candidate; */
|
|
|
|
switch (oid->ids[2])
|
|
|
|
{
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_VERSION:
|
|
|
|
state = BGP4_MIB_S_VERSION;
|
2023-10-25 14:44:08 +00:00
|
|
|
break;
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_LOCAL_AS:
|
|
|
|
state = BGP4_MIB_S_LOCAL_AS;
|
2023-10-25 14:44:08 +00:00
|
|
|
break;
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_PEER_TABLE:
|
2023-10-25 14:44:08 +00:00
|
|
|
/* We use candidate to avoid overriding more specific state */
|
2024-01-23 23:23:31 +00:00
|
|
|
candidate = BGP4_MIB_S_PEER_TABLE;
|
2023-10-25 14:44:08 +00:00
|
|
|
break;
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_IDENTIFIER:
|
|
|
|
state = BGP4_MIB_S_IDENTIFIER;
|
2023-10-25 14:44:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* test fails */
|
|
|
|
/* We force state invalidation */
|
2024-01-23 23:23:31 +00:00
|
|
|
if (oid->ids[2] < BGP4_MIB_VERSION)
|
2023-10-25 14:44:08 +00:00
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
state = BGP4_MIB_S_NO_VALUE;
|
|
|
|
candidate = BGP4_MIB_S_NO_VALUE;
|
2023-10-25 14:44:08 +00:00
|
|
|
}
|
2024-01-23 23:23:31 +00:00
|
|
|
else /* oid->ids[2] > BGP4_MIB_PEER_TABLE */
|
|
|
|
state = BGP4_MIB_S_END;
|
2023-10-25 14:44:08 +00:00
|
|
|
}
|
2024-01-23 23:23:31 +00:00
|
|
|
state = (state == BGP4_MIB_S_NO_VALUE) ?
|
2023-10-25 14:44:08 +00:00
|
|
|
candidate : state;
|
|
|
|
|
|
|
|
/* fall through */
|
|
|
|
|
|
|
|
case 2: /* We found bare BGP4-MIB::bgp ObjectId */
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state == BGP4_MIB_S_NO_VALUE ||
|
|
|
|
state == BGP4_MIB_S_INVALID)
|
|
|
|
state = BGP4_MIB_S_BGP;
|
2023-10-25 14:44:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
static void
|
|
|
|
snmp_bgp_reg_ok(struct snmp_proto *p, const struct agentx_response *res, struct snmp_registration *reg)
|
2023-10-25 14:57:46 +00:00
|
|
|
{
|
2024-05-24 13:20:30 +00:00
|
|
|
const struct oid * const oid = reg->oid;
|
2024-04-22 10:55:33 +00:00
|
|
|
(void)oid;
|
2024-05-24 13:20:30 +00:00
|
|
|
(void)p;
|
|
|
|
(void) res;
|
2023-10-25 14:57:46 +00:00
|
|
|
}
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
static void
|
|
|
|
snmp_bgp_reg_failed(struct snmp_proto *p, const struct agentx_response *res, struct snmp_registration *reg)
|
2023-10-25 14:57:46 +00:00
|
|
|
{
|
2024-05-24 13:20:30 +00:00
|
|
|
const struct oid * const oid = reg->oid;
|
|
|
|
(void) res;
|
|
|
|
(void)oid;
|
|
|
|
(void)p;
|
2023-10-25 14:57:46 +00:00
|
|
|
}
|
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
/*
|
|
|
|
* snmp_bgp_notify_common - common functionaly for BGP4-MIB notifications
|
|
|
|
* @p: SNMP protocol instance
|
2024-01-23 23:23:31 +00:00
|
|
|
* @type: type of notification send - either established or backward transition
|
|
|
|
* @ip4: IPv4 remote addr
|
|
|
|
* @last_error: 2 bytes of BGP last error
|
|
|
|
* @state_val: BGP peer state as defined in MIB
|
2023-11-15 14:03:55 +00:00
|
|
|
*/
|
2023-09-04 11:53:45 +00:00
|
|
|
static void
|
|
|
|
snmp_bgp_notify_common(struct snmp_proto *p, uint type, ip4_addr ip4, char last_error[], uint state_val)
|
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
uint sz = (uint) (snmp_varbind_size_from_len(9, AGENTX_IP_ADDRESS, 0)
|
|
|
|
+ snmp_varbind_size_from_len(9, AGENTX_OCTET_STRING, 2)
|
|
|
|
+ snmp_varbind_size_from_len(9, AGENTX_INTEGER, 0));
|
2023-09-04 11:53:45 +00:00
|
|
|
|
|
|
|
u32 trap_ids[] = { 1, 0, type };
|
2024-01-23 23:23:31 +00:00
|
|
|
STATIC_ASSERT(ARRAY_SIZE(trap_ids) == 3);
|
2024-04-22 10:55:33 +00:00
|
|
|
/* additional size for trap identification, here either
|
2024-01-23 23:23:31 +00:00
|
|
|
* bgpEstablishedNotification or bgpBackwardTransNotification (see below) */
|
2024-04-22 10:55:33 +00:00
|
|
|
void *data = tmp_alloc(snmp_oid_size_from_len(ARRAY_SIZE(trap_ids)) + sz);
|
|
|
|
struct oid *head = data;
|
2024-01-23 23:23:31 +00:00
|
|
|
|
|
|
|
{ /* trap id BGP4-MIB::bgpEstablishedNotification (.1.3.6.1.2.15.0.1)
|
|
|
|
* or BGP4-MIB::bgpBackwardTransNotification (.1.3.6.1.2.15.0.2) */
|
|
|
|
head->n_subid = ARRAY_SIZE(trap_ids);
|
|
|
|
head->prefix = SNMP_MGMT;
|
|
|
|
head->include = head->reserved = 0;
|
|
|
|
|
|
|
|
for (uint i = 0; i < head->n_subid; i++)
|
|
|
|
head->ids[i] = trap_ids[i];
|
|
|
|
}
|
2023-09-04 11:53:45 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
data += sz;
|
2023-09-04 11:53:45 +00:00
|
|
|
struct agentx_varbind *addr_vb = data;
|
2024-01-23 23:23:31 +00:00
|
|
|
struct agentx_varbind *error_vb = \
|
|
|
|
data + snmp_varbind_size_from_len(9, AGENTX_IP_ADDRESS, 0);
|
|
|
|
struct agentx_varbind *state_vb = \
|
|
|
|
(void *) error_vb + snmp_varbind_size_from_len(9, AGENTX_OCTET_STRING, 2);
|
2023-09-04 11:53:45 +00:00
|
|
|
|
|
|
|
u32 oid_ids[] = {
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_MIB_2, BGP4_MIB, BGP4_MIB_PEER_TABLE, BGP4_MIB_PEER_ENTRY
|
2023-09-04 11:53:45 +00:00
|
|
|
};
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
/*
|
|
|
|
* The n_subid is 9 in all cases because all are rows entries of
|
|
|
|
* BGP4-MIB::bgpPeerTable
|
|
|
|
* BGP4-MIB::bgpPeerRemoteAddr = .1.3.6.1.[2].1.15.3.1.7.a.b.c.d
|
|
|
|
* where .1.3.6.1 is internet prefix, .[2] is SNMP_MGMT,
|
|
|
|
* .1.15.3.1.7.a.b.c.d has 9 elements (a.b.c.d are IP addr bytes)
|
|
|
|
* Here subidentifier 7 is entry type bgpPeerRemoteAddr.
|
|
|
|
*/
|
|
|
|
#define PEER_TABLE_ENTRY 9
|
|
|
|
#define ENTRY_TYPE 4
|
|
|
|
|
|
|
|
{ /* BGP4-MIB::bgpPeerRemoteAddr */
|
|
|
|
struct oid *addr = &addr_vb->name;
|
|
|
|
*addr = (struct oid) {
|
|
|
|
.n_subid = PEER_TABLE_ENTRY, .prefix = SNMP_MGMT, .include = 0,
|
|
|
|
.reserved = 0,
|
|
|
|
};
|
|
|
|
for (uint i = 0; i < ARRAY_SIZE(oid_ids); i++)
|
|
|
|
addr->ids[i] = oid_ids[i];
|
|
|
|
addr->ids[ENTRY_TYPE] = BGP4_MIB_REMOTE_ADDR;
|
|
|
|
ip4_to_oid(addr, ip4);
|
|
|
|
}
|
|
|
|
/* We have enough space inside the TX-buffer prepared */
|
2024-05-24 13:20:30 +00:00
|
|
|
struct snmp_pdu dummy = { 0 };
|
|
|
|
dummy.sr_vb_start = addr_vb;
|
|
|
|
snmp_varbind_ip4(&dummy, ip4);
|
2024-01-23 23:23:31 +00:00
|
|
|
|
|
|
|
{ /* BGP4-MIB::bgpPeerLastError */
|
|
|
|
struct oid *error = &error_vb->name;
|
|
|
|
*error = (struct oid) {
|
|
|
|
.n_subid = PEER_TABLE_ENTRY, .prefix = SNMP_MGMT, .include = 0,
|
|
|
|
.reserved = 0,
|
|
|
|
};
|
|
|
|
for (uint i = 0; i < ARRAY_SIZE(oid_ids); i++)
|
|
|
|
error->ids[i] = oid_ids[i];
|
|
|
|
error->ids[ENTRY_TYPE] = BGP4_MIB_LAST_ERROR;
|
|
|
|
ip4_to_oid(error, ip4);
|
|
|
|
}
|
2024-05-24 13:20:30 +00:00
|
|
|
|
|
|
|
dummy.sr_vb_start = error_vb;
|
|
|
|
snmp_varbind_nstr(&dummy, last_error, 2);
|
2024-01-23 23:23:31 +00:00
|
|
|
|
|
|
|
{ /* BGP4-MIB::bgpPeerState */
|
|
|
|
struct oid *state = &state_vb->name;
|
|
|
|
*state = (struct oid) {
|
|
|
|
.n_subid = PEER_TABLE_ENTRY, .prefix = SNMP_MGMT, .include = 0,
|
|
|
|
.reserved = 0,
|
|
|
|
};
|
|
|
|
for (uint i = 0; i < ARRAY_SIZE(oid_ids); i++)
|
|
|
|
state->ids[i] = oid_ids[i];
|
|
|
|
state->ids[ENTRY_TYPE] = BGP4_MIB_STATE;
|
|
|
|
ip4_to_oid(state, ip4);
|
|
|
|
}
|
2024-05-24 13:20:30 +00:00
|
|
|
|
|
|
|
dummy.sr_vb_start = state_vb;
|
|
|
|
snmp_varbind_int(&dummy, state_val);
|
2023-09-04 11:53:45 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
/* We do not send the systemUpTime.0 */
|
2023-09-04 11:53:45 +00:00
|
|
|
snmp_notify_pdu(p, head, data, sz, 0);
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
#undef OID_N_SUBID
|
2023-09-04 11:53:45 +00:00
|
|
|
}
|
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
/*
|
|
|
|
* snmp_bgp_fsm_state - extract BGP FSM state for SNMP BGP4-MIB
|
|
|
|
* @bgp_proto: BGP instance
|
|
|
|
*
|
|
|
|
* Return FSM state in BGP4-MIB encoding
|
|
|
|
*/
|
2023-09-04 11:46:02 +00:00
|
|
|
static inline uint
|
2023-11-15 14:03:55 +00:00
|
|
|
snmp_bgp_fsm_state(const struct bgp_proto *bgp_proto)
|
2023-09-04 11:46:02 +00:00
|
|
|
{
|
|
|
|
const struct bgp_conn *bgp_conn = bgp_proto->conn;
|
|
|
|
const struct bgp_conn *bgp_in = &bgp_proto->incoming_conn;
|
|
|
|
const struct bgp_conn *bgp_out = &bgp_proto->outgoing_conn;
|
|
|
|
|
|
|
|
if (bgp_conn)
|
2024-01-10 11:21:46 +00:00
|
|
|
return bgp_conn->state + 1;
|
2023-09-04 11:46:02 +00:00
|
|
|
|
|
|
|
if (MAX(bgp_in->state, bgp_out->state) == BS_CLOSE &&
|
|
|
|
MIN(bgp_in->state, bgp_out->state) != BS_CLOSE)
|
2024-01-23 23:23:31 +00:00
|
|
|
return MIN(bgp_in->state, bgp_out->state) + 1;
|
2023-09-04 11:46:02 +00:00
|
|
|
if (MIN(bgp_in->state, bgp_out->state) == BS_CLOSE)
|
|
|
|
return BS_IDLE;
|
2024-04-22 10:55:33 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
return MAX(bgp_in->state, bgp_out->state) + 1;
|
2023-09-04 11:46:02 +00:00
|
|
|
}
|
|
|
|
|
2023-09-04 11:53:45 +00:00
|
|
|
static void
|
|
|
|
snmp_bgp_notify_wrapper(struct snmp_proto *p, struct bgp_proto *bgp, uint type)
|
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
/* possibly incorrect cast */
|
2023-09-04 11:53:45 +00:00
|
|
|
ip4_addr ip4 = ipa_to_ip4(bgp->remote_ip);
|
2023-11-15 14:03:55 +00:00
|
|
|
char last_error[2];
|
|
|
|
snmp_bgp_last_error(bgp, last_error);
|
2023-09-04 11:53:45 +00:00
|
|
|
uint state_val = snmp_bgp_fsm_state(bgp);
|
|
|
|
snmp_bgp_notify_common(p, type, ip4, last_error, state_val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
snmp_bgp_notify_established(struct snmp_proto *p, struct bgp_proto *bgp)
|
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
snmp_bgp_notify_wrapper(p, bgp, BGP4_MIB_ESTABLISHED_NOTIFICATION);
|
2023-09-04 11:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
snmp_bgp_notify_backward_trans(struct snmp_proto *p, struct bgp_proto *bgp)
|
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
snmp_bgp_notify_wrapper(p, bgp, BGP4_MIB_BACKWARD_TRANS_NOTIFICATION);
|
2023-09-04 11:53:45 +00:00
|
|
|
}
|
2023-09-04 11:46:02 +00:00
|
|
|
|
2022-08-02 14:04:25 +00:00
|
|
|
void
|
2024-05-24 13:20:30 +00:00
|
|
|
snmp_bgp4_register(struct snmp_proto *p)
|
2022-12-10 17:08:00 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
u32 bgp_mib_prefix[] = { 1, BGP4_MIB }; // TODO remove constant
|
2022-12-10 17:08:00 +00:00
|
|
|
|
2023-08-08 19:51:38 +00:00
|
|
|
{
|
|
|
|
/* Register the whole BGP4-MIB::bgp root tree node */
|
2023-11-15 14:03:55 +00:00
|
|
|
struct snmp_registration *reg;
|
2024-01-23 23:23:31 +00:00
|
|
|
reg = snmp_registration_create(p, BGP4_MIB);
|
2022-12-10 17:08:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
struct oid *oid = mb_allocz(p->pool,
|
|
|
|
snmp_oid_size_from_len(ARRAY_SIZE(bgp_mib_prefix)));
|
2023-10-25 14:57:46 +00:00
|
|
|
STORE_U8(oid->n_subid, ARRAY_SIZE(bgp_mib_prefix));
|
2023-09-11 11:06:20 +00:00
|
|
|
STORE_U8(oid->prefix, SNMP_MGMT);
|
2022-12-10 17:08:00 +00:00
|
|
|
|
2023-10-25 14:57:46 +00:00
|
|
|
memcpy(oid->ids, bgp_mib_prefix, sizeof(bgp_mib_prefix));
|
2023-11-15 14:03:55 +00:00
|
|
|
reg->oid = oid;
|
2024-05-24 13:20:30 +00:00
|
|
|
reg->reg_hook_ok = snmp_bgp_reg_ok;
|
|
|
|
reg->reg_hook_fail = snmp_bgp_reg_failed;
|
2022-12-10 17:08:00 +00:00
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
/*
|
|
|
|
* We set both upper bound and index to zero, therefore only single OID
|
|
|
|
* is being registered.
|
|
|
|
*/
|
|
|
|
snmp_register(p, oid, 0, 0, SNMP_REGISTER_TREE, SNMP_DEFAULT_CONTEXT);
|
2022-12-10 17:08:00 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-02 14:04:25 +00:00
|
|
|
|
2023-03-31 07:56:39 +00:00
|
|
|
static int
|
2024-05-24 13:20:30 +00:00
|
|
|
snmp_bgp_valid_ip4(const struct oid *o)
|
2022-11-05 15:29:00 +00:00
|
|
|
{
|
2022-11-15 15:29:03 +00:00
|
|
|
return snmp_valid_ip4_index(o, 5);
|
2022-11-05 15:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-08 08:27:01 +00:00
|
|
|
static inline ip4_addr
|
2022-11-05 15:29:00 +00:00
|
|
|
ip4_from_oid(const struct oid *o)
|
|
|
|
{
|
2023-07-26 12:02:23 +00:00
|
|
|
return ip4_build(
|
|
|
|
o->n_subid > 5 ? (o->ids[5] & 0xff) : 0,
|
|
|
|
o->n_subid > 6 ? (o->ids[6] & 0xff) : 0,
|
|
|
|
o->n_subid > 7 ? (o->ids[7] & 0xff) : 0,
|
|
|
|
o->n_subid > 8 ? (o->ids[8] & 0xff) : 0
|
|
|
|
);
|
2022-11-05 15:29:00 +00:00
|
|
|
}
|
|
|
|
|
2023-09-11 11:06:20 +00:00
|
|
|
static inline void
|
|
|
|
ip4_to_oid(struct oid *o, ip4_addr addr)
|
|
|
|
{
|
|
|
|
u32 tmp = ip4_to_u32(addr);
|
|
|
|
ASSUME(o->n_subid >= 9);
|
|
|
|
STORE_U32(o->ids[5], (tmp & 0xFF000000) >> 24);
|
|
|
|
STORE_U32(o->ids[6], (tmp & 0x00FF0000) >> 16);
|
|
|
|
STORE_U32(o->ids[7], (tmp & 0x0000FF00) >> 8);
|
|
|
|
STORE_U32(o->ids[8], (tmp & 0x000000FF) >> 0);
|
|
|
|
}
|
|
|
|
|
2022-12-06 15:32:26 +00:00
|
|
|
static void
|
2023-11-15 14:03:55 +00:00
|
|
|
print_bgp_record(const struct bgp_proto *bgp_proto)
|
2022-12-06 15:32:26 +00:00
|
|
|
{
|
2023-11-15 14:03:55 +00:00
|
|
|
//struct proto_config *cf = bgp_proto->p.cf;
|
2022-12-06 15:32:26 +00:00
|
|
|
struct bgp_conn *conn = bgp_proto->conn;
|
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
DBG(" name: %s", cf->name);
|
|
|
|
DBG(".");
|
|
|
|
DBG(" rem. identifier: %u", bgp_proto->remote_id);
|
|
|
|
DBG(" local ip: %I", config->local_ip);
|
|
|
|
DBG(" remote ip: %I", config->remote_ip);
|
|
|
|
DBG(" local port: %u", config->local_port);
|
|
|
|
DBG(" remote port: %u", config->remote_port);
|
2022-12-06 15:32:26 +00:00
|
|
|
|
|
|
|
if (conn) {
|
2023-11-15 14:03:55 +00:00
|
|
|
DBG(" state: %u", conn->state);
|
|
|
|
DBG(" remote as: %u", conn->remote_caps->as4_number);
|
2022-12-06 15:32:26 +00:00
|
|
|
}
|
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
DBG(" in updates: %u", bgp_proto->stats.rx_updates);
|
|
|
|
DBG(" out updates: %u", bgp_proto->stats.tx_updates);
|
|
|
|
DBG(" in total: %u", bgp_proto->stats.rx_messages);
|
|
|
|
DBG(" out total: %u", bgp_proto->stats.tx_messages);
|
|
|
|
DBG(" fsm transitions: %u",
|
2023-08-08 19:51:38 +00:00
|
|
|
bgp_proto->stats.fsm_established_transitions);
|
2022-12-06 15:32:26 +00:00
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
DBG(" fsm total time: -- (0)"); // not supported by bird
|
|
|
|
DBG(" retry interval: %u", config->connect_retry_time);
|
2022-12-06 15:32:26 +00:00
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
DBG(" hold configurated: %u", config->hold_time );
|
|
|
|
DBG(" keep alive config: %u", config->keepalive_time );
|
2022-12-06 15:32:26 +00:00
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
DBG(" min AS origin. int.: -- (0)"); // not supported by bird
|
|
|
|
DBG(" min route advertisement: %u", 0 );
|
|
|
|
DBG(" in update elapsed time: %u", 0 );
|
2022-12-06 15:32:26 +00:00
|
|
|
|
|
|
|
if (!conn)
|
2023-11-15 14:03:55 +00:00
|
|
|
DBG(" no connection established");
|
2022-12-06 15:32:26 +00:00
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
DBG(" outgoinin_conn state %u", bgp_proto->outgoing_conn.state + 1);
|
|
|
|
DBG(" incoming_conn state: %u", bgp_proto->incoming_conn.state + 1);
|
2022-12-06 15:32:26 +00:00
|
|
|
}
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
static void UNUSED
|
2022-12-06 15:32:26 +00:00
|
|
|
print_bgp_record_all(struct snmp_proto *p)
|
|
|
|
{
|
2023-11-15 14:03:55 +00:00
|
|
|
DBG("dumping watched bgp status");
|
2022-12-06 15:32:26 +00:00
|
|
|
HASH_WALK(p->bgp_hash, next, peer)
|
|
|
|
{
|
2023-11-15 14:03:55 +00:00
|
|
|
print_bgp_record(peer->bgp_proto);
|
2022-12-06 15:32:26 +00:00
|
|
|
}
|
|
|
|
HASH_WALK_END;
|
2023-11-15 14:03:55 +00:00
|
|
|
DBG("dumping watched end");
|
2022-12-06 15:32:26 +00:00
|
|
|
}
|
|
|
|
|
2023-09-04 07:25:51 +00:00
|
|
|
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
/*
|
|
|
|
* is_dynamic - is state dependent on runtime BGP peer state
|
|
|
|
* @state: tested bgp4_mib state
|
|
|
|
*
|
|
|
|
* Used to distinguish states that depend on runtime BGP peer states.
|
|
|
|
*
|
|
|
|
* Return nonzero for states with value that may change at runtime.
|
|
|
|
*/
|
2022-11-15 15:29:03 +00:00
|
|
|
static inline int
|
2022-11-05 15:29:00 +00:00
|
|
|
is_dynamic(u8 state)
|
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
return (state >= BGP4_MIB_S_PEER_IDENTIFIER &&
|
|
|
|
state <= BGP4_MIB_S_IN_UPDATE_ELAPSED_TIME);
|
2022-11-05 15:29:00 +00:00
|
|
|
}
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
/*
|
|
|
|
* is_static - logical inverse of is_dynamic() for states with value
|
|
|
|
* @state: tested bgp4_mib state
|
|
|
|
*
|
|
|
|
* Return nonzero for states with value that do not change at runtime.
|
|
|
|
*/
|
2023-10-11 08:44:18 +00:00
|
|
|
static inline int
|
|
|
|
is_static(u8 state)
|
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
return (state == BGP4_MIB_S_VERSION ||
|
|
|
|
state == BGP4_MIB_S_LOCAL_AS ||
|
|
|
|
state == BGP4_MIB_S_IDENTIFIER);
|
2023-10-11 08:44:18 +00:00
|
|
|
}
|
|
|
|
|
2022-11-05 15:29:00 +00:00
|
|
|
static inline int
|
|
|
|
snmp_bgp_has_value(u8 state)
|
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state <= BGP4_MIB_S_BGP ||
|
|
|
|
state == BGP4_MIB_S_PEER_TABLE ||
|
|
|
|
state == BGP4_MIB_S_PEER_ENTRY ||
|
|
|
|
state == BGP4_MIB_S_PEER_TABLE_END ||
|
|
|
|
state >= BGP4_MIB_S_END)
|
2023-07-26 12:02:23 +00:00
|
|
|
return 0;
|
2022-11-05 15:29:00 +00:00
|
|
|
else
|
2023-07-26 12:02:23 +00:00
|
|
|
return 1;
|
2022-11-05 15:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snmp_bgp_get_valid - only states with valid value
|
|
|
|
* @state: BGP linearized state
|
|
|
|
*
|
|
|
|
* Returns @state if has value in BGP4-MIB, zero otherwise. Used for Get-PDU
|
2024-01-10 11:21:46 +00:00
|
|
|
* packets.
|
2022-11-05 15:29:00 +00:00
|
|
|
*/
|
|
|
|
u8
|
|
|
|
snmp_bgp_get_valid(u8 state)
|
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state == BGP4_MIB_S_INVALID ||
|
|
|
|
state == BGP4_MIB_S_BGP ||
|
|
|
|
state == BGP4_MIB_S_PEER_TABLE ||
|
|
|
|
state == BGP4_MIB_S_PEER_ENTRY ||
|
|
|
|
state == BGP4_MIB_S_PEER_TABLE_END ||
|
|
|
|
state >= BGP4_MIB_S_END)
|
2022-11-05 15:29:00 +00:00
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snmp_bgp_next_state - next state that has value
|
|
|
|
* @state: BGP linearized state
|
|
|
|
*
|
|
|
|
* Returns successor state of @state with valid value in BG4-MIB. Used for
|
|
|
|
* GetNext-PDU and GetBulk-PDU packets.
|
|
|
|
*/
|
|
|
|
u8
|
|
|
|
snmp_bgp_next_state(u8 state)
|
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_LOCAL_AS:
|
|
|
|
case BGP4_MIB_S_PEER_TABLE:
|
|
|
|
case BGP4_MIB_S_PEER_ENTRY:
|
|
|
|
return BGP4_MIB_S_PEER_IDENTIFIER;
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_IN_UPDATE_ELAPSED_TIME:
|
|
|
|
case BGP4_MIB_S_PEER_TABLE_END:
|
|
|
|
return BGP4_MIB_S_IDENTIFIER;
|
2023-10-11 08:44:18 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_IDENTIFIER:
|
|
|
|
case BGP4_MIB_S_END:
|
|
|
|
return BGP4_MIB_S_END;
|
2022-11-05 15:29:00 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return state + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-26 12:02:23 +00:00
|
|
|
static int
|
|
|
|
oid_state_compare(const struct oid *oid, u8 state)
|
|
|
|
{
|
|
|
|
ASSUME(oid != NULL);
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state >= BGP4_MIB_S_PEER_IDENTIFIER &&
|
|
|
|
state <= BGP4_MIB_S_IN_UPDATE_ELAPSED_TIME)
|
2023-07-26 12:02:23 +00:00
|
|
|
return (oid->n_subid > 9) - (oid->n_subid < 9);
|
2024-01-23 23:23:31 +00:00
|
|
|
if ((state >= BGP4_MIB_S_VERSION && state <= BGP4_MIB_S_PEER_TABLE) ||
|
|
|
|
(state == BGP4_MIB_S_IDENTIFIER))
|
2023-07-26 12:02:23 +00:00
|
|
|
return (oid->n_subid > 3) - (oid->n_subid < 3);
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state == BGP4_MIB_S_PEER_ENTRY)
|
2023-07-26 12:02:23 +00:00
|
|
|
return (oid->n_subid > 4) - (oid->n_subid < 4);
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state == BGP4_MIB_S_BGP)
|
2023-07-26 12:02:23 +00:00
|
|
|
return (oid->n_subid > 2) - (oid->n_subid < 2);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
static inline enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
populate_bgp4(struct snmp_data *d, ip4_addr *addr, const struct bgp_proto **proto, const struct bgp_conn
|
2024-05-24 13:20:30 +00:00
|
|
|
**conn, const struct bgp_stats **stats, const struct bgp_config **config)
|
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
const struct oid * const oid = &d->c->sr_vb_start->name;
|
2024-07-09 14:30:04 +00:00
|
|
|
if (snmp_bgp_valid_ip4(oid) && LOAD_U8(oid->n_subid) == 9)
|
2024-05-24 13:20:30 +00:00
|
|
|
*addr = ip4_from_oid(oid);
|
|
|
|
else
|
2024-07-04 14:33:44 +00:00
|
|
|
{
|
|
|
|
snmp_log("populate() invalid ip4");
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_NO_INSTANCE;
|
2024-07-04 14:33:44 +00:00
|
|
|
}
|
2024-05-24 13:20:30 +00:00
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
struct snmp_bgp_peer *pe = snmp_hash_find(d->p, *addr);
|
2024-05-24 13:20:30 +00:00
|
|
|
if (!pe)
|
2024-07-04 14:33:44 +00:00
|
|
|
{
|
|
|
|
snmp_log("populate() hash find failed");
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_NO_INSTANCE;
|
2024-07-04 14:33:44 +00:00
|
|
|
}
|
2024-05-24 13:20:30 +00:00
|
|
|
|
|
|
|
const struct bgp_proto *bgp_proto;
|
|
|
|
*proto = bgp_proto = pe->bgp_proto;
|
2024-07-04 14:33:44 +00:00
|
|
|
if (!ipa_is_ip4(bgp_proto->remote_ip))
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
log(L_ERR "%s: Found BGP protocol instance with IPv6 address", bgp_proto->p.name);
|
|
|
|
d->c->error = AGENTX_RES_GEN_ERROR;
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_NO_INSTANCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ip4_addr proto_ip = ipa_to_ip4(bgp_proto->remote_ip);
|
|
|
|
if (!ip4_equal(proto_ip, pe->peer_ip))
|
|
|
|
{
|
|
|
|
/* Here, we could be in problem as the bgp_proto IP address could be changed */
|
2024-07-04 14:33:44 +00:00
|
|
|
log(L_ERR "%s: Stored hash key IP address and peer remote address differ "
|
|
|
|
"(%I, %I).", bgp_proto->p.name, proto_ip, pe->peer_ip);
|
|
|
|
d->c->error = AGENTX_RES_GEN_ERROR;
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_NO_INSTANCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*conn = bgp_proto->conn;
|
|
|
|
*stats = &bgp_proto->stats;
|
|
|
|
*config = bgp_proto->cf;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("populate() ok");
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_bgp_version(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill ver");
|
2024-07-09 14:30:04 +00:00
|
|
|
if (LOAD_U8(d->c->sr_vb_start->name.n_subid) != 3)
|
|
|
|
return SNMP_SEARCH_NO_INSTANCE;
|
2024-07-04 14:33:44 +00:00
|
|
|
d->c->size -= snmp_str_size_from_len(1);
|
|
|
|
snmp_varbind_nstr(d->c, BGP4_VERSIONS, 1);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_local_as(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill as");
|
2024-07-09 14:30:04 +00:00
|
|
|
if (LOAD_U8(d->c->sr_vb_start->name.n_subid) != 3)
|
|
|
|
return SNMP_SEARCH_NO_INSTANCE;
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, d->p->bgp_local_as);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_peer_id(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill peer id");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
uint fsm_state = snmp_bgp_fsm_state(bgp_proto);
|
|
|
|
|
|
|
|
if (fsm_state == BGP4_MIB_OPENCONFIRM || fsm_state == BGP4_MIB_ESTABLISHED)
|
|
|
|
// TODO last
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_ip4(d->c, ip4_from_u32(bgp_proto->remote_id));
|
2024-05-24 13:20:30 +00:00
|
|
|
else
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_ip4(d->c, IP4_NONE);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_peer_state(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill peer state");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
uint fsm_state = snmp_bgp_fsm_state(bgp_proto);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, fsm_state);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_admin_status(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill adm status");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
if (bgp_proto->p.disabled)
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, AGENTX_ADMIN_STOP);
|
2024-05-24 13:20:30 +00:00
|
|
|
else
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, AGENTX_ADMIN_START);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_neg_version(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill neg ver");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
uint fsm_state = snmp_bgp_fsm_state(bgp_proto);
|
|
|
|
|
|
|
|
if (fsm_state == BGP4_MIB_ESTABLISHED || fsm_state == BGP4_MIB_ESTABLISHED)
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, BGP4_MIB_NEGOTIATED_VER_VALUE);
|
2024-05-24 13:20:30 +00:00
|
|
|
else
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, BGP4_MIB_NEGOTIATED_VER_NO_VALUE);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_local_addr(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("bgp4_mib fill local addr");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
2024-07-04 14:33:44 +00:00
|
|
|
|
|
|
|
snmp_log("fill local addr result %u", res);
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_ip4(d->c, ipa_to_ip4(bgp_proto->local_ip));
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_local_port(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("bgp4_mib fill local port");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, bgp_conf->local_port);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_remote_addr(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("bgp4_mib fill remote addr");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_ip4(d->c, ipa_to_ip4(bgp_proto->remote_ip));
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_remote_port(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("bgp4_mib fill remote port");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, bgp_conf->remote_port);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_remote_as(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill rem as");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, bgp_proto->remote_as);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_in_updates(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill in updates");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_counter32(d->c, bgp_stats->rx_updates);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_out_updates(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill out updates");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_counter32(d->c, bgp_stats->tx_updates);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_in_total_msg(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill in total");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_counter32(d->c, bgp_stats->rx_messages);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_out_total_msg(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill out total");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_counter32(d->c, bgp_stats->tx_messages);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_last_err(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill last err");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
char last_error[2];
|
|
|
|
snmp_bgp_last_error(bgp_proto, last_error);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_nstr(d->c, last_error, 2);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_established_trans(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill est trans");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_counter32(d->c,
|
2024-05-24 13:20:30 +00:00
|
|
|
bgp_stats->fsm_established_transitions);
|
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_established_time(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill est time");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_gauge32(d->c,
|
2024-05-24 13:20:30 +00:00
|
|
|
(current_time() - bgp_proto->last_established) TO_S);
|
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_retry_interval(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill retry int");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, bgp_conf->connect_retry_time);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_hold_time(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill hold time");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, (bgp_conn) ? bgp_conn->hold_time : 0);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_keep_alive(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill keepalive");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
if (!bgp_conf->hold_time)
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, 0);
|
2024-05-24 13:20:30 +00:00
|
|
|
else
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c,
|
2024-05-24 13:20:30 +00:00
|
|
|
(bgp_conn) ? bgp_conn->keepalive_time : 0);
|
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_hold_time_conf(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill hold time c");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, bgp_conf->hold_time);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_keep_alive_conf(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill keepalive c");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
|
|
|
|
if (!bgp_conf->keepalive_time)
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, 0);
|
2024-05-24 13:20:30 +00:00
|
|
|
else
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c,
|
2024-05-24 13:20:30 +00:00
|
|
|
(bgp_conn) ? bgp_conn->keepalive_time : 0);
|
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_min_as_org_interval(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill min org int");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
/* value should be in 1..65535 but is not supported by bird */
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, 0);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_route_adv_interval(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fill rt adv int");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
/* value should be in 1..65535 but is not supported by bird */
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_int(d->c, 0);
|
2024-05-24 13:20:30 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum snmp_search_res
|
2024-07-04 14:33:44 +00:00
|
|
|
fill_in_update_elapsed_time(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_log("fil in elapsed");
|
2024-05-24 13:20:30 +00:00
|
|
|
enum snmp_search_res res;
|
|
|
|
DECLARE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
res = POPULATE_BGP4(addr, bgp_proto, bgp_conn, bgp_stats, bgp_conf);
|
|
|
|
if (res != SNMP_SEARCH_OK)
|
|
|
|
return res;
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_gauge32(d->c,
|
2024-05-24 13:20:30 +00:00
|
|
|
(current_time() - bgp_proto->last_rx_update) TO_S
|
|
|
|
);
|
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
static enum snmp_search_res
|
|
|
|
fill_local_id(struct mib_walk_state *walk UNUSED, struct snmp_data *d)
|
|
|
|
{
|
|
|
|
snmp_log("fill local id");
|
2024-07-09 14:30:04 +00:00
|
|
|
if (LOAD_U8(d->c->sr_vb_start->name.n_subid) != 3)
|
|
|
|
return SNMP_SEARCH_NO_INSTANCE;
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_varbind_ip4(d->c, d->p->bgp_local_id);
|
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
2022-11-05 15:29:00 +00:00
|
|
|
static struct oid *
|
2024-04-22 10:55:33 +00:00
|
|
|
update_bgp_vb(struct snmp_proto *p, struct agentx_varbind **vb, u8 state, struct snmp_pdu *c)
|
2022-11-05 15:29:00 +00:00
|
|
|
{
|
2024-04-22 10:55:33 +00:00
|
|
|
struct oid *oid = &(*vb)->name;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state == BGP4_MIB_S_END || state == BGP4_MIB_S_INVALID ||
|
|
|
|
state == BGP4_MIB_S_NO_VALUE)
|
2024-04-22 10:55:33 +00:00
|
|
|
return &(*vb)->name;
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2023-09-04 07:25:51 +00:00
|
|
|
/* No need to reallocate anything if the OID has same lin. state */
|
2022-11-05 15:29:00 +00:00
|
|
|
if (snmp_bgp_state(oid) == state)
|
2023-07-26 12:02:23 +00:00
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state >= BGP4_MIB_S_PEER_IDENTIFIER &&
|
|
|
|
state <= BGP4_MIB_S_IN_UPDATE_ELAPSED_TIME &&
|
2023-07-26 12:02:23 +00:00
|
|
|
oid->n_subid == 9)
|
|
|
|
return oid;
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state >= BGP4_MIB_S_VERSION &&
|
|
|
|
state <= BGP4_MIB_S_PEER_TABLE && oid->n_subid == 3)
|
2023-07-26 12:02:23 +00:00
|
|
|
return oid;
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state == BGP4_MIB_S_PEER_ENTRY && oid->n_subid == 4)
|
2023-07-26 12:02:23 +00:00
|
|
|
return oid;
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state == BGP4_MIB_S_BGP && oid->n_subid == 2)
|
2023-07-26 12:02:23 +00:00
|
|
|
return oid;
|
|
|
|
}
|
2022-11-05 15:29:00 +00:00
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_BGP:
|
2023-08-08 19:51:38 +00:00
|
|
|
/* This could potentially destroy same old data */
|
2023-07-26 12:02:23 +00:00
|
|
|
if (oid->n_subid != 2)
|
2024-04-22 10:55:33 +00:00
|
|
|
oid = snmp_varbind_set_name_len(p, vb, 2, c);
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2023-08-08 19:51:38 +00:00
|
|
|
oid->ids[0] = SNMP_MIB_2;
|
2024-01-23 23:23:31 +00:00
|
|
|
oid->ids[1] = BGP4_MIB;
|
2022-11-05 15:29:00 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_VERSION:
|
2023-07-26 12:02:23 +00:00
|
|
|
if (oid->n_subid != 3)
|
2024-04-22 10:55:33 +00:00
|
|
|
oid = snmp_varbind_set_name_len(p, vb, 3, c);
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
oid->ids[2] = BGP4_MIB_VERSION;
|
2022-11-05 15:29:00 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_LOCAL_AS:
|
2023-07-26 12:02:23 +00:00
|
|
|
if (oid->n_subid != 3)
|
2024-04-22 10:55:33 +00:00
|
|
|
oid =snmp_varbind_set_name_len(p, vb, 3, c);
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
oid->ids[2] = BGP4_MIB_LOCAL_AS;
|
2022-11-05 15:29:00 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_PEER_IDENTIFIER:
|
2023-07-26 12:02:23 +00:00
|
|
|
if (oid->n_subid != 9)
|
|
|
|
{
|
2024-04-22 10:55:33 +00:00
|
|
|
u8 n_subid = LOAD_U8(oid->n_subid);
|
|
|
|
oid = snmp_varbind_set_name_len(p, vb, 9, c);
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2024-04-22 10:55:33 +00:00
|
|
|
if (n_subid < 6)
|
2023-07-26 12:02:23 +00:00
|
|
|
oid->ids[5] = 0;
|
2024-04-22 10:55:33 +00:00
|
|
|
if (n_subid < 7)
|
2023-07-26 12:02:23 +00:00
|
|
|
oid->ids[6] = 0;
|
2024-04-22 10:55:33 +00:00
|
|
|
if (n_subid < 8)
|
2023-07-26 12:02:23 +00:00
|
|
|
oid->ids[7] = 0;
|
2024-04-22 10:55:33 +00:00
|
|
|
if (n_subid < 9)
|
2023-07-26 12:02:23 +00:00
|
|
|
oid->ids[8] = 0;
|
|
|
|
}
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
oid->ids[2] = BGP4_MIB_PEER_TABLE;
|
|
|
|
oid->ids[3] = BGP4_MIB_PEER_ENTRY;
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
oid->ids[4] = BGP4_MIB_PEER_IDENTIFIER;
|
2022-11-05 15:29:00 +00:00
|
|
|
break;
|
|
|
|
|
2023-07-26 12:02:23 +00:00
|
|
|
#define SNMP_UPDATE_CASE(num, update) \
|
|
|
|
case num: \
|
|
|
|
if (oid->n_subid != 9) \
|
|
|
|
{ \
|
2024-04-22 10:55:33 +00:00
|
|
|
u8 n_subid = LOAD_U8(oid->n_subid); \
|
|
|
|
oid = snmp_varbind_set_name_len(p, vb, 9, c); \
|
2023-07-26 12:02:23 +00:00
|
|
|
\
|
2024-04-22 10:55:33 +00:00
|
|
|
if (n_subid < 6) \
|
2023-07-26 12:02:23 +00:00
|
|
|
oid->ids[5] = 0; \
|
2024-04-22 10:55:33 +00:00
|
|
|
if (n_subid < 7) \
|
2023-07-26 12:02:23 +00:00
|
|
|
oid->ids[6] = 0; \
|
2024-04-22 10:55:33 +00:00
|
|
|
if (n_subid < 8) \
|
2023-07-26 12:02:23 +00:00
|
|
|
oid->ids[7] = 0; \
|
2024-04-22 10:55:33 +00:00
|
|
|
if (n_subid < 9) \
|
2023-07-26 12:02:23 +00:00
|
|
|
oid->ids[8] = 0; \
|
|
|
|
} \
|
2024-04-22 10:55:33 +00:00
|
|
|
\
|
2023-07-26 12:02:23 +00:00
|
|
|
oid->n_subid = 9; \
|
|
|
|
oid->ids[4] = update; \
|
2022-11-05 15:29:00 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_STATE, BGP4_MIB_STATE)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_ADMIN_STATUS, BGP4_MIB_ADMIN_STATUS)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_NEGOTIATED_VERSION, BGP4_MIB_NEGOTIATED_VERSION)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_LOCAL_ADDR, BGP4_MIB_LOCAL_ADDR)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_LOCAL_PORT, BGP4_MIB_LOCAL_PORT)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_REMOTE_ADDR, BGP4_MIB_REMOTE_ADDR)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_REMOTE_PORT, BGP4_MIB_REMOTE_PORT)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_REMOTE_AS, BGP4_MIB_REMOTE_AS)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_RX_UPDATES, BGP4_MIB_RX_UPDATES)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_TX_UPDATES, BGP4_MIB_TX_UPDATES)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_RX_MESSAGES, BGP4_MIB_RX_MESSAGES)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_TX_MESSAGES, BGP4_MIB_TX_MESSAGES)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_LAST_ERROR, BGP4_MIB_LAST_ERROR)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_FSM_TRANSITIONS, BGP4_MIB_FSM_TRANSITIONS)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_FSM_ESTABLISHED_TIME, BGP4_MIB_FSM_ESTABLISHED_TIME)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_RETRY_INTERVAL, BGP4_MIB_RETRY_INTERVAL)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_HOLD_TIME, BGP4_MIB_HOLD_TIME)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_KEEPALIVE, BGP4_MIB_KEEPALIVE)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_HOLD_TIME_CONFIGURED, BGP4_MIB_HOLD_TIME_CONFIGURED)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_KEEPALIVE_CONFIGURED, BGP4_MIB_KEEPALIVE_CONFIGURED)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_ORIGINATION_INTERVAL, BGP4_MIB_ORIGINATION_INTERVAL)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_MIN_ROUTE_ADVERTISEMENT, BGP4_MIB_MIN_ROUTE_ADVERTISEMENT)
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
SNMP_UPDATE_CASE(BGP4_MIB_S_IN_UPDATE_ELAPSED_TIME, BGP4_MIB_IN_UPDATE_ELAPSED_TIME)
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_IDENTIFIER:
|
2023-10-11 08:44:18 +00:00
|
|
|
if (oid->n_subid != 3)
|
2024-04-22 10:55:33 +00:00
|
|
|
oid = snmp_varbind_set_name_len(p, vb, 3, c);
|
2023-10-11 08:44:18 +00:00
|
|
|
|
|
|
|
oid->n_subid = 3;
|
|
|
|
oid->ids[2] = 4;
|
|
|
|
break;
|
|
|
|
|
2023-07-26 12:02:23 +00:00
|
|
|
default:
|
2023-08-08 19:51:38 +00:00
|
|
|
/* intentionally left blank */
|
|
|
|
break;
|
2022-11-05 15:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return oid;
|
|
|
|
#undef SNMP_UPDATE_CASE
|
|
|
|
}
|
|
|
|
|
2024-04-22 10:55:33 +00:00
|
|
|
|
2023-07-26 12:02:23 +00:00
|
|
|
/**
|
|
|
|
* snmp_bgp_find_next_oid - walk bgp peer addresses and update @o_start oid
|
|
|
|
*
|
|
|
|
* @p:
|
|
|
|
* @oid:
|
|
|
|
* @contid:
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
snmp_bgp_find_next_oid(struct snmp_proto *p, struct oid *oid, uint UNUSED contid)
|
|
|
|
{
|
|
|
|
ip4_addr ip4 = ip4_from_oid(oid);
|
|
|
|
|
|
|
|
net_addr net;
|
|
|
|
net_fill_ip4(&net, ip4, IP4_MAX_PREFIX_LENGTH);
|
|
|
|
struct f_trie_walk_state ws;
|
|
|
|
|
|
|
|
int match = trie_walk_init(&ws, p->bgp_trie, &net, 1);
|
|
|
|
|
|
|
|
if (match && oid->include)
|
|
|
|
{
|
|
|
|
oid->include = 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We skip the first match as we should not include ip address in oid */
|
|
|
|
if (match)
|
|
|
|
{
|
|
|
|
trie_walk_next(&ws, &net);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trie_walk_next(&ws, &net))
|
|
|
|
{
|
|
|
|
ASSUME(oid->n_subid == 9);
|
2024-01-23 23:23:31 +00:00
|
|
|
ip4_addr res = ipa_to_ip4(net_prefix(&net));
|
|
|
|
ip4_to_oid(oid, res);
|
2023-07-26 12:02:23 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-04-22 10:55:33 +00:00
|
|
|
static enum snmp_search_res UNUSED
|
|
|
|
snmp_bgp_search_dynamic(struct snmp_proto *p, struct oid **searched, const struct oid *o_end, uint UNUSED contid, u8 next_state, struct snmp_pdu *c)
|
2023-07-26 12:02:23 +00:00
|
|
|
{
|
|
|
|
struct oid *oid = *searched;
|
2024-01-23 23:23:31 +00:00
|
|
|
u8 end_state = MIN(snmp_bgp_state(o_end), BGP4_MIB_S_PEER_TABLE_END);
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
ASSUME(end_state <= BGP4_MIB_S_END);
|
2023-07-26 12:02:23 +00:00
|
|
|
ASSUME(oid != NULL);
|
|
|
|
|
2024-04-22 10:55:33 +00:00
|
|
|
// TODO TODO remove me
|
|
|
|
struct agentx_varbind data = { 0 };
|
|
|
|
struct agentx_varbind *vb = &data;
|
|
|
|
|
|
|
|
oid = update_bgp_vb(p, &vb, next_state, c);
|
|
|
|
//oid = update_bgp_oid(oid, next_state);
|
2023-07-26 12:02:23 +00:00
|
|
|
|
|
|
|
int found;
|
|
|
|
while (!(found = snmp_bgp_find_next_oid(p, oid, contid)) && next_state <= end_state)
|
|
|
|
{
|
|
|
|
next_state = snmp_bgp_next_state(next_state);
|
2024-01-23 23:23:31 +00:00
|
|
|
if (next_state == BGP4_MIB_S_IDENTIFIER)
|
2023-07-26 12:02:23 +00:00
|
|
|
break;
|
2024-04-22 10:55:33 +00:00
|
|
|
//oid = update_bgp_oid(oid, next_state);
|
|
|
|
oid = update_bgp_vb(p, &vb, next_state, c);
|
2023-08-08 19:51:38 +00:00
|
|
|
/* In case of search for next bgp state, we want to start from beginning. */
|
2023-07-26 12:02:23 +00:00
|
|
|
oid->ids[5] = oid->ids[6] = oid->ids[7] = oid->ids[8] = 0;
|
|
|
|
}
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
if (next_state < BGP4_MIB_S_PEER_TABLE_END && next_state <= end_state)
|
2023-07-26 12:02:23 +00:00
|
|
|
{
|
|
|
|
*searched = oid;
|
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SNMP_SEARCH_END_OF_VIEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum snmp_search_res
|
2024-04-22 10:55:33 +00:00
|
|
|
snmp_bgp_search(struct snmp_proto *p, struct agentx_varbind **vb_search, const struct oid *o_end, struct snmp_pdu *c)
|
2023-07-26 12:02:23 +00:00
|
|
|
{
|
2024-04-22 10:55:33 +00:00
|
|
|
(void)p;
|
|
|
|
(void)vb_search;
|
|
|
|
(void)o_end;
|
|
|
|
(void)c;
|
|
|
|
return SNMP_SEARCH_END_OF_VIEW;
|
|
|
|
#if 0
|
2023-10-11 08:44:18 +00:00
|
|
|
enum snmp_search_res r = SNMP_SEARCH_END_OF_VIEW;
|
2023-07-26 12:02:23 +00:00
|
|
|
u8 bgp_state = snmp_bgp_state(*searched);
|
2023-10-11 08:44:18 +00:00
|
|
|
u8 state;
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
if (bgp_state == BGP4_MIB_S_END)
|
2023-09-04 07:25:51 +00:00
|
|
|
{
|
|
|
|
return SNMP_SEARCH_NO_OBJECT;
|
|
|
|
}
|
|
|
|
|
2023-10-11 08:44:18 +00:00
|
|
|
if (is_static(bgp_state) && (*searched)->include)
|
2023-07-26 12:02:23 +00:00
|
|
|
{
|
2023-10-11 08:44:18 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
2023-07-26 12:02:23 +00:00
|
|
|
}
|
|
|
|
|
2023-10-11 08:44:18 +00:00
|
|
|
state = snmp_bgp_next_state(bgp_state);
|
|
|
|
if (is_static(state) && !is_dynamic(bgp_state))
|
2023-07-26 12:02:23 +00:00
|
|
|
{
|
2023-10-11 08:44:18 +00:00
|
|
|
*searched = update_bgp_oid(*searched, state);
|
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2023-10-11 08:44:18 +00:00
|
|
|
if (is_dynamic(state) && !is_dynamic(bgp_state))
|
|
|
|
{
|
|
|
|
for (uint i = 5; i < MIN(9, (*searched)->n_subid); i++)
|
|
|
|
(*searched)->ids[i] = 0;
|
|
|
|
r = snmp_bgp_search_dynamic(p, searched, o_end, contid, state);
|
|
|
|
if (r != SNMP_SEARCH_END_OF_VIEW)
|
|
|
|
return r;
|
2023-07-26 12:02:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_dynamic(bgp_state))
|
|
|
|
{
|
2023-10-11 08:44:18 +00:00
|
|
|
r = snmp_bgp_search_dynamic(p, searched, o_end, contid, bgp_state);
|
|
|
|
|
|
|
|
if (r != SNMP_SEARCH_END_OF_VIEW)
|
|
|
|
return r;
|
2023-07-26 12:02:23 +00:00
|
|
|
}
|
|
|
|
|
2023-10-11 08:44:18 +00:00
|
|
|
state = snmp_bgp_next_state(bgp_state);
|
2024-01-23 23:23:31 +00:00
|
|
|
if (state <= BGP4_MIB_S_IDENTIFIER)
|
2023-07-26 12:02:23 +00:00
|
|
|
{
|
2023-10-11 08:44:18 +00:00
|
|
|
*searched = update_bgp_oid(*searched, state);
|
2023-07-26 12:02:23 +00:00
|
|
|
return SNMP_SEARCH_OK;
|
|
|
|
}
|
|
|
|
|
2023-10-11 08:44:18 +00:00
|
|
|
// TODO add route table
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2023-10-11 08:44:18 +00:00
|
|
|
/* end not found */
|
2023-07-26 12:02:23 +00:00
|
|
|
return SNMP_SEARCH_END_OF_VIEW;
|
2024-04-22 10:55:33 +00:00
|
|
|
#endif
|
2023-07-26 12:02:23 +00:00
|
|
|
}
|
|
|
|
|
2024-04-22 10:55:33 +00:00
|
|
|
static void
|
|
|
|
bgp_fill_dynamic(struct snmp_proto *p, struct agentx_varbind **vb, struct snmp_pdu *c, u8 state)
|
2022-11-15 15:29:03 +00:00
|
|
|
{
|
2024-04-22 10:55:33 +00:00
|
|
|
struct oid *oid = &(*vb)->name;
|
|
|
|
//byte *pkt;
|
2022-11-15 15:29:03 +00:00
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
ip4_addr addr;
|
2023-07-26 12:02:23 +00:00
|
|
|
if (oid_state_compare(oid, state) == 0 && snmp_bgp_valid_ip4(oid))
|
2023-11-15 14:03:55 +00:00
|
|
|
addr = ip4_from_oid(oid);
|
2022-11-15 15:29:03 +00:00
|
|
|
else
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
|
|
|
snmp_set_varbind_type(*vb, AGENTX_NO_SUCH_INSTANCE);
|
|
|
|
return;
|
|
|
|
}
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
struct snmp_bgp_peer *pe = snmp_hash_find(p, addr);
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
if (!pe)
|
2024-05-24 13:20:30 +00:00
|
|
|
{
|
|
|
|
snmp_set_varbind_type(*vb, AGENTX_NO_SUCH_INSTANCE);
|
|
|
|
return;
|
|
|
|
}
|
2023-11-15 14:03:55 +00:00
|
|
|
|
|
|
|
const struct bgp_proto *bgp_proto = pe->bgp_proto;
|
|
|
|
if (!ipa_is_ip4(bgp_proto->remote_ip))
|
|
|
|
{
|
|
|
|
log(L_ERR, "%s: Found BGP protocol instance with IPv6 address", bgp_proto->p.name);
|
|
|
|
c->error = AGENTX_RES_GEN_ERROR;
|
2024-05-24 13:20:30 +00:00
|
|
|
snmp_set_varbind_type(*vb, AGENTX_NO_SUCH_INSTANCE);
|
|
|
|
return;
|
2023-11-15 14:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ip4_addr proto_ip = ipa_to_ip4(bgp_proto->remote_ip);
|
|
|
|
if (!ip4_equal(proto_ip, pe->peer_ip))
|
2022-11-19 22:00:02 +00:00
|
|
|
{
|
2023-11-15 14:03:55 +00:00
|
|
|
/* Here, we could be in problem as the bgp_proto IP address could be changed */
|
|
|
|
log(L_ERR, "%s: Stored hash key IP address and peer remote address differ.",
|
|
|
|
bgp_proto->p.name);
|
|
|
|
c->error = AGENTX_RES_GEN_ERROR;
|
2024-05-24 13:20:30 +00:00
|
|
|
snmp_set_varbind_type(*vb, AGENTX_NO_SUCH_INSTANCE);
|
|
|
|
return;
|
2022-11-19 22:00:02 +00:00
|
|
|
}
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
//const struct bgp_conn *bgp_conn = bgp_proto->conn;
|
|
|
|
//const struct bgp_stats *bgp_stats = &bgp_proto->stats;
|
2022-11-15 15:29:03 +00:00
|
|
|
const struct bgp_config *bgp_conf = bgp_proto->cf;
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-10 11:21:46 +00:00
|
|
|
uint fsm_state = snmp_bgp_fsm_state(bgp_proto);
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
char last_error[2];
|
|
|
|
snmp_bgp_last_error(bgp_proto, last_error);
|
2024-04-22 10:55:33 +00:00
|
|
|
|
|
|
|
snmp_set_varbind_type(*vb, AGENTX_NO_SUCH_INSTANCE);
|
2022-11-15 15:29:03 +00:00
|
|
|
switch (state)
|
2022-11-05 15:29:00 +00:00
|
|
|
{
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_PEER_IDENTIFIER:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_IP4_SIZE)
|
2024-07-04 14:33:44 +00:00
|
|
|
{
|
|
|
|
snmp_log("BGP4-MIB small buffer");
|
2024-05-24 13:20:30 +00:00
|
|
|
snmp_manage_tbuf(p, c);
|
2024-07-04 14:33:44 +00:00
|
|
|
}
|
2024-04-22 10:55:33 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
if (fsm_state == BGP4_MIB_OPENCONFIRM || fsm_state == BGP4_MIB_ESTABLISHED)
|
2024-04-22 10:55:33 +00:00
|
|
|
// TODO last
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_ip4(*vb, c, ip4_from_u32(bgp_proto->remote_id));
|
2022-11-15 15:29:03 +00:00
|
|
|
else
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_ip4(*vb, c, IP4_NONE);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_STATE:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
2024-07-04 14:33:44 +00:00
|
|
|
{
|
|
|
|
snmp_log("BGP4-MIB small buffer 2");
|
2024-05-24 13:20:30 +00:00
|
|
|
snmp_manage_tbuf(p, c);
|
2024-07-04 14:33:44 +00:00
|
|
|
}
|
2024-04-22 10:55:33 +00:00
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_int(*vb, c, fsm_state);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_ADMIN_STATUS:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
if (bgp_proto->p.disabled)
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_int(*vb, c, AGENTX_ADMIN_STOP);
|
2022-11-15 15:29:03 +00:00
|
|
|
else
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_int(*vb, c, AGENTX_ADMIN_START);
|
2022-11-15 15:29:03 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_NEGOTIATED_VERSION:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
uint fsm_state = snmp_bgp_fsm_state(bgp_proto);
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
if (fsm_state == BGP4_MIB_ESTABLISHED || fsm_state == BGP4_MIB_ESTABLISHED)
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_int(*vb, c, BGP4_MIB_NEGOTIATED_VER_VALUE);
|
2022-11-15 15:29:03 +00:00
|
|
|
else
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_int(*vb, c, BGP4_MIB_NEGOTIATED_VER_NO_VALUE);
|
2022-11-15 15:29:03 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_LOCAL_ADDR:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_IP4_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_ip4(*vb, c, ipa_to_ip4(bgp_proto->local_ip));
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_LOCAL_PORT:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_int(*vb, c, bgp_conf->local_port);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_REMOTE_ADDR:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_IP4_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_ip4(*vb, c, ipa_to_ip4(bgp_proto->remote_ip));
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_REMOTE_PORT:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_int(*vb, c, bgp_conf->remote_port);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_REMOTE_AS:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_int(*vb, c, bgp_proto->remote_as);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_RX_UPDATES: /* bgpPeerInUpdates */
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_COUNTER32_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_counter32(*vb, c, bgp_stats->rx_updates);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_TX_UPDATES: /* bgpPeerOutUpdate */
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_COUNTER32_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_counter32(*vb, c, bgp_stats->tx_updates);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_RX_MESSAGES: /* bgpPeerInTotalMessages */
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_COUNTER32_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_counter32(*vb, c, bgp_stats->rx_messages);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_TX_MESSAGES: /* bgpPeerOutTotalMessages */
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_COUNTER32_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_counter32(*vb, c, bgp_stats->tx_messages);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_LAST_ERROR:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < snmp_str_size_from_len(2))
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_nstr(*vb, c, last_error, 2);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_FSM_TRANSITIONS:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_COUNTER32_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_counter32(*vb, c,
|
|
|
|
// bgp_stats->fsm_established_transitions);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2023-03-24 14:01:35 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_FSM_ESTABLISHED_TIME:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_COUNTER32_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_gauge32(*vb, c,
|
|
|
|
// (current_time() - bgp_proto->last_established) TO_S);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2023-03-24 14:01:35 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_RETRY_INTERVAL: /* retry inverval value should be != 0 */
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_int(*vb, c, bgp_conf->connect_retry_time);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2023-03-24 14:01:35 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_HOLD_TIME: /* hold time should be == 0 or in 3..65535 */
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_int(*vb, c, (bgp_conn) ? bgp_conn->hold_time : 0);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2023-03-24 14:01:35 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_KEEPALIVE:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2023-08-08 17:45:50 +00:00
|
|
|
if (!bgp_conf->hold_time)
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_int(*vb, c, 0);
|
2023-08-08 17:45:50 +00:00
|
|
|
else
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_int(*vb, c,
|
2024-05-24 13:20:30 +00:00
|
|
|
// (bgp_conn) ? bgp_conn->keepalive_time : 0);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2023-03-24 14:01:35 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_HOLD_TIME_CONFIGURED:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_int(*vb, c, bgp_conf->hold_time);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_KEEPALIVE_CONFIGURED:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
|
|
|
|
2023-08-08 17:45:50 +00:00
|
|
|
if (!bgp_conf->keepalive_time)
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_int(*vb, c, 0);
|
2023-08-08 17:45:50 +00:00
|
|
|
else
|
2024-07-04 14:33:44 +00:00
|
|
|
{} //snmp_varbind_int(*vb, c,
|
2024-05-24 13:20:30 +00:00
|
|
|
// (bgp_conn) ? bgp_conn->keepalive_time : 0);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2023-03-24 14:01:35 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_ORIGINATION_INTERVAL:
|
|
|
|
/* value should be in 1..65535 but is not supported by bird */
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_int(*vb, c, 0);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_MIN_ROUTE_ADVERTISEMENT:
|
|
|
|
/* value should be in 1..65535 but is not supported by bird */
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_int(*vb, c, 0);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2023-03-24 14:01:35 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_IN_UPDATE_ELAPSED_TIME:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_gauge32(*vb, c,
|
|
|
|
//(current_time() - bgp_proto->last_rx_update) TO_S
|
|
|
|
//);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2023-03-24 14:01:35 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_END:
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_INVALID:
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_BGP:
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_PEER_TABLE:
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_PEER_ENTRY:
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_NO_VALUE:
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2022-11-05 15:29:00 +00:00
|
|
|
}
|
2022-11-15 15:29:03 +00:00
|
|
|
}
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2024-04-22 10:55:33 +00:00
|
|
|
void
|
|
|
|
bgp_fill_static(struct snmp_proto *p, struct agentx_varbind **vb, struct snmp_pdu *c, u8 state)
|
2022-11-15 15:29:03 +00:00
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
(void)p;
|
2024-04-22 10:55:33 +00:00
|
|
|
ASSUME(c->buffer == snmp_varbind_data(*vb));
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-04-22 10:55:33 +00:00
|
|
|
struct oid *oid = &(*vb)->name;
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2023-08-08 19:51:38 +00:00
|
|
|
/*
|
|
|
|
* snmp_bgp_state() check only prefix. To be sure on OID equivalence we need to
|
2022-11-15 15:29:03 +00:00
|
|
|
* compare the oid->n_subid length. All BGP static fields have same n_subid.
|
|
|
|
*/
|
2024-01-23 23:23:31 +00:00
|
|
|
if (oid_state_compare(oid, state) < 0 || state == BGP4_MIB_S_END)
|
2024-04-22 10:55:33 +00:00
|
|
|
snmp_set_varbind_type(*vb, AGENTX_NO_SUCH_OBJECT);
|
2023-07-26 12:02:23 +00:00
|
|
|
else if (oid_state_compare(oid, state) > 0)
|
2024-04-22 10:55:33 +00:00
|
|
|
snmp_set_varbind_type(*vb, AGENTX_NO_SUCH_INSTANCE);
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2022-11-15 15:29:03 +00:00
|
|
|
switch (state)
|
|
|
|
{
|
2024-04-22 10:55:33 +00:00
|
|
|
case BGP4_MIB_S_VERSION:;
|
|
|
|
uint sz = snmp_str_size_from_len(1);
|
|
|
|
if (c->size < sz)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
|
|
|
c->size -= sz;
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_nstr(*vb, c, BGP4_VERSIONS, 1);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2022-11-05 15:29:00 +00:00
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_LOCAL_AS:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_INT_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_int(*vb, c, p->bgp_local_as);
|
2023-10-11 08:44:18 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-23 23:23:31 +00:00
|
|
|
case BGP4_MIB_S_IDENTIFIER:
|
2024-04-22 10:55:33 +00:00
|
|
|
if (c->size < AGENTX_TYPE_IP4_SIZE)
|
|
|
|
SNMP_MANAGE_TBUF(p, vb, c);
|
|
|
|
|
2024-05-24 13:20:30 +00:00
|
|
|
//snmp_varbind_ip4(*vb, c, p->bgp_local_id);
|
2022-11-15 15:29:03 +00:00
|
|
|
break;
|
2022-11-19 22:00:02 +00:00
|
|
|
|
2023-07-26 12:02:23 +00:00
|
|
|
default:
|
2024-04-22 10:55:33 +00:00
|
|
|
snmp_set_varbind_type(*vb, AGENTX_NO_SUCH_OBJECT);
|
2023-07-26 12:02:23 +00:00
|
|
|
break;
|
2022-11-15 15:29:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-26 12:02:23 +00:00
|
|
|
void
|
2024-04-22 10:55:33 +00:00
|
|
|
snmp_bgp_fill(struct snmp_proto *p, struct agentx_varbind **vb, struct snmp_pdu *c)
|
2022-11-15 15:29:03 +00:00
|
|
|
{
|
2024-04-22 10:55:33 +00:00
|
|
|
ASSERT(vb != NULL);
|
|
|
|
u8 state = snmp_bgp_state(&((*vb)->name));
|
2022-11-15 15:29:03 +00:00
|
|
|
|
2023-10-11 08:44:18 +00:00
|
|
|
if (is_static(state))
|
2023-07-26 12:02:23 +00:00
|
|
|
{
|
2024-04-22 10:55:33 +00:00
|
|
|
bgp_fill_static(p, vb, c, state);
|
2023-07-26 12:02:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-11-15 15:29:03 +00:00
|
|
|
|
2023-10-11 08:44:18 +00:00
|
|
|
if (is_dynamic(state))
|
2022-11-15 15:29:03 +00:00
|
|
|
{
|
2024-04-22 10:55:33 +00:00
|
|
|
bgp_fill_dynamic(p, vb, c, state);
|
2023-07-26 12:02:23 +00:00
|
|
|
return;
|
2022-11-19 22:00:02 +00:00
|
|
|
}
|
2023-10-11 08:44:18 +00:00
|
|
|
|
2024-04-22 10:55:33 +00:00
|
|
|
snmp_set_varbind_type(*vb, AGENTX_NO_SUCH_OBJECT);
|
2022-08-02 14:04:25 +00:00
|
|
|
}
|
2023-07-26 12:02:23 +00:00
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
/*
|
|
|
|
* bgp4_next_peer
|
|
|
|
*/
|
|
|
|
static int UNUSED
|
|
|
|
bgp4_next_peer(struct mib_walk_state *state, struct snmp_data *data)
|
|
|
|
{
|
|
|
|
//struct agentx_varbind *vb = data->c->sr_vb_start;
|
|
|
|
struct oid *oid = &data->c->sr_vb_start->name;
|
|
|
|
|
|
|
|
/* BGP4-MIB::bgpPeerIdentifier */
|
|
|
|
STATIC_OID(9) bgp4_peer_id = {
|
|
|
|
.n_subid = 9,
|
|
|
|
.prefix = SNMP_MGMT,
|
|
|
|
.include = 0,
|
|
|
|
.reserved = 0,
|
|
|
|
.ids = { SNMP_MIB_2, BGP4_MIB,
|
|
|
|
BGP4_MIB_PEER_TABLE, BGP4_MIB_PEER_ENTRY, BGP4_MIB_PEER_IDENTIFIER,
|
|
|
|
/* IP4_NONE */ 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
2024-07-09 14:30:04 +00:00
|
|
|
ip4_addr ip4 = ip4_from_oid(oid);
|
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
const struct oid *peer_oid = (const struct oid *) &bgp4_peer_id;
|
|
|
|
|
2024-07-09 14:30:04 +00:00
|
|
|
int precise = 1;
|
|
|
|
if (LOAD_U8(oid->n_subid) > 9)
|
|
|
|
precise = 0;
|
2024-07-04 14:33:44 +00:00
|
|
|
|
2024-07-09 14:30:04 +00:00
|
|
|
if (LOAD_U8(oid->n_subid) != 9 || snmp_oid_compare(oid, peer_oid) < 0)
|
|
|
|
{
|
2024-07-04 14:33:44 +00:00
|
|
|
int old = snmp_oid_size(oid);
|
|
|
|
int new = snmp_oid_size(peer_oid);
|
|
|
|
|
|
|
|
if (new - old > 0 && (uint) new - old > data->c->size)
|
|
|
|
{
|
|
|
|
snmp_log("bgp4_next_peer small buffer");
|
|
|
|
snmp_manage_tbuf(data->p, data->c);
|
2024-07-09 14:30:04 +00:00
|
|
|
oid = &data->c->sr_vb_start->name; // TODO fix sr_vb_start in manage_tbuf
|
2024-07-04 14:33:44 +00:00
|
|
|
}
|
|
|
|
|
2024-07-09 14:30:04 +00:00
|
|
|
data->c->buffer += (new - old);
|
2024-07-04 14:33:44 +00:00
|
|
|
|
|
|
|
snmp_oid_copy(oid, peer_oid);
|
|
|
|
STORE_U8(oid->include, 1);
|
|
|
|
}
|
|
|
|
|
2024-07-09 14:30:04 +00:00
|
|
|
|
2024-07-04 14:33:44 +00:00
|
|
|
ASSUME(oid->n_subid == 9);
|
2024-07-09 14:30:04 +00:00
|
|
|
/* full path BGP4-MIB::bgpPeerEntry.x: .1.3.6.1.2.1.15.3.1.x
|
|
|
|
* index offset = ARRAY_SIZE(snmp_internet) + 1 <prefix> + 4 + 1 <identifier x> */
|
|
|
|
ASSUME(state->stack_pos > 10);
|
|
|
|
oid->ids[4] = state->stack[10]->empty.id;
|
2024-07-04 14:33:44 +00:00
|
|
|
|
|
|
|
net_addr net;
|
|
|
|
net_fill_ip4(&net, ip4, IP4_MAX_PREFIX_LENGTH);
|
|
|
|
struct f_trie_walk_state ws;
|
|
|
|
|
|
|
|
int match = trie_walk_init(&ws, data->p->bgp_trie, &net, 1);
|
|
|
|
|
2024-07-09 14:30:04 +00:00
|
|
|
if (match && LOAD_U8(oid->include) && precise)
|
2024-07-04 14:33:44 +00:00
|
|
|
{
|
|
|
|
STORE_U8(oid->include, 0);
|
|
|
|
ip4_to_oid(oid, ip4);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We skip the first match as we should not include ip address in oid */
|
|
|
|
if (match)
|
|
|
|
(void) trie_walk_next(&ws, &net);
|
|
|
|
|
|
|
|
if (trie_walk_next(&ws, &net))
|
|
|
|
{
|
|
|
|
ASSUME(oid->n_subid == 9);
|
|
|
|
ip4_addr res = ipa_to_ip4(net_prefix(&net));
|
|
|
|
ip4_to_oid(oid, res);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2023-11-15 14:03:55 +00:00
|
|
|
/*
|
|
|
|
* snmp_bgp_start - prepare BGP4-MIB
|
|
|
|
* @p - SNMP protocol instance holding memory pool
|
|
|
|
*
|
|
|
|
* This function create all runtime bindings to BGP procotol structures.
|
|
|
|
* It is gruaranteed that the BGP protocols exist.
|
|
|
|
*/
|
|
|
|
void
|
2024-07-04 14:33:44 +00:00
|
|
|
snmp_bgp4_start(struct snmp_proto *p)
|
2023-11-15 14:03:55 +00:00
|
|
|
{
|
|
|
|
struct snmp_config *cf = SKIP_BACK(struct snmp_config, cf, p->p.cf);
|
|
|
|
/* Create binding to BGP protocols */
|
|
|
|
|
|
|
|
struct snmp_bond *b;
|
|
|
|
WALK_LIST(b, cf->bgp_entries)
|
|
|
|
{
|
|
|
|
const struct bgp_config *bgp_config = (struct bgp_config *) b->config;
|
|
|
|
const struct bgp_proto *bgp = SKIP_BACK(struct bgp_proto, p,
|
|
|
|
bgp_config->c.proto);
|
|
|
|
|
|
|
|
struct snmp_bgp_peer *peer = \
|
|
|
|
mb_alloc(p->pool, sizeof(struct snmp_bgp_peer));
|
|
|
|
|
|
|
|
peer->bgp_proto = bgp;
|
|
|
|
peer->peer_ip = ipa_to_ip4(bgp->remote_ip);
|
|
|
|
|
|
|
|
struct net_addr net;
|
|
|
|
net_fill_ip4(&net, ipa_to_ip4(bgp->remote_ip), IP4_MAX_PREFIX_LENGTH);
|
|
|
|
trie_add_prefix(p->bgp_trie, &net, IP4_MAX_PREFIX_LENGTH,
|
|
|
|
IP4_MAX_PREFIX_LENGTH);
|
|
|
|
|
|
|
|
snmp_hash_add_peer(p, peer);
|
|
|
|
}
|
2024-07-04 14:33:44 +00:00
|
|
|
|
|
|
|
const STATIC_OID(2) bgp4_mib_root = {
|
|
|
|
.n_subid = 2,
|
|
|
|
.prefix = SNMP_MGMT,
|
|
|
|
.include = 0,
|
|
|
|
.reserved = 0,
|
|
|
|
.ids = { SNMP_MIB_2, BGP4_MIB },
|
|
|
|
};
|
|
|
|
|
|
|
|
const STATIC_OID(4) bgp4_mib_peer_entry = {
|
|
|
|
.n_subid = 4,
|
|
|
|
.prefix = SNMP_MGMT,
|
|
|
|
.include = 0,
|
|
|
|
.reserved = 0,
|
|
|
|
.ids = { SNMP_MIB_2, BGP4_MIB, BGP4_MIB_PEER_TABLE, BGP4_MIB_PEER_ENTRY },
|
|
|
|
};
|
|
|
|
|
|
|
|
(void) mib_tree_hint(p->pool, p->mib_tree,
|
|
|
|
(const struct oid *) &bgp4_mib_root, BGP4_MIB_IDENTIFIER);
|
|
|
|
(void) mib_tree_hint(p->pool, p->mib_tree,
|
|
|
|
(const struct oid *) &bgp4_mib_peer_entry, BGP4_MIB_IN_UPDATE_ELAPSED_TIME);
|
|
|
|
|
|
|
|
mib_node_u *node;
|
|
|
|
struct mib_leaf *leaf;
|
|
|
|
STATIC_OID(3) bgp4_var = {
|
|
|
|
.n_subid = 3,
|
|
|
|
.prefix = SNMP_MGMT,
|
|
|
|
.include = 0,
|
|
|
|
.reserved = 0,
|
|
|
|
.ids = { SNMP_MIB_2, BGP4_MIB, BGP4_MIB_VERSION },
|
|
|
|
};
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 id;
|
|
|
|
enum snmp_search_res (*filler)(struct mib_walk_state *state, struct snmp_data *data);
|
|
|
|
enum agentx_type type;
|
|
|
|
int size;
|
|
|
|
} leafs[] = {
|
|
|
|
{
|
|
|
|
.id = BGP4_MIB_VERSION,
|
|
|
|
.filler = fill_bgp_version,
|
|
|
|
.type = AGENTX_OCTET_STRING,
|
|
|
|
.size = snmp_str_size_from_len(sizeof(BGP4_VERSIONS)),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.id = BGP4_MIB_LOCAL_AS,
|
|
|
|
.filler = fill_local_as,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.id = BGP4_MIB_IDENTIFIER,
|
|
|
|
.filler = fill_local_id,
|
|
|
|
.type = AGENTX_IP_ADDRESS,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
for (uint i = 0; i < ARRAY_SIZE(leafs); i++)
|
|
|
|
{
|
|
|
|
bgp4_var.ids[ARRAY_SIZE(bgp4_var.ids) - 1] = leafs[i].id;
|
|
|
|
node = mib_tree_add(p->pool, p->mib_tree, (const struct oid *) &bgp4_var, 1);
|
|
|
|
|
|
|
|
ASSUME(mib_node_is_leaf(node));
|
|
|
|
leaf = &node->leaf;
|
|
|
|
|
|
|
|
leaf->filler = leafs[i].filler;
|
2024-07-09 14:30:04 +00:00
|
|
|
leaf->call_next = NULL;
|
2024-07-04 14:33:44 +00:00
|
|
|
leaf->type = leafs[i].type;
|
|
|
|
leaf->size = leafs[i].size;
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC_OID(5) bgp4_entry_var = {
|
|
|
|
.n_subid = 5,
|
|
|
|
.prefix = SNMP_MGMT,
|
|
|
|
.include = 0,
|
|
|
|
.reserved = 0,
|
|
|
|
.ids = { SNMP_MIB_2, BGP4_MIB,
|
|
|
|
BGP4_MIB_PEER_TABLE, BGP4_MIB_PEER_ENTRY, BGP4_MIB_PEER_IDENTIFIER },
|
|
|
|
};
|
|
|
|
|
|
|
|
struct {
|
|
|
|
enum snmp_search_res (*filler)(struct mib_walk_state *state, struct snmp_data *data);
|
|
|
|
enum agentx_type type;
|
|
|
|
int size;
|
|
|
|
} entry_leafs[] = {
|
|
|
|
[BGP4_MIB_PEER_IDENTIFIER] = {
|
|
|
|
.filler = fill_peer_id,
|
|
|
|
.type = AGENTX_IP_ADDRESS,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_STATE] = {
|
|
|
|
.filler = fill_peer_state,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_ADMIN_STATUS] = {
|
|
|
|
.filler = fill_admin_status,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_NEGOTIATED_VERSION] = {
|
|
|
|
.filler = fill_neg_version,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_LOCAL_ADDR] = {
|
|
|
|
.filler = fill_local_addr,
|
|
|
|
.type = AGENTX_IP_ADDRESS,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_LOCAL_PORT] = {
|
|
|
|
.filler = fill_local_port,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_REMOTE_ADDR] = {
|
|
|
|
.filler = fill_remote_addr,
|
|
|
|
.type = AGENTX_IP_ADDRESS,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_REMOTE_PORT] = {
|
|
|
|
.filler = fill_remote_port,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_REMOTE_AS] = {
|
|
|
|
.filler = fill_remote_as,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_RX_UPDATES] = {
|
|
|
|
.filler = fill_in_updates,
|
|
|
|
.type = AGENTX_COUNTER_32,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_TX_UPDATES] = {
|
|
|
|
.filler = fill_out_updates,
|
|
|
|
.type = AGENTX_COUNTER_32,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_RX_MESSAGES] = {
|
|
|
|
.filler = fill_in_total_msg,
|
|
|
|
.type = AGENTX_COUNTER_32,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_TX_MESSAGES] = {
|
|
|
|
.filler = fill_out_total_msg,
|
|
|
|
.type = AGENTX_COUNTER_32,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_LAST_ERROR] = {
|
|
|
|
.filler = fill_last_err,
|
|
|
|
.type = AGENTX_OCTET_STRING,
|
|
|
|
.size = snmp_str_size_from_len(2),
|
|
|
|
},
|
|
|
|
[BGP4_MIB_FSM_TRANSITIONS] = {
|
|
|
|
.filler = fill_established_trans,
|
|
|
|
.type = AGENTX_COUNTER_32,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_FSM_ESTABLISHED_TIME] = {
|
|
|
|
.filler = fill_established_time,
|
|
|
|
.type = AGENTX_GAUGE_32,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_RETRY_INTERVAL] = {
|
|
|
|
.filler = fill_retry_interval,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_HOLD_TIME] = {
|
|
|
|
.filler = fill_hold_time,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_KEEPALIVE] = {
|
|
|
|
.filler = fill_keep_alive,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_HOLD_TIME_CONFIGURED] = {
|
|
|
|
.filler = fill_hold_time_conf,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_KEEPALIVE_CONFIGURED] = {
|
|
|
|
.filler = fill_keep_alive_conf,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_ORIGINATION_INTERVAL] = {
|
|
|
|
.filler = fill_min_as_org_interval,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_MIN_ROUTE_ADVERTISEMENT] = {
|
|
|
|
.filler = fill_route_adv_interval,
|
|
|
|
.type = AGENTX_INTEGER,
|
|
|
|
},
|
|
|
|
[BGP4_MIB_IN_UPDATE_ELAPSED_TIME] = {
|
|
|
|
.filler = fill_in_update_elapsed_time,
|
|
|
|
.type = AGENTX_GAUGE_32,
|
|
|
|
},
|
|
|
|
}; /* struct _anon entry_leafs[] */
|
|
|
|
|
|
|
|
for (enum bgp4_mib_peer_entry_row e = BGP4_MIB_PEER_IDENTIFIER;
|
|
|
|
e <= BGP4_MIB_IN_UPDATE_ELAPSED_TIME; e++)
|
|
|
|
{
|
|
|
|
bgp4_entry_var.ids[ARRAY_SIZE(bgp4_entry_var.ids) - 1] = (u32) e;
|
|
|
|
node = mib_tree_add(p->pool, p->mib_tree, (const struct oid *) &bgp4_entry_var, 1);
|
|
|
|
|
|
|
|
ASSUME(mib_node_is_leaf(node));
|
|
|
|
leaf = &node->leaf;
|
|
|
|
|
|
|
|
leaf->filler = entry_leafs[e].filler;
|
|
|
|
leaf->call_next = bgp4_next_peer;
|
|
|
|
leaf->type = entry_leafs[e].type;
|
|
|
|
leaf->size = entry_leafs[e].size;
|
|
|
|
}
|
2023-11-15 14:03:55 +00:00
|
|
|
}
|