Re: [PATCH 009 of 14] knfsd: SUNRPC: teach svc_sendto() to deal with IPv6 addresses

From: Ingo Oeser
Date: Sun Dec 17 2006 - 10:16:08 EST


On Wednesday, 13. December 2006 00:59, NeilBrown wrote:
> diff .prev/net/sunrpc/svcsock.c ./net/sunrpc/svcsock.c
> --- .prev/net/sunrpc/svcsock.c 2006-12-13 10:31:39.000000000 +1100
> +++ ./net/sunrpc/svcsock.c 2006-12-13 10:32:15.000000000 +1100
> @@ -438,6 +439,47 @@ svc_wake_up(struct svc_serv *serv)
> }
> }
>
> +union svc_pktinfo_u {
> + struct in_pktinfo pkti;
> +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
> + struct in6_pktinfo pkti6;
> +#endif
> +};
> +
> +static void svc_set_cmsg_data(struct svc_rqst *rqstp, struct cmsghdr *cmh)
> +{
> + switch (rqstp->rq_sock->sk_sk->sk_family) {
> + case AF_INET:
> + do {
> + struct in_pktinfo *pki =
> + (struct in_pktinfo *) CMSG_DATA(cmh);

struct in_pktinfo *pki = CMSG_DATA(cmh);

Ugly casting not needed here, since CMSG_DATA should return "void *",
which can be casted to any pointer.

> +
> + cmh->cmsg_level = SOL_IP;
> + cmh->cmsg_type = IP_PKTINFO;
> + pki->ipi_ifindex = 0;
> + pki->ipi_spec_dst.s_addr = rqstp->rq_daddr.addr.s_addr;
> + cmh->cmsg_len = CMSG_LEN(sizeof(*pki));
> + } while (0);
> + break;
> +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
> + case AF_INET6:
> + do {
> + struct in6_pktinfo *pki =
> + (struct in6_pktinfo *) CMSG_DATA(cmh);
> +

No casting needed, so:

struct in6_pktinfo *pki = CMSG_DATA(cmh);


Regards

Ingo Oeser
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/