]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
tmp: minor changes
authorVojtech Vilimek <vojtech.vilimek@nic.cz>
Fri, 31 Mar 2023 07:56:39 +0000 (09:56 +0200)
committerVojtech Vilimek <vojtech.vilimek@nic.cz>
Fri, 31 Mar 2023 07:56:39 +0000 (09:56 +0200)
proto/snmp/bgp_mib.c
proto/snmp/bgp_mib.h

index 9a1ad601c7a58f44379f3f6fa512a2b85cc5cf98..12fe859ed91912e1aaa0c6a0ebea8a5ce617320f 100644 (file)
@@ -155,7 +155,7 @@ snmp_bgp_register(struct snmp_proto *p)
   */
 }
 
-int
+static int
 snmp_bgp_valid_ip4(struct oid *o)
 {
   return snmp_valid_ip4_index(o, 5);
@@ -204,7 +204,7 @@ static inline struct ip4_addr
 ip4_from_oid(const struct oid *o)
 {
   return (o->n_subid == 9) ? ip4_build(o->ids[5], o->ids[6], o->ids[7],
-o->ids[8]) : IP4_NONE;
+o->ids[8]) : ip4_from_u32(0xFFFFFFFF);
 }
 
 static void
@@ -390,7 +390,7 @@ snmp_bgp_has_value(u8 state)
  * @state: BGP linearized state
  *
  * Returns @state if has value in BGP4-MIB, zero otherwise. Used for Get-PDU
- * packets.
+ * ackets.
  */
 u8
 snmp_bgp_get_valid(u8 state)
@@ -571,6 +571,7 @@ bgp_find_dynamic_oid(struct snmp_proto *p, struct oid *o_start, struct oid *o_en
 {
   snmp_log("bgp_find_dynamic_oid()");
   ip4_addr ip4 = ip4_from_oid(o_start);
+  /* dest is 255.255.255.255 if o_end is empty */
   ip4_addr dest = ip4_from_oid(o_end);
 
   snmp_log("ip addresses build (ip4) %I (dest) %I", ipa_from_ip4(ip4), ipa_from_ip4(dest));
@@ -592,7 +593,12 @@ bgp_find_dynamic_oid(struct snmp_proto *p, struct oid *o_start, struct oid *o_en
   if (trie_walk_next(ws, net)) // && ip4_less(net4_prefix(net), dest))
   {
     snmp_log("trie_walk_next() returned true");
-    if (ip4_less(net4_prefix(net), dest))  // <- delete me
+
+    /*
+     * if the o_end is empty then there are no conditions on the ip4 addr
+     */
+    int cmp = ip4_compare(net4_prefix(net), dest);
+    if (cmp < 0 || (cmp == 0 && snmp_is_oid_empty(o_end)))
     {
       snmp_log("ip4_less() returned true");
       struct oid *o = mb_allocz(p->p.pool, snmp_oid_sizeof(9));
index 44c8a54116655e199d49401264ab50d7238ed86e..d2db74673d3499da622b9bf88ce9f23869a42002 100644 (file)
@@ -40,7 +40,7 @@ struct oid;
 void snmp_bgp_register(struct snmp_proto *p);
 // - int snmp_bgp_is_supported(struct oid *o);
 
-int snmp_bgp_valid_ip4(struct oid *o);
+//int snmp_bgp_valid_ip4(struct oid *o);
 u8 snmp_bgp_state(struct oid *o);
 u8 snmp_bgp_get_valid(u8 state);
 u8 snmp_bgp_getnext_valid(u8 state);