]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
xfrm: simplify xfrm_address_t use
authorJiri Benc <jbenc@redhat.com>
Sun, 29 Mar 2015 14:59:24 +0000 (16:59 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 31 Mar 2015 17:58:35 +0000 (13:58 -0400)
In many places, the a6 field is typecasted to struct in6_addr. As the
fields are in union anyway, just add in6_addr type to the union and
get rid of the typecasting.

Modifying the uapi header is okay, the union has still the same size.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/xfrm.h
include/uapi/linux/xfrm.h
net/ipv6/xfrm6_mode_beet.c
net/ipv6/xfrm6_policy.c
net/key/af_key.c
net/xfrm/xfrm_state.c

index d0ac7d7be8a71cdc13c444677b5bef4f3aa82fc9..461f8353949370f7342f83d23513d864ac0adc6f 100644 (file)
@@ -1025,7 +1025,7 @@ xfrm_addr_any(const xfrm_address_t *addr, unsigned short family)
        case AF_INET:
                return addr->a4 == 0;
        case AF_INET6:
-               return ipv6_addr_any((struct in6_addr *)&addr->a6);
+               return ipv6_addr_any(&addr->in6);
        }
        return 0;
 }
@@ -1238,8 +1238,8 @@ void xfrm_flowi_addr_get(const struct flowi *fl,
                memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4));
                break;
        case AF_INET6:
-               *(struct in6_addr *)saddr->a6 = fl->u.ip6.saddr;
-               *(struct in6_addr *)daddr->a6 = fl->u.ip6.daddr;
+               saddr->in6 = fl->u.ip6.saddr;
+               daddr->in6 = fl->u.ip6.daddr;
                break;
        }
 }
index 02d5125a5ee8b285032ef3b066d2c48efca7c95a..2cd9e608d0d17d88985c3e32774e567da3236bb5 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _LINUX_XFRM_H
 #define _LINUX_XFRM_H
 
+#include <linux/in6.h>
 #include <linux/types.h>
 
 /* All of the structures in this file may not change size as they are
@@ -13,6 +14,7 @@
 typedef union {
        __be32          a4;
        __be32          a6[4];
+       struct in6_addr in6;
 } xfrm_address_t;
 
 /* Ident of a specific xfrm_state. It is used on input to lookup
index 9949a356d62c8f5e1808e3de0957b28a814b5084..1e205c3253acbcdde34ccf2c2dbce3fb63b10967 100644 (file)
@@ -95,8 +95,8 @@ static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb)
 
        ip6h = ipv6_hdr(skb);
        ip6h->payload_len = htons(skb->len - size);
-       ip6h->daddr = *(struct in6_addr *)&x->sel.daddr.a6;
-       ip6h->saddr = *(struct in6_addr *)&x->sel.saddr.a6;
+       ip6h->daddr = x->sel.daddr.in6;
+       ip6h->saddr = x->sel.saddr.in6;
        err = 0;
 out:
        return err;
index 91d934c22a2a103e4bb6785d7428dfcd22335d05..f337a908a76a1145c8b878c224f961d087769785 100644 (file)
@@ -61,9 +61,7 @@ static int xfrm6_get_saddr(struct net *net,
                return -EHOSTUNREACH;
 
        dev = ip6_dst_idev(dst)->dev;
-       ipv6_dev_get_saddr(dev_net(dev), dev,
-                          (struct in6_addr *)&daddr->a6, 0,
-                          (struct in6_addr *)&saddr->a6);
+       ipv6_dev_get_saddr(dev_net(dev), dev, &daddr->in6, 0, &saddr->in6);
        dst_release(dst);
        return 0;
 }
index 9255fd9d94bc9eb2762e18997d8d3cb609f4054d..f0d52d721b3a4405b47f38d8f5d6c1990cbf8b5f 100644 (file)
@@ -709,7 +709,7 @@ static unsigned int pfkey_sockaddr_fill(const xfrm_address_t *xaddr, __be16 port
                sin6->sin6_family = AF_INET6;
                sin6->sin6_port = port;
                sin6->sin6_flowinfo = 0;
-               sin6->sin6_addr = *(struct in6_addr *)xaddr->a6;
+               sin6->sin6_addr = xaddr->in6;
                sin6->sin6_scope_id = 0;
                return 128;
            }
index de971b6d38c58310f744988bb970ccb5438ef39b..f5e39e35d73aa96c3551b0e46f9b26ab291d23aa 100644 (file)
@@ -1043,12 +1043,12 @@ static struct xfrm_state *__find_acq_core(struct net *net,
                        break;
 
                case AF_INET6:
-                       *(struct in6_addr *)x->sel.daddr.a6 = *(struct in6_addr *)daddr;
-                       *(struct in6_addr *)x->sel.saddr.a6 = *(struct in6_addr *)saddr;
+                       x->sel.daddr.in6 = daddr->in6;
+                       x->sel.saddr.in6 = saddr->in6;
                        x->sel.prefixlen_d = 128;
                        x->sel.prefixlen_s = 128;
-                       *(struct in6_addr *)x->props.saddr.a6 = *(struct in6_addr *)saddr;
-                       *(struct in6_addr *)x->id.daddr.a6 = *(struct in6_addr *)daddr;
+                       x->props.saddr.in6 = saddr->in6;
+                       x->id.daddr.in6 = daddr->in6;
                        break;
                }