Skip to content

Commit d801e1e

Browse files
committed
nvme-print: fix traddr transformation for ave discovery log
inet_ntop wants the network address structure as input not converted string. Fixes: 1571543 ("nvme: add ave-discovery-log command") Signed-off-by: Daniel Wagner <[email protected]>
1 parent c066303 commit d801e1e

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

nvme-print-json.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5636,16 +5636,22 @@ static void json_host_discovery_log(struct nvme_host_discover_log *log)
56365636

56375637
static void obj_add_traddr(struct json_object *o, const char *k, __u8 adrfam, __u8 *traddr)
56385638
{
5639-
int af = AF_INET;
5640-
socklen_t size = INET_ADDRSTRLEN;
56415639
char dst[INET6_ADDRSTRLEN];
5640+
socklen_t size;
5641+
int af;
56425642

5643-
if (adrfam == NVMF_ADDR_FAMILY_IP6) {
5643+
if (adrfam == NVMF_ADDR_FAMILY_IP4) {
5644+
af = AF_INET;
5645+
size = INET_ADDRSTRLEN;
5646+
} else if (adrfam == NVMF_ADDR_FAMILY_IP6) {
56445647
af = AF_INET6;
56455648
size = INET6_ADDRSTRLEN;
5649+
} else {
5650+
obj_add_str(o, k, "<invalid>");
5651+
return;
56465652
}
56475653

5648-
if (inet_ntop(af, libnvmf_adrfam_str(adrfam), dst, size))
5654+
if (inet_ntop(af, traddr, dst, size))
56495655
obj_add_str(o, k, dst);
56505656
}
56515657

nvme-print-stdout.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6646,16 +6646,22 @@ static void stdout_host_discovery_log(struct nvme_host_discover_log *log)
66466646

66476647
static void print_traddr(char *field, __u8 adrfam, __u8 *traddr)
66486648
{
6649-
int af = AF_INET;
6650-
socklen_t size = INET_ADDRSTRLEN;
66516649
char dst[INET6_ADDRSTRLEN];
6650+
socklen_t size;
6651+
int af;
66526652

6653-
if (adrfam == NVMF_ADDR_FAMILY_IP6) {
6653+
if (adrfam == NVMF_ADDR_FAMILY_IP4) {
6654+
af = AF_INET;
6655+
size = INET_ADDRSTRLEN;
6656+
} else if (adrfam == NVMF_ADDR_FAMILY_IP6) {
66546657
af = AF_INET6;
66556658
size = INET6_ADDRSTRLEN;
6659+
} else {
6660+
printf("%s: <invalid>\n", field);
6661+
return;
66566662
}
66576663

6658-
if (inet_ntop(af, libnvmf_adrfam_str(adrfam), dst, size))
6664+
if (inet_ntop(af, traddr, dst, size))
66596665
printf("%s: %s\n", field, dst);
66606666
}
66616667

0 commit comments

Comments
 (0)