Bug 174974 - [patch] bsnmpd(8): bsnmpd SNMPv3 engine discovery is broken
Summary: [patch] bsnmpd(8): bsnmpd SNMPv3 engine discovery is broken
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Many People
Assignee: Bjoern A. Zeeb
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-04 16:20 UTC by pguyot
Modified: 2018-04-10 23:41 UTC (History)
5 users (show)

See Also:
emaste: mfc-stable11+
op: mfc-stable10?


Attachments
file.diff (1.04 KB, patch)
2013-01-04 16:20 UTC, pguyot
no flags Details | Diff
Patch to fix auto-discovery in snmpagent by setting the proper response type (525 bytes, patch)
2016-10-25 04:24 UTC, pguyot
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description pguyot 2013-01-04 16:20:00 UTC
bsnmpd apparently does not properly reply to discovery packets.

According to RFC3414 ยง 4, response to discovery packets should be of REPORT type. Instead, bsnmpd replies with packets of RESPONSE type. As a result, bsnmpd does not work with clients that require a Report PDU (or, more precisely, that validate that Response PDUs match the EngineID of the Request).

bsnmp* clients accept both types of responses and is therefore unaffected.

Fix: Attached patch fixes the problem by using the SNMP_MSG_AUTODISCOVER internal flag of bsnmp. Patch is designed as the minimum change to fix the issue. However, bsnmp implementation obviously does not match the layout of the RFC.

Also, compiling bsnmp with clang reveals several bad issues which should be fixed...

Patch attached with submission follows:
How-To-Repeat: Install net-snmp from ports.
Configure bsnmpd with SNMPv3 authentication.
Try to connect with net-snmp to the bsnmpd server.
Comment 1 Bjoern A. Zeeb freebsd_committer freebsd_triage 2014-07-27 12:01:59 UTC
Found and independently diagnosed during IETF90 by fenner,marcus,bz.

Neither mine nor this patch is a complete fix;  I'll commit a slightly more minimalistic version soon and we can take it from there.
Comment 2 Andrej Ota 2016-01-23 16:00:27 UTC
What is missing to make it a complete fix? Is there something or anything that whoever interested in getting this fixed shold do or look at to help speed the things along?
Comment 3 pguyot 2016-10-14 18:59:14 UTC
After every FreeBSD new release, I have to apply this patch, recompile and install bsnmp binaries for SNMP monitoring to work properly. It's been more than three years, and it's still the case with FreeBSD 11.

Is there anything that can be done to get this fix, or whatever complete version would be, committed to future releases of FreeBSD?
Comment 4 Bjoern A. Zeeb freebsd_committer freebsd_triage 2016-10-24 20:14:48 UTC
Hi,

why in snmpd/main.c do you need the extra
    pdu->flags |= SNMP_MSG_AUTODISCOVER;

Do you remember?  I couldn't find the need for it.  Is there a case when things fail for you without it?
Comment 5 Bjoern A. Zeeb freebsd_committer freebsd_triage 2016-10-24 20:16:47 UTC
(In reply to Bjoern A. Zeeb from comment #4)

And I should have added that it seems to me that snmp_pdu_auth_user() does it already for us way above all this.
Comment 6 pguyot 2016-10-25 04:24:45 UTC
Created attachment 176129 [details]
Patch to fix auto-discovery in snmpagent by setting the proper response type
Comment 7 pguyot 2016-10-25 04:28:48 UTC
(In reply to Bjoern A. Zeeb from comment #5)

Thank you for the review. Indeed, this line in main.c is useless, as you noted, the flag is already set. I do not remember why my initial patch included this line, and I believe it was initially superfluous.

With the regression fix you have just reviewed and the simplified patch I have uploaded, bsnmpd works as expected with my test case (simply an SNMPv3 authenticated snmpget).
Comment 8 commit-hook freebsd_committer freebsd_triage 2016-11-10 20:51:46 UTC
A commit references this bug:

Author: syrinx
Date: Thu Nov 10 20:51:26 UTC 2016
New revision: 308490
URL: https://svnweb.freebsd.org/changeset/base/308490

Log:
  Reply to a snmpEngineID discovery PDU with a Report PDU as per the
  requirements of RFC 3414 section 4.

  PR:	174974
  Submitted by:	pguyot@kallisys.net
  Reported by:	several people
  Reviewed by:	bz@

Changes:
  head/contrib/bsnmp/lib/snmpagent.c
Comment 9 commit-hook freebsd_committer freebsd_triage 2018-04-10 23:38:53 UTC
A commit references this bug:

Author: emaste
Date: Tue Apr 10 23:38:32 UTC 2018
New revision: 332397
URL: https://svnweb.freebsd.org/changeset/base/332397

Log:
  MFC r308490 by syrinx:

  Reply to a snmpEngineID discovery PDU with a Report PDU as per the
  requirements of RFC 3414 section 4.

  PR:		174974
  Submitted by:	pguyot@kallisys.net

Changes:
_U  stable/11/
  stable/11/contrib/bsnmp/lib/snmpagent.c
Comment 10 Ed Maste freebsd_committer freebsd_triage 2018-04-10 23:41:42 UTC
Now merged to stable/11, thank you for the submission.