buglwIP - A Lightweight TCP/IP stack - Bugs: bug #48342, SNMP Traps not working correct

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #48342: SNMP Traps not working correct

Submitted by:  Marco Veeneman <mave>
Submitted on:  Wed 29 Jun 2016 02:12:42 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Faulty BehaviourStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned Release: None
lwIP version: git head

Wed 29 Jun 2016 08:17:40 PM UTC, comment #1:

Thank you for your patch, Marco!

Dirk Ziegelmeier <dziegel>
Project Member
Wed 29 Jun 2016 02:12:42 PM UTC, original submission:

I found two issues regarding SNMP Traps.

1) When trying to receive some generic traps (coldstart(0), authenticationfailure(4)) i noticed the traps are received by my PC, but not in the trap server.
This had worked before the SNMP rewrite. Diving into the trap encoding functions and comparing wireshark captures i found the issue: the variable bindings field is missing in the trap message. Even if there are no varbinds attached to the trap, this field should still be present. See patch:

diff --git a/src/apps/snmp/snmp_traps.c b/src/apps/snmp/snmp_traps.c
index 3da2dca..528a054 100644
--- a/src/apps/snmp/snmp_traps.c
+++ b/src/apps/snmp/snmp_traps.c
@@ -247,6 +247,9 @@ snmp_trap_header_sum(struct snmp_msg_trap *trap)

tot_len = 0;

+ snmp_asn1_enc_length_cnt(0, &lenlen);
+ tot_len += 1 + lenlen;
+
snmp_asn1_enc_u32t_cnt(trap->ts, &len);
snmp_asn1_enc_length_cnt(len, &lenlen);
tot_len += 1 + len + lenlen;
@@ -359,6 +362,9 @@ snmp_trap_header_enc(struct snmp_msg_trap trap, struct snmp_pbuf_stream pbuf_s
snmp_asn1_enc_s32t_cnt(trap->ts, &tlv.value_len);
snmp_ans1_enc_tlv(pbuf_stream, &tlv);
snmp_asn1_enc_s32t(pbuf_stream, tlv.value_len, trap->ts);
+
+ SNMP_ASN1_SET_TLV_PARAMS(tlv, SNMP_ASN1_TYPE_SEQUENCE, 0, 0);
+ snmp_ans1_enc_tlv(pbuf_stream, &tlv);
}

#endif /* LWIP_SNMP */

2) Generic snmpv1 traps should be sent from .1.3.6.1.2.1.11 (iso.org.dod.internet.mgmt.mib-2.snmp).
Currently they are sent from the oid set to snmp_device_enterprise_oid because NULL is passed to snmp_send_trap from snmp_send_trap_generic. See patch:

diff --git a/src/apps/snmp/snmp_traps.c b/src/apps/snmp/snmp_traps.c
index 3da2dca..52ec101 100644
--- a/src/apps/snmp/snmp_traps.c
+++ b/src/apps/snmp/snmp_traps.c
@@ -207,7 +207,8 @@ snmp_send_trap(const struct snmp_obj_id *device_enterprise_oid, s32_t generic_tr
err_t
snmp_send_trap_generic(s32_t generic_trap)
{
- return snmp_send_trap(NULL, generic_trap, 0);
+ static const struct snmp_obj_id oid = { 7, { 1, 3, 6, 1, 2, 1, 11 } };
+ return snmp_send_trap(&oid, generic_trap, 0, NULL);
}

err_t

Marco Veeneman <mave>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by dziegel (Posted a comment)
  • -unavailable- added by mave (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 29 Jun 2016 08:17:40 PM UTCdziegelStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1