Commit 6c40d100 authored by YOSHIFUJI Hideaki / 吉藤英明's avatar YOSHIFUJI Hideaki / 吉藤英明 Committed by David S. Miller

ipv6: Use container_of macro instead of magic number to get ipv6 header.

In ipv6_recv_error(), addr_offset points to daddr field of the ip header.
To get ipv6 header, use container_of() macro instead of substracting magic
number (24).
Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 29166107
...@@ -356,12 +356,11 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) ...@@ -356,12 +356,11 @@ 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 (skb->protocol == htons(ETH_P_IPV6)) { if (skb->protocol == htons(ETH_P_IPV6)) {
sin->sin6_addr = const struct ipv6hdr *ip6h = container_of((struct in6_addr *)(nh + serr->addr_offset),
*(struct in6_addr *)(nh + serr->addr_offset); struct ipv6hdr, daddr);
sin->sin6_addr = ip6h->daddr;
if (np->sndflow) if (np->sndflow)
sin->sin6_flowinfo = sin->sin6_flowinfo = *(__be32 *)ip6h & IPV6_FLOWINFO_MASK;
(*(__be32 *)(nh + 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)
sin->sin6_scope_id = IP6CB(skb)->iif; sin->sin6_scope_id = IP6CB(skb)->iif;
} else { } else {
......
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