Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go snmp server#20 #21

Merged
merged 10 commits into from
Oct 10, 2023
Merged

Go snmp server#20 #21

merged 10 commits into from
Oct 10, 2023

Conversation

upsampled
Copy link
Contributor

Fixed #20 working with gosnmp/gosnmp mainline

Also works with SHA256/AES256, to test this:

  • ensure you have compiled net-snmp to support more advanced hash/cipher
$snmpwalk -h 2>&1 | grep "\-x\|\-a"
  -a PROTOCOL           set authentication protocol (MD5|SHA|SHA-224|SHA-256|SHA-384|SHA-512)
  -x PROTOCOL           set privacy protocol (DES|AES|AES-192|AES-256)
  • modify gosnmpserver/main.go and run it:
AuthenticationProtocol:   gosnmp.SHA256,
PrivacyProtocol:          gosnmp.AES256,
  • access the server with:
$snmpwalk -v 3 -l authPriv -n public -u testuser -a SHA-256 -A testauth -x AES-256 -X testpriv-L e 127.0.0.1:1161 1

Also works with SHA256/AES256, to test this:

* ensure you have compiled net-snmp to support more advanced hash/cipher
```
$snmpwalk -h 2>&1 | grep "\-x\|\-a"
  -a PROTOCOL           set authentication protocol (MD5|SHA|SHA-224|SHA-256|SHA-384|SHA-512)
  -x PROTOCOL           set privacy protocol (DES|AES|AES-192|AES-256)
``
* modify `gosnmpserver/main.go` and run it:
```
AuthenticationProtocol:   gosnmp.SHA256,
PrivacyProtocol:               gosnmp.AES256,
```
* access the server with:
```
snmpwalk -v 3 -l authPriv -n public -u testuser -a SHA-256 -A testauth -x AES-256 -X testpriv -L e 127.0.0.1:1161 1
```
@slayercat
Copy link
Owner

sure~

@slayercat
Copy link
Owner

I am doing some tests and found that both the TestServerTestsSuite/TestGetSetOids/SNMPWalk and TestServerTestsSuite/TestGetSetOids/SNMPSet tests have failed. I am still investigating the reasons for these failures.

@upsampled
Copy link
Contributor Author

upsampled commented Sep 28, 2023

I had some time this morning to look into this, below is a stand alone program that runs the server for the test. Here is what I found:

TestServerTestsSuite/TestGetSetOids/SNMPWalk

When I run snmpwalk -v2c -c public localhost:6161 1 on a server configured the same way as the test I get the following:

$ snmpwalk -v2c -c public localhost:6161 1
iso.2.3.1 = INTEGER: 0
iso.2.3.2 = NULL
iso.2.3.3 = ""
iso.2.3.4 = OID: iso.2.3.4
iso.2.3.6 = Counter32: 0
iso.2.3.7 = Gauge32: 0
iso.2.3.8 = Timeticks: (0) 0:00:00.00
iso.2.3.9 = Counter64: 0
iso.2.3.10 = 0
Timeout: No Response from localhost:6161

So the issue is serving Oids iso.2.3.11 and iso.2.3.12. This is probably another issue with Oid sorting and lookup (IE: f220d18). I'll look into it more later.

TestServerTestsSuite/TestGetSetOids/SNMPSet/ByGoSNMP/Counter32,

it is pretty straight forward:

gosnmp currently only supports SNMP SETs for Integers, IPAddress and OctetStrings

In your fork the Set function is just

// Set sends an SNMP SET request
func (x *GoSNMP) Set(pdus []SnmpPDU) (result *SnmpPacket, err error) {
	var packetOut *SnmpPacket
	packetOut = x.mkSnmpPacket(SetRequest, pdus, 0, 0)
	return x.send(packetOut, true)
}

While gosnmp/gosnmp it is:

// Set sends an SNMP SET request
func (x *GoSNMP) Set(pdus []SnmpPDU) (result *SnmpPacket, err error) {
	var packetOut *SnmpPacket
	switch pdus[0].Type {
	// TODO test Gauge32
	case Integer, OctetString, Gauge32, IPAddress, ObjectIdentifier:
		packetOut = x.mkSnmpPacket(SetRequest, pdus, 0, 0)
	default:
		return nil, fmt.Errorf("ERR:gosnmp currently only supports SNMP SETs for Integers, IPAddress and OctetStrings")
	}
	return x.send(packetOut, true)
}

If we need to support Counter64 Set, then I'll work on getting a PR to gosnmp/gosnmp

@upsampled
Copy link
Contributor Author

Tracking TestServerTestsSuite/TestGetSetOids/SNMPSet/ByGoSNMP/Counter32 issue in my bigger ticket gosnmp/gosnmp#448

@slayercat if you could look at TestServerTestsSuite/TestGetSetOids/SNMPWalk that be great, if not I will get around to it eventually

@slayercat
Copy link
Owner

Thank you for your investigation. I apologize for the delayed response during this time due to personal matters.

I believe that as the upstream gosnmp library improves, the set issues can gradually be resolved. Additionally, some set operations lack use cases and packet captures, so I tend to ignore TestGetSetOids/SNMPSet.

On the other hand, in the previous commit (tag v0.4), the tests for TestGetSetOids/SNMPWalk were successful. Therefore, while this could possibly be caused by an existing issue, I would like to investigate to ensure that no other problems have been introduced.

I would greatly appreciate it if you could assist in the investigation. I expect to return to normal responsiveness by October 8th.

@upsampled
Copy link
Contributor Author

@slayercat the issue is isolated to the OpaqueFloat type (see logs in #22 ). Not sure the specifics yet.

@upsampled
Copy link
Contributor Author

The issue is that OpaqueDouble and OpaqueFloat are having issue when set to 0

@upsampled
Copy link
Contributor Author

Ok so far the outstanding times to get these tests working are all in gosnmp, the issues are:

@upsampled
Copy link
Contributor Author

Ok I have everything working on GoSNMPServer's side with just that additional change to hand IP Addresses.

I have the rest of the items above working locally for gosnmp but I just need to write tests and the them accepted in the PR

@upsampled
Copy link
Contributor Author

upsampled commented Oct 4, 2023

Ok all needed changes are in gosnmp/gosnmp#452 . If/When that is accepted all tests will pass.

@slayercat slayercat merged commit c822e25 into slayercat:master Oct 10, 2023
@slayercat
Copy link
Owner

Thanks~ Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use mainline gosnmp to allow for up-to-date crypto functions
2 participants