Commit 6b63219c authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji Committed by David S. Miller

[IPV6]: Fix IPV6_PKTINFO et al. handling in udpv6_recvmsg().

CMSG reception needs to occur even if msg_name is not
set.
Signed-off-by: default avatarHideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ad6540a6
...@@ -219,6 +219,7 @@ static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -219,6 +219,7 @@ static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
int noblock, int flags, int *addr_len) int noblock, int flags, int *addr_len)
{ {
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
struct inet_sock *inet = inet_sk(sk);
struct sk_buff *skb; struct sk_buff *skb;
size_t copied; size_t copied;
int err; int err;
...@@ -268,21 +269,22 @@ static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -268,21 +269,22 @@ static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
sin6->sin6_flowinfo = 0; sin6->sin6_flowinfo = 0;
sin6->sin6_scope_id = 0; sin6->sin6_scope_id = 0;
if (skb->protocol == htons(ETH_P_IP)) { if (skb->protocol == htons(ETH_P_IP))
struct inet_sock *inet = inet_sk(sk);
ipv6_addr_set(&sin6->sin6_addr, 0, 0, ipv6_addr_set(&sin6->sin6_addr, 0, 0,
htonl(0xffff), skb->nh.iph->saddr); htonl(0xffff), skb->nh.iph->saddr);
else {
ipv6_addr_copy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr);
if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)
sin6->sin6_scope_id = IP6CB(skb)->iif;
}
}
if (skb->protocol == htons(ETH_P_IP)) {
if (inet->cmsg_flags) if (inet->cmsg_flags)
ip_cmsg_recv(msg, skb); ip_cmsg_recv(msg, skb);
} else { } else {
ipv6_addr_copy(&sin6->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(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)
sin6->sin6_scope_id = IP6CB(skb)->iif;
}
} }
err = copied; err = copied;
......
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