diff options
| author | Jiri Benc <jbenc@redhat.com> | 2015-03-29 10:59:25 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2015-03-31 13:58:35 -0400 |
| commit | 930345ea630405aa6e6f42efcb149c3f360a6b67 (patch) | |
| tree | c88d0858785c246038fddac3ca51571b371416b0 /net/l2tp | |
| parent | 15e318bdc6dfb82914c82fb7ad00badaa8387d8e (diff) | |
netlink: implement nla_put_in_addr and nla_put_in6_addr
IP addresses are often stored in netlink attributes. Add generic functions
to do that.
For nla_put_in_addr, it would be nicer to pass struct in_addr but this is
not used universally throughout the kernel, in way too many places __be32 is
used to store IPv4 address.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/l2tp')
| -rw-r--r-- | net/l2tp/l2tp_netlink.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c index b4e923f77954..a4f78d36bace 100644 --- a/net/l2tp/l2tp_netlink.c +++ b/net/l2tp/l2tp_netlink.c | |||
| @@ -376,15 +376,17 @@ static int l2tp_nl_tunnel_send(struct sk_buff *skb, u32 portid, u32 seq, int fla | |||
| 376 | case L2TP_ENCAPTYPE_IP: | 376 | case L2TP_ENCAPTYPE_IP: |
| 377 | #if IS_ENABLED(CONFIG_IPV6) | 377 | #if IS_ENABLED(CONFIG_IPV6) |
| 378 | if (np) { | 378 | if (np) { |
| 379 | if (nla_put(skb, L2TP_ATTR_IP6_SADDR, sizeof(np->saddr), | 379 | if (nla_put_in6_addr(skb, L2TP_ATTR_IP6_SADDR, |
| 380 | &np->saddr) || | 380 | &np->saddr) || |
| 381 | nla_put(skb, L2TP_ATTR_IP6_DADDR, sizeof(sk->sk_v6_daddr), | 381 | nla_put_in6_addr(skb, L2TP_ATTR_IP6_DADDR, |
| 382 | &sk->sk_v6_daddr)) | 382 | &sk->sk_v6_daddr)) |
| 383 | goto nla_put_failure; | 383 | goto nla_put_failure; |
| 384 | } else | 384 | } else |
| 385 | #endif | 385 | #endif |
| 386 | if (nla_put_be32(skb, L2TP_ATTR_IP_SADDR, inet->inet_saddr) || | 386 | if (nla_put_in_addr(skb, L2TP_ATTR_IP_SADDR, |
| 387 | nla_put_be32(skb, L2TP_ATTR_IP_DADDR, inet->inet_daddr)) | 387 | inet->inet_saddr) || |
| 388 | nla_put_in_addr(skb, L2TP_ATTR_IP_DADDR, | ||
| 389 | inet->inet_daddr)) | ||
| 388 | goto nla_put_failure; | 390 | goto nla_put_failure; |
| 389 | break; | 391 | break; |
| 390 | } | 392 | } |
