Browse Source

[iscsi] Parse IPv6 address in root path

The iSCSI root path may contain a literal IPv6 address.  Update the
parser to handle this address format correctly.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Hannes Reinecke 6 years ago
parent
commit
c84f9d6727
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      src/net/tcp/iscsi.c

+ 6
- 1
src/net/tcp/iscsi.c View File

@@ -1921,6 +1921,7 @@ static int iscsi_parse_root_path ( struct iscsi_session *iscsi,
1921 1921
 	char rp_copy[ strlen ( root_path ) + 1 ];
1922 1922
 	char *rp_comp[NUM_RP_COMPONENTS];
1923 1923
 	char *rp = rp_copy;
1924
+	int skip = 0;
1924 1925
 	int i = 0;
1925 1926
 	int rc;
1926 1927
 
@@ -1930,11 +1931,15 @@ static int iscsi_parse_root_path ( struct iscsi_session *iscsi,
1930 1931
 		rp_comp[i++] = rp;
1931 1932
 		if ( i == NUM_RP_COMPONENTS )
1932 1933
 			break;
1933
-		for ( ; *rp != ':' ; rp++ ) {
1934
+		for ( ; ( ( *rp != ':' ) || skip ) ; rp++ ) {
1934 1935
 			if ( ! *rp ) {
1935 1936
 				DBGC ( iscsi, "iSCSI %p root path \"%s\" "
1936 1937
 				       "too short\n", iscsi, root_path );
1937 1938
 				return -EINVAL_ROOT_PATH_TOO_SHORT;
1939
+			} else if ( *rp == '[' ) {
1940
+				skip = 1;
1941
+			} else if ( *rp == ']' ) {
1942
+				skip = 0;
1938 1943
 			}
1939 1944
 		}
1940 1945
 		*(rp++) = '\0';

Loading…
Cancel
Save