|  | @@ -290,8 +290,7 @@ static struct ipv6_miniroute * ipv6_route ( unsigned int scope_id,
 | 
		
	
		
			
			| 290 | 290 |  		if ( ! ( miniroute->flags & IPV6_HAS_ADDRESS ) )
 | 
		
	
		
			
			| 291 | 291 |  			continue;
 | 
		
	
		
			
			| 292 | 292 |  
 | 
		
	
		
			
			| 293 |  | -		if ( IN6_IS_ADDR_LINKLOCAL ( *dest ) ||
 | 
		
	
		
			
			| 294 |  | -		     IN6_IS_ADDR_MULTICAST ( *dest ) ) {
 | 
		
	
		
			
			|  | 293 | +		if ( IN6_IS_ADDR_NONGLOBAL ( *dest ) ) {
 | 
		
	
		
			
			| 295 | 294 |  
 | 
		
	
		
			
			| 296 | 295 |  			/* If destination is non-global, and the scope ID
 | 
		
	
		
			
			| 297 | 296 |  			 * matches this network device, then use this route.
 | 
		
	
	
		
			
			|  | @@ -901,7 +900,7 @@ static const char * ipv6_sock_ntoa ( struct sockaddr *sa ) {
 | 
		
	
		
			
			| 901 | 900 |  	const char *netdev_name;
 | 
		
	
		
			
			| 902 | 901 |  
 | 
		
	
		
			
			| 903 | 902 |  	/* Identify network device, if applicable */
 | 
		
	
		
			
			| 904 |  | -	if ( IN6_IS_ADDR_LINKLOCAL ( in ) || IN6_IS_ADDR_MULTICAST ( in ) ) {
 | 
		
	
		
			
			|  | 903 | +	if ( IN6_IS_ADDR_NONGLOBAL ( in ) ) {
 | 
		
	
		
			
			| 905 | 904 |  		netdev = find_netdev_by_index ( sin6->sin6_scope_id );
 | 
		
	
		
			
			| 906 | 905 |  		netdev_name = ( netdev ? netdev->name : "UNKNOWN" );
 | 
		
	
		
			
			| 907 | 906 |  	} else {
 | 
		
	
	
		
			
			|  | @@ -956,14 +955,26 @@ static int ipv6_sock_aton ( const char *string, struct sockaddr *sa ) {
 | 
		
	
		
			
			| 956 | 955 |  	if ( ( rc = inet6_aton ( in_string, &in ) ) != 0 )
 | 
		
	
		
			
			| 957 | 956 |  		goto err_inet6_aton;
 | 
		
	
		
			
			| 958 | 957 |  
 | 
		
	
		
			
			| 959 |  | -	/* Parse network device name, if present */
 | 
		
	
		
			
			|  | 958 | +	/* Parse scope ID, if applicable */
 | 
		
	
		
			
			| 960 | 959 |  	if ( netdev_string ) {
 | 
		
	
		
			
			|  | 960 | +
 | 
		
	
		
			
			|  | 961 | +		/* Parse explicit network device name, if present */
 | 
		
	
		
			
			| 961 | 962 |  		netdev = find_netdev ( netdev_string );
 | 
		
	
		
			
			| 962 | 963 |  		if ( ! netdev ) {
 | 
		
	
		
			
			| 963 | 964 |  			rc = -ENODEV;
 | 
		
	
		
			
			| 964 | 965 |  			goto err_find_netdev;
 | 
		
	
		
			
			| 965 | 966 |  		}
 | 
		
	
		
			
			| 966 | 967 |  		sin6->sin6_scope_id = netdev->index;
 | 
		
	
		
			
			|  | 968 | +
 | 
		
	
		
			
			|  | 969 | +	} else if ( IN6_IS_ADDR_NONGLOBAL ( &in ) ) {
 | 
		
	
		
			
			|  | 970 | +
 | 
		
	
		
			
			|  | 971 | +		/* If no network device is explicitly specified for a
 | 
		
	
		
			
			|  | 972 | +		 * link-local or multicast address, default to using
 | 
		
	
		
			
			|  | 973 | +		 * "netX" (if existent).
 | 
		
	
		
			
			|  | 974 | +		 */
 | 
		
	
		
			
			|  | 975 | +		netdev = last_opened_netdev();
 | 
		
	
		
			
			|  | 976 | +		if ( netdev )
 | 
		
	
		
			
			|  | 977 | +			sin6->sin6_scope_id = netdev->index;
 | 
		
	
		
			
			| 967 | 978 |  	}
 | 
		
	
		
			
			| 968 | 979 |  
 | 
		
	
		
			
			| 969 | 980 |  	/* Copy IPv6 address portion to socket address */
 |