From: Vojtech Vilimek Date: Tue, 6 Dec 2022 15:32:26 +0000 (+0100) Subject: tmp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74c68fc89e2ef09eb380fbd10274c465690463da;p=thirdparty%2Fbird.git tmp --- diff --git a/proto/snmp/bgp_mib.c b/proto/snmp/bgp_mib.c index cb386950b..5be28da84 100644 --- a/proto/snmp/bgp_mib.c +++ b/proto/snmp/bgp_mib.c @@ -106,6 +106,67 @@ ip4_from_oid(const struct oid *o) o->ids[8]) : IP4_NONE; } +static void +print_bgp_record(struct bgp_config *config) +{ + struct proto_config *cf = (struct proto_config *) config; + struct proto *P = cf->proto; + struct bgp_proto *bgp_proto = (struct bgp_proto *) cf->proto; + struct bgp_conn *conn = bgp_proto->conn; + + log(L_INFO " name: %s", cf->name); + log(L_INFO ""); + log(L_INFO " rem. identifier: %u", bgp_proto->remote_id); + log(L_INFO " local ip: %I", config->local_ip); + log(L_INFO " remote ip: %I", config->remote_ip); + log(L_INFO " local port: %u", config->local_port); + log(L_INFO " remote port: %u", config->remote_port); + + // crashes ? + if (conn) { + log(L_INFO " state: %u", conn->state); + log(L_INFO " remote as: %u", conn->remote_caps->as4_number); + } + + + log(L_INFO " in updates: %u", bgp_proto->stats.rx_updates); + log(L_INFO " out updates: %u", bgp_proto->stats.tx_updates); + log(L_INFO " in total: %u", bgp_proto->stats.rx_messages); + log(L_INFO " out total: %u", bgp_proto->stats.tx_messages); + log(L_INFO " fsm transitions: %u", +bgp_proto->stats.fsm_established_transitions); + + // not supported yet + log(L_INFO " fsm total time: --"); + log(L_INFO " retry interval: %u", config->connect_retry_time); + + log(L_INFO " hold configurated: %u", config->hold_time ); + log(L_INFO " keep alive config: %u", config->keepalive_time ); + + // unknown + log(L_INFO " min AS origin. int.: --"); + log(L_INFO " min route advertisement: %u", 0 ); + log(L_INFO " in update elapsed time: %u", 0 ); + + if (!conn) + log(L_INFO " no connection established"); + + log(L_INFO " outgoinin_conn state %u", bgp_proto->outgoing_conn.state + 1); + log(L_INFO " incoming_conn state: %u", bgp_proto->incoming_conn.state + 1); + +} + +static void +print_bgp_record_all(struct snmp_proto *p) +{ + log(L_INFO "dumping watched bgp status"); + HASH_WALK(p->bgp_hash, next, peer) + { + print_bgp_record(peer->config); + } + HASH_WALK_END; +} + /** * snmp_bgp_state - linearize oid from BGP4-MIB * @oid: prefixed object identifier from BGP4-MIB::bgp subtree @@ -471,6 +532,11 @@ search_bgp_mib(struct snmp_proto *p, struct oid *o_start, struct oid *o_end, uin //u8 state_curr = snmp_bgp_state(o_start); //u8 state_end = (o_end) ? snmp_bgp_state(o_end) : 0; + + + // print debugging information + print_bgp_record_all(p); + if (o_start->include && snmp_bgp_has_value(start_state) && !is_dynamic(start_state) && o_start->n_subid == 3) { diff --git a/proto/snmp/snmp.c b/proto/snmp/snmp.c index eb517243a..72a82c443 100644 --- a/proto/snmp/snmp.c +++ b/proto/snmp/snmp.c @@ -66,7 +66,10 @@ snmp_startup_timeout(timer *t) static void snmp_startup(struct snmp_proto *p) { + p->state = SNMP_INIT; + /* starting agentX communicaiton channel */ + log(L_INFO "preparing lock"); struct object_lock *lock; log(L_INFO "snmp_startup() object lock state %p", p->lock); @@ -258,8 +261,8 @@ static void snmp_show_proto_info(struct proto *P) cli_msg(-1006, ""); cli_msg(-1006, " rem. identifier: %u", bp->remote_id); // learn more !! - cli_msg(-1006, " admin status: %s", (p->disabled) ? "start" : - "stop"); + 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); diff --git a/proto/snmp/snmp.h b/proto/snmp/snmp.h index ac2f01d6e..4b7978887 100644 --- a/proto/snmp/snmp.h +++ b/proto/snmp/snmp.h @@ -106,4 +106,6 @@ struct snmp_proto { uint errs; }; +#define snmp_log(x) log(L_INFO "snmp" x); + #endif diff --git a/proto/snmp/snmp_test.c b/proto/snmp/snmp_test.c index d6acda34c..2a54d6cf0 100644 --- a/proto/snmp/snmp_test.c +++ b/proto/snmp/snmp_test.c @@ -13,7 +13,6 @@ #include "subagent.h" #include "snmp.h" #include "snmp_utils.h" -#include "snmp_internal.h" #define SNMP_EXPECTED(actual, expected) \ bt_debug("%s expected: %3u actual: %3u\n", \ diff --git a/proto/snmp/snmp_utils.h b/proto/snmp/snmp_utils.h index 1d2136f3f..a1bd6df33 100644 --- a/proto/snmp/snmp_utils.h +++ b/proto/snmp/snmp_utils.h @@ -31,4 +31,5 @@ void snmp_oid_dump(struct oid *oid); int snmp_oid_compare(struct oid *left, struct oid *right); +struct oid *snmp_prefixize(struct snmp_proto *p, struct oid *o, int byte_ord); #endif diff --git a/proto/snmp/subagent.c b/proto/snmp/subagent.c index e4742e1ec..ffbb3f96e 100644 --- a/proto/snmp/subagent.c +++ b/proto/snmp/subagent.c @@ -13,8 +13,6 @@ #include "snmp_utils.h" #include "bgp_mib.h" -#include "snmp_internal.h" - /* ============================================================= * Problems * ------------------------------------------------------------