aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/route.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 /net/ipv6/route.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 'net/ipv6/route.c')
-rw-r--r--net/ipv6/route.c14
1 files changed, 7 insertions, 7 deletions
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