o ipv4/ipv6: use ipv6_addr_copy where appropriate

parent f4e0fb85
...@@ -88,8 +88,10 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, ...@@ -88,8 +88,10 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
r->tcpdiag_inode = 0; r->tcpdiag_inode = 0;
#ifdef CONFIG_IPV6 #ifdef CONFIG_IPV6
if (r->tcpdiag_family == AF_INET6) { if (r->tcpdiag_family == AF_INET6) {
memcpy(r->id.tcpdiag_src, &tw->v6_rcv_saddr, 16); ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,
memcpy(r->id.tcpdiag_dst, &tw->v6_daddr, 16); &tw->v6_rcv_saddr);
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,
&tw->v6_daddr);
} }
#endif #endif
nlh->nlmsg_len = skb->tail - b; nlh->nlmsg_len = skb->tail - b;
...@@ -105,8 +107,10 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, ...@@ -105,8 +107,10 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
if (r->tcpdiag_family == AF_INET6) { if (r->tcpdiag_family == AF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
memcpy(r->id.tcpdiag_src, &np->rcv_saddr, 16); ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,
memcpy(r->id.tcpdiag_dst, &np->daddr, 16); &np->rcv_saddr);
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,
&np->daddr);
} }
#endif #endif
......
...@@ -381,10 +381,8 @@ void tcp_time_wait(struct sock *sk, int state, int timeo) ...@@ -381,10 +381,8 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
if(tw->family == PF_INET6) { if(tw->family == PF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
memcpy(&tw->v6_daddr, &np->daddr, ipv6_addr_copy(&tw->v6_daddr, &np->daddr);
sizeof(struct in6_addr)); ipv6_addr_copy(&tw->v6_rcv_saddr, &np->rcv_saddr);
memcpy(&tw->v6_rcv_saddr, &np->rcv_saddr,
sizeof(struct in6_addr));
} }
#endif #endif
/* Linkage updates. */ /* Linkage updates. */
......
...@@ -1195,7 +1195,7 @@ addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev, ...@@ -1195,7 +1195,7 @@ addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev,
struct in6_rtmsg rtmsg; struct in6_rtmsg rtmsg;
memset(&rtmsg, 0, sizeof(rtmsg)); memset(&rtmsg, 0, sizeof(rtmsg));
memcpy(&rtmsg.rtmsg_dst, pfx, sizeof(struct in6_addr)); ipv6_addr_copy(&rtmsg.rtmsg_dst, pfx);
rtmsg.rtmsg_dst_len = plen; rtmsg.rtmsg_dst_len = plen;
rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF; rtmsg.rtmsg_metric = IP6_RT_PRIO_ADDRCONF;
rtmsg.rtmsg_ifindex = dev->ifindex; rtmsg.rtmsg_ifindex = dev->ifindex;
......
...@@ -437,16 +437,14 @@ int inet6_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -437,16 +437,14 @@ int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
if (((1<<sk->state)&(TCPF_CLOSE|TCPF_SYN_SENT)) && peer == 1) if (((1<<sk->state)&(TCPF_CLOSE|TCPF_SYN_SENT)) && peer == 1)
return -ENOTCONN; return -ENOTCONN;
sin->sin6_port = inet->dport; sin->sin6_port = inet->dport;
memcpy(&sin->sin6_addr, &np->daddr, sizeof(struct in6_addr)); ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
if (np->sndflow) if (np->sndflow)
sin->sin6_flowinfo = np->flow_label; sin->sin6_flowinfo = np->flow_label;
} else { } else {
if (ipv6_addr_type(&np->rcv_saddr) == IPV6_ADDR_ANY) if (ipv6_addr_type(&np->rcv_saddr) == IPV6_ADDR_ANY)
memcpy(&sin->sin6_addr, &np->saddr, ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
sizeof(struct in6_addr));
else else
memcpy(&sin->sin6_addr, &np->rcv_saddr, ipv6_addr_copy(&sin->sin6_addr, &np->rcv_saddr);
sizeof(struct in6_addr));
sin->sin6_port = inet->sport; sin->sin6_port = inet->sport;
} }
......
...@@ -75,8 +75,8 @@ int ah6_output(struct sk_buff *skb) ...@@ -75,8 +75,8 @@ int ah6_output(struct sk_buff *skb)
skb->nh.ipv6h->version = 6; skb->nh.ipv6h->version = 6;
skb->nh.ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); skb->nh.ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
skb->nh.ipv6h->nexthdr = IPPROTO_AH; skb->nh.ipv6h->nexthdr = IPPROTO_AH;
memcpy(&skb->nh.ipv6h->saddr, &x->props.saddr, sizeof(struct in6_addr)); ipv6_addr_copy(&skb->nh.ipv6h->saddr, &x->props.saddr);
memcpy(&skb->nh.ipv6h->daddr, &x->id.daddr, sizeof(struct in6_addr)); ipv6_addr_copy(&skb->nh.ipv6h->daddr, &x->id.daddr);
ah = (struct ip_auth_hdr*)(skb->nh.ipv6h+1); ah = (struct ip_auth_hdr*)(skb->nh.ipv6h+1);
ah->nexthdr = IPPROTO_IPV6; ah->nexthdr = IPPROTO_IPV6;
} else { } else {
......
...@@ -80,7 +80,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info) ...@@ -80,7 +80,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
iph = (struct ipv6hdr*)skb_put(skb, sizeof(struct ipv6hdr)); iph = (struct ipv6hdr*)skb_put(skb, sizeof(struct ipv6hdr));
skb->nh.ipv6h = iph; skb->nh.ipv6h = iph;
memcpy(&iph->daddr, fl->fl6_dst, 16); ipv6_addr_copy(&iph->daddr, fl->fl6_dst);
serr = SKB_EXT_ERR(skb); serr = SKB_EXT_ERR(skb);
serr->ee.ee_errno = err; serr->ee.ee_errno = err;
...@@ -141,7 +141,8 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) ...@@ -141,7 +141,8 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
sin->sin6_port = serr->port; sin->sin6_port = serr->port;
sin->sin6_scope_id = 0; sin->sin6_scope_id = 0;
if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) { if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) {
memcpy(&sin->sin6_addr, skb->nh.raw + serr->addr_offset, 16); ipv6_addr_copy(&sin->sin6_addr,
(struct in6_addr *)(skb->nh.raw + serr->addr_offset));
if (np->sndflow) if (np->sndflow)
sin->sin6_flowinfo = *(u32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK; sin->sin6_flowinfo = *(u32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK;
if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) { if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
...@@ -163,7 +164,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) ...@@ -163,7 +164,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
sin->sin6_flowinfo = 0; sin->sin6_flowinfo = 0;
sin->sin6_scope_id = 0; sin->sin6_scope_id = 0;
if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) { if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) {
memcpy(&sin->sin6_addr, &skb->nh.ipv6h->saddr, 16); ipv6_addr_copy(&sin->sin6_addr, &skb->nh.ipv6h->saddr);
if (np->rxopt.all) if (np->rxopt.all)
datagram_recv_ctl(sk, msg, skb); datagram_recv_ctl(sk, msg, skb);
if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) { if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
......
...@@ -184,8 +184,10 @@ int esp6_output(struct sk_buff *skb) ...@@ -184,8 +184,10 @@ int esp6_output(struct sk_buff *skb)
top_iph->nexthdr = IPPROTO_ESP; top_iph->nexthdr = IPPROTO_ESP;
top_iph->payload_len = htons(skb->len + alen - sizeof(struct ipv6hdr)); top_iph->payload_len = htons(skb->len + alen - sizeof(struct ipv6hdr));
top_iph->hop_limit = iph->hop_limit; top_iph->hop_limit = iph->hop_limit;
memcpy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr, sizeof(struct in6_addr)); ipv6_addr_copy(&top_iph->saddr,
memcpy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr, sizeof(struct in6_addr)); (struct in6_addr *)&x->props.saddr);
ipv6_addr_copy(&top_iph->daddr,
(struct in6_addr *)&x->id.daddr);
} else { } else {
/* XXX exthdr */ /* XXX exthdr */
esph = (struct ipv6_esp_hdr*)skb_push(skb, x->props.header_len); esph = (struct ipv6_esp_hdr*)skb_push(skb, x->props.header_len);
......
...@@ -1463,8 +1463,8 @@ int ip6_push_pending_frames(struct sock *sk) ...@@ -1463,8 +1463,8 @@ int ip6_push_pending_frames(struct sock *sk)
hdr->payload_len = 0; hdr->payload_len = 0;
hdr->hop_limit = np->hop_limit; hdr->hop_limit = np->hop_limit;
hdr->nexthdr = proto; hdr->nexthdr = proto;
memcpy(&hdr->saddr, fl->fl6_src, sizeof(struct in6_addr)); ipv6_addr_copy(&hdr->saddr, fl->fl6_src);
memcpy(&hdr->daddr, final_dst, sizeof(struct in6_addr)); ipv6_addr_copy(&hdr->daddr, final_dst);
skb->dst = dst_clone(&rt->u.dst); skb->dst = dst_clone(&rt->u.dst);
err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dst->dev, dst_output); err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dst->dev, dst_output);
......
...@@ -179,7 +179,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr) ...@@ -179,7 +179,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr)
return -ENOMEM; return -ENOMEM;
mc_lst->next = NULL; mc_lst->next = NULL;
memcpy(&mc_lst->addr, addr, sizeof(struct in6_addr)); ipv6_addr_copy(&mc_lst->addr, addr);
if (ifindex == 0) { if (ifindex == 0) {
struct rt6_info *rt; struct rt6_info *rt;
...@@ -825,7 +825,7 @@ int ipv6_dev_mc_inc(struct net_device *dev, struct in6_addr *addr) ...@@ -825,7 +825,7 @@ int ipv6_dev_mc_inc(struct net_device *dev, struct in6_addr *addr)
mc->mca_timer.function = igmp6_timer_handler; mc->mca_timer.function = igmp6_timer_handler;
mc->mca_timer.data = (unsigned long) mc; mc->mca_timer.data = (unsigned long) mc;
memcpy(&mc->mca_addr, addr, sizeof(struct in6_addr)); ipv6_addr_copy(&mc->mca_addr, addr);
mc->idev = idev; mc->idev = idev;
mc->mca_users = 1; mc->mca_users = 1;
atomic_set(&mc->mca_refcnt, 2); atomic_set(&mc->mca_refcnt, 2);
......
...@@ -398,8 +398,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg ...@@ -398,8 +398,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
/* Copy the address. */ /* Copy the address. */
if (sin6) { if (sin6) {
sin6->sin6_family = AF_INET6; sin6->sin6_family = AF_INET6;
memcpy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr, ipv6_addr_copy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr);
sizeof(struct in6_addr));
sin6->sin6_flowinfo = 0; sin6->sin6_flowinfo = 0;
sin6->sin6_scope_id = 0; sin6->sin6_scope_id = 0;
if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) { if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
......
...@@ -467,8 +467,7 @@ static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg ...@@ -467,8 +467,7 @@ static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
if (inet->cmsg_flags) if (inet->cmsg_flags)
ip_cmsg_recv(msg, skb); ip_cmsg_recv(msg, skb);
} else { } else {
memcpy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr, ipv6_addr_copy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr);
sizeof(struct in6_addr));
if (np->rxopt.all) if (np->rxopt.all)
datagram_recv_ctl(sk, msg, skb); datagram_recv_ctl(sk, msg, skb);
......
...@@ -25,8 +25,8 @@ __xfrm6_init_tempsel(struct xfrm_state *x, struct flowi *fl, ...@@ -25,8 +25,8 @@ __xfrm6_init_tempsel(struct xfrm_state *x, struct flowi *fl,
{ {
/* Initialize temporary selector matching only /* Initialize temporary selector matching only
* to current session. */ * to current session. */
memcpy(&x->sel.daddr, fl->fl6_dst, sizeof(struct in6_addr)); ipv6_addr_copy((struct in6_addr *)&x->sel.daddr, fl->fl6_dst);
memcpy(&x->sel.saddr, fl->fl6_src, sizeof(struct in6_addr)); ipv6_addr_copy((struct in6_addr *)&x->sel.saddr, fl->fl6_src);
x->sel.dport = fl->fl_ip_dport; x->sel.dport = fl->fl_ip_dport;
x->sel.dport_mask = ~0; x->sel.dport_mask = ~0;
x->sel.sport = fl->fl_ip_sport; x->sel.sport = fl->fl_ip_sport;
...@@ -93,13 +93,17 @@ __xfrm6_find_acq(u8 mode, u16 reqid, u8 proto, ...@@ -93,13 +93,17 @@ __xfrm6_find_acq(u8 mode, u16 reqid, u8 proto,
if (x0) { if (x0) {
xfrm_state_hold(x0); xfrm_state_hold(x0);
} else if (create && (x0 = xfrm_state_alloc()) != NULL) { } else if (create && (x0 = xfrm_state_alloc()) != NULL) {
memcpy(x0->sel.daddr.a6, daddr, sizeof(struct in6_addr)); ipv6_addr_copy((struct in6_addr *)x0->sel.daddr.a6,
memcpy(x0->sel.saddr.a6, saddr, sizeof(struct in6_addr)); (struct in6_addr *)daddr);
ipv6_addr_copy((struct in6_addr *)x0->sel.saddr.a6,
(struct in6_addr *)saddr);
x0->sel.prefixlen_d = 128; x0->sel.prefixlen_d = 128;
x0->sel.prefixlen_s = 128; x0->sel.prefixlen_s = 128;
memcpy(x0->props.saddr.a6, saddr, sizeof(struct in6_addr)); ipv6_addr_copy((struct in6_addr *)x0->props.saddr.a6,
(struct in6_addr *)saddr);
x0->km.state = XFRM_STATE_ACQ; x0->km.state = XFRM_STATE_ACQ;
memcpy(x0->id.daddr.a6, daddr, sizeof(struct in6_addr)); ipv6_addr_copy((struct in6_addr *)x0->id.daddr.a6,
(struct in6_addr *)daddr);
x0->id.proto = proto; x0->id.proto = proto;
x0->props.family = AF_INET6; x0->props.family = AF_INET6;
x0->props.mode = mode; x0->props.mode = mode;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment