Subject: Re: [PATCH 1/4] [NETLINK]: Handle NLM_F_ECHO in netlink_rcv_skb()

From: Thomas Graf <[email-masked]>
Date: Sat, 12 Aug 2006 13:19:08 +0200

* Alexey Kuznetsov <[email-masked]> 2006-08-12 15:03
> Actually, it was the idea. If requestor asked NLM_F_ECHO and subscribed
> to muticasts, it suppresses double notifications. If it did not ask
> NLM_F_ECHO, he is not interested in results, he knows what's going on
> without this.
> 
> F.e. it was used by my implementation in gated: it did not set either
> NLM_F_ECHO or even NLM_F_ACK. And when making massive batch updates,
> it received nothing back: only errors and updates made by someone else.

So we do something like this:

/**
 * nlmsg_notify - send a notification netlink message
 * @sk: netlink socket to use
 * @skb: notification message
 * @pid: destination netlink pid for reports or 0
 * @group: destination multicast group or 0
 * @report: 1 to report back, 0 to disable
 * @flags: allocation flags
 */
int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 pid,
		 unsigned int group, int report, gfp_t flags)
{
	int err = 0;

	if (group) {
		int exclude_pid = 0;

		if (report) {
			atomic_inc(&skb->users);
			exclude_pid = pid;
		}

		/* errors reported via destination sk->sk_err */
		nlmsg_multicast(sk, skb, exclude_pid, group, flags);
	}

	if (report)
		err = nlmsg_unicast(sk, skb, pid);

	return err;
}