-
Bug
-
Resolution: Unresolved
-
Medium
-
None
-
None
-
None
-
3
-
9223372036854775807
Problem
lnetctl peer show can print a peer: key before each peer. The output then has duplicate keys at the top level. A YAML parser that rejects duplicate keys fails, for example with duplicate field `peer`. A parser that accepts duplicate keys keeps only the last peer.
peer:
- primary nid: 1.1.1.1@tcp
...
peer:
- primary nid: 1.1.1.2@tcp
...
Environment
- master (2.17.58), and every branch with the Netlink peer show from LU-9680 f0be00678c ("LU-9680 lnet: collect data about peer_ni by using Netlink"). The first tag with that commit is 2.15.59.
- Any node where the 0@lo peer is entry 0 of the peer list.
Reproduction
- Load libcfs with cpu_npartitions=1, and configure LNet.
- Run lnetctl discover 0@lo.
- Run lnetctl peer add --prim_nid 1.1.1.1@tcp.
- Run lnetctl peer add --prim_nid 1.1.1.2@tcp.
- Run lnetctl peer show. The output has 2 peer: keys.
Analysis
lnet_peer_ni_show_dump() sends the empty LNET_PEER_NI_ATTR_HDR attribute only when idx == 1. The loop increments idx and then skips 0@lo. When 0@lo is entry 0, no message has idx == 1, so the kernel does not send the header.
In userspace, yaml_parse_value_list() prints the top-level key for each message. Only a received empty header clears the key. Without the header, each peer gets its own peer: key.
lnet_peer_dist_show_dump() has the same defect. Its only caller, lctl which_nid, does not print the YAML, so that defect has no visible symptom.
Proposed fix
Put the header in the first message that each dump sends, not in the message for idx == 1. Add a sanity-lnet test that creates the 0@lo peer first on one CPT.