[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20131121.125707.653753874005080724.davem@davemloft.net>
Date: Thu, 21 Nov 2013 12:57:07 -0500 (EST)
From: David Miller <davem@...emloft.net>
To: eric.dumazet@...il.com
Cc: vyasevich@...il.com, netdev@...r.kernel.org
Subject: Re: [PATCH] net: rework recvmsg handler msg_name and msg_namelen
logic
From: Eric Dumazet <eric.dumazet@...il.com>
Date: Thu, 21 Nov 2013 07:00:14 -0800
> So a protocol should use BUILD_BUG_ON() to make sure sockaddr_storage is
> big enough.
Hannes mentioned trying to do this, somehow, automatically. Best I could
come up with is something like:
#define DECLARE_RECVMSG_HANDLER(name, ..., sockaddr_type) \
static ... __name(...); \
static ... name(...) \
{ \
BUILD_BUG_ON(sizeof(sockaddr_type) > sizeof(sockaddr_storage); \
__name(...); \
} \
static ... __name(...)
And then the protocols go:
DECLARE_RECVMSG_HANDLER(udp_recvmsg, ..., struct sockaddr_in)
{
struct inet_sock *inet = inet_sk(sk);
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
...
You get the idea.
Slightly convoluted, and we can do something special with types or the
prot ops member name to enforce usage of the macro.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists