diff mbox series

[net-next,2/7] ipv4: nexthop: Use nla_put_be32() for NHA_GATEWAY

Message ID 20200826164857.1029764-3-idosch@idosch.org
State Accepted
Delegated to: David Miller
Headers show
Series ipv4: nexthop: Various improvements | expand

Commit Message

Ido Schimmel Aug. 26, 2020, 4:48 p.m. UTC
From: Ido Schimmel <idosch@nvidia.com>

The code correctly uses nla_get_be32() to get the payload of the
attribute, but incorrectly uses nla_put_u32() to add the attribute to
the payload. This results in the following warning:

net/ipv4/nexthop.c:279:59: warning: incorrect type in argument 3 (different base types)
net/ipv4/nexthop.c:279:59:    expected unsigned int [usertype] value
net/ipv4/nexthop.c:279:59:    got restricted __be32 [usertype] ipv4

Suppress the warning by using nla_put_be32().

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 net/ipv4/nexthop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Ahern Aug. 26, 2020, 7:07 p.m. UTC | #1
On 8/26/20 10:48 AM, Ido Schimmel wrote:
> From: Ido Schimmel <idosch@nvidia.com>
> 
> The code correctly uses nla_get_be32() to get the payload of the
> attribute, but incorrectly uses nla_put_u32() to add the attribute to
> the payload. This results in the following warning:
> 
> net/ipv4/nexthop.c:279:59: warning: incorrect type in argument 3 (different base types)
> net/ipv4/nexthop.c:279:59:    expected unsigned int [usertype] value
> net/ipv4/nexthop.c:279:59:    got restricted __be32 [usertype] ipv4
> 
> Suppress the warning by using nla_put_be32().
> 
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> ---
>  net/ipv4/nexthop.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
> index d13730ff9aeb..0823643a7dec 100644
> --- a/net/ipv4/nexthop.c
> +++ b/net/ipv4/nexthop.c
> @@ -276,7 +276,7 @@ static int nh_fill_node(struct sk_buff *skb, struct nexthop *nh,
>  	case AF_INET:
>  		fib_nh = &nhi->fib_nh;
>  		if (fib_nh->fib_nh_gw_family &&
> -		    nla_put_u32(skb, NHA_GATEWAY, fib_nh->fib_nh_gw4))
> +		    nla_put_be32(skb, NHA_GATEWAY, fib_nh->fib_nh_gw4))
>  			goto nla_put_failure;
>  		break;
>  
> 

Reviewed-by: David Ahern <dsahern@gmail.com>
diff mbox series

Patch

diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index d13730ff9aeb..0823643a7dec 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -276,7 +276,7 @@  static int nh_fill_node(struct sk_buff *skb, struct nexthop *nh,
 	case AF_INET:
 		fib_nh = &nhi->fib_nh;
 		if (fib_nh->fib_nh_gw_family &&
-		    nla_put_u32(skb, NHA_GATEWAY, fib_nh->fib_nh_gw4))
+		    nla_put_be32(skb, NHA_GATEWAY, fib_nh->fib_nh_gw4))
 			goto nla_put_failure;
 		break;