@@ -737,16 +737,23 @@ static int inet_pton_with_scope(struct libnvme_global_ctx *ctx, int af,
737737 return ret ;
738738}
739739
740- static bool traddr_is_hostname (struct libnvme_global_ctx * ctx , libnvme_ctrl_t c )
740+ bool traddr_is_hostname (const char * transport , const char * traddr )
741741{
742- struct sockaddr_storage addr ;
743742
744- if (!c -> traddr )
743+ char addrstr [NVMF_TRADDR_SIZE ];
744+
745+ if (!traddr || !transport )
745746 return false;
746- if (strcmp (c -> transport , "tcp" ) && strcmp ( c -> transport , "rdma " ))
747+ if (! strcmp (traddr , "none " ))
747748 return false;
748- if (inet_pton_with_scope (ctx , AF_UNSPEC , c -> traddr , c -> trsvcid , & addr ) == 0 )
749+
750+ if (strcmp (transport , "tcp" ) &&
751+ strcmp (transport , "rdma" ))
749752 return false;
753+ if (inet_pton (AF_INET , traddr , addrstr ) > 0 ||
754+ inet_pton (AF_INET6 , traddr , addrstr ) > 0 )
755+ return false;
756+
750757 return true;
751758}
752759
@@ -1140,7 +1147,7 @@ __public int libnvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c)
11401147 }
11411148
11421149 libnvme_ctrl_set_discovered (c , true);
1143- if (traddr_is_hostname (h -> ctx , c )) {
1150+ if (traddr_is_hostname (c -> transport , c -> traddr )) {
11441151 char * traddr = c -> traddr ;
11451152
11461153 if (hostname2traddr (h -> ctx , traddr , & c -> traddr )) {
0 commit comments