forked from mirrors/linux
		
	ip_tunnel: Preserve pointer const in ip_tunnel_info_opts
Change ip_tunnel_info_opts( ) from static function to macro to cast return value and preserve the const-ness of the pointer. Signed-off-by: Gavin Li <gavinl@nvidia.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
		
							parent
							
								
									58de53c102
								
							
						
					
					
						commit
						bc9d003dc4
					
				
					 1 changed files with 6 additions and 5 deletions
				
			
		|  | @ -67,6 +67,12 @@ struct ip_tunnel_key { | ||||||
| 	GENMASK((sizeof_field(struct ip_tunnel_info,		\ | 	GENMASK((sizeof_field(struct ip_tunnel_info,		\ | ||||||
| 			      options_len) * BITS_PER_BYTE) - 1, 0) | 			      options_len) * BITS_PER_BYTE) - 1, 0) | ||||||
| 
 | 
 | ||||||
|  | #define ip_tunnel_info_opts(info)				\ | ||||||
|  | 	_Generic(info,						\ | ||||||
|  | 		 const struct ip_tunnel_info * : ((const void *)((info) + 1)),\ | ||||||
|  | 		 struct ip_tunnel_info * : ((void *)((info) + 1))\ | ||||||
|  | 	) | ||||||
|  | 
 | ||||||
| struct ip_tunnel_info { | struct ip_tunnel_info { | ||||||
| 	struct ip_tunnel_key	key; | 	struct ip_tunnel_key	key; | ||||||
| #ifdef CONFIG_DST_CACHE | #ifdef CONFIG_DST_CACHE | ||||||
|  | @ -485,11 +491,6 @@ static inline void iptunnel_xmit_stats(struct net_device *dev, int pkt_len) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static inline void *ip_tunnel_info_opts(struct ip_tunnel_info *info) |  | ||||||
| { |  | ||||||
| 	return info + 1; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline void ip_tunnel_info_opts_get(void *to, | static inline void ip_tunnel_info_opts_get(void *to, | ||||||
| 					   const struct ip_tunnel_info *info) | 					   const struct ip_tunnel_info *info) | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Gavin Li
						Gavin Li