aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/vxlan.c
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 /drivers/net/vxlan.c
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>
Diffstat (limited to 'drivers/net/vxlan.c')
-rw-r--r--drivers/net/vxlan.c22
1 files changed, 11 insertions, 11 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 }