Bug 242056 - bsnmpd: ipv4 addresses in begemotSnmpdTransInetStatus table are reversed
Summary: bsnmpd: ipv4 addresses in begemotSnmpdTransInetStatus table are reversed
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Andrey V. Elsukov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-18 12:29 UTC by topical
Modified: 2019-11-26 02:52 UTC (History)
2 users (show)

See Also:


Attachments
Proposed patch (828 bytes, patch)
2019-11-19 09:44 UTC, Andrey V. Elsukov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description topical 2019-11-18 12:29:51 UTC
review D16654 replaced begemotSnmpdPortStatus with begemotSnmpdTransInetStatus to support ipv6.

With ipv4, addresses are reversed now, i.e. they must be both specified reversed and are shown reversed.

If you enable the following standard example line in /etc/snmpd.config

# UDP over IPv4: 127.0.0.1:161
# begemotSnmpdTransInetStatus.1.4.127.0.0.1.161.1 = 4

bsnmpd doesn't listen to 127.0.0.1. Unfortunately, you don't even get an error messages.

But if you write the address reversed

# UDP over IPv4: 127.0.0.1:161
# begemotSnmpdTransInetStatus.1.4.1.0.0.127.161.1 = 4

bsnmp listens to 127.0.0.1 according to "netstat -an4 | grep 161"

udp4       0      0 127.0.0.1.161          *.*

Even if you query the daemon using snmpwalk, you get

BEGEMOT-SNMPD-MIB::begemotSnmpdTransInetStatus.ipv4."1.0.0.127".161.udp = INTEGER: active(1)

So it seems that to endianess problem occurs when the daemon binds to the given address. Probably there is some missing or superflous hton or ntoh there.
Comment 1 Andrey V. Elsukov freebsd_committer 2019-11-19 09:44:57 UTC
Created attachment 209245 [details]
Proposed patch

Hello,

can you test this patch?
Comment 2 topical 2019-11-19 13:34:06 UTC
Hi,

I've just compiled the daemon - and it works now!

Thanks a lot,


Thomas
Comment 3 commit-hook freebsd_committer 2019-11-19 16:30:42 UTC
A commit references this bug:

Author: ae
Date: Tue Nov 19 16:29:47 UTC 2019
New revision: 354858
URL: https://svnweb.freebsd.org/changeset/base/354858

Log:
  Fix the byte order of IPv4 address parsed from begemotSnmpdTransInetStatus
  config option.

  An address is already in network byte order, there is no need to do
  htonl().

  PR:		242056
  MFC after:	1 week

Changes:
  head/contrib/bsnmp/snmpd/trans_inet.c
Comment 4 commit-hook freebsd_committer 2019-11-26 02:51:19 UTC
A commit references this bug:

Author: ae
Date: Tue Nov 26 02:50:26 UTC 2019
New revision: 355105
URL: https://svnweb.freebsd.org/changeset/base/355105

Log:
  MFC r354858:
    Fix the byte order of IPv4 address parsed from begemotSnmpdTransInetStatus
    config option.

    An address is already in network byte order, there is no need to do
    htonl().

    PR:		242056

Changes:
_U  stable/12/
  stable/12/contrib/bsnmp/snmpd/trans_inet.c
Comment 5 Andrey V. Elsukov freebsd_committer 2019-11-26 02:52:06 UTC
Fixed in head/ and stable/12. Thanks!