From: Thomas Graf <tgraf@suug.ch>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH 1/4] [NETLINK]: Handle NLM_F_ECHO in netlink_rcv_skb()
Date: Wed, 09 Aug 2006 00:00:01 +0200 [thread overview]
Message-ID: <20060809205439.434010049@postel.suug.ch> (raw)
In-Reply-To: 20060809204821.216122988@postel.suug.ch
[-- Attachment #1: nl_echo --]
[-- Type: text/plain, Size: 1839 bytes --]
The current behaviour around NLM_F_ECHO is inconsistent
and spread all around in various subsystems and doesn't
represent what it was meant for.
This patch handles NLM_F_ECHO in netlink_rcv_skb() to
handle it in a central point. Most subsystems currently
interpret NLM_F_ECHO as to just unicast events to the
originator of the change while the real meaning of the
flag is to echo the request.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Index: net-2.6.19.git/net/netlink/af_netlink.c
===================================================================
--- net-2.6.19.git.orig/net/netlink/af_netlink.c
+++ net-2.6.19.git/net/netlink/af_netlink.c
@@ -1430,6 +1430,28 @@ int netlink_dump_start(struct sock *ssk,
return 0;
}
+static void netlink_echo(struct sk_buff *in_skb, struct nlmsghdr *orig)
+{
+ struct sk_buff *skb;
+ struct nlmsghdr *nlh;
+ int payload = nlmsg_len(orig);
+
+ skb = nlmsg_new(nlmsg_total_size(payload), GFP_KERNEL);
+ if (skb == NULL)
+ return;
+
+ /*
+ * Return original header with pid set to 0 (from kernel) and
+ * NLM_F_REQUEST flag removed to indicate this is not a request
+ * for an echo but the reply.
+ */
+ nlh = __nlmsg_put(skb, 0, orig->nlmsg_seq, orig->nlmsg_type,
+ payload, orig->nlmsg_flags & ~NLM_F_REQUEST);
+ memcpy(nlmsg_data(nlh), nlmsg_data(orig), payload);
+
+ nlmsg_unicast(in_skb->sk, skb, NETLINK_CB(in_skb).pid);
+}
+
void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err)
{
struct sk_buff *skb;
@@ -1476,6 +1498,9 @@ static int netlink_rcv_skb(struct sk_buf
if (nlh->nlmsg_len < NLMSG_HDRLEN || skb->len < nlh->nlmsg_len)
return 0;
+ if (nlh->nlmsg_flags & NLM_F_ECHO)
+ netlink_echo(skb, nlh);
+
if (cb(skb, nlh, &err) < 0) {
/* Not an error, but we have to interrupt processing
* here. Note: that in this case we do not pull
next prev parent reply other threads:[~2006-08-09 20:55 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-09 20:48 [PATCHSET]: Clean up netlink NLM_F_ECHO and rtnl event notifications Thomas Graf
2006-08-08 22:00 ` Thomas Graf [this message]
2006-08-10 15:51 ` [PATCH 1/4] [NETLINK]: Handle NLM_F_ECHO in netlink_rcv_skb() Alexey Kuznetsov
2006-08-10 19:02 ` Thomas Graf
2006-08-10 20:32 ` Alexey Kuznetsov
2006-08-10 21:18 ` Thomas Graf
2006-08-11 15:35 ` Alexey Kuznetsov
2006-08-11 21:47 ` Thomas Graf
2006-08-12 11:03 ` Alexey Kuznetsov
2006-08-12 11:19 ` Thomas Graf
2006-08-13 13:45 ` Alexey Kuznetsov
2006-08-12 3:05 ` Herbert Xu
2006-08-12 11:05 ` Alexey Kuznetsov
2006-08-08 22:00 ` [PATCH 2/4] [RTNETLINK]: Use rtnl_multicast()/rtnl_unicast() Thomas Graf
2006-08-09 21:00 ` [RESEND " Thomas Graf
2006-08-08 22:00 ` [PATCH 3/4] [NETLINK]: Dont set socket error for failed event notifications Thomas Graf
2006-08-10 18:09 ` Patrick McHardy
2006-08-10 19:04 ` Thomas Graf
2006-08-10 19:08 ` Patrick McHardy
2006-08-10 19:23 ` Thomas Graf
2006-08-11 6:02 ` David Miller
2006-08-11 10:38 ` Thomas Graf
2006-08-11 10:42 ` David Miller
2006-08-08 22:00 ` [PATCH 4/4] [RTNETLINK]: Unexport global rtnl sock Thomas Graf
2006-08-10 4:16 ` [PATCHSET]: Clean up netlink NLM_F_ECHO and rtnl event notifications David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060809205439.434010049@postel.suug.ch \
--to=tgraf@suug.ch \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).