aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Benc <jbenc@redhat.com>2015-03-29 10:59:25 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-31 13:58:35 -0400
commit930345ea630405aa6e6f42efcb149c3f360a6b67 (patch)
treec88d0858785c246038fddac3ca51571b371416b0
parent15e318bdc6dfb82914c82fb7ad00badaa8387d8e (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>
-rw-r--r--drivers/net/vxlan.c22
-rw-r--r--include/linux/netfilter/ipset/ip_set.h5
-rw-r--r--include/net/netlink.h29
-rw-r--r--net/ipv4/devinet.c6
-rw-r--r--net/ipv4/fib_rules.c4
-rw-r--r--net/ipv4/fib_semantics.c8
-rw-r--r--net/ipv4/ip_gre.c4
-rw-r--r--net/ipv4/ip_vti.c4
-rw-r--r--net/ipv4/ipip.c4
-rw-r--r--net/ipv4/ipmr.c4
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c4
-rw-r--r--net/ipv4/route.c8
-rw-r--r--net/ipv4/tcp_metrics.c16
-rw-r--r--net/ipv6/addrconf.c10
-rw-r--r--net/ipv6/addrlabel.c2
-rw-r--r--net/ipv6/fib6_rules.c6
-rw-r--r--net/ipv6/ip6_gre.c4
-rw-r--r--net/ipv6/ip6_tunnel.c6
-rw-r--r--net/ipv6/ip6_vti.c6
-rw-r--r--net/ipv6/ip6mr.c4
-rw-r--r--net/ipv6/ndisc.c3
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c6
-rw-r--r--net/ipv6/route.c14
-rw-r--r--net/ipv6/sit.c12
-rw-r--r--net/l2tp/l2tp_netlink.c14
-rw-r--r--net/netlabel/netlabel_mgmt.c20
-rw-r--r--net/netlabel/netlabel_unlabeled.c28
-rw-r--r--net/openvswitch/flow_netlink.c6
-rw-r--r--net/wireless/nl80211.c4
29 files changed, 139 insertions, 124 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 1c80b67c688d..86f085f95408 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -187,9 +187,9 @@ static int vxlan_nla_put_addr(struct sk_buff *skb, int attr,
187 const union vxlan_addr *ip) 187 const union vxlan_addr *ip)
188{ 188{
189 if (ip->sa.sa_family == AF_INET6) 189 if (ip->sa.sa_family == AF_INET6)
190 return nla_put(skb, attr, sizeof(struct in6_addr), &ip->sin6.sin6_addr); 190 return nla_put_in6_addr(skb, attr, &ip->sin6.sin6_addr);
191 else 191 else
192 return nla_put_be32(skb, attr, ip->sin.sin_addr.s_addr); 192 return nla_put_in_addr(skb, attr, ip->sin.sin_addr.s_addr);
193} 193}
194 194
195#else /* !CONFIG_IPV6 */ 195#else /* !CONFIG_IPV6 */
@@ -226,7 +226,7 @@ static int vxlan_nla_get_addr(union vxlan_addr *ip, struct nlattr *nla)
226static int vxlan_nla_put_addr(struct sk_buff *skb, int attr, 226static int vxlan_nla_put_addr(struct sk_buff *skb, int attr,
227 const union vxlan_addr *ip) 227 const union vxlan_addr *ip)
228{ 228{
229 return nla_put_be32(skb, attr, ip->sin.sin_addr.s_addr); 229 return nla_put_in_addr(skb, attr, ip->sin.sin_addr.s_addr);
230} 230}
231#endif 231#endif
232 232
@@ -2807,13 +2807,13 @@ static int vxlan_fill_info(struct sk_buff *skb, const struct net_device *dev)
2807 2807
2808 if (!vxlan_addr_any(&dst->remote_ip)) { 2808 if (!vxlan_addr_any(&dst->remote_ip)) {
2809 if (dst->remote_ip.sa.sa_family == AF_INET) { 2809 if (dst->remote_ip.sa.sa_family == AF_INET) {
2810 if (nla_put_be32(skb, IFLA_VXLAN_GROUP, 2810 if (nla_put_in_addr(skb, IFLA_VXLAN_GROUP,
2811 dst->remote_ip.sin.sin_addr.s_addr)) 2811 dst->remote_ip.sin.sin_addr.s_addr))
2812 goto nla_put_failure; 2812 goto nla_put_failure;
2813#if IS_ENABLED(CONFIG_IPV6) 2813#if IS_ENABLED(CONFIG_IPV6)
2814 } else { 2814 } else {
2815 if (nla_put(skb, IFLA_VXLAN_GROUP6, sizeof(struct in6_addr), 2815 if (nla_put_in6_addr(skb, IFLA_VXLAN_GROUP6,
2816 &dst->remote_ip.sin6.sin6_addr)) 2816 &dst->remote_ip.sin6.sin6_addr))
2817 goto nla_put_failure; 2817 goto nla_put_failure;
2818#endif 2818#endif
2819 } 2819 }
@@ -2824,13 +2824,13 @@ static int vxlan_fill_info(struct sk_buff *skb, const struct net_device *dev)
2824 2824
2825 if (!vxlan_addr_any(&vxlan->saddr)) { 2825 if (!vxlan_addr_any(&vxlan->saddr)) {
2826 if (vxlan->saddr.sa.sa_family == AF_INET) { 2826 if (vxlan->saddr.sa.sa_family == AF_INET) {
2827 if (nla_put_be32(skb, IFLA_VXLAN_LOCAL, 2827 if (nla_put_in_addr(skb, IFLA_VXLAN_LOCAL,
2828 vxlan->saddr.sin.sin_addr.s_addr)) 2828 vxlan->saddr.sin.sin_addr.s_addr))
2829 goto nla_put_failure; 2829 goto nla_put_failure;
2830#if IS_ENABLED(CONFIG_IPV6) 2830#if IS_ENABLED(CONFIG_IPV6)
2831 } else { 2831 } else {
2832 if (nla_put(skb, IFLA_VXLAN_LOCAL6, sizeof(struct in6_addr), 2832 if (nla_put_in6_addr(skb, IFLA_VXLAN_LOCAL6,
2833 &vxlan->saddr.sin6.sin6_addr)) 2833 &vxlan->saddr.sin6.sin6_addr))
2834 goto nla_put_failure; 2834 goto nla_put_failure;
2835#endif 2835#endif
2836 } 2836 }
diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
index f1606fa6132d..34b172301558 100644
--- a/include/linux/netfilter/ipset/ip_set.h
+++ b/include/linux/netfilter/ipset/ip_set.h
@@ -483,7 +483,7 @@ static inline int nla_put_ipaddr4(struct sk_buff *skb, int type, __be32 ipaddr)
483 483
484 if (!__nested) 484 if (!__nested)
485 return -EMSGSIZE; 485 return -EMSGSIZE;
486 ret = nla_put_net32(skb, IPSET_ATTR_IPADDR_IPV4, ipaddr); 486 ret = nla_put_in_addr(skb, IPSET_ATTR_IPADDR_IPV4, ipaddr);
487 if (!ret) 487 if (!ret)
488 ipset_nest_end(skb, __nested); 488 ipset_nest_end(skb, __nested);
489 return ret; 489 return ret;
@@ -497,8 +497,7 @@ static inline int nla_put_ipaddr6(struct sk_buff *skb, int type,
497 497
498 if (!__nested) 498 if (!__nested)
499 return -EMSGSIZE; 499 return -EMSGSIZE;
500 ret = nla_put(skb, IPSET_ATTR_IPADDR_IPV6, 500 ret = nla_put_in6_addr(skb, IPSET_ATTR_IPADDR_IPV6, ipaddrptr);
501 sizeof(struct in6_addr), ipaddrptr);
502 if (!ret) 501 if (!ret)
503 ipset_nest_end(skb, __nested); 502 ipset_nest_end(skb, __nested);
504 return ret; 503 return ret;
diff --git a/include/net/netlink.h b/include/net/netlink.h
index e010ee8da41d..17fc76e5b05e 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -4,6 +4,7 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/netlink.h> 5#include <linux/netlink.h>
6#include <linux/jiffies.h> 6#include <linux/jiffies.h>
7#include <linux/in6.h>
7 8
8/* ======================================================================== 9/* ========================================================================
9 * Netlink Messages and Attributes Interface (As Seen On TV) 10 * Netlink Messages and Attributes Interface (As Seen On TV)
@@ -105,6 +106,8 @@
105 * nla_put_string(skb, type, str) add string attribute to skb 106 * nla_put_string(skb, type, str) add string attribute to skb
106 * nla_put_flag(skb, type) add flag attribute to skb 107 * nla_put_flag(skb, type) add flag attribute to skb
107 * nla_put_msecs(skb, type, jiffies) add msecs attribute to skb 108 * nla_put_msecs(skb, type, jiffies) add msecs attribute to skb
109 * nla_put_in_addr(skb, type, addr) add IPv4 address attribute to skb
110 * nla_put_in6_addr(skb, type, addr) add IPv6 address attribute to skb
108 * 111 *
109 * Nested Attributes Construction: 112 * Nested Attributes Construction:
110 * nla_nest_start(skb, type) start a nested attribute 113 * nla_nest_start(skb, type) start a nested attribute
@@ -957,6 +960,32 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
957} 960}
958 961
959/** 962/**
963 * nla_put_in_addr - Add an IPv4 address netlink attribute to a socket
964 * buffer
965 * @skb: socket buffer to add attribute to
966 * @attrtype: attribute type
967 * @addr: IPv4 address
968 */
969static inline int nla_put_in_addr(struct sk_buff *skb, int attrtype,
970 __be32 addr)
971{
972 return nla_put_be32(skb, attrtype, addr);
973}
974
975/**
976 * nla_put_in6_addr - Add an IPv6 address netlink attribute to a socket
977 * buffer
978 * @skb: socket buffer to add attribute to
979 * @attrtype: attribute type
980 * @addr: IPv6 address
981 */
982static inline int nla_put_in6_addr(struct sk_buff *skb, int attrtype,
983 const struct in6_addr *addr)
984{
985 return nla_put(skb, attrtype, sizeof(*addr), addr);
986}
987
988/**
960 * nla_get_u32 - return payload of u32 attribute 989 * nla_get_u32 - return payload of u32 attribute
961 * @nla: u32 netlink attribute 990 * @nla: u32 netlink attribute
962 */ 991 */
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 975ee5e30c64..66cd85973056 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1541,11 +1541,11 @@ static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
1541 valid = INFINITY_LIFE_TIME; 1541 valid = INFINITY_LIFE_TIME;
1542 } 1542 }
1543 if ((ifa->ifa_address && 1543 if ((ifa->ifa_address &&
1544 nla_put_be32(skb, IFA_ADDRESS, ifa->ifa_address)) || 1544 nla_put_in_addr(skb, IFA_ADDRESS, ifa->ifa_address)) ||
1545 (ifa->ifa_local && 1545 (ifa->ifa_local &&
1546 nla_put_be32(skb, IFA_LOCAL, ifa->ifa_local)) || 1546 nla_put_in_addr(skb, IFA_LOCAL, ifa->ifa_local)) ||
1547 (ifa->ifa_broadcast && 1547 (ifa->ifa_broadcast &&
1548 nla_put_be32(skb, IFA_BROADCAST, ifa->ifa_broadcast)) || 1548 nla_put_in_addr(skb, IFA_BROADCAST, ifa->ifa_broadcast)) ||
1549 (ifa->ifa_label[0] && 1549 (ifa->ifa_label[0] &&
1550 nla_put_string(skb, IFA_LABEL, ifa->ifa_label)) || 1550 nla_put_string(skb, IFA_LABEL, ifa->ifa_label)) ||
1551 nla_put_u32(skb, IFA_FLAGS, ifa->ifa_flags) || 1551 nla_put_u32(skb, IFA_FLAGS, ifa->ifa_flags) ||
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index e9bc5e42cf43..edfea0deec43 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -279,9 +279,9 @@ static int fib4_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
279 frh->tos = rule4->tos; 279 frh->tos = rule4->tos;
280 280
281 if ((rule4->dst_len && 281 if ((rule4->dst_len &&
282 nla_put_be32(skb, FRA_DST, rule4->dst)) || 282 nla_put_in_addr(skb, FRA_DST, rule4->dst)) ||
283 (rule4->src_len && 283 (rule4->src_len &&
284 nla_put_be32(skb, FRA_SRC, rule4->src))) 284 nla_put_in_addr(skb, FRA_SRC, rule4->src)))
285 goto nla_put_failure; 285 goto nla_put_failure;
286#ifdef CONFIG_IP_ROUTE_CLASSID 286#ifdef CONFIG_IP_ROUTE_CLASSID
287 if (rule4->tclassid && 287 if (rule4->tclassid &&
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 66c1e4fbf884..453b24e5322c 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1015,7 +1015,7 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
1015 rtm->rtm_protocol = fi->fib_protocol; 1015 rtm->rtm_protocol = fi->fib_protocol;
1016 1016
1017 if (rtm->rtm_dst_len && 1017 if (rtm->rtm_dst_len &&
1018 nla_put_be32(skb, RTA_DST, dst)) 1018 nla_put_in_addr(skb, RTA_DST, dst))
1019 goto nla_put_failure; 1019 goto nla_put_failure;
1020 if (fi->fib_priority && 1020 if (fi->fib_priority &&
1021 nla_put_u32(skb, RTA_PRIORITY, fi->fib_priority)) 1021 nla_put_u32(skb, RTA_PRIORITY, fi->fib_priority))
@@ -1024,11 +1024,11 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
1024 goto nla_put_failure; 1024 goto nla_put_failure;
1025 1025
1026 if (fi->fib_prefsrc && 1026 if (fi->fib_prefsrc &&
1027 nla_put_be32(skb, RTA_PREFSRC, fi->fib_prefsrc)) 1027 nla_put_in_addr(skb, RTA_PREFSRC, fi->fib_prefsrc))
1028 goto nla_put_failure; 1028 goto nla_put_failure;
1029 if (fi->fib_nhs == 1) { 1029 if (fi->fib_nhs == 1) {
1030 if (fi->fib_nh->nh_gw && 1030 if (fi->fib_nh->nh_gw &&
1031 nla_put_be32(skb, RTA_GATEWAY, fi->fib_nh->nh_gw)) 1031 nla_put_in_addr(skb, RTA_GATEWAY, fi->fib_nh->nh_gw))
1032 goto nla_put_failure; 1032 goto nla_put_failure;
1033 if (fi->fib_nh->nh_oif && 1033 if (fi->fib_nh->nh_oif &&
1034 nla_put_u32(skb, RTA_OIF, fi->fib_nh->nh_oif)) 1034 nla_put_u32(skb, RTA_OIF, fi->fib_nh->nh_oif))
@@ -1058,7 +1058,7 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
1058 rtnh->rtnh_ifindex = nh->nh_oif; 1058 rtnh->rtnh_ifindex = nh->nh_oif;
1059 1059
1060 if (nh->nh_gw && 1060 if (nh->nh_gw &&
1061 nla_put_be32(skb, RTA_GATEWAY, nh->nh_gw)) 1061 nla_put_in_addr(skb, RTA_GATEWAY, nh->nh_gw))
1062 goto nla_put_failure; 1062 goto nla_put_failure;
1063#ifdef CONFIG_IP_ROUTE_CLASSID 1063#ifdef CONFIG_IP_ROUTE_CLASSID
1064 if (nh->nh_tclassid && 1064 if (nh->nh_tclassid &&
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 6207275fc749..2e878df46075 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -776,8 +776,8 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)
776 nla_put_be16(skb, IFLA_GRE_OFLAGS, tnl_flags_to_gre_flags(p->o_flags)) || 776 nla_put_be16(skb, IFLA_GRE_OFLAGS, tnl_flags_to_gre_flags(p->o_flags)) ||
777 nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) || 777 nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) ||
778 nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) || 778 nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) ||
779 nla_put_be32(skb, IFLA_GRE_LOCAL, p->iph.saddr) || 779 nla_put_in_addr(skb, IFLA_GRE_LOCAL, p->iph.saddr) ||
780 nla_put_be32(skb, IFLA_GRE_REMOTE, p->iph.daddr) || 780 nla_put_in_addr(skb, IFLA_GRE_REMOTE, p->iph.daddr) ||
781 nla_put_u8(skb, IFLA_GRE_TTL, p->iph.ttl) || 781 nla_put_u8(skb, IFLA_GRE_TTL, p->iph.ttl) ||
782 nla_put_u8(skb, IFLA_GRE_TOS, p->iph.tos) || 782 nla_put_u8(skb, IFLA_GRE_TOS, p->iph.tos) ||
783 nla_put_u8(skb, IFLA_GRE_PMTUDISC, 783 nla_put_u8(skb, IFLA_GRE_PMTUDISC,
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 94efe148181c..f189f2a8aaa5 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -505,8 +505,8 @@ static int vti_fill_info(struct sk_buff *skb, const struct net_device *dev)
505 nla_put_u32(skb, IFLA_VTI_LINK, p->link); 505 nla_put_u32(skb, IFLA_VTI_LINK, p->link);
506 nla_put_be32(skb, IFLA_VTI_IKEY, p->i_key); 506 nla_put_be32(skb, IFLA_VTI_IKEY, p->i_key);
507 nla_put_be32(skb, IFLA_VTI_OKEY, p->o_key); 507 nla_put_be32(skb, IFLA_VTI_OKEY, p->o_key);
508 nla_put_be32(skb, IFLA_VTI_LOCAL, p->iph.saddr); 508 nla_put_in_addr(skb, IFLA_VTI_LOCAL, p->iph.saddr);
509 nla_put_be32(skb, IFLA_VTI_REMOTE, p->iph.daddr); 509 nla_put_in_addr(skb, IFLA_VTI_REMOTE, p->iph.daddr);
510 510
511 return 0; 511 return 0;
512} 512}
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 915d215a7d14..17df8d38bbbd 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -450,8 +450,8 @@ static int ipip_fill_info(struct sk_buff *skb, const struct net_device *dev)
450 struct ip_tunnel_parm *parm = &tunnel->parms; 450 struct ip_tunnel_parm *parm = &tunnel->parms;
451 451
452 if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) || 452 if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
453 nla_put_be32(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) || 453 nla_put_in_addr(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) ||
454 nla_put_be32(skb, IFLA_IPTUN_REMOTE, parm->iph.daddr) || 454 nla_put_in_addr(skb, IFLA_IPTUN_REMOTE, parm->iph.daddr) ||
455 nla_put_u8(skb, IFLA_IPTUN_TTL, parm->iph.ttl) || 455 nla_put_u8(skb, IFLA_IPTUN_TTL, parm->iph.ttl) ||
456 nla_put_u8(skb, IFLA_IPTUN_TOS, parm->iph.tos) || 456 nla_put_u8(skb, IFLA_IPTUN_TOS, parm->iph.tos) ||
457 nla_put_u8(skb, IFLA_IPTUN_PMTUDISC, 457 nla_put_u8(skb, IFLA_IPTUN_PMTUDISC,
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index c688cd1b2110..b4a545d24adb 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -2281,8 +2281,8 @@ static int ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb,
2281 rtm->rtm_protocol = RTPROT_MROUTED; 2281 rtm->rtm_protocol = RTPROT_MROUTED;
2282 rtm->rtm_flags = 0; 2282 rtm->rtm_flags = 0;
2283 2283
2284 if (nla_put_be32(skb, RTA_SRC, c->mfc_origin) || 2284 if (nla_put_in_addr(skb, RTA_SRC, c->mfc_origin) ||
2285 nla_put_be32(skb, RTA_DST, c->mfc_mcastgrp)) 2285 nla_put_in_addr(skb, RTA_DST, c->mfc_mcastgrp))
2286 goto nla_put_failure; 2286 goto nla_put_failure;
2287 err = __ipmr_fill_mroute(mrt, skb, c, rtm); 2287 err = __ipmr_fill_mroute(mrt, skb, c, rtm);
2288 /* do not break the dump if cache is unresolved */ 2288 /* do not break the dump if cache is unresolved */
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 5c61328b7704..b36ebfc6b812 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -322,8 +322,8 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len)
322static int ipv4_tuple_to_nlattr(struct sk_buff *skb, 322static int ipv4_tuple_to_nlattr(struct sk_buff *skb,
323 const struct nf_conntrack_tuple *tuple) 323 const struct nf_conntrack_tuple *tuple)
324{ 324{
325 if (nla_put_be32(skb, CTA_IP_V4_SRC, tuple->src.u3.ip) || 325 if (nla_put_in_addr(skb, CTA_IP_V4_SRC, tuple->src.u3.ip) ||
326 nla_put_be32(skb, CTA_IP_V4_DST, tuple->dst.u3.ip)) 326 nla_put_in_addr(skb, CTA_IP_V4_DST, tuple->dst.u3.ip))
327 goto nla_put_failure; 327 goto nla_put_failure;
328 return 0; 328 return 0;
329 329
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index be8703d02ef0..1f147204f1f3 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2319,11 +2319,11 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
2319 if (IPCB(skb)->flags & IPSKB_DOREDIRECT) 2319 if (IPCB(skb)->flags & IPSKB_DOREDIRECT)
2320 r->rtm_flags |= RTCF_DOREDIRECT; 2320 r->rtm_flags |= RTCF_DOREDIRECT;
2321 2321
2322 if (nla_put_be32(skb, RTA_DST, dst)) 2322 if (nla_put_in_addr(skb, RTA_DST, dst))
2323 goto nla_put_failure; 2323 goto nla_put_failure;
2324 if (src) { 2324 if (src) {
2325 r->rtm_src_len = 32; 2325 r->rtm_src_len = 32;
2326 if (nla_put_be32(skb, RTA_SRC, src)) 2326 if (nla_put_in_addr(skb, RTA_SRC, src))
2327 goto nla_put_failure; 2327 goto nla_put_failure;
2328 } 2328 }
2329 if (rt->dst.dev && 2329 if (rt->dst.dev &&
@@ -2336,11 +2336,11 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
2336#endif 2336#endif
2337 if (!rt_is_input_route(rt) && 2337 if (!rt_is_input_route(rt) &&
2338 fl4->saddr != src) { 2338 fl4->saddr != src) {
2339 if (nla_put_be32(skb, RTA_PREFSRC, fl4->saddr)) 2339 if (nla_put_in_addr(skb, RTA_PREFSRC, fl4->saddr))
2340 goto nla_put_failure; 2340 goto nla_put_failure;
2341 } 2341 }
2342 if (rt->rt_uses_gateway && 2342 if (rt->rt_uses_gateway &&
2343 nla_put_be32(skb, RTA_GATEWAY, rt->rt_gateway)) 2343 nla_put_in_addr(skb, RTA_GATEWAY, rt->rt_gateway))
2344 goto nla_put_failure; 2344 goto nla_put_failure;
2345 2345
2346 expires = rt->dst.expires; 2346 expires = rt->dst.expires;
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index f62c2c68ced0..32e36ea6bc0f 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -786,19 +786,19 @@ static int tcp_metrics_fill_info(struct sk_buff *msg,
786 786
787 switch (tm->tcpm_daddr.family) { 787 switch (tm->tcpm_daddr.family) {
788 case AF_INET: 788 case AF_INET:
789 if (nla_put_be32(msg, TCP_METRICS_ATTR_ADDR_IPV4, 789 if (nla_put_in_addr(msg, TCP_METRICS_ATTR_ADDR_IPV4,
790 tm->tcpm_daddr.addr.a4) < 0) 790 tm->tcpm_daddr.addr.a4) < 0)
791 goto nla_put_failure; 791 goto nla_put_failure;
792 if (nla_put_be32(msg, TCP_METRICS_ATTR_SADDR_IPV4, 792 if (nla_put_in_addr(msg, TCP_METRICS_ATTR_SADDR_IPV4,
793 tm->tcpm_saddr.addr.a4) < 0) 793 tm->tcpm_saddr.addr.a4) < 0)
794 goto nla_put_failure; 794 goto nla_put_failure;
795 break; 795 break;
796 case AF_INET6: 796 case AF_INET6:
797 if (nla_put(msg, TCP_METRICS_ATTR_ADDR_IPV6, 16, 797 if (nla_put_in6_addr(msg, TCP_METRICS_ATTR_ADDR_IPV6,
798 tm->tcpm_daddr.addr.a6) < 0) 798 &tm->tcpm_daddr.addr.in6) < 0)
799 goto nla_put_failure; 799 goto nla_put_failure;
800 if (nla_put(msg, TCP_METRICS_ATTR_SADDR_IPV6, 16, 800 if (nla_put_in6_addr(msg, TCP_METRICS_ATTR_SADDR_IPV6,
801 tm->tcpm_saddr.addr.a6) < 0) 801 &tm->tcpm_saddr.addr.in6) < 0)
802 goto nla_put_failure; 802 goto nla_put_failure;
803 break; 803 break;
804 default: 804 default:
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index e86f7434e3c3..5c9e94cb1b2c 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4237,11 +4237,11 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
4237 } 4237 }
4238 4238
4239 if (!ipv6_addr_any(&ifa->peer_addr)) { 4239 if (!ipv6_addr_any(&ifa->peer_addr)) {
4240 if (nla_put(skb, IFA_LOCAL, 16, &ifa->addr) < 0 || 4240 if (nla_put_in6_addr(skb, IFA_LOCAL, &ifa->addr) < 0 ||
4241 nla_put(skb, IFA_ADDRESS, 16, &ifa->peer_addr) < 0) 4241 nla_put_in6_addr(skb, IFA_ADDRESS, &ifa->peer_addr) < 0)
4242 goto error; 4242 goto error;
4243 } else 4243 } else
4244 if (nla_put(skb, IFA_ADDRESS, 16, &ifa->addr) < 0) 4244 if (nla_put_in6_addr(skb, IFA_ADDRESS, &ifa->addr) < 0)
4245 goto error; 4245 goto error;
4246 4246
4247 if (put_cacheinfo(skb, ifa->cstamp, ifa->tstamp, preferred, valid) < 0) 4247 if (put_cacheinfo(skb, ifa->cstamp, ifa->tstamp, preferred, valid) < 0)
@@ -4273,7 +4273,7 @@ static int inet6_fill_ifmcaddr(struct sk_buff *skb, struct ifmcaddr6 *ifmca,
4273 return -EMSGSIZE; 4273 return -EMSGSIZE;
4274 4274
4275 put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex); 4275 put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
4276 if (nla_put(skb, IFA_MULTICAST, 16, &ifmca->mca_addr) < 0 || 4276 if (nla_put_in6_addr(skb, IFA_MULTICAST, &ifmca->mca_addr) < 0 ||
4277 put_cacheinfo(skb, ifmca->mca_cstamp, ifmca->mca_tstamp, 4277 put_cacheinfo(skb, ifmca->mca_cstamp, ifmca->mca_tstamp,
4278 INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) { 4278 INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) {
4279 nlmsg_cancel(skb, nlh); 4279 nlmsg_cancel(skb, nlh);
@@ -4299,7 +4299,7 @@ static int inet6_fill_ifacaddr(struct sk_buff *skb, struct ifacaddr6 *ifaca,
4299 return -EMSGSIZE; 4299 return -EMSGSIZE;
4300 4300
4301 put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex); 4301 put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
4302 if (nla_put(skb, IFA_ANYCAST, 16, &ifaca->aca_addr) < 0 || 4302 if (nla_put_in6_addr(skb, IFA_ANYCAST, &ifaca->aca_addr) < 0 ||
4303 put_cacheinfo(skb, ifaca->aca_cstamp, ifaca->aca_tstamp, 4303 put_cacheinfo(skb, ifaca->aca_cstamp, ifaca->aca_tstamp,
4304 INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) { 4304 INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) {
4305 nlmsg_cancel(skb, nlh); 4305 nlmsg_cancel(skb, nlh);
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c
index 3cc50e2d3bf5..882124ebb438 100644
--- a/net/ipv6/addrlabel.c
+++ b/net/ipv6/addrlabel.c
@@ -477,7 +477,7 @@ static int ip6addrlbl_fill(struct sk_buff *skb,
477 477
478 ip6addrlbl_putmsg(nlh, p->prefixlen, p->ifindex, lseq); 478 ip6addrlbl_putmsg(nlh, p->prefixlen, p->ifindex, lseq);
479 479
480 if (nla_put(skb, IFAL_ADDRESS, 16, &p->prefix) < 0 || 480 if (nla_put_in6_addr(skb, IFAL_ADDRESS, &p->prefix) < 0 ||
481 nla_put_u32(skb, IFAL_LABEL, p->label) < 0) { 481 nla_put_u32(skb, IFAL_LABEL, p->label) < 0) {
482 nlmsg_cancel(skb, nlh); 482 nlmsg_cancel(skb, nlh);
483 return -EMSGSIZE; 483 return -EMSGSIZE;
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 273eb26cd6d4..d313bfd88512 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -250,11 +250,9 @@ static int fib6_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
250 frh->tos = rule6->tclass; 250 frh->tos = rule6->tclass;
251 251
252 if ((rule6->dst.plen && 252 if ((rule6->dst.plen &&
253 nla_put(skb, FRA_DST, sizeof(struct in6_addr), 253 nla_put_in6_addr(skb, FRA_DST, &rule6->dst.addr)) ||
254 &rule6->dst.addr)) ||
255 (rule6->src.plen && 254 (rule6->src.plen &&
256 nla_put(skb, FRA_SRC, sizeof(struct in6_addr), 255 nla_put_in6_addr(skb, FRA_SRC, &rule6->src.addr)))
257 &rule6->src.addr)))
258 goto nla_put_failure; 256 goto nla_put_failure;
259 return 0; 257 return 0;
260 258
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 67e014d88e55..f61f7ad2d045 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1622,8 +1622,8 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev)
1622 nla_put_be16(skb, IFLA_GRE_OFLAGS, p->o_flags) || 1622 nla_put_be16(skb, IFLA_GRE_OFLAGS, p->o_flags) ||
1623 nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) || 1623 nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) ||
1624 nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) || 1624 nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) ||
1625 nla_put(skb, IFLA_GRE_LOCAL, sizeof(struct in6_addr), &p->laddr) || 1625 nla_put_in6_addr(skb, IFLA_GRE_LOCAL, &p->laddr) ||
1626 nla_put(skb, IFLA_GRE_REMOTE, sizeof(struct in6_addr), &p->raddr) || 1626 nla_put_in6_addr(skb, IFLA_GRE_REMOTE, &p->raddr) ||
1627 nla_put_u8(skb, IFLA_GRE_TTL, p->hop_limit) || 1627 nla_put_u8(skb, IFLA_GRE_TTL, p->hop_limit) ||
1628 /*nla_put_u8(skb, IFLA_GRE_TOS, t->priority) ||*/ 1628 /*nla_put_u8(skb, IFLA_GRE_TOS, t->priority) ||*/
1629 nla_put_u8(skb, IFLA_GRE_ENCAP_LIMIT, p->encap_limit) || 1629 nla_put_u8(skb, IFLA_GRE_ENCAP_LIMIT, p->encap_limit) ||
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 0c68012b6d6e..80543d13ea7c 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1739,10 +1739,8 @@ static int ip6_tnl_fill_info(struct sk_buff *skb, const struct net_device *dev)
1739 struct __ip6_tnl_parm *parm = &tunnel->parms; 1739 struct __ip6_tnl_parm *parm = &tunnel->parms;
1740 1740
1741 if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) || 1741 if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
1742 nla_put(skb, IFLA_IPTUN_LOCAL, sizeof(struct in6_addr), 1742 nla_put_in6_addr(skb, IFLA_IPTUN_LOCAL, &parm->laddr) ||
1743 &parm->laddr) || 1743 nla_put_in6_addr(skb, IFLA_IPTUN_REMOTE, &parm->raddr) ||
1744 nla_put(skb, IFLA_IPTUN_REMOTE, sizeof(struct in6_addr),
1745 &parm->raddr) ||
1746 nla_put_u8(skb, IFLA_IPTUN_TTL, parm->hop_limit) || 1744 nla_put_u8(skb, IFLA_IPTUN_TTL, parm->hop_limit) ||
1747 nla_put_u8(skb, IFLA_IPTUN_ENCAP_LIMIT, parm->encap_limit) || 1745 nla_put_u8(skb, IFLA_IPTUN_ENCAP_LIMIT, parm->encap_limit) ||
1748 nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) || 1746 nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) ||
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index 1ec5b4a530d0..87a262b0f07b 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -983,10 +983,8 @@ static int vti6_fill_info(struct sk_buff *skb, const struct net_device *dev)
983 struct __ip6_tnl_parm *parm = &tunnel->parms; 983 struct __ip6_tnl_parm *parm = &tunnel->parms;
984 984
985 if (nla_put_u32(skb, IFLA_VTI_LINK, parm->link) || 985 if (nla_put_u32(skb, IFLA_VTI_LINK, parm->link) ||
986 nla_put(skb, IFLA_VTI_LOCAL, sizeof(struct in6_addr), 986 nla_put_in6_addr(skb, IFLA_VTI_LOCAL, &parm->laddr) ||
987 &parm->laddr) || 987 nla_put_in6_addr(skb, IFLA_VTI_REMOTE, &parm->raddr) ||
988 nla_put(skb, IFLA_VTI_REMOTE, sizeof(struct in6_addr),
989 &parm->raddr) ||
990 nla_put_be32(skb, IFLA_VTI_IKEY, parm->i_key) || 988 nla_put_be32(skb, IFLA_VTI_IKEY, parm->i_key) ||
991 nla_put_be32(skb, IFLA_VTI_OKEY, parm->o_key)) 989 nla_put_be32(skb, IFLA_VTI_OKEY, parm->o_key))
992 goto nla_put_failure; 990 goto nla_put_failure;
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index ff883c9d0e3c..caf6b99374e6 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -2378,8 +2378,8 @@ static int ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb,
2378 rtm->rtm_protocol = RTPROT_MROUTED; 2378 rtm->rtm_protocol = RTPROT_MROUTED;
2379 rtm->rtm_flags = 0; 2379 rtm->rtm_flags = 0;
2380 2380
2381 if (nla_put(skb, RTA_SRC, 16, &c->mf6c_origin) || 2381 if (nla_put_in6_addr(skb, RTA_SRC, &c->mf6c_origin) ||
2382 nla_put(skb, RTA_DST, 16, &c->mf6c_mcastgrp)) 2382 nla_put_in6_addr(skb, RTA_DST, &c->mf6c_mcastgrp))
2383 goto nla_put_failure; 2383 goto nla_put_failure;
2384 err = __ip6mr_fill_mroute(mrt, skb, c, rtm); 2384 err = __ip6mr_fill_mroute(mrt, skb, c, rtm);
2385 /* do not break the dump if cache is unresolved */ 2385 /* do not break the dump if cache is unresolved */
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 482dfb9f0f7e..c283827d60e2 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1049,8 +1049,7 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt)
1049 1049
1050 memcpy(ndmsg + 1, opt, opt->nd_opt_len << 3); 1050 memcpy(ndmsg + 1, opt, opt->nd_opt_len << 3);
1051 1051
1052 if (nla_put(skb, NDUSEROPT_SRCADDR, sizeof(struct in6_addr), 1052 if (nla_put_in6_addr(skb, NDUSEROPT_SRCADDR, &ipv6_hdr(ra)->saddr))
1053 &ipv6_hdr(ra)->saddr))
1054 goto nla_put_failure; 1053 goto nla_put_failure;
1055 nlmsg_end(skb, nlh); 1054 nlmsg_end(skb, nlh);
1056 1055
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index b68d0e59c1f8..78284a697439 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -290,10 +290,8 @@ ipv6_getorigdst(struct sock *sk, int optval, void __user *user, int *len)
290static int ipv6_tuple_to_nlattr(struct sk_buff *skb, 290static int ipv6_tuple_to_nlattr(struct sk_buff *skb,
291 const struct nf_conntrack_tuple *tuple) 291 const struct nf_conntrack_tuple *tuple)
292{ 292{
293 if (nla_put(skb, CTA_IP_V6_SRC, sizeof(u_int32_t) * 4, 293 if (nla_put_in6_addr(skb, CTA_IP_V6_SRC, &tuple->src.u3.in6) ||
294 &tuple->src.u3.ip6) || 294 nla_put_in6_addr(skb, CTA_IP_V6_DST, &tuple->dst.u3.in6))
295 nla_put(skb, CTA_IP_V6_DST, sizeof(u_int32_t) * 4,
296 &tuple->dst.u3.ip6))
297 goto nla_put_failure; 295 goto nla_put_failure;
298 return 0; 296 return 0;
299 297
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index fe742fa0f7ff..385e9bd4f218 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2669,19 +2669,19 @@ static int rt6_fill_node(struct net *net,
2669 rtm->rtm_flags |= RTM_F_CLONED; 2669 rtm->rtm_flags |= RTM_F_CLONED;
2670 2670
2671 if (dst) { 2671 if (dst) {
2672 if (nla_put(skb, RTA_DST, 16, dst)) 2672 if (nla_put_in6_addr(skb, RTA_DST, dst))
2673 goto nla_put_failure; 2673 goto nla_put_failure;
2674 rtm->rtm_dst_len = 128; 2674 rtm->rtm_dst_len = 128;
2675 } else if (rtm->rtm_dst_len) 2675 } else if (rtm->rtm_dst_len)
2676 if (nla_put(skb, RTA_DST, 16, &rt->rt6i_dst.addr)) 2676 if (nla_put_in6_addr(skb, RTA_DST, &rt->rt6i_dst.addr))
2677 goto nla_put_failure; 2677 goto nla_put_failure;
2678#ifdef CONFIG_IPV6_SUBTREES 2678#ifdef CONFIG_IPV6_SUBTREES
2679 if (src) { 2679 if (src) {
2680 if (nla_put(skb, RTA_SRC, 16, src)) 2680 if (nla_put_in6_addr(skb, RTA_SRC, src))
2681 goto nla_put_failure; 2681 goto nla_put_failure;
2682 rtm->rtm_src_len = 128; 2682 rtm->rtm_src_len = 128;
2683 } else if (rtm->rtm_src_len && 2683 } else if (rtm->rtm_src_len &&
2684 nla_put(skb, RTA_SRC, 16, &rt->rt6i_src.addr)) 2684 nla_put_in6_addr(skb, RTA_SRC, &rt->rt6i_src.addr))
2685 goto nla_put_failure; 2685 goto nla_put_failure;
2686#endif 2686#endif
2687 if (iif) { 2687 if (iif) {
@@ -2705,14 +2705,14 @@ static int rt6_fill_node(struct net *net,
2705 } else if (dst) { 2705 } else if (dst) {
2706 struct in6_addr saddr_buf; 2706 struct in6_addr saddr_buf;
2707 if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0 && 2707 if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0 &&
2708 nla_put(skb, RTA_PREFSRC, 16, &saddr_buf)) 2708 nla_put_in6_addr(skb, RTA_PREFSRC, &saddr_buf))
2709 goto nla_put_failure; 2709 goto nla_put_failure;
2710 } 2710 }
2711 2711
2712 if (rt->rt6i_prefsrc.plen) { 2712 if (rt->rt6i_prefsrc.plen) {
2713 struct in6_addr saddr_buf; 2713 struct in6_addr saddr_buf;
2714 saddr_buf = rt->rt6i_prefsrc.addr; 2714 saddr_buf = rt->rt6i_prefsrc.addr;
2715 if (nla_put(skb, RTA_PREFSRC, 16, &saddr_buf)) 2715 if (nla_put_in6_addr(skb, RTA_PREFSRC, &saddr_buf))
2716 goto nla_put_failure; 2716 goto nla_put_failure;
2717 } 2717 }
2718 2718
@@ -2720,7 +2720,7 @@ static int rt6_fill_node(struct net *net,
2720 goto nla_put_failure; 2720 goto nla_put_failure;
2721 2721
2722 if (rt->rt6i_flags & RTF_GATEWAY) { 2722 if (rt->rt6i_flags & RTF_GATEWAY) {
2723 if (nla_put(skb, RTA_GATEWAY, 16, &rt->rt6i_gateway) < 0) 2723 if (nla_put_in6_addr(skb, RTA_GATEWAY, &rt->rt6i_gateway) < 0)
2724 goto nla_put_failure; 2724 goto nla_put_failure;
2725 } 2725 }
2726 2726
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 92692a7e8a2b..0e2bb538a556 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1683,8 +1683,8 @@ static int ipip6_fill_info(struct sk_buff *skb, const struct net_device *dev)
1683 struct ip_tunnel_parm *parm = &tunnel->parms; 1683 struct ip_tunnel_parm *parm = &tunnel->parms;
1684 1684
1685 if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) || 1685 if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
1686 nla_put_be32(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) || 1686 nla_put_in_addr(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) ||
1687 nla_put_be32(skb, IFLA_IPTUN_REMOTE, parm->iph.daddr) || 1687 nla_put_in_addr(skb, IFLA_IPTUN_REMOTE, parm->iph.daddr) ||
1688 nla_put_u8(skb, IFLA_IPTUN_TTL, parm->iph.ttl) || 1688 nla_put_u8(skb, IFLA_IPTUN_TTL, parm->iph.ttl) ||
1689 nla_put_u8(skb, IFLA_IPTUN_TOS, parm->iph.tos) || 1689 nla_put_u8(skb, IFLA_IPTUN_TOS, parm->iph.tos) ||
1690 nla_put_u8(skb, IFLA_IPTUN_PMTUDISC, 1690 nla_put_u8(skb, IFLA_IPTUN_PMTUDISC,
@@ -1694,10 +1694,10 @@ static int ipip6_fill_info(struct sk_buff *skb, const struct net_device *dev)
1694 goto nla_put_failure; 1694 goto nla_put_failure;
1695 1695
1696#ifdef CONFIG_IPV6_SIT_6RD 1696#ifdef CONFIG_IPV6_SIT_6RD
1697 if (nla_put(skb, IFLA_IPTUN_6RD_PREFIX, sizeof(struct in6_addr), 1697 if (nla_put_in6_addr(skb, IFLA_IPTUN_6RD_PREFIX,
1698 &tunnel->ip6rd.prefix) || 1698 &tunnel->ip6rd.prefix) ||
1699 nla_put_be32(skb, IFLA_IPTUN_6RD_RELAY_PREFIX, 1699 nla_put_in_addr(skb, IFLA_IPTUN_6RD_RELAY_PREFIX,
1700 tunnel->ip6rd.relay_prefix) || 1700 tunnel->ip6rd.relay_prefix) ||
1701 nla_put_u16(skb, IFLA_IPTUN_6RD_PREFIXLEN, 1701 nla_put_u16(skb, IFLA_IPTUN_6RD_PREFIXLEN,
1702 tunnel->ip6rd.prefixlen) || 1702 tunnel->ip6rd.prefixlen) ||
1703 nla_put_u16(skb, IFLA_IPTUN_6RD_RELAY_PREFIXLEN, 1703 nla_put_u16(skb, IFLA_IPTUN_6RD_RELAY_PREFIXLEN,
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 }
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index 70440748fe5c..13f777f20995 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -293,15 +293,13 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
293 return -ENOMEM; 293 return -ENOMEM;
294 294
295 addr_struct.s_addr = iter4->addr; 295 addr_struct.s_addr = iter4->addr;
296 ret_val = nla_put(skb, NLBL_MGMT_A_IPV4ADDR, 296 ret_val = nla_put_in_addr(skb, NLBL_MGMT_A_IPV4ADDR,
297 sizeof(struct in_addr), 297 addr_struct.s_addr);
298 &addr_struct);
299 if (ret_val != 0) 298 if (ret_val != 0)
300 return ret_val; 299 return ret_val;
301 addr_struct.s_addr = iter4->mask; 300 addr_struct.s_addr = iter4->mask;
302 ret_val = nla_put(skb, NLBL_MGMT_A_IPV4MASK, 301 ret_val = nla_put_in_addr(skb, NLBL_MGMT_A_IPV4MASK,
303 sizeof(struct in_addr), 302 addr_struct.s_addr);
304 &addr_struct);
305 if (ret_val != 0) 303 if (ret_val != 0)
306 return ret_val; 304 return ret_val;
307 map4 = netlbl_domhsh_addr4_entry(iter4); 305 map4 = netlbl_domhsh_addr4_entry(iter4);
@@ -328,14 +326,12 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
328 if (nla_b == NULL) 326 if (nla_b == NULL)
329 return -ENOMEM; 327 return -ENOMEM;
330 328
331 ret_val = nla_put(skb, NLBL_MGMT_A_IPV6ADDR, 329 ret_val = nla_put_in6_addr(skb, NLBL_MGMT_A_IPV6ADDR,
332 sizeof(struct in6_addr), 330 &iter6->addr);
333 &iter6->addr);
334 if (ret_val != 0) 331 if (ret_val != 0)
335 return ret_val; 332 return ret_val;
336 ret_val = nla_put(skb, NLBL_MGMT_A_IPV6MASK, 333 ret_val = nla_put_in6_addr(skb, NLBL_MGMT_A_IPV6MASK,
337 sizeof(struct in6_addr), 334 &iter6->mask);
338 &iter6->mask);
339 if (ret_val != 0) 335 if (ret_val != 0)
340 return ret_val; 336 return ret_val;
341 map6 = netlbl_domhsh_addr6_entry(iter6); 337 map6 = netlbl_domhsh_addr6_entry(iter6);
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index aec7994f78cf..b0380927f05f 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -1117,34 +1117,30 @@ static int netlbl_unlabel_staticlist_gen(u32 cmd,
1117 struct in_addr addr_struct; 1117 struct in_addr addr_struct;
1118 1118
1119 addr_struct.s_addr = addr4->list.addr; 1119 addr_struct.s_addr = addr4->list.addr;
1120 ret_val = nla_put(cb_arg->skb, 1120 ret_val = nla_put_in_addr(cb_arg->skb,
1121 NLBL_UNLABEL_A_IPV4ADDR, 1121 NLBL_UNLABEL_A_IPV4ADDR,
1122 sizeof(struct in_addr), 1122 addr_struct.s_addr);
1123 &addr_struct);
1124 if (ret_val != 0) 1123 if (ret_val != 0)
1125 goto list_cb_failure; 1124 goto list_cb_failure;
1126 1125
1127 addr_struct.s_addr = addr4->list.mask; 1126 addr_struct.s_addr = addr4->list.mask;
1128 ret_val = nla_put(cb_arg->skb, 1127 ret_val = nla_put_in_addr(cb_arg->skb,
1129 NLBL_UNLABEL_A_IPV4MASK, 1128 NLBL_UNLABEL_A_IPV4MASK,
1130 sizeof(struct in_addr), 1129 addr_struct.s_addr);
1131 &addr_struct);
1132 if (ret_val != 0) 1130 if (ret_val != 0)
1133 goto list_cb_failure; 1131 goto list_cb_failure;
1134 1132
1135 secid = addr4->secid; 1133 secid = addr4->secid;
1136 } else { 1134 } else {
1137 ret_val = nla_put(cb_arg->skb, 1135 ret_val = nla_put_in6_addr(cb_arg->skb,
1138 NLBL_UNLABEL_A_IPV6ADDR, 1136 NLBL_UNLABEL_A_IPV6ADDR,
1139 sizeof(struct in6_addr), 1137 &addr6->list.addr);
1140 &addr6->list.addr);
1141 if (ret_val != 0) 1138 if (ret_val != 0)
1142 goto list_cb_failure; 1139 goto list_cb_failure;
1143 1140
1144 ret_val = nla_put(cb_arg->skb, 1141 ret_val = nla_put_in6_addr(cb_arg->skb,
1145 NLBL_UNLABEL_A_IPV6MASK, 1142 NLBL_UNLABEL_A_IPV6MASK,
1146 sizeof(struct in6_addr), 1143 &addr6->list.mask);
1147 &addr6->list.mask);
1148 if (ret_val != 0) 1144 if (ret_val != 0)
1149 goto list_cb_failure; 1145 goto list_cb_failure;
1150 1146
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 22b18c145c92..c0c5b5519f45 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -648,10 +648,12 @@ static int __ipv4_tun_to_nlattr(struct sk_buff *skb,
648 nla_put_be64(skb, OVS_TUNNEL_KEY_ATTR_ID, output->tun_id)) 648 nla_put_be64(skb, OVS_TUNNEL_KEY_ATTR_ID, output->tun_id))
649 return -EMSGSIZE; 649 return -EMSGSIZE;
650 if (output->ipv4_src && 650 if (output->ipv4_src &&
651 nla_put_be32(skb, OVS_TUNNEL_KEY_ATTR_IPV4_SRC, output->ipv4_src)) 651 nla_put_in_addr(skb, OVS_TUNNEL_KEY_ATTR_IPV4_SRC,
652 output->ipv4_src))
652 return -EMSGSIZE; 653 return -EMSGSIZE;
653 if (output->ipv4_dst && 654 if (output->ipv4_dst &&
654 nla_put_be32(skb, OVS_TUNNEL_KEY_ATTR_IPV4_DST, output->ipv4_dst)) 655 nla_put_in_addr(skb, OVS_TUNNEL_KEY_ATTR_IPV4_DST,
656 output->ipv4_dst))
655 return -EMSGSIZE; 657 return -EMSGSIZE;
656 if (output->ipv4_tos && 658 if (output->ipv4_tos &&
657 nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TOS, output->ipv4_tos)) 659 nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TOS, output->ipv4_tos))
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d6ba4a6bbff6..6a4a4d7db1fc 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -8761,8 +8761,8 @@ static int nl80211_send_wowlan_tcp(struct sk_buff *msg,
8761 if (!nl_tcp) 8761 if (!nl_tcp)
8762 return -ENOBUFS; 8762 return -ENOBUFS;
8763 8763
8764 if (nla_put_be32(msg, NL80211_WOWLAN_TCP_SRC_IPV4, tcp->src) || 8764 if (nla_put_in_addr(msg, NL80211_WOWLAN_TCP_SRC_IPV4, tcp->src) ||
8765 nla_put_be32(msg, NL80211_WOWLAN_TCP_DST_IPV4, tcp->dst) || 8765 nla_put_in_addr(msg, NL80211_WOWLAN_TCP_DST_IPV4, tcp->dst) ||
8766 nla_put(msg, NL80211_WOWLAN_TCP_DST_MAC, ETH_ALEN, tcp->dst_mac) || 8766 nla_put(msg, NL80211_WOWLAN_TCP_DST_MAC, ETH_ALEN, tcp->dst_mac) ||
8767 nla_put_u16(msg, NL80211_WOWLAN_TCP_SRC_PORT, tcp->src_port) || 8767 nla_put_u16(msg, NL80211_WOWLAN_TCP_SRC_PORT, tcp->src_port) ||
8768 nla_put_u16(msg, NL80211_WOWLAN_TCP_DST_PORT, tcp->dst_port) || 8768 nla_put_u16(msg, NL80211_WOWLAN_TCP_DST_PORT, tcp->dst_port) ||