Skip to content

Commit

Permalink
Add experimental NCSI packet sniffer tool
Browse files Browse the repository at this point in the history
Summary:
`ncsi-util` does not produce human-readable payload output. This diff introduces an NC-SI packet sniffer that is packaged in a python script for portability.

## Dependencies
* python >= 3.6

Test Plan:
To run, first copy all files over to BMC. Then, start the script with `sudo python3 -i eth0` to bind to the eth0 interface.

Supported arguments are:
```
  --host HOST           Host Address to receive packets on. Defaults to `localhost`. Not applicable if attaching to interface.
  --port PORT           Port to listen on. Defaults to `5555`. Not applicable if attaching to interface.
  -v, --verbose         Verbosity (-v, -vv, etc)
  -e, --echo            Whether or not to reply to incoming messages
  -i INTERFACE, --interface INTERFACE Interface to bind to (such as tap0, eth0, etc)
```
Then, observe packets on BMC:
```
root@dhcp6-2620-10d-c0b9-4b08-0-0-0-f10:/tmp/ncsi_dump# python3 packet_sniffer.py -i eth0
INFO:MOCK:===================================
INFO:MOCK:RUNNING WITH MOCK
INFO:MOCK:===================================

INFO:MOCK:Listening on ('eth0', 0)
DEBUG:MOCK:Received NCSICommand: MC ID: 0x0, Rev: 0x1, IID: 0x12
            Type: 0xa, Type code: NCSI_GET_LINK_STATUS
            Channel: 0x0
                Payload length: 0
                Payload:

DEBUG:MOCK:Received NCSIResponse: MC ID: 0x0, Rev: 0x1, IID: 0x12
            Type: 0x8a, Type code: NCSI_GET_LINK_STATUS
            Channel: 0x0
                Payload length: 16
                Payload:
                	response: 0 (Command Completed)
                	reason: 0 (No Error/No Reason)
                	status: 0x75
                	other: 0x0
                	oem_status: 0x0

DEBUG:MOCK:Received NCSICommand: MC ID: 0x0, Rev: 0x1, IID: 0x13
            Type: 0x15, Type code: NCSI_GET_VERSION_ID
            Channel: 0x0
                Payload length: 0
                Payload:

DEBUG:MOCK:Received NCSIResponse: MC ID: 0x0, Rev: 0x1, IID: 0x13
            Type: 0x95, Type code: NCSI_GET_VERSION_ID
            Channel: 0x0
                Payload length: 40
                Payload:
                	response: 0 (Command Completed)
                	reason: 0 (No Error/No Reason)
                	ncsi_version: 0xf1f1f000
                	alpha2: 0x0
                	fw_name: b'mlx0.1\x00\x00\x00\x00\x00\x00'
                	fw_version: 0x161d07d2
                	pci_did: 0x101d
                	pci_vid: 0x15b3
                	pci_ssid: 0x17
                	pci_svid: 0x15b3
                	mf_id: 0x8119

DEBUG:MOCK:Received NCSICommand: MC ID: 0x0, Rev: 0x1, IID: 0x14
            Type: 0x51, Type code: NCSI_RESRVED1
            Channel: 0x0
                Payload length: 0
                Payload:

DEBUG:MOCK:Received NCSIResponse: MC ID: 0x0, Rev: 0x1, IID: 0x14
            Type: 0xd1, Type code: NCSI_RESRVED1
            Channel: 0x0
                Payload length: 4
                Payload:
                	response: 0 (Command Completed)
                	reason: 0 (No Error/No Reason)

DEBUG:MOCK:Received NCSICommand: MC ID: 0x0, Rev: 0x1, IID: 0x15
            Type: 0x51, Type code: NCSI_RESRVED1
            Channel: 0x0
                Payload length: 0
                Payload:

DEBUG:MOCK:Received NCSIResponse: MC ID: 0x0, Rev: 0x1, IID: 0x15
            Type: 0xd1, Type code: NCSI_RESRVED1
            Channel: 0x0
                Payload length: 4
                Payload:
                	response: 0 (Command Completed)
                	reason: 0 (No Error/No Reason)
...
```
Note that PLDM commands are not currently supported, so that is why there is no good readable output from the 0x51 commands.

Reviewed By: peterdelevoryas

fbshipit-source-id: 36cae09686aee9121f7694dd85bdcbf1c3f31b26
  • Loading branch information
Timothy Vitkin authored and facebook-github-bot committed Aug 12, 2022
1 parent c791b93 commit 736264c
Show file tree
Hide file tree
Showing 5 changed files with 1,168 additions and 0 deletions.
Loading

0 comments on commit 736264c

Please sign in to comment.