@@ -1860,26 +1860,11 @@ static inline bool
1860
1860
__nvme_rdma_options_match (struct nvme_rdma_ctrl * ctrl ,
1861
1861
struct nvmf_ctrl_options * opts )
1862
1862
{
1863
- char * stdport = __stringify (NVME_RDMA_IP_PORT );
1864
-
1865
-
1866
1863
if (!nvmf_ctlr_matches_baseopts (& ctrl -> ctrl , opts ) ||
1867
- strcmp (opts -> traddr , ctrl -> ctrl .opts -> traddr ))
1864
+ strcmp (opts -> traddr , ctrl -> ctrl .opts -> traddr ) ||
1865
+ strcmp (opts -> trsvcid , ctrl -> ctrl .opts -> trsvcid ))
1868
1866
return false;
1869
1867
1870
- if (opts -> mask & NVMF_OPT_TRSVCID &&
1871
- ctrl -> ctrl .opts -> mask & NVMF_OPT_TRSVCID ) {
1872
- if (strcmp (opts -> trsvcid , ctrl -> ctrl .opts -> trsvcid ))
1873
- return false;
1874
- } else if (opts -> mask & NVMF_OPT_TRSVCID ) {
1875
- if (strcmp (opts -> trsvcid , stdport ))
1876
- return false;
1877
- } else if (ctrl -> ctrl .opts -> mask & NVMF_OPT_TRSVCID ) {
1878
- if (strcmp (stdport , ctrl -> ctrl .opts -> trsvcid ))
1879
- return false;
1880
- }
1881
- /* else, it's a match as both have stdport. Fall to next checks */
1882
-
1883
1868
/*
1884
1869
* checking the local address is rough. In most cases, one
1885
1870
* is not specified and the host port is selected by the stack.
@@ -1939,23 +1924,28 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
1939
1924
struct nvme_rdma_ctrl * ctrl ;
1940
1925
int ret ;
1941
1926
bool changed ;
1942
- char * port ;
1943
1927
1944
1928
ctrl = kzalloc (sizeof (* ctrl ), GFP_KERNEL );
1945
1929
if (!ctrl )
1946
1930
return ERR_PTR (- ENOMEM );
1947
1931
ctrl -> ctrl .opts = opts ;
1948
1932
INIT_LIST_HEAD (& ctrl -> list );
1949
1933
1950
- if (opts -> mask & NVMF_OPT_TRSVCID )
1951
- port = opts -> trsvcid ;
1952
- else
1953
- port = __stringify (NVME_RDMA_IP_PORT );
1934
+ if (!(opts -> mask & NVMF_OPT_TRSVCID )) {
1935
+ opts -> trsvcid =
1936
+ kstrdup (__stringify (NVME_RDMA_IP_PORT ), GFP_KERNEL );
1937
+ if (!opts -> trsvcid ) {
1938
+ ret = - ENOMEM ;
1939
+ goto out_free_ctrl ;
1940
+ }
1941
+ opts -> mask |= NVMF_OPT_TRSVCID ;
1942
+ }
1954
1943
1955
1944
ret = inet_pton_with_scope (& init_net , AF_UNSPEC ,
1956
- opts -> traddr , port , & ctrl -> addr );
1945
+ opts -> traddr , opts -> trsvcid , & ctrl -> addr );
1957
1946
if (ret ) {
1958
- pr_err ("malformed address passed: %s:%s\n" , opts -> traddr , port );
1947
+ pr_err ("malformed address passed: %s:%s\n" ,
1948
+ opts -> traddr , opts -> trsvcid );
1959
1949
goto out_free_ctrl ;
1960
1950
}
1961
1951
0 commit comments