netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/7] netlink: Add allocation flag to netlink_unicast()
@ 2016-07-06  0:28 Masashi Honma
  2016-07-06  0:28 ` [RFC 1/7] " Masashi Honma
                   ` (7 more replies)
  0 siblings, 8 replies; 24+ messages in thread
From: Masashi Honma @ 2016-07-06  0:28 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-audit-H+wXaHxf7aLQT0dZR+AlfA,
	cluster-devel-H+wXaHxf7aLQT0dZR+AlfA
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, johannes-cdvu00un1VgdHxzADdlk8Q,
	pablo-Cap9r6Oaw4JrovVCs/uTlw, kaber-dcUjhNyLwpNeoWH0uzbU5w,
	kadlec-K40Dz/62t/MgiyqX0sVFJYdd74u8MsAO,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	paul-r2n+y4ga6xFZroRs9YW3xA, eparis-H+wXaHxf7aLQT0dZR+AlfA,
	zbr-i6C2adt8DTjR7s880joybQ, pshelar-l0M0P4e3n4LQT0dZR+AlfA,
	ccaulfie-H+wXaHxf7aLQT0dZR+AlfA, teigland-H+wXaHxf7aLQT0dZR+AlfA,
	bsingharora-Re5JQEeQqe8AvxtiuMwx3w, Masashi Honma

Though netlink_broadcast() has allocation flag which can specify
memory allocation type (ex. GFP_KERNEL/GFP_ATOMIC), netlink_unicast()
does not have it. This can cause "BUG: sleeping function called from
invalid context at" with CONFIG_DEBUG_ATOMIC_SLEEP enabled kernel when
calling netlink_unicast() inside RCU read-side section and not in IRQ.

Though currently such a use case was not found, to solve potential
issue we will add an allocation flag to netlink_unicast(). Previously
netlink_unicast() have used gfp_any() as a flag. We replaced it to
GFP_KERNEL or GFP_ATOMIC or etc by guessing based on context. If we
could not determine the value, we remain it gfp_any(). We welcome
comments like "this gfp_any() should be GFP_KERNEL". Of course other
comments are welcome as well.

This series of patches are not tested.
This is a RFC because this does not fix existing issue.

Masashi Honma (7):
  netlink: Add allocation flag to netlink_unicast()
  netfilter: Add allocation flag to nfnetlink_unicast()
  netlink: Add allocation flag to nlmsg_unicast()
  infiniband: Add allocation flag to ibnl_unicast()
  net: Add allocation flag to rtnl_unicast()
  genetlink: Add allocation flag to genlmsg_unicast()
  genetlink: Add allocation flag to genlmsg_reply()

 crypto/crypto_user.c                  |  3 ++-
 drivers/block/drbd/drbd_nl.c          |  2 +-
 drivers/connector/connector.c         |  2 +-
 drivers/infiniband/core/iwpm_msg.c    |  6 ++---
 drivers/infiniband/core/iwpm_util.c   |  5 ++--
 drivers/infiniband/core/iwpm_util.h   |  1 +
 drivers/infiniband/core/netlink.c     |  4 ++--
 drivers/net/gtp.c                     |  3 ++-
 drivers/net/team/team.c               |  5 ++--
 drivers/net/wireless/mac80211_hwsim.c |  4 ++--
 fs/dlm/netlink.c                      |  2 +-
 include/linux/netfilter/nfnetlink.h   |  2 +-
 include/linux/netlink.h               |  3 ++-
 include/linux/rtnetlink.h             |  3 ++-
 include/net/genetlink.h               | 13 +++++++----
 include/net/netlink.h                 |  6 +++--
 include/rdma/rdma_netlink.h           |  3 ++-
 kernel/audit.c                        |  9 ++++----
 kernel/taskstats.c                    |  4 ++--
 net/core/devlink.c                    | 12 +++++-----
 net/core/net_namespace.c              |  2 +-
 net/core/rtnetlink.c                  | 12 ++++++----
 net/dcb/dcbnl.c                       |  2 +-
 net/decnet/dn_route.c                 |  3 ++-
 net/hsr/hsr_netlink.c                 |  6 +++--
 net/ieee802154/ieee802154.h           |  3 ++-
 net/ieee802154/netlink.c              |  5 ++--
 net/ieee802154/nl-mac.c               |  4 ++--
 net/ieee802154/nl-phy.c               |  6 ++---
 net/ieee802154/nl802154.c             |  4 ++--
 net/ipv4/devinet.c                    |  2 +-
 net/ipv4/fib_frontend.c               |  2 +-
 net/ipv4/fou.c                        |  2 +-
 net/ipv4/inet_diag.c                  |  2 +-
 net/ipv4/ipmr.c                       |  6 +++--
 net/ipv4/route.c                      |  2 +-
 net/ipv4/tcp_metrics.c                |  2 +-
 net/ipv4/udp_diag.c                   |  2 +-
 net/ipv6/addrconf.c                   |  4 ++--
 net/ipv6/addrlabel.c                  |  2 +-
 net/ipv6/ila/ila_xlat.c               |  2 +-
 net/ipv6/ip6mr.c                      |  6 +++--
 net/ipv6/route.c                      |  2 +-
 net/irda/irnetlink.c                  |  2 +-
 net/l2tp/l2tp_netlink.c               |  8 ++++---
 net/netfilter/ipset/ip_set_core.c     | 11 +++++----
 net/netfilter/ipvs/ip_vs_ctl.c        |  2 +-
 net/netfilter/nf_conntrack_netlink.c  |  9 +++++---
 net/netfilter/nf_tables_api.c         | 10 ++++----
 net/netfilter/nfnetlink.c             |  4 ++--
 net/netfilter/nfnetlink_acct.c        |  2 +-
 net/netfilter/nfnetlink_cthelper.c    |  2 +-
 net/netfilter/nfnetlink_cttimeout.c   |  5 ++--
 net/netfilter/nfnetlink_log.c         |  4 ++--
 net/netfilter/nfnetlink_queue.c       |  3 ++-
 net/netfilter/nft_compat.c            |  4 ++--
 net/netlabel/netlabel_cipso_v4.c      |  2 +-
 net/netlabel/netlabel_mgmt.c          |  4 ++--
 net/netlabel/netlabel_unlabeled.c     |  2 +-
 net/netlink/af_netlink.c              | 14 +++++++-----
 net/netlink/genetlink.c               |  2 +-
 net/nfc/netlink.c                     |  6 ++---
 net/openvswitch/datapath.c            |  9 ++++----
 net/sched/act_api.c                   |  2 +-
 net/sctp/sctp_diag.c                  |  2 +-
 net/tipc/bearer.c                     |  4 ++--
 net/tipc/netlink_compat.c             |  2 +-
 net/tipc/node.c                       |  2 +-
 net/unix/diag.c                       |  2 +-
 net/wireless/nl80211.c                | 43 ++++++++++++++++++-----------------
 net/xfrm/xfrm_user.c                  | 15 +++++++-----
 samples/connector/cn_test.c           |  2 +-
 72 files changed, 199 insertions(+), 155 deletions(-)

-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [RFC 1/7] netlink: Add allocation flag to netlink_unicast()
  2016-07-06  0:28 [RFC 0/7] netlink: Add allocation flag to netlink_unicast() Masashi Honma
@ 2016-07-06  0:28 ` Masashi Honma
  2016-07-06  0:28 ` [RFC 2/7] netfilter: Add allocation flag to nfnetlink_unicast() Masashi Honma
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Masashi Honma @ 2016-07-06  0:28 UTC (permalink / raw)
  To: netdev, netfilter-devel, linux-wireless, linux-rdma, linux-audit,
	cluster-devel
  Cc: davem, johannes, pablo, kaber, kadlec, dledford, sean.hefty,
	hal.rosenstock, paul, eparis, zbr, pshelar, ccaulfie, teigland,
	bsingharora, Masashi Honma

Though netlink_broadcast() has allocation flag which can specify
memory allocation type (ex. GFP_KERNEL/GFP_ATOMIC), netlink_unicast()
does not have it. This can cause "BUG: sleeping function called from
invalid context at" with CONFIG_DEBUG_ATOMIC_SLEEP enabled kernel when
calling netlink_unicast() inside RCU read-side section and not in IRQ.

This patch adds an allocation flag to netlink_unicast().

At this moment, the allocation flag could be zero to imply gfp_any().
This is a temporal functionality for stepwise modification and
removed at the end of the series of patches.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 drivers/connector/connector.c        |  2 +-
 include/linux/netlink.h              |  3 ++-
 include/net/netlink.h                |  2 +-
 kernel/audit.c                       |  9 +++++----
 net/core/rtnetlink.c                 |  2 +-
 net/ipv4/fib_frontend.c              |  2 +-
 net/ipv4/inet_diag.c                 |  2 +-
 net/ipv4/udp_diag.c                  |  2 +-
 net/netfilter/ipset/ip_set_core.c    | 11 +++++++----
 net/netfilter/nf_conntrack_netlink.c |  9 ++++++---
 net/netfilter/nfnetlink.c            |  2 +-
 net/netfilter/nfnetlink_acct.c       |  2 +-
 net/netfilter/nfnetlink_cthelper.c   |  2 +-
 net/netfilter/nfnetlink_cttimeout.c  |  5 +++--
 net/netfilter/nft_compat.c           |  4 ++--
 net/netlink/af_netlink.c             | 12 +++++++-----
 net/sctp/sctp_diag.c                 |  2 +-
 net/unix/diag.c                      |  2 +-
 samples/connector/cn_test.c          |  2 +-
 19 files changed, 44 insertions(+), 33 deletions(-)

diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 25693b0..44470e6 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -125,7 +125,7 @@ int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 __group,
 		return netlink_broadcast(dev->nls, skb, portid, group,
 					 gfp_mask);
 	return netlink_unicast(dev->nls, skb, portid,
-			!gfpflags_allow_blocking(gfp_mask));
+			       !gfpflags_allow_blocking(gfp_mask), gfp_mask);
 }
 EXPORT_SYMBOL_GPL(cn_netlink_send_mult);
 
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index da14ab6..f90d24a 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -69,7 +69,8 @@ extern void __netlink_clear_multicast_users(struct sock *sk, unsigned int group)
 extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
 extern int netlink_has_listeners(struct sock *sk, unsigned int group);
 
-extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 portid, int nonblock);
+extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 portid,
+			   int nonblock, gfp_t allocation);
 extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 portid,
 			     __u32 group, gfp_t allocation);
 extern int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb,
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 254a0fc..898e449 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -590,7 +590,7 @@ static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 portid
 {
 	int err;
 
-	err = netlink_unicast(sk, skb, portid, MSG_DONTWAIT);
+	err = netlink_unicast(sk, skb, portid, MSG_DONTWAIT, 0);
 	if (err > 0)
 		err = 0;
 
diff --git a/kernel/audit.c b/kernel/audit.c
index 8d528f9..131577d 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -411,7 +411,7 @@ static void kauditd_send_skb(struct sk_buff *skb)
 restart:
 	/* take a reference in case we can't send it and we want to hold it */
 	skb_get(skb);
-	err = netlink_unicast(audit_sock, skb, audit_nlk_portid, 0);
+	err = netlink_unicast(audit_sock, skb, audit_nlk_portid, 0, gfp_any());
 	if (err < 0) {
 		pr_err("netlink_unicast sending to audit_pid=%d returned error: %d\n",
 		       audit_pid, err);
@@ -547,7 +547,7 @@ int audit_send_list(void *_dest)
 	mutex_unlock(&audit_cmd_mutex);
 
 	while ((skb = __skb_dequeue(&dest->q)) != NULL)
-		netlink_unicast(aunet->nlsk, skb, dest->portid, 0);
+		netlink_unicast(aunet->nlsk, skb, dest->portid, 0, gfp_any());
 
 	put_net(net);
 	kfree(dest);
@@ -591,7 +591,7 @@ static int audit_send_reply_thread(void *arg)
 
 	/* Ignore failure. It'll only happen if the sender goes away,
 	   because our timeout is set to infinite. */
-	netlink_unicast(aunet->nlsk , reply->skb, reply->portid, 0);
+	netlink_unicast(aunet->nlsk , reply->skb, reply->portid, 0, gfp_any());
 	put_net(net);
 	kfree(reply);
 	return 0;
@@ -814,7 +814,8 @@ static int audit_replace(pid_t pid)
 
 	if (!skb)
 		return -ENOMEM;
-	return netlink_unicast(audit_sock, skb, audit_nlk_portid, 0);
+	return netlink_unicast(audit_sock, skb, audit_nlk_portid, 0,
+			       GFP_KERNEL);
 }
 
 static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index eb49ca2..3433633f 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -649,7 +649,7 @@ int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int g
 		atomic_inc(&skb->users);
 	netlink_broadcast(rtnl, skb, pid, group, GFP_KERNEL);
 	if (echo)
-		err = netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT);
+		err = netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT, GFP_KERNEL);
 	return err;
 }
 
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index ef2ebeb..6a4286f 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -1096,7 +1096,7 @@ static void nl_fib_input(struct sk_buff *skb)
 	portid = NETLINK_CB(skb).portid;      /* netlink portid */
 	NETLINK_CB(skb).portid = 0;        /* from kernel */
 	NETLINK_CB(skb).dst_group = 0;  /* unicast */
-	netlink_unicast(net->ipv4.fibnl, skb, portid, MSG_DONTWAIT);
+	netlink_unicast(net->ipv4.fibnl, skb, portid, MSG_DONTWAIT, GFP_KERNEL);
 }
 
 static int __net_init nl_fib_lookup_init(struct net *net)
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 38c2c47..2963b5f 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -441,7 +441,7 @@ int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
 		goto out;
 	}
 	err = netlink_unicast(net->diag_nlsk, rep, NETLINK_CB(in_skb).portid,
-			      MSG_DONTWAIT);
+			      MSG_DONTWAIT, GFP_KERNEL);
 	if (err > 0)
 		err = 0;
 
diff --git a/net/ipv4/udp_diag.c b/net/ipv4/udp_diag.c
index 3d5ccf4..69ac502 100644
--- a/net/ipv4/udp_diag.c
+++ b/net/ipv4/udp_diag.c
@@ -83,7 +83,7 @@ static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb,
 		goto out;
 	}
 	err = netlink_unicast(net->diag_nlsk, rep, NETLINK_CB(in_skb).portid,
-			      MSG_DONTWAIT);
+			      MSG_DONTWAIT, GFP_KERNEL);
 	if (err > 0)
 		err = 0;
 out:
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index a748b0c..fcbe122 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1510,7 +1510,7 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,
 		*errline = lineno;
 
 		netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid,
-				MSG_DONTWAIT);
+				MSG_DONTWAIT, GFP_KERNEL);
 		/* Signal netlink not to send its ACK/errmsg.  */
 		return -EINTR;
 	}
@@ -1695,7 +1695,8 @@ static int ip_set_header(struct net *net, struct sock *ctnl,
 		goto nla_put_failure;
 	nlmsg_end(skb2, nlh2);
 
-	ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
+	ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT,
+			      GFP_KERNEL);
 	if (ret < 0)
 		return ret;
 
@@ -1755,7 +1756,8 @@ static int ip_set_type(struct net *net, struct sock *ctnl, struct sk_buff *skb,
 	nlmsg_end(skb2, nlh2);
 
 	pr_debug("Send TYPE, nlmsg_len: %u\n", nlh2->nlmsg_len);
-	ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
+	ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT,
+			      GFP_KERNEL);
 	if (ret < 0)
 		return ret;
 
@@ -1798,7 +1800,8 @@ static int ip_set_protocol(struct net *net, struct sock *ctnl,
 		goto nla_put_failure;
 	nlmsg_end(skb2, nlh2);
 
-	ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
+	ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT,
+			      GFP_KERNEL);
 	if (ret < 0)
 		return ret;
 
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index a18d1ce..6537e8d 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1224,7 +1224,8 @@ static int ctnetlink_get_conntrack(struct net *net, struct sock *ctnl,
 	if (err <= 0)
 		goto free;
 
-	err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
+	err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT,
+			      GFP_KERNEL);
 	if (err < 0)
 		goto out;
 
@@ -2083,7 +2084,8 @@ static int ctnetlink_stat_ct(struct net *net, struct sock *ctnl,
 	if (err <= 0)
 		goto free;
 
-	err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
+	err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT,
+			      GFP_KERNEL);
 	if (err < 0)
 		goto out;
 
@@ -2821,7 +2823,8 @@ static int ctnetlink_get_expect(struct net *net, struct sock *ctnl,
 	if (err <= 0)
 		goto free;
 
-	err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
+	err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT,
+			      GFP_KERNEL);
 	if (err < 0)
 		goto out;
 
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 2278d9a..f6193e7 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -143,7 +143,7 @@ EXPORT_SYMBOL_GPL(nfnetlink_set_err);
 int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid,
 		      int flags)
 {
-	return netlink_unicast(net->nfnl, skb, portid, flags);
+	return netlink_unicast(net->nfnl, skb, portid, flags, 0);
 }
 EXPORT_SYMBOL_GPL(nfnetlink_unicast);
 
diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
index 1b4de4b..8b5bd59 100644
--- a/net/netfilter/nfnetlink_acct.c
+++ b/net/netfilter/nfnetlink_acct.c
@@ -311,7 +311,7 @@ static int nfnl_acct_get(struct net *net, struct sock *nfnl,
 			break;
 		}
 		ret = netlink_unicast(nfnl, skb2, NETLINK_CB(skb).portid,
-					MSG_DONTWAIT);
+				      MSG_DONTWAIT, GFP_KERNEL);
 		if (ret > 0)
 			ret = 0;
 
diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
index e924e95..e46b7cd 100644
--- a/net/netfilter/nfnetlink_cthelper.c
+++ b/net/netfilter/nfnetlink_cthelper.c
@@ -559,7 +559,7 @@ static int nfnl_cthelper_get(struct net *net, struct sock *nfnl,
 			}
 
 			ret = netlink_unicast(nfnl, skb2, NETLINK_CB(skb).portid,
-						MSG_DONTWAIT);
+					      MSG_DONTWAIT, GFP_KERNEL);
 			if (ret > 0)
 				ret = 0;
 
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index 3c84f14..813eb8a 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -279,7 +279,7 @@ static int cttimeout_get_timeout(struct net *net, struct sock *ctnl,
 			break;
 		}
 		ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid,
-					MSG_DONTWAIT);
+				      MSG_DONTWAIT, GFP_KERNEL);
 		if (ret > 0)
 			ret = 0;
 
@@ -496,7 +496,8 @@ static int cttimeout_default_get(struct net *net, struct sock *ctnl,
 		err = -ENOMEM;
 		goto err;
 	}
-	ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
+	ret = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid,
+			      MSG_DONTWAIT, GFP_KERNEL);
 	if (ret > 0)
 		ret = 0;
 
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 6228c42..7de9ea4 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -582,8 +582,8 @@ static int nfnl_compat_get(struct net *net, struct sock *nfnl,
 		return -ENOSPC;
 	}
 
-	ret = netlink_unicast(nfnl, skb2, NETLINK_CB(skb).portid,
-				MSG_DONTWAIT);
+	ret = netlink_unicast(nfnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT,
+			      GFP_KERNEL);
 	if (ret > 0)
 		ret = 0;
 
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 627f898..c68bf74 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1220,14 +1220,14 @@ static int netlink_unicast_kernel(struct sock *sk, struct sk_buff *skb,
 	return ret;
 }
 
-int netlink_unicast(struct sock *ssk, struct sk_buff *skb,
-		    u32 portid, int nonblock)
+int netlink_unicast(struct sock *ssk, struct sk_buff *skb, u32 portid,
+		    int nonblock, gfp_t allocation)
 {
 	struct sock *sk;
 	int err;
 	long timeo;
 
-	skb = netlink_trim(skb, gfp_any());
+	skb = netlink_trim(skb, allocation ? allocation : gfp_any());
 
 	timeo = sock_sndtimeo(ssk, nonblock);
 retry:
@@ -1783,7 +1783,8 @@ static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 		atomic_inc(&skb->users);
 		netlink_broadcast(sk, skb, dst_portid, dst_group, GFP_KERNEL);
 	}
-	err = netlink_unicast(sk, skb, dst_portid, msg->msg_flags&MSG_DONTWAIT);
+	err = netlink_unicast(sk, skb, dst_portid,
+			      msg->msg_flags & MSG_DONTWAIT, GFP_KERNEL);
 
 out:
 	scm_destroy(&scm);
@@ -2250,7 +2251,8 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err)
 	errmsg = nlmsg_data(rep);
 	errmsg->error = err;
 	memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh));
-	netlink_unicast(in_skb->sk, skb, NETLINK_CB(in_skb).portid, MSG_DONTWAIT);
+	netlink_unicast(in_skb->sk, skb, NETLINK_CB(in_skb).portid,
+			MSG_DONTWAIT, GFP_KERNEL);
 }
 EXPORT_SYMBOL(netlink_ack);
 
diff --git a/net/sctp/sctp_diag.c b/net/sctp/sctp_diag.c
index f69edcf..4e66405 100644
--- a/net/sctp/sctp_diag.c
+++ b/net/sctp/sctp_diag.c
@@ -259,7 +259,7 @@ static int sctp_tsp_dump_one(struct sctp_transport *tsp, void *p)
 	}
 
 	err = netlink_unicast(net->diag_nlsk, rep, NETLINK_CB(in_skb).portid,
-			      MSG_DONTWAIT);
+			      MSG_DONTWAIT, GFP_KERNEL);
 	if (err > 0)
 		err = 0;
 out:
diff --git a/net/unix/diag.c b/net/unix/diag.c
index 4d96797..5e7e952 100644
--- a/net/unix/diag.c
+++ b/net/unix/diag.c
@@ -280,7 +280,7 @@ again:
 		goto again;
 	}
 	err = netlink_unicast(net->diag_nlsk, rep, NETLINK_CB(in_skb).portid,
-			      MSG_DONTWAIT);
+			      MSG_DONTWAIT, GFP_KERNEL);
 	if (err > 0)
 		err = 0;
 out:
diff --git a/samples/connector/cn_test.c b/samples/connector/cn_test.c
index d12cc94..640d11b 100644
--- a/samples/connector/cn_test.c
+++ b/samples/connector/cn_test.c
@@ -116,7 +116,7 @@ static int cn_test_want_notify(void)
 
 	NETLINK_CB(skb).dst_group = ctl->group;
 	//netlink_broadcast(nls, skb, 0, ctl->group, GFP_ATOMIC);
-	netlink_unicast(nls, skb, 0, 0);
+	netlink_unicast(nls, skb, 0, 0, GFP_ATOMIC);
 
 	pr_info("request was sent: group=0x%x\n", ctl->group);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 2/7] netfilter: Add allocation flag to nfnetlink_unicast()
  2016-07-06  0:28 [RFC 0/7] netlink: Add allocation flag to netlink_unicast() Masashi Honma
  2016-07-06  0:28 ` [RFC 1/7] " Masashi Honma
@ 2016-07-06  0:28 ` Masashi Honma
  2016-07-06  0:28 ` [RFC 3/7] netlink: Add allocation flag to nlmsg_unicast() Masashi Honma
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Masashi Honma @ 2016-07-06  0:28 UTC (permalink / raw)
  To: netdev, netfilter-devel, linux-wireless, linux-rdma, linux-audit,
	cluster-devel
  Cc: davem, johannes, pablo, kaber, kadlec, dledford, sean.hefty,
	hal.rosenstock, paul, eparis, zbr, pshelar, ccaulfie, teigland,
	bsingharora, Masashi Honma

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 include/linux/netfilter/nfnetlink.h | 2 +-
 net/netfilter/nfnetlink.c           | 4 ++--
 net/netfilter/nfnetlink_log.c       | 4 ++--
 net/netfilter/nfnetlink_queue.c     | 3 ++-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
index 1d82dd5..a1c7808 100644
--- a/include/linux/netfilter/nfnetlink.h
+++ b/include/linux/netfilter/nfnetlink.h
@@ -38,7 +38,7 @@ int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 portid,
 		   unsigned int group, int echo, gfp_t flags);
 int nfnetlink_set_err(struct net *net, u32 portid, u32 group, int error);
 int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid,
-		      int flags);
+		      int flags, gfp_t allocation);
 
 void nfnl_lock(__u8 subsys_id);
 void nfnl_unlock(__u8 subsys_id);
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index f6193e7..b0910c7 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -141,9 +141,9 @@ int nfnetlink_set_err(struct net *net, u32 portid, u32 group, int error)
 EXPORT_SYMBOL_GPL(nfnetlink_set_err);
 
 int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid,
-		      int flags)
+		      int flags, gfp_t allocation)
 {
-	return netlink_unicast(net->nfnl, skb, portid, flags, 0);
+	return netlink_unicast(net->nfnl, skb, portid, flags, allocation);
 }
 EXPORT_SYMBOL_GPL(nfnetlink_unicast);
 
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 11f81c8..c834306 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -357,8 +357,8 @@ __nfulnl_send(struct nfulnl_instance *inst)
 			goto out;
 		}
 	}
-	nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid,
-			  MSG_DONTWAIT);
+	nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid, MSG_DONTWAIT,
+			  gfp_any());
 out:
 	inst->qlen = 0;
 	inst->skb = NULL;
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 5d36a09..8d7b6ff 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -638,7 +638,8 @@ __nfqnl_enqueue_packet(struct net *net, struct nfqnl_instance *queue,
 	*packet_id_ptr = htonl(entry->id);
 
 	/* nfnetlink_unicast will either free the nskb or add it to a socket */
-	err = nfnetlink_unicast(nskb, net, queue->peer_portid, MSG_DONTWAIT);
+	err = nfnetlink_unicast(nskb, net, queue->peer_portid, MSG_DONTWAIT,
+				GFP_ATOMIC);
 	if (err < 0) {
 		if (queue->flags & NFQA_CFG_F_FAIL_OPEN) {
 			failopen = 1;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 3/7] netlink: Add allocation flag to nlmsg_unicast()
  2016-07-06  0:28 [RFC 0/7] netlink: Add allocation flag to netlink_unicast() Masashi Honma
  2016-07-06  0:28 ` [RFC 1/7] " Masashi Honma
  2016-07-06  0:28 ` [RFC 2/7] netfilter: Add allocation flag to nfnetlink_unicast() Masashi Honma
@ 2016-07-06  0:28 ` Masashi Honma
  2016-07-06  0:28 ` [RFC 4/7] infiniband: Add allocation flag to ibnl_unicast() Masashi Honma
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Masashi Honma @ 2016-07-06  0:28 UTC (permalink / raw)
  To: netdev, netfilter-devel, linux-wireless, linux-rdma, linux-audit,
	cluster-devel
  Cc: sean.hefty, paul, bsingharora, pshelar, eparis, kaber,
	hal.rosenstock, dledford, kadlec, zbr, johannes, davem, pablo

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 crypto/crypto_user.c              |  3 ++-
 drivers/infiniband/core/netlink.c |  2 +-
 include/net/genetlink.h           |  2 +-
 include/net/netlink.h             |  6 ++++--
 net/core/rtnetlink.c              |  2 +-
 net/netfilter/nf_tables_api.c     | 10 +++++-----
 net/netlink/af_netlink.c          |  2 +-
 net/xfrm/xfrm_user.c              | 15 +++++++++------
 8 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index 7097a33..f379b74 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -249,7 +249,8 @@ drop_alg:
 	if (err)
 		return err;
 
-	return nlmsg_unicast(crypto_nlsk, skb, NETLINK_CB(in_skb).portid);
+	return nlmsg_unicast(crypto_nlsk, skb, NETLINK_CB(in_skb).portid,
+			     GFP_ATOMIC);
 }
 
 static int crypto_dump_report(struct sk_buff *skb, struct netlink_callback *cb)
diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c
index 9b8c20c..09037a9 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -229,7 +229,7 @@ static void ibnl_rcv(struct sk_buff *skb)
 int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
 			__u32 pid)
 {
-	return nlmsg_unicast(nls, skb, pid);
+	return nlmsg_unicast(nls, skb, pid, gfp_any());
 }
 EXPORT_SYMBOL(ibnl_unicast);
 
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 8d4608c..b107a35 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -334,7 +334,7 @@ int genlmsg_multicast_allns(struct genl_family *family,
  */
 static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 portid)
 {
-	return nlmsg_unicast(net->genl_sock, skb, portid);
+	return nlmsg_unicast(net->genl_sock, skb, portid, 0);
 }
 
 /**
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 898e449..df5b533 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -585,12 +585,14 @@ static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb,
  * @sk: netlink socket to spread message to
  * @skb: netlink message as socket buffer
  * @portid: netlink portid of the destination socket
+ * @flags: allocation flags
  */
-static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 portid)
+static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb,
+				u32 portid, gfp_t flags)
 {
 	int err;
 
-	err = netlink_unicast(sk, skb, portid, MSG_DONTWAIT, 0);
+	err = netlink_unicast(sk, skb, portid, MSG_DONTWAIT, flags);
 	if (err > 0)
 		err = 0;
 
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 3433633f..7f7927f 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -657,7 +657,7 @@ int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid)
 {
 	struct sock *rtnl = net->rtnl;
 
-	return nlmsg_unicast(rtnl, skb, pid);
+	return nlmsg_unicast(rtnl, skb, pid, gfp_any());
 }
 EXPORT_SYMBOL(rtnl_unicast);
 
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 2c88187..4afb751 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -581,7 +581,7 @@ static int nf_tables_gettable(struct net *net, struct sock *nlsk,
 	if (err < 0)
 		goto err;
 
-	return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+	return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid, GFP_KERNEL);
 
 err:
 	kfree_skb(skb2);
@@ -1144,7 +1144,7 @@ static int nf_tables_getchain(struct net *net, struct sock *nlsk,
 	if (err < 0)
 		goto err;
 
-	return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+	return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid, GFP_KERNEL);
 
 err:
 	kfree_skb(skb2);
@@ -1976,7 +1976,7 @@ static int nf_tables_getrule(struct net *net, struct sock *nlsk,
 	if (err < 0)
 		goto err;
 
-	return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+	return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid, GFP_KERNEL);
 
 err:
 	kfree_skb(skb2);
@@ -2664,7 +2664,7 @@ static int nf_tables_getset(struct net *net, struct sock *nlsk,
 	if (err < 0)
 		goto err;
 
-	return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+	return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid, GFP_KERNEL);
 
 err:
 	kfree_skb(skb2);
@@ -3798,7 +3798,7 @@ static int nf_tables_getgen(struct net *net, struct sock *nlsk,
 	if (err < 0)
 		goto err;
 
-	return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+	return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid, GFP_KERNEL);
 err:
 	kfree_skb(skb2);
 	return err;
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index c68bf74..acc1ee6 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2328,7 +2328,7 @@ int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 portid,
 	if (report) {
 		int err2;
 
-		err2 = nlmsg_unicast(sk, skb, portid);
+		err2 = nlmsg_unicast(sk, skb, portid, flags);
 		if (!err || err == -ESRCH)
 			err = err2;
 	}
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index d516845..4af9977 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1108,7 +1108,7 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
 	if (build_spdinfo(r_skb, net, sportid, seq, *flags) < 0)
 		BUG();
 
-	return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid);
+	return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid, GFP_ATOMIC);
 }
 
 static inline size_t xfrm_sadinfo_msgsize(void)
@@ -1166,7 +1166,7 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
 	if (build_sadinfo(r_skb, net, sportid, seq, *flags) < 0)
 		BUG();
 
-	return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid);
+	return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid, GFP_ATOMIC);
 }
 
 static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -1186,7 +1186,8 @@ static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
 	if (IS_ERR(resp_skb)) {
 		err = PTR_ERR(resp_skb);
 	} else {
-		err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).portid);
+		err = nlmsg_unicast(net->xfrm.nlsk, resp_skb,
+				    NETLINK_CB(skb).portid, GFP_ATOMIC);
 	}
 	xfrm_state_put(x);
 out_noput:
@@ -1244,7 +1245,8 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh,
 		goto out;
 	}
 
-	err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).portid);
+	err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).portid,
+			    GFP_ATOMIC);
 
 out:
 	xfrm_state_put(x);
@@ -1760,7 +1762,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
 			err = PTR_ERR(resp_skb);
 		} else {
 			err = nlmsg_unicast(net->xfrm.nlsk, resp_skb,
-					    NETLINK_CB(skb).portid);
+					    NETLINK_CB(skb).portid, GFP_KERNEL);
 		}
 	} else {
 		xfrm_audit_policy_delete(xp, err ? 0 : 1, true);
@@ -1914,7 +1916,8 @@ static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	if (build_aevent(r_skb, x, &c) < 0)
 		BUG();
-	err = nlmsg_unicast(net->xfrm.nlsk, r_skb, NETLINK_CB(skb).portid);
+	err = nlmsg_unicast(net->xfrm.nlsk, r_skb, NETLINK_CB(skb).portid,
+			    GFP_ATOMIC);
 	spin_unlock_bh(&x->lock);
 	xfrm_state_put(x);
 	return err;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 4/7] infiniband: Add allocation flag to ibnl_unicast()
  2016-07-06  0:28 [RFC 0/7] netlink: Add allocation flag to netlink_unicast() Masashi Honma
                   ` (2 preceding siblings ...)
  2016-07-06  0:28 ` [RFC 3/7] netlink: Add allocation flag to nlmsg_unicast() Masashi Honma
@ 2016-07-06  0:28 ` Masashi Honma
  2016-07-06  0:28 ` [RFC 5/7] net: Add allocation flag to rtnl_unicast() Masashi Honma
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Masashi Honma @ 2016-07-06  0:28 UTC (permalink / raw)
  To: netdev, netfilter-devel, linux-wireless, linux-rdma, linux-audit,
	cluster-devel
  Cc: davem, johannes, pablo, kaber, kadlec, dledford, sean.hefty,
	hal.rosenstock, paul, eparis, zbr, pshelar, ccaulfie, teigland,
	bsingharora, Masashi Honma

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 drivers/infiniband/core/iwpm_msg.c  | 6 +++---
 drivers/infiniband/core/iwpm_util.c | 5 +++--
 drivers/infiniband/core/iwpm_util.h | 1 +
 drivers/infiniband/core/netlink.c   | 4 ++--
 include/rdma/rdma_netlink.h         | 3 ++-
 5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/core/iwpm_msg.c b/drivers/infiniband/core/iwpm_msg.c
index 1c41b95..4307eab 100644
--- a/drivers/infiniband/core/iwpm_msg.c
+++ b/drivers/infiniband/core/iwpm_msg.c
@@ -174,7 +174,7 @@ int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client)
 		goto add_mapping_error;
 	nlmsg_request->req_buffer = pm_msg;
 
-	ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
+	ret = ibnl_unicast(skb, nlh, iwpm_user_pid, GFP_ATOMIC);
 	if (ret) {
 		skb = NULL; /* skb is freed in the netlink send-op handling */
 		iwpm_user_pid = IWPM_PID_UNDEFINED;
@@ -251,7 +251,7 @@ int iwpm_add_and_query_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client)
 		goto query_mapping_error;
 	nlmsg_request->req_buffer = pm_msg;
 
-	ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
+	ret = ibnl_unicast(skb, nlh, iwpm_user_pid, GFP_ATOMIC);
 	if (ret) {
 		skb = NULL; /* skb is freed in the netlink send-op handling */
 		err_str = "Unable to send a nlmsg";
@@ -312,7 +312,7 @@ int iwpm_remove_mapping(struct sockaddr_storage *local_addr, u8 nl_client)
 	if (ret)
 		goto remove_mapping_error;
 
-	ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
+	ret = ibnl_unicast(skb, nlh, iwpm_user_pid, GFP_ATOMIC);
 	if (ret) {
 		skb = NULL; /* skb is freed in the netlink send-op handling */
 		iwpm_user_pid = IWPM_PID_UNDEFINED;
diff --git a/drivers/infiniband/core/iwpm_util.c b/drivers/infiniband/core/iwpm_util.c
index b65e06c..6dcbb2d 100644
--- a/drivers/infiniband/core/iwpm_util.c
+++ b/drivers/infiniband/core/iwpm_util.c
@@ -609,7 +609,7 @@ static int send_mapinfo_num(u32 mapping_num, u8 nl_client, int iwpm_pid)
 				&mapping_num, IWPM_NLA_MAPINFO_SEND_NUM);
 	if (ret)
 		goto mapinfo_num_error;
-	ret = ibnl_unicast(skb, nlh, iwpm_pid);
+	ret = ibnl_unicast(skb, nlh, iwpm_pid, GFP_ATOMIC);
 	if (ret) {
 		skb = NULL;
 		err_str = "Unable to send a nlmsg";
@@ -638,7 +638,8 @@ static int send_nlmsg_done(struct sk_buff *skb, u8 nl_client, int iwpm_pid)
 		return -ENOMEM;
 	}
 	nlh->nlmsg_type = NLMSG_DONE;
-	ret = ibnl_unicast(skb, (struct nlmsghdr *)skb->data, iwpm_pid);
+	ret = ibnl_unicast(skb, (struct nlmsghdr *)skb->data, iwpm_pid,
+			   GFP_ATOMIC);
 	if (ret)
 		pr_warn("%s Unable to send a nlmsg\n", __func__);
 	return ret;
diff --git a/drivers/infiniband/core/iwpm_util.h b/drivers/infiniband/core/iwpm_util.h
index af1fc14..0ced7f4 100644
--- a/drivers/infiniband/core/iwpm_util.h
+++ b/drivers/infiniband/core/iwpm_util.h
@@ -46,6 +46,7 @@
 #include <linux/jhash.h>
 #include <linux/kref.h>
 #include <net/netlink.h>
+#include <net/sock.h>
 #include <linux/errno.h>
 #include <rdma/iw_portmap.h>
 #include <rdma/rdma_netlink.h>
diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c
index 09037a9..1451238 100644
--- a/drivers/infiniband/core/netlink.c
+++ b/drivers/infiniband/core/netlink.c
@@ -227,9 +227,9 @@ static void ibnl_rcv(struct sk_buff *skb)
 }
 
 int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
-			__u32 pid)
+			__u32 pid, gfp_t flags)
 {
-	return nlmsg_unicast(nls, skb, pid, gfp_any());
+	return nlmsg_unicast(nls, skb, pid, flags);
 }
 EXPORT_SYMBOL(ibnl_unicast);
 
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
index 5852661..0bb3010 100644
--- a/include/rdma/rdma_netlink.h
+++ b/include/rdma/rdma_netlink.h
@@ -61,10 +61,11 @@ int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
  * @skb: The netlink skb
  * @nlh: Header of the netlink message to send
  * @pid: Userspace netlink process ID
+ * @flags: allocation flags
  * Returns 0 on success or a negative error code.
  */
 int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
-			__u32 pid);
+			__u32 pid, gfp_t flags);
 
 /**
  * Send the supplied skb to a netlink group.
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 5/7] net: Add allocation flag to rtnl_unicast()
  2016-07-06  0:28 [RFC 0/7] netlink: Add allocation flag to netlink_unicast() Masashi Honma
                   ` (3 preceding siblings ...)
  2016-07-06  0:28 ` [RFC 4/7] infiniband: Add allocation flag to ibnl_unicast() Masashi Honma
@ 2016-07-06  0:28 ` Masashi Honma
  2016-07-08  2:56   ` Eric Dumazet
  2016-07-07  0:35 ` [RFC 0/7] netlink: Add allocation flag to netlink_unicast() Masashi Honma
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: Masashi Honma @ 2016-07-06  0:28 UTC (permalink / raw)
  To: netdev, netfilter-devel, linux-wireless, linux-rdma, linux-audit,
	cluster-devel
  Cc: davem, johannes, pablo, kaber, kadlec, dledford, sean.hefty,
	hal.rosenstock, paul, eparis, zbr, pshelar, ccaulfie, teigland,
	bsingharora, Masashi Honma

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 include/linux/rtnetlink.h |  3 ++-
 net/core/net_namespace.c  |  2 +-
 net/core/rtnetlink.c      | 10 ++++++----
 net/dcb/dcbnl.c           |  2 +-
 net/decnet/dn_route.c     |  3 ++-
 net/ipv4/devinet.c        |  2 +-
 net/ipv4/ipmr.c           |  6 ++++--
 net/ipv4/route.c          |  2 +-
 net/ipv6/addrconf.c       |  4 ++--
 net/ipv6/addrlabel.c      |  2 +-
 net/ipv6/ip6mr.c          |  6 ++++--
 net/ipv6/route.c          |  2 +-
 net/sched/act_api.c       |  2 +-
 13 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 2daece8..132730f 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -8,7 +8,8 @@
 #include <uapi/linux/rtnetlink.h>
 
 extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
-extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid);
+extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid,
+			gfp_t flags);
 extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
 			u32 group, struct nlmsghdr *nlh, gfp_t flags);
 extern void rtnl_set_sk_err(struct net *net, u32 group, int error);
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 2c2eb1b..28eed58 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -646,7 +646,7 @@ static int rtnl_net_getid(struct sk_buff *skb, struct nlmsghdr *nlh)
 	if (err < 0)
 		goto err_out;
 
-	err = rtnl_unicast(msg, net, NETLINK_CB(skb).portid);
+	err = rtnl_unicast(msg, net, NETLINK_CB(skb).portid, GFP_KERNEL);
 	goto out;
 
 err_out:
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 7f7927f..89fd826 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -653,11 +653,11 @@ int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int g
 	return err;
 }
 
-int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid)
+int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid, gfp_t flags)
 {
 	struct sock *rtnl = net->rtnl;
 
-	return nlmsg_unicast(rtnl, skb, pid, gfp_any());
+	return nlmsg_unicast(rtnl, skb, pid, flags);
 }
 EXPORT_SYMBOL(rtnl_unicast);
 
@@ -2565,7 +2565,8 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh)
 		WARN_ON(err == -EMSGSIZE);
 		kfree_skb(nskb);
 	} else
-		err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid);
+		err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid,
+				   GFP_KERNEL);
 
 	return err;
 }
@@ -3601,7 +3602,8 @@ static int rtnl_stats_get(struct sk_buff *skb, struct nlmsghdr *nlh)
 		WARN_ON(err == -EMSGSIZE);
 		kfree_skb(nskb);
 	} else {
-		err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid);
+		err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid,
+				   GFP_KERNEL);
 	}
 
 	return err;
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 4f6c186..e4de9fe 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1749,7 +1749,7 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
 
 	nlmsg_end(reply_skb, reply_nlh);
 
-	ret = rtnl_unicast(reply_skb, net, portid);
+	ret = rtnl_unicast(reply_skb, net, portid, GFP_KERNEL);
 out:
 	return ret;
 }
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index b1dc096..6fe02bb 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -1714,7 +1714,8 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 		goto out_free;
 	}
 
-	return rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).portid);
+	return rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).portid,
+			    GFP_KERNEL);
 
 out_free:
 	kfree_skb(skb);
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index e333bc8..5e969e5 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1917,7 +1917,7 @@ static int inet_netconf_get_devconf(struct sk_buff *in_skb,
 		kfree_skb(skb);
 		goto errout;
 	}
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_ATOMIC);
 errout:
 	return err;
 }
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 5ad48ec..c704a2a 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -654,7 +654,8 @@ static void ipmr_destroy_unres(struct mr_table *mrt, struct mfc_cache *c)
 			e->error = -ETIMEDOUT;
 			memset(&e->msg, 0, sizeof(e->msg));
 
-			rtnl_unicast(skb, net, NETLINK_CB(skb).portid);
+			rtnl_unicast(skb, net, NETLINK_CB(skb).portid,
+				     gfp_any());
 		} else {
 			kfree_skb(skb);
 		}
@@ -933,7 +934,8 @@ static void ipmr_cache_resolve(struct net *net, struct mr_table *mrt,
 				memset(&e->msg, 0, sizeof(e->msg));
 			}
 
-			rtnl_unicast(skb, net, NETLINK_CB(skb).portid);
+			rtnl_unicast(skb, net, NETLINK_CB(skb).portid,
+				     gfp_any());
 		} else {
 			ip_mr_forward(net, mrt, skb, c, 0);
 		}
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a1f2830..10cb0e0 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2621,7 +2621,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 	if (err < 0)
 		goto errout_free;
 
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_KERNEL);
 errout:
 	return err;
 
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index a1f6b7b..2b0b994 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -628,7 +628,7 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
 		kfree_skb(skb);
 		goto errout;
 	}
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_ATOMIC);
 errout:
 	return err;
 }
@@ -4824,7 +4824,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 		kfree_skb(skb);
 		goto errout_ifa;
 	}
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_KERNEL);
 errout_ifa:
 	in6_ifa_put(ifa);
 errout:
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c
index a8f6986..597e0eb 100644
--- a/net/ipv6/addrlabel.c
+++ b/net/ipv6/addrlabel.c
@@ -580,7 +580,7 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 		goto out;
 	}
 
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_KERNEL);
 out:
 	return err;
 }
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 487ef3b..135ba15 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -850,7 +850,8 @@ static void ip6mr_destroy_unres(struct mr6_table *mrt, struct mfc6_cache *c)
 			nlh->nlmsg_len = nlmsg_msg_size(sizeof(struct nlmsgerr));
 			skb_trim(skb, nlh->nlmsg_len);
 			((struct nlmsgerr *)nlmsg_data(nlh))->error = -ETIMEDOUT;
-			rtnl_unicast(skb, net, NETLINK_CB(skb).portid);
+			rtnl_unicast(skb, net, NETLINK_CB(skb).portid,
+				     gfp_any());
 		} else
 			kfree_skb(skb);
 	}
@@ -1114,7 +1115,8 @@ static void ip6mr_cache_resolve(struct net *net, struct mr6_table *mrt,
 				skb_trim(skb, nlh->nlmsg_len);
 				((struct nlmsgerr *)nlmsg_data(nlh))->error = -EMSGSIZE;
 			}
-			rtnl_unicast(skb, net, NETLINK_CB(skb).portid);
+			rtnl_unicast(skb, net, NETLINK_CB(skb).portid,
+				     gfp_any());
 		} else
 			ip6_mr_forward(net, mrt, skb, c);
 	}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 4981755..81318a8 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3367,7 +3367,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 		goto errout;
 	}
 
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_KERNEL);
 errout:
 	return err;
 }
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 47ec230..b988a84 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -737,7 +737,7 @@ act_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,
 		return -EINVAL;
 	}
 
-	return rtnl_unicast(skb, net, portid);
+	return rtnl_unicast(skb, net, portid, GFP_KERNEL);
 }
 
 static struct tc_action *create_a(int i)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 6/7] genetlink: Add allocation flag to genlmsg_unicast()
       [not found] ` <1467764916-4983-1-git-send-email-masashi.honma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-07-06  0:28   ` Masashi Honma
  2016-07-06  0:28   ` [RFC 7/7] genetlink: Add allocation flag to genlmsg_reply() Masashi Honma
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 24+ messages in thread
From: Masashi Honma @ 2016-07-06  0:28 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-audit-H+wXaHxf7aLQT0dZR+AlfA,
	cluster-devel-H+wXaHxf7aLQT0dZR+AlfA
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, johannes-cdvu00un1VgdHxzADdlk8Q,
	pablo-Cap9r6Oaw4JrovVCs/uTlw, kaber-dcUjhNyLwpNeoWH0uzbU5w,
	kadlec-K40Dz/62t/MgiyqX0sVFJYdd74u8MsAO,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	paul-r2n+y4ga6xFZroRs9YW3xA, eparis-H+wXaHxf7aLQT0dZR+AlfA,
	zbr-i6C2adt8DTjR7s880joybQ, pshelar-l0M0P4e3n4LQT0dZR+AlfA,
	ccaulfie-H+wXaHxf7aLQT0dZR+AlfA, teigland-H+wXaHxf7aLQT0dZR+AlfA,
	bsingharora-Re5JQEeQqe8AvxtiuMwx3w, Masashi Honma

Signed-off-by: Masashi Honma <masashi.honma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/net/gtp.c                     | 3 ++-
 drivers/net/team/team.c               | 5 +++--
 drivers/net/wireless/mac80211_hwsim.c | 2 +-
 fs/dlm/netlink.c                      | 2 +-
 include/net/genetlink.h               | 8 +++++---
 kernel/taskstats.c                    | 2 +-
 net/hsr/hsr_netlink.c                 | 6 ++++--
 net/l2tp/l2tp_netlink.c               | 8 +++++---
 net/openvswitch/datapath.c            | 3 ++-
 net/tipc/netlink_compat.c             | 2 +-
 net/wireless/nl80211.c                | 9 +++++----
 11 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 97e0cbc..0156abb 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -1210,7 +1210,8 @@ static int gtp_genl_get_pdp(struct sk_buff *skb, struct genl_info *info)
 		goto err_unlock_free;
 
 	rcu_read_unlock();
-	return genlmsg_unicast(genl_info_net(info), skb2, info->snd_portid);
+	return genlmsg_unicast(genl_info_net(info), skb2, info->snd_portid,
+			       GFP_ATOMIC);
 
 err_unlock_free:
 	kfree_skb(skb2);
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index f9eebea..3d40b55 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -2194,7 +2194,8 @@ static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
 
 	genlmsg_end(msg, hdr);
 
-	return genlmsg_unicast(genl_info_net(info), msg, info->snd_portid);
+	return genlmsg_unicast(genl_info_net(info), msg, info->snd_portid,
+			       GFP_KERNEL);
 
 err_msg_put:
 	nlmsg_free(msg);
@@ -2240,7 +2241,7 @@ typedef int team_nl_send_func_t(struct sk_buff *skb,
 
 static int team_nl_send_unicast(struct sk_buff *skb, struct team *team, u32 portid)
 {
-	return genlmsg_unicast(dev_net(team->dev), skb, portid);
+	return genlmsg_unicast(dev_net(team->dev), skb, portid, gfp_any());
 }
 
 static int team_nl_fill_one_option_get(struct sk_buff *skb, struct team *team,
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 382109bb..5c7bf77 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -1008,7 +1008,7 @@ static int hwsim_unicast_netgroup(struct mac80211_hwsim_data *data,
 	rcu_read_lock();
 	for_each_net_rcu(net) {
 		if (data->netgroup == hwsim_net_get_netgroup(net)) {
-			res = genlmsg_unicast(net, skb, portid);
+			res = genlmsg_unicast(net, skb, portid, GFP_ATOMIC);
 			found = true;
 			break;
 		}
diff --git a/fs/dlm/netlink.c b/fs/dlm/netlink.c
index 1e6e227..c498616 100644
--- a/fs/dlm/netlink.c
+++ b/fs/dlm/netlink.c
@@ -59,7 +59,7 @@ static int send_data(struct sk_buff *skb)
 
 	genlmsg_end(skb, data);
 
-	return genlmsg_unicast(&init_net, skb, listener_nlportid);
+	return genlmsg_unicast(&init_net, skb, listener_nlportid, GFP_NOFS);
 }
 
 static int user_cmd(struct sk_buff *skb, struct genl_info *info)
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index b107a35..5f0f2ff 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -331,10 +331,12 @@ int genlmsg_multicast_allns(struct genl_family *family,
  * genlmsg_unicast - unicast a netlink message
  * @skb: netlink message as socket buffer
  * @portid: netlink portid of the destination socket
+ * @flags: allocation flags
  */
-static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 portid)
+static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb,
+				  u32 portid, gfp_t flags)
 {
-	return nlmsg_unicast(net->genl_sock, skb, portid, 0);
+	return nlmsg_unicast(net->genl_sock, skb, portid, flags);
 }
 
 /**
@@ -344,7 +346,7 @@ static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 port
  */
 static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
 {
-	return genlmsg_unicast(genl_info_net(info), skb, info->snd_portid);
+	return genlmsg_unicast(genl_info_net(info), skb, info->snd_portid, 0);
 }
 
 /**
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index b3f05ee..ecfcaff 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -140,7 +140,7 @@ static void send_cpu_listeners(struct sk_buff *skb,
 			if (!skb_next)
 				break;
 		}
-		rc = genlmsg_unicast(&init_net, skb_cur, s->pid);
+		rc = genlmsg_unicast(&init_net, skb_cur, s->pid, GFP_KERNEL);
 		if (rc == -ECONNREFUSED) {
 			s->valid = 0;
 			delcount++;
diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c
index d4d1617..dcc674f 100644
--- a/net/hsr/hsr_netlink.c
+++ b/net/hsr/hsr_netlink.c
@@ -351,7 +351,8 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
 		goto nla_put_failure;
 
 	genlmsg_end(skb_out, msg_head);
-	genlmsg_unicast(genl_info_net(info), skb_out, info->snd_portid);
+	genlmsg_unicast(genl_info_net(info), skb_out, info->snd_portid,
+			GFP_KERNEL);
 
 	return 0;
 
@@ -433,7 +434,8 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
 	rcu_read_unlock();
 
 	genlmsg_end(skb_out, msg_head);
-	genlmsg_unicast(genl_info_net(info), skb_out, info->snd_portid);
+	genlmsg_unicast(genl_info_net(info), skb_out, info->snd_portid,
+			GFP_KERNEL);
 
 	return 0;
 
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index 1d02e8d..5a3cc56 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -100,7 +100,8 @@ static int l2tp_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
 
 	genlmsg_end(msg, hdr);
 
-	return genlmsg_unicast(genl_info_net(info), msg, info->snd_portid);
+	return genlmsg_unicast(genl_info_net(info), msg, info->snd_portid,
+			       GFP_KERNEL);
 
 err_out:
 	nlmsg_free(msg);
@@ -450,7 +451,7 @@ static int l2tp_nl_cmd_tunnel_get(struct sk_buff *skb, struct genl_info *info)
 	if (ret < 0)
 		goto err_out;
 
-	return genlmsg_unicast(net, msg, info->snd_portid);
+	return genlmsg_unicast(net, msg, info->snd_portid, GFP_KERNEL);
 
 err_out:
 	nlmsg_free(msg);
@@ -820,7 +821,8 @@ static int l2tp_nl_cmd_session_get(struct sk_buff *skb, struct genl_info *info)
 	if (ret < 0)
 		goto err_out;
 
-	return genlmsg_unicast(genl_info_net(info), msg, info->snd_portid);
+	return genlmsg_unicast(genl_info_net(info), msg, info->snd_portid,
+			       GFP_KERNEL);
 
 err_out:
 	nlmsg_free(msg);
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 524c0fd..374e0ec 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -542,7 +542,8 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
 
 	((struct nlmsghdr *) user_skb->data)->nlmsg_len = user_skb->len;
 
-	err = genlmsg_unicast(ovs_dp_get_net(dp), user_skb, upcall_info->portid);
+	err = genlmsg_unicast(ovs_dp_get_net(dp), user_skb, upcall_info->portid,
+			      GFP_ATOMIC);
 	user_skb = NULL;
 out:
 	if (err)
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index 3ad9fab..205577c 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -1210,7 +1210,7 @@ send:
 	rep_nlh = nlmsg_hdr(msg.rep);
 	memcpy(rep_nlh, info->nlhdr, len);
 	rep_nlh->nlmsg_len = msg.rep->len;
-	genlmsg_unicast(msg.net, msg.rep, NETLINK_CB(skb).portid);
+	genlmsg_unicast(msg.net, msg.rep, NETLINK_CB(skb).portid, GFP_KERNEL);
 
 	return err;
 }
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 244d552..e608937 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -12648,7 +12648,7 @@ static bool __nl80211_unexpected_frame(struct net_device *dev, u8 cmd,
 		goto nla_put_failure;
 
 	genlmsg_end(msg, hdr);
-	genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid);
+	genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid, gfp);
 	return true;
 
  nla_put_failure:
@@ -12733,7 +12733,7 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev,
 
 	genlmsg_end(msg, hdr);
 
-	return genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid);
+	return genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid, gfp);
 
  nla_put_failure:
 	genlmsg_cancel(msg, hdr);
@@ -13245,7 +13245,8 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy,
 
 		genlmsg_end(msg, hdr);
 
-		genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, reg->nlportid);
+		genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, reg->nlportid,
+				GFP_ATOMIC);
 	}
 	spin_unlock_bh(&rdev->beacon_registrations_lock);
 	return;
@@ -13623,7 +13624,7 @@ void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp)
 
 	genlmsg_end(msg, hdr);
 
-	genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid);
+	genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid, gfp);
 	return;
 
  nla_put_failure:
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [RFC 7/7] genetlink: Add allocation flag to genlmsg_reply()
       [not found] ` <1467764916-4983-1-git-send-email-masashi.honma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2016-07-06  0:28   ` [RFC 6/7] genetlink: Add allocation flag to genlmsg_unicast() Masashi Honma
@ 2016-07-06  0:28   ` Masashi Honma
  2016-07-06  3:22   ` [RFC 0/7] netlink: Add allocation flag to netlink_unicast() David Miller
  2016-07-09  3:54   ` Masashi Honma
  3 siblings, 0 replies; 24+ messages in thread
From: Masashi Honma @ 2016-07-06  0:28 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-audit-H+wXaHxf7aLQT0dZR+AlfA,
	cluster-devel-H+wXaHxf7aLQT0dZR+AlfA
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, johannes-cdvu00un1VgdHxzADdlk8Q,
	pablo-Cap9r6Oaw4JrovVCs/uTlw, kaber-dcUjhNyLwpNeoWH0uzbU5w,
	kadlec-K40Dz/62t/MgiyqX0sVFJYdd74u8MsAO,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	paul-r2n+y4ga6xFZroRs9YW3xA, eparis-H+wXaHxf7aLQT0dZR+AlfA,
	zbr-i6C2adt8DTjR7s880joybQ, pshelar-l0M0P4e3n4LQT0dZR+AlfA,
	ccaulfie-H+wXaHxf7aLQT0dZR+AlfA, teigland-H+wXaHxf7aLQT0dZR+AlfA,
	bsingharora-Re5JQEeQqe8AvxtiuMwx3w, Masashi Honma

Add allocation flag to genlmsg_reply() and remove netlink_unicast()
temporal functionality for stepwise modification.

Signed-off-by: Masashi Honma <masashi.honma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/block/drbd/drbd_nl.c          |  2 +-
 drivers/net/wireless/mac80211_hwsim.c |  2 +-
 include/net/genetlink.h               |  7 +++++--
 kernel/taskstats.c                    |  2 +-
 net/core/devlink.c                    | 12 ++++++------
 net/ieee802154/ieee802154.h           |  3 ++-
 net/ieee802154/netlink.c              |  5 +++--
 net/ieee802154/nl-mac.c               |  4 ++--
 net/ieee802154/nl-phy.c               |  6 +++---
 net/ieee802154/nl802154.c             |  4 ++--
 net/ipv4/fou.c                        |  2 +-
 net/ipv4/tcp_metrics.c                |  2 +-
 net/ipv6/ila/ila_xlat.c               |  2 +-
 net/irda/irnetlink.c                  |  2 +-
 net/netfilter/ipvs/ip_vs_ctl.c        |  2 +-
 net/netlabel/netlabel_cipso_v4.c      |  2 +-
 net/netlabel/netlabel_mgmt.c          |  4 ++--
 net/netlabel/netlabel_unlabeled.c     |  2 +-
 net/netlink/af_netlink.c              |  2 +-
 net/netlink/genetlink.c               |  2 +-
 net/nfc/netlink.c                     |  6 +++---
 net/openvswitch/datapath.c            |  6 +++---
 net/tipc/bearer.c                     |  4 ++--
 net/tipc/node.c                       |  2 +-
 net/wireless/nl80211.c                | 34 +++++++++++++++++-----------------
 25 files changed, 63 insertions(+), 58 deletions(-)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 0bac9c8..3162608 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -100,7 +100,7 @@ static char *drbd_m_holder = "Hands off! this is DRBD's meta data device.";
 static void drbd_adm_send_reply(struct sk_buff *skb, struct genl_info *info)
 {
 	genlmsg_end(skb, genlmsg_data(nlmsg_data(nlmsg_hdr(skb))));
-	if (genlmsg_reply(skb, info))
+	if (genlmsg_reply(skb, info, GFP_KERNEL))
 		pr_err("error sending genl reply\n");
 }
 
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 5c7bf77..5319cd1 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3160,7 +3160,7 @@ static int hwsim_get_radio_nl(struct sk_buff *msg, struct genl_info *info)
 			goto out_err;
 		}
 
-		genlmsg_reply(skb, info);
+		genlmsg_reply(skb, info, GFP_KERNEL);
 		break;
 	}
 
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 5f0f2ff..99c9c39 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -343,10 +343,13 @@ static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb,
  * genlmsg_reply - reply to a request
  * @skb: netlink message to be sent back
  * @info: receiver information
+ * @flags: allocation flags
  */
-static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
+static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info,
+				gfp_t flags)
 {
-	return genlmsg_unicast(genl_info_net(info), skb, info->snd_portid, 0);
+	return genlmsg_unicast(genl_info_net(info), skb, info->snd_portid,
+			       flags);
 }
 
 /**
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index ecfcaff..894d0da 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -114,7 +114,7 @@ static int send_reply(struct sk_buff *skb, struct genl_info *info)
 
 	genlmsg_end(skb, reply);
 
-	return genlmsg_reply(skb, info);
+	return genlmsg_reply(skb, info, GFP_KERNEL);
 }
 
 /*
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 933e8d4..61a1c8a 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -501,7 +501,7 @@ static int devlink_nl_cmd_get_doit(struct sk_buff *skb, struct genl_info *info)
 		return err;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int devlink_nl_cmd_get_dumpit(struct sk_buff *msg,
@@ -554,7 +554,7 @@ static int devlink_nl_cmd_port_get_doit(struct sk_buff *skb,
 		return err;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int devlink_nl_cmd_port_get_dumpit(struct sk_buff *msg,
@@ -736,7 +736,7 @@ static int devlink_nl_cmd_sb_get_doit(struct sk_buff *skb,
 		return err;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int devlink_nl_cmd_sb_get_dumpit(struct sk_buff *msg,
@@ -843,7 +843,7 @@ static int devlink_nl_cmd_sb_pool_get_doit(struct sk_buff *skb,
 		return err;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int __sb_pool_get_dumpit(struct sk_buff *msg, int start, int *p_idx,
@@ -1030,7 +1030,7 @@ static int devlink_nl_cmd_sb_port_pool_get_doit(struct sk_buff *skb,
 		return err;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int __sb_port_pool_get_dumpit(struct sk_buff *msg, int start, int *p_idx,
@@ -1233,7 +1233,7 @@ static int devlink_nl_cmd_sb_tc_pool_bind_get_doit(struct sk_buff *skb,
 		return err;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int __sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
diff --git a/net/ieee802154/ieee802154.h b/net/ieee802154/ieee802154.h
index a5d7515..76f81be 100644
--- a/net/ieee802154/ieee802154.h
+++ b/net/ieee802154/ieee802154.h
@@ -40,7 +40,8 @@ struct sk_buff *ieee802154_nl_create(int flags, u8 req);
 int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group);
 struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info,
 					int flags, u8 req);
-int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info);
+int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info,
+			gfp_t flags);
 
 extern struct genl_family nl802154_family;
 
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c
index c8133c0..9a8779b 100644
--- a/net/ieee802154/netlink.c
+++ b/net/ieee802154/netlink.c
@@ -87,14 +87,15 @@ struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info,
 	return msg;
 }
 
-int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info)
+int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info,
+			gfp_t flags)
 {
 	struct nlmsghdr *nlh = nlmsg_hdr(msg);
 	void *hdr = genlmsg_data(nlmsg_data(nlh));
 
 	genlmsg_end(msg, hdr);
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, flags);
 }
 
 static const struct genl_ops ieee8021154_ops[] = {
diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
index d3cbb32..17b5797 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -435,7 +435,7 @@ int ieee802154_list_iface(struct sk_buff *skb, struct genl_info *info)
 
 	dev_put(dev);
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 out_free:
 	nlmsg_free(msg);
 out_dev:
@@ -692,7 +692,7 @@ int ieee802154_llsec_getparams(struct sk_buff *skb, struct genl_info *info)
 
 	dev_put(dev);
 
-	return ieee802154_nl_reply(msg, info);
+	return ieee802154_nl_reply(msg, info, GFP_KERNEL);
 out_free:
 	nlmsg_free(msg);
 out_dev:
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index 77d7301..4862fbe 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -110,7 +110,7 @@ int ieee802154_list_phy(struct sk_buff *skb, struct genl_info *info)
 
 	wpan_phy_put(phy);
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 out_free:
 	nlmsg_free(msg);
 out_dev:
@@ -255,7 +255,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
 
 	wpan_phy_put(phy);
 
-	return ieee802154_nl_reply(msg, info);
+	return ieee802154_nl_reply(msg, info, GFP_ATOMIC);
 
 dev_unregister:
 	rtnl_lock(); /* del_iface must be called with RTNL lock */
@@ -336,7 +336,7 @@ int ieee802154_del_iface(struct sk_buff *skb, struct genl_info *info)
 		goto nla_put_failure;
 	wpan_phy_put(phy);
 
-	return ieee802154_nl_reply(msg, info);
+	return ieee802154_nl_reply(msg, info, GFP_ATOMIC);
 
 nla_put_failure:
 	nlmsg_free(msg);
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 116187b..8d58da3 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -681,7 +681,7 @@ static int nl802154_get_wpan_phy(struct sk_buff *skb, struct genl_info *info)
 		return -ENOBUFS;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static inline u64 wpan_dev_id(struct wpan_dev *wpan_dev)
@@ -918,7 +918,7 @@ static int nl802154_get_interface(struct sk_buff *skb, struct genl_info *info)
 		return -ENOBUFS;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info)
diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c
index 321d57f..2bf8342 100644
--- a/net/ipv4/fou.c
+++ b/net/ipv4/fou.c
@@ -780,7 +780,7 @@ static int fou_nl_cmd_get_port(struct sk_buff *skb, struct genl_info *info)
 	if (ret < 0)
 		goto out_free;
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
 out_free:
 	nlmsg_free(msg);
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index b617826..cb624c1 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -1024,7 +1024,7 @@ static int tcp_metrics_nl_cmd_get(struct sk_buff *skb, struct genl_info *info)
 		goto out_free;
 
 	genlmsg_end(msg, reply);
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
 nla_put_failure:
 	ret = -EMSGSIZE;
diff --git a/net/ipv6/ila/ila_xlat.c b/net/ipv6/ila/ila_xlat.c
index e6eca5f..2e008bf3 100644
--- a/net/ipv6/ila/ila_xlat.c
+++ b/net/ipv6/ila/ila_xlat.c
@@ -467,7 +467,7 @@ static int ila_nl_cmd_get_mapping(struct sk_buff *skb, struct genl_info *info)
 	if (ret < 0)
 		goto out_free;
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
 out_free:
 	nlmsg_free(msg);
diff --git a/net/irda/irnetlink.c b/net/irda/irnetlink.c
index e15c40e..ffa5b5c 100644
--- a/net/irda/irnetlink.c
+++ b/net/irda/irnetlink.c
@@ -116,7 +116,7 @@ static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info)
 
 	genlmsg_end(msg, hdr);
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
  err_out:
 	nlmsg_free(msg);
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index c3c809b..cccf673 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -3760,7 +3760,7 @@ static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info)
 	}
 
 	genlmsg_end(msg, reply);
-	ret = genlmsg_reply(msg, info);
+	ret = genlmsg_reply(msg, info, GFP_KERNEL);
 	goto out;
 
 nla_put_failure:
diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
index 7fd1104..c2b6fb5 100644
--- a/net/netlabel/netlabel_cipso_v4.c
+++ b/net/netlabel/netlabel_cipso_v4.c
@@ -590,7 +590,7 @@ list_start:
 	rcu_read_unlock();
 
 	genlmsg_end(ans_skb, data);
-	return genlmsg_reply(ans_skb, info);
+	return genlmsg_reply(ans_skb, info, GFP_KERNEL);
 
 list_retry:
 	/* XXX - this limit is a guesstimate */
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index 13f777f..23099ee 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -577,7 +577,7 @@ static int netlbl_mgmt_listdef(struct sk_buff *skb, struct genl_info *info)
 		goto listdef_failure;
 
 	genlmsg_end(ans_skb, data);
-	return genlmsg_reply(ans_skb, info);
+	return genlmsg_reply(ans_skb, info, GFP_KERNEL);
 
 listdef_failure_lock:
 	rcu_read_unlock();
@@ -688,7 +688,7 @@ static int netlbl_mgmt_version(struct sk_buff *skb, struct genl_info *info)
 		goto version_failure;
 
 	genlmsg_end(ans_skb, data);
-	return genlmsg_reply(ans_skb, info);
+	return genlmsg_reply(ans_skb, info, GFP_KERNEL);
 
 version_failure:
 	kfree_skb(ans_skb);
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index 9eaa9a1..bbe1337 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -874,7 +874,7 @@ static int netlbl_unlabel_list(struct sk_buff *skb, struct genl_info *info)
 		goto list_failure;
 
 	genlmsg_end(ans_skb, data);
-	return genlmsg_reply(ans_skb, info);
+	return genlmsg_reply(ans_skb, info, GFP_KERNEL);
 
 list_failure:
 	kfree_skb(ans_skb);
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index acc1ee6..980cc86 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1227,7 +1227,7 @@ int netlink_unicast(struct sock *ssk, struct sk_buff *skb, u32 portid,
 	int err;
 	long timeo;
 
-	skb = netlink_trim(skb, allocation ? allocation : gfp_any());
+	skb = netlink_trim(skb, allocation);
 
 	timeo = sock_sndtimeo(ssk, nonblock);
 retry:
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index a09132a..1552380 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -933,7 +933,7 @@ static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info)
 	if (IS_ERR(msg))
 		return PTR_ERR(msg);
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int genl_ctrl_event(int event, struct genl_family *family,
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index ea023b3..052a5d1 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -772,7 +772,7 @@ static int nfc_genl_get_device(struct sk_buff *skb, struct genl_info *info)
 
 	nfc_put_device(dev);
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
 out_free:
 	nlmsg_free(msg);
@@ -1056,7 +1056,7 @@ exit:
 		return rc;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int nfc_genl_llc_set_params(struct sk_buff *skb, struct genl_info *info)
@@ -1653,7 +1653,7 @@ int nfc_vendor_cmd_reply(struct sk_buff *skb)
 	}
 
 	genlmsg_end(skb, hdr);
-	return genlmsg_reply(skb, dev->cur_cmd_info);
+	return genlmsg_reply(skb, dev->cur_cmd_info, gfp_any());
 }
 EXPORT_SYMBOL(nfc_vendor_cmd_reply);
 
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 374e0ec..44a3cbc 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1274,7 +1274,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)
 	}
 
 	ovs_unlock();
-	return genlmsg_reply(reply, info);
+	return genlmsg_reply(reply, info, GFP_KERNEL);
 unlock:
 	ovs_unlock();
 	return err;
@@ -1760,7 +1760,7 @@ static int ovs_dp_cmd_get(struct sk_buff *skb, struct genl_info *info)
 	BUG_ON(err < 0);
 	ovs_unlock();
 
-	return genlmsg_reply(reply, info);
+	return genlmsg_reply(reply, info, GFP_KERNEL);
 
 err_unlock_free:
 	ovs_unlock();
@@ -2163,7 +2163,7 @@ static int ovs_vport_cmd_get(struct sk_buff *skb, struct genl_info *info)
 	BUG_ON(err < 0);
 	rcu_read_unlock();
 
-	return genlmsg_reply(reply, info);
+	return genlmsg_reply(reply, info, GFP_KERNEL);
 
 exit_unlock_free:
 	rcu_read_unlock();
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 8584cc4..f00d355 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -763,7 +763,7 @@ int tipc_nl_bearer_get(struct sk_buff *skb, struct genl_info *info)
 		goto err_out;
 	rtnl_unlock();
 
-	return genlmsg_reply(rep, info);
+	return genlmsg_reply(rep, info, GFP_KERNEL);
 err_out:
 	rtnl_unlock();
 	nlmsg_free(rep);
@@ -1022,7 +1022,7 @@ int tipc_nl_media_get(struct sk_buff *skb, struct genl_info *info)
 		goto err_out;
 	rtnl_unlock();
 
-	return genlmsg_reply(rep, info);
+	return genlmsg_reply(rep, info, GFP_KERNEL);
 err_out:
 	rtnl_unlock();
 	nlmsg_free(rep);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index a3fc0a3..a86f21c 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1774,7 +1774,7 @@ int tipc_nl_node_get_link(struct sk_buff *skb, struct genl_info *info)
 		}
 	}
 
-	return genlmsg_reply(msg.skb, info);
+	return genlmsg_reply(msg.skb, info, GFP_KERNEL);
 }
 
 int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index e608937..d8e1984 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1948,7 +1948,7 @@ static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info)
 		return -ENOBUFS;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static const struct nla_policy txq_params_policy[NL80211_TXQ_ATTR_MAX + 1] = {
@@ -2574,7 +2574,7 @@ static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info)
 		return -ENOBUFS;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static const struct nla_policy mntr_flags_policy[NL80211_MNTR_FLAG_MAX + 1] = {
@@ -2833,7 +2833,7 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
 	}
 
 out:
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
@@ -3007,7 +3007,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
 		goto nla_put_failure;
 
 	genlmsg_end(msg, hdr);
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
  nla_put_failure:
 	err = -ENOBUFS;
@@ -4050,7 +4050,7 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info)
 		return -ENOBUFS;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 int cfg80211_check_station_change(struct wiphy *wiphy,
@@ -4852,7 +4852,7 @@ static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info)
 		return -ENOBUFS;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info)
@@ -4957,7 +4957,7 @@ static int nl80211_get_mpp(struct sk_buff *skb, struct genl_info *info)
 		return -ENOBUFS;
 	}
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 }
 
 static int nl80211_dump_mpp(struct sk_buff *skb,
@@ -5234,7 +5234,7 @@ static int nl80211_get_mesh_config(struct sk_buff *skb,
 		goto nla_put_failure;
 	nla_nest_end(msg, pinfoattr);
 	genlmsg_end(msg, hdr);
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
  nla_put_failure:
 	genlmsg_cancel(msg, hdr);
@@ -5672,7 +5672,7 @@ static int nl80211_get_reg_do(struct sk_buff *skb, struct genl_info *info)
 	rcu_read_unlock();
 
 	genlmsg_end(msg, hdr);
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
 nla_put_failure_rcu:
 	rcu_read_unlock();
@@ -8485,7 +8485,7 @@ static int nl80211_remain_on_channel(struct sk_buff *skb,
 
 	genlmsg_end(msg, hdr);
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
  nla_put_failure:
 	err = -ENOBUFS;
@@ -8897,7 +8897,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
 			goto nla_put_failure;
 
 		genlmsg_end(msg, hdr);
-		return genlmsg_reply(msg, info);
+		return genlmsg_reply(msg, info, GFP_KERNEL);
 	}
 
 	return 0;
@@ -9007,7 +9007,7 @@ static int nl80211_get_power_save(struct sk_buff *skb, struct genl_info *info)
 		goto nla_put_failure;
 
 	genlmsg_end(msg, hdr);
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
  nla_put_failure:
 	err = -ENOBUFS;
@@ -9428,7 +9428,7 @@ static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info)
 	}
 
 	genlmsg_end(msg, hdr);
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
 nla_put_failure:
 	nlmsg_free(msg);
@@ -9892,7 +9892,7 @@ static int nl80211_get_coalesce(struct sk_buff *skb, struct genl_info *info)
 		goto nla_put_failure;
 
 	genlmsg_end(msg, hdr);
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
 nla_put_failure:
 	nlmsg_free(msg);
@@ -10185,7 +10185,7 @@ static int nl80211_probe_client(struct sk_buff *skb,
 
 	genlmsg_end(msg, hdr);
 
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
  nla_put_failure:
 	err = -ENOBUFS;
@@ -10292,7 +10292,7 @@ static int nl80211_get_protocol_features(struct sk_buff *skb,
 		goto nla_put_failure;
 
 	genlmsg_end(msg, hdr);
-	return genlmsg_reply(msg, info);
+	return genlmsg_reply(msg, info, GFP_KERNEL);
 
  nla_put_failure:
 	kfree_skb(msg);
@@ -10672,7 +10672,7 @@ int cfg80211_vendor_cmd_reply(struct sk_buff *skb)
 
 	nla_nest_end(skb, data);
 	genlmsg_end(skb, hdr);
-	return genlmsg_reply(skb, rdev->cur_cmd_info);
+	return genlmsg_reply(skb, rdev->cur_cmd_info, gfp_any());
 }
 EXPORT_SYMBOL_GPL(cfg80211_vendor_cmd_reply);
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [RFC 0/7] netlink: Add allocation flag to netlink_unicast()
       [not found] ` <1467764916-4983-1-git-send-email-masashi.honma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2016-07-06  0:28   ` [RFC 6/7] genetlink: Add allocation flag to genlmsg_unicast() Masashi Honma
  2016-07-06  0:28   ` [RFC 7/7] genetlink: Add allocation flag to genlmsg_reply() Masashi Honma
@ 2016-07-06  3:22   ` David Miller
  2016-07-09  3:54   ` Masashi Honma
  3 siblings, 0 replies; 24+ messages in thread
From: David Miller @ 2016-07-06  3:22 UTC (permalink / raw)
  To: masashi.honma-Re5JQEeQqe8AvxtiuMwx3w
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-audit-H+wXaHxf7aLQT0dZR+AlfA,
	cluster-devel-H+wXaHxf7aLQT0dZR+AlfA,
	johannes-cdvu00un1VgdHxzADdlk8Q, pablo-Cap9r6Oaw4JrovVCs/uTlw,
	kaber-dcUjhNyLwpNeoWH0uzbU5w,
	kadlec-K40Dz/62t/MgiyqX0sVFJYdd74u8MsAO,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	paul-r2n+y4ga6xFZroRs9YW3xA, eparis-H+wXaHxf7aLQT0dZR+AlfA,
	zbr-i6C2adt8DTjR7s880joybQ, pshelar-l0M0P4e3n4LQT0dZR+AlfA,
	ccaulfie-H+wXaHxf7aLQT0dZR+AlfA, teigland-H+wXaHxf7aLQT0dZR+AlfA,
	bsingharora-Re5JQEeQqe8AvxtiuMwx3w

From: Masashi Honma <masashi.honma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Wed,  6 Jul 2016 09:28:29 +0900

> Though currently such a use case was not found, to solve potential
> issue we will add an allocation flag to netlink_unicast().

We don't solve potential issues, we solve real issues.

There is no reason to add the GFP parameter until it is actually
needed.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFC 0/7] netlink: Add allocation flag to netlink_unicast()
  2016-07-06  0:28 [RFC 0/7] netlink: Add allocation flag to netlink_unicast() Masashi Honma
                   ` (4 preceding siblings ...)
  2016-07-06  0:28 ` [RFC 5/7] net: Add allocation flag to rtnl_unicast() Masashi Honma
@ 2016-07-07  0:35 ` Masashi Honma
       [not found]   ` <20160708160821.GA2048@redhat.com>
       [not found] ` <1467764916-4983-1-git-send-email-masashi.honma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2016-07-09  3:59 ` [PATCH v2 net-next] rtnl: Add GFP flag argument to rtnl_unicast() Masashi Honma
  7 siblings, 1 reply; 24+ messages in thread
From: Masashi Honma @ 2016-07-07  0:35 UTC (permalink / raw)
  To: ccaulfie, teigland
  Cc: netdev, netfilter-devel, linux-wireless, linux-rdma, linux-audit,
	cluster-devel, davem, johannes, pablo, kaber, kadlec, dledford,
	sean.hefty, hal.rosenstock, paul, eparis, zbr, pshelar,
	bsingharora

At the fs/dlm/netlink.c#dlm_timeout_warn(),
prepare_data allocates buffer with GFP_NOFS
and send_data() sends the buffer.

But send_data() uses GFP_KERNEL or GFP_ATOMIC inside it.
Should it be replaced by GFP_NOFS ?

Masashi Honma

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFC 5/7] net: Add allocation flag to rtnl_unicast()
  2016-07-06  0:28 ` [RFC 5/7] net: Add allocation flag to rtnl_unicast() Masashi Honma
@ 2016-07-08  2:56   ` Eric Dumazet
  2016-07-08  3:15     ` Masashi Honma
  2016-07-08  3:18     ` [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf() Eric Dumazet
  0 siblings, 2 replies; 24+ messages in thread
From: Eric Dumazet @ 2016-07-08  2:56 UTC (permalink / raw)
  To: Masashi Honma
  Cc: netdev, netfilter-devel, linux-wireless, linux-rdma, linux-audit,
	cluster-devel, davem, johannes, pablo, kaber, kadlec, dledford,
	sean.hefty, hal.rosenstock, paul, eparis, zbr, pshelar, ccaulfie,
	teigland, bsingharora

On Wed, 2016-07-06 at 09:28 +0900, Masashi Honma wrote:
> Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
> ---


> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index a1f6b7b..2b0b994 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -628,7 +628,7 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
>  		kfree_skb(skb);
>  		goto errout;
>  	}
> -	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
> +	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_ATOMIC);
>  errout:
>  	return err;
>  }
> @@ -4824,7 +4824,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh)
>  		kfree_skb(skb);
>  		goto errout_ifa;
>  	}
> -	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
> +	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_KERNEL);
>  errout_ifa:
>  	in6_ifa_put(ifa);
>  errout:


Managing to mix GFP_ATOMIC and GFP_KERNEL almost randomly as you did in
this patch is definitely not good.

Further more, RTNL is a mutex, held in control path, designed to allow
schedules and waiting for memory under pressure.

We do not want to encourage GFP_ATOMIC usage in control path.

Your patch series gives the wrong signal to developers.

I will send a patch against net/ipv4/devinet.c so that we remove
GFP_ATOMIC usage there.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFC 5/7] net: Add allocation flag to rtnl_unicast()
  2016-07-08  2:56   ` Eric Dumazet
@ 2016-07-08  3:15     ` Masashi Honma
       [not found]       ` <577F1AD7.8040800-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2016-07-08  3:18     ` [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf() Eric Dumazet
  1 sibling, 1 reply; 24+ messages in thread
From: Masashi Honma @ 2016-07-08  3:15 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: netdev, netfilter-devel, linux-wireless, linux-rdma, linux-audit,
	cluster-devel, davem, johannes, pablo, kaber, kadlec, dledford,
	sean.hefty, hal.rosenstock, paul, eparis, zbr, pshelar, ccaulfie,
	teigland, bsingharora

On 2016年07月08日 11:56, Eric Dumazet wrote:
>
> Managing to mix GFP_ATOMIC and GFP_KERNEL almost randomly as you did in
> this patch is definitely not good.
>
> Further more, RTNL is a mutex, held in control path, designed to allow
> schedules and waiting for memory under pressure.
>
> We do not want to encourage GFP_ATOMIC usage in control path.
>
> Your patch series gives the wrong signal to developers.
>
>
>

Thanks for comment.

I have selected GFP flags based on existing code.

I have selected GFP_ATOMIC in inet6_netconf_get_devconf() because
skb was allocated with GFP_ATOMIC.

I have used GFP_KERNEL in inet6_rtm_getaddr() by same reason.

 > I will send a patch against net/ipv4/devinet.c so that we remove
 > GFP_ATOMIC usage there.

Thanks. I will modify my patch based on your new code.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf()
  2016-07-08  2:56   ` Eric Dumazet
  2016-07-08  3:15     ` Masashi Honma
@ 2016-07-08  3:18     ` Eric Dumazet
  2016-07-08  3:46       ` [PATCH net-next] ipv6: do not abuse GFP_ATOMIC in inet6_netconf_notify_devconf() Eric Dumazet
                         ` (2 more replies)
  1 sibling, 3 replies; 24+ messages in thread
From: Eric Dumazet @ 2016-07-08  3:18 UTC (permalink / raw)
  To: Masashi Honma, David Miller; +Cc: netdev, Nicolas Dichtel

From: Eric Dumazet <edumazet@google.com>

inet_forward_change() runs with RTNL held.
We are allowed to sleep if required.

If we use __in_dev_get_rtnl() instead of __in_dev_get_rcu(),
we no longer have to use GFP_ATOMIC allocations in
inet_netconf_notify_devconf(), meaning we are less likely to miss
notifications under memory pressure, and wont touch precious memory
reserves either and risk dropping incoming packets.

inet_netconf_get_devconf() can also use GFP_KERNEL allocation.

Fixes: edc9e748934c ("rtnl/ipv4: use netconf msg to advertise forwarding status")
Fixes: 9e5511106f99 ("rtnl/ipv4: add support of RTM_GETNETCONF")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv4/devinet.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index e333bc86bd39d8baf08ea336f20f99cc51ec945f..415e117967c775f805b43cd634bdf9a55f064e2f 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1834,7 +1834,7 @@ void inet_netconf_notify_devconf(struct net *net, int type, int ifindex,
 	struct sk_buff *skb;
 	int err = -ENOBUFS;
 
-	skb = nlmsg_new(inet_netconf_msgsize_devconf(type), GFP_ATOMIC);
+	skb = nlmsg_new(inet_netconf_msgsize_devconf(type), GFP_KERNEL);
 	if (!skb)
 		goto errout;
 
@@ -1846,7 +1846,7 @@ void inet_netconf_notify_devconf(struct net *net, int type, int ifindex,
 		kfree_skb(skb);
 		goto errout;
 	}
-	rtnl_notify(skb, net, 0, RTNLGRP_IPV4_NETCONF, NULL, GFP_ATOMIC);
+	rtnl_notify(skb, net, 0, RTNLGRP_IPV4_NETCONF, NULL, GFP_KERNEL);
 	return;
 errout:
 	if (err < 0)
@@ -1903,7 +1903,7 @@ static int inet_netconf_get_devconf(struct sk_buff *in_skb,
 	}
 
 	err = -ENOBUFS;
-	skb = nlmsg_new(inet_netconf_msgsize_devconf(NETCONFA_ALL), GFP_ATOMIC);
+	skb = nlmsg_new(inet_netconf_msgsize_devconf(NETCONFA_ALL), GFP_KERNEL);
 	if (!skb)
 		goto errout;
 
@@ -2027,16 +2027,16 @@ static void inet_forward_change(struct net *net)
 
 	for_each_netdev(net, dev) {
 		struct in_device *in_dev;
+
 		if (on)
 			dev_disable_lro(dev);
-		rcu_read_lock();
-		in_dev = __in_dev_get_rcu(dev);
+
+		in_dev = __in_dev_get_rtnl(dev);
 		if (in_dev) {
 			IN_DEV_CONF_SET(in_dev, FORWARDING, on);
 			inet_netconf_notify_devconf(net, NETCONFA_FORWARDING,
 						    dev->ifindex, &in_dev->cnf);
 		}
-		rcu_read_unlock();
 	}
 }
 

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH net-next] ipv6: do not abuse GFP_ATOMIC in inet6_netconf_notify_devconf()
  2016-07-08  3:18     ` [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf() Eric Dumazet
@ 2016-07-08  3:46       ` Eric Dumazet
  2016-07-08  7:58         ` Nicolas Dichtel
  2016-07-09 22:14         ` David Miller
  2016-07-08  7:54       ` [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf() Nicolas Dichtel
  2016-07-09 22:12       ` David Miller
  2 siblings, 2 replies; 24+ messages in thread
From: Eric Dumazet @ 2016-07-08  3:46 UTC (permalink / raw)
  To: Masashi Honma; +Cc: David Miller, netdev, Nicolas Dichtel

From: Eric Dumazet <edumazet@google.com>

All inet6_netconf_notify_devconf() callers are in process context,
so we can use GFP_KERNEL allocations if we take care of not holding
a rwlock while not needed in ip6mr (we hold RTNL there)


Fixes: d67b8c616b48 ("netconf: advertise mc_forwarding status")
Fixes: f3a1bfb11ccb ("rtnl/ipv6: use netconf msg to advertise forwarding status")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv6/addrconf.c |    4 ++--
 net/ipv6/ip6mr.c    |   13 +++++++------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index a1f6b7b315317f811cafbf386cf21dfc510c2010..24f1b0898e4013a45ce21cc73090607f9578131a 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -547,7 +547,7 @@ void inet6_netconf_notify_devconf(struct net *net, int type, int ifindex,
 	struct sk_buff *skb;
 	int err = -ENOBUFS;
 
-	skb = nlmsg_new(inet6_netconf_msgsize_devconf(type), GFP_ATOMIC);
+	skb = nlmsg_new(inet6_netconf_msgsize_devconf(type), GFP_KERNEL);
 	if (!skb)
 		goto errout;
 
@@ -559,7 +559,7 @@ void inet6_netconf_notify_devconf(struct net *net, int type, int ifindex,
 		kfree_skb(skb);
 		goto errout;
 	}
-	rtnl_notify(skb, net, 0, RTNLGRP_IPV6_NETCONF, NULL, GFP_ATOMIC);
+	rtnl_notify(skb, net, 0, RTNLGRP_IPV6_NETCONF, NULL, GFP_KERNEL);
 	return;
 errout:
 	rtnl_set_sk_err(net, RTNLGRP_IPV6_NETCONF, err);
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 487ef3bc7bbcde7f3509b76b3a68aee9d2ab7e8b..c7ca0f5d1a3b7114abbf87db884ecb9c0fcfa8c6 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1592,14 +1592,15 @@ static int ip6mr_sk_init(struct mr6_table *mrt, struct sock *sk)
 	if (likely(mrt->mroute6_sk == NULL)) {
 		mrt->mroute6_sk = sk;
 		net->ipv6.devconf_all->mc_forwarding++;
-		inet6_netconf_notify_devconf(net, NETCONFA_MC_FORWARDING,
-					     NETCONFA_IFINDEX_ALL,
-					     net->ipv6.devconf_all);
-	}
-	else
+	} else {
 		err = -EADDRINUSE;
+	}
 	write_unlock_bh(&mrt_lock);
 
+	if (!err)
+		inet6_netconf_notify_devconf(net, NETCONFA_MC_FORWARDING,
+					     NETCONFA_IFINDEX_ALL,
+					     net->ipv6.devconf_all);
 	rtnl_unlock();
 
 	return err;
@@ -1617,11 +1618,11 @@ int ip6mr_sk_done(struct sock *sk)
 			write_lock_bh(&mrt_lock);
 			mrt->mroute6_sk = NULL;
 			net->ipv6.devconf_all->mc_forwarding--;
+			write_unlock_bh(&mrt_lock);
 			inet6_netconf_notify_devconf(net,
 						     NETCONFA_MC_FORWARDING,
 						     NETCONFA_IFINDEX_ALL,
 						     net->ipv6.devconf_all);
-			write_unlock_bh(&mrt_lock);
 
 			mroute_clean_tables(mrt, false);
 			err = 0;

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [RFC 5/7] net: Add allocation flag to rtnl_unicast()
       [not found]       ` <577F1AD7.8040800-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-07-08  4:00         ` Eric Dumazet
  0 siblings, 0 replies; 24+ messages in thread
From: Eric Dumazet @ 2016-07-08  4:00 UTC (permalink / raw)
  To: Masashi Honma
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-audit-H+wXaHxf7aLQT0dZR+AlfA,
	cluster-devel-H+wXaHxf7aLQT0dZR+AlfA,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q, johannes-cdvu00un1VgdHxzADdlk8Q,
	pablo-Cap9r6Oaw4JrovVCs/uTlw, kaber-dcUjhNyLwpNeoWH0uzbU5w,
	kadlec-K40Dz/62t/MgiyqX0sVFJYdd74u8MsAO,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	paul-r2n+y4ga6xFZroRs9YW3xA, eparis-H+wXaHxf7aLQT0dZR+AlfA,
	zbr-i6C2adt8DTjR7s880joybQ, pshelar-l0M0P4e3n4LQT0dZR+AlfA,
	ccaulfie-H+wXaHxf7aLQT0dZR+AlfA, teigland-H+wXaHxf7aLQT0dZR+AlfA,
	bsingharora-Re5JQEeQqe8AvxtiuMwx3w

On Fri, 2016-07-08 at 12:15 +0900, Masashi Honma wrote:
=
> Thanks for comment.
> 
> I have selected GFP flags based on existing code.
> 
> I have selected GFP_ATOMIC in inet6_netconf_get_devconf() because
> skb was allocated with GFP_ATOMIC.

Point is : we should remove GFP_ATOMIC uses as much as we can.

Everytime we see one of them, we should think why it was added
and if this is really needed.

inet6_netconf_get_devconf() is a perfect example of one careless
GFP_ATOMIC usage

https://patchwork.ozlabs.org/patch/646291/






--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf()
  2016-07-08  3:18     ` [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf() Eric Dumazet
  2016-07-08  3:46       ` [PATCH net-next] ipv6: do not abuse GFP_ATOMIC in inet6_netconf_notify_devconf() Eric Dumazet
@ 2016-07-08  7:54       ` Nicolas Dichtel
  2016-07-09 22:12       ` David Miller
  2 siblings, 0 replies; 24+ messages in thread
From: Nicolas Dichtel @ 2016-07-08  7:54 UTC (permalink / raw)
  To: Eric Dumazet, Masashi Honma, David Miller; +Cc: netdev

Le 08/07/2016 05:18, Eric Dumazet a écrit :
> From: Eric Dumazet <edumazet@google.com>
> 
> inet_forward_change() runs with RTNL held.
> We are allowed to sleep if required.
> 
> If we use __in_dev_get_rtnl() instead of __in_dev_get_rcu(),
> we no longer have to use GFP_ATOMIC allocations in
> inet_netconf_notify_devconf(), meaning we are less likely to miss
> notifications under memory pressure, and wont touch precious memory
> reserves either and risk dropping incoming packets.
> 
> inet_netconf_get_devconf() can also use GFP_KERNEL allocation.
> 
> Fixes: edc9e748934c ("rtnl/ipv4: use netconf msg to advertise forwarding status")
> Fixes: 9e5511106f99 ("rtnl/ipv4: add support of RTM_GETNETCONF")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Nice catch, thank you!

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH net-next] ipv6: do not abuse GFP_ATOMIC in inet6_netconf_notify_devconf()
  2016-07-08  3:46       ` [PATCH net-next] ipv6: do not abuse GFP_ATOMIC in inet6_netconf_notify_devconf() Eric Dumazet
@ 2016-07-08  7:58         ` Nicolas Dichtel
  2016-07-09 22:14         ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: Nicolas Dichtel @ 2016-07-08  7:58 UTC (permalink / raw)
  To: Eric Dumazet, Masashi Honma; +Cc: David Miller, netdev

Le 08/07/2016 05:46, Eric Dumazet a écrit :
> From: Eric Dumazet <edumazet@google.com>
> 
> All inet6_netconf_notify_devconf() callers are in process context,
> so we can use GFP_KERNEL allocations if we take care of not holding
> a rwlock while not needed in ip6mr (we hold RTNL there)
> 
> 
> Fixes: d67b8c616b48 ("netconf: advertise mc_forwarding status")
> Fixes: f3a1bfb11ccb ("rtnl/ipv6: use netconf msg to advertise forwarding status")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Also nice, thanks.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFC 0/7] netlink: Add allocation flag to netlink_unicast()
       [not found]     ` <20160708160821.GA2048-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2016-07-09  3:52       ` Masashi Honma
  0 siblings, 0 replies; 24+ messages in thread
From: Masashi Honma @ 2016-07-09  3:52 UTC (permalink / raw)
  To: David Teigland
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-audit-H+wXaHxf7aLQT0dZR+AlfA,
	cluster-devel-H+wXaHxf7aLQT0dZR+AlfA,
	johannes-cdvu00un1VgdHxzADdlk8Q, pablo-Cap9r6Oaw4JrovVCs/uTlw,
	kaber-dcUjhNyLwpNeoWH0uzbU5w,
	kadlec-K40Dz/62t/MgiyqX0sVFJYdd74u8MsAO,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	paul-r2n+y4ga6xFZroRs9YW3xA, eparis-H+wXaHxf7aLQT0dZR+AlfA,
	zbr-i6C2adt8DTjR7s880joybQ, pshelar-l0M0P4e3n4LQT0dZR+AlfA,
	ccaulfie-H+wXaHxf7aLQT0dZR+AlfA,
	bsingharora-Re5JQEeQqe8AvxtiuMwx3w

On 2016年07月09日 01:08, David Teigland wrote:
> On Thu, Jul 07, 2016 at 09:35:45AM +0900, Masashi Honma wrote:
>> At the fs/dlm/netlink.c#dlm_timeout_warn(),
>> prepare_data allocates buffer with GFP_NOFS
>> and send_data() sends the buffer.
>>
>> But send_data() uses GFP_KERNEL or GFP_ATOMIC inside it.
>> Should it be replaced by GFP_NOFS ?
> That's old code that's never been used so it doesn't really matter.
>
I see. Thank you.

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFC 0/7] netlink: Add allocation flag to netlink_unicast()
       [not found] ` <1467764916-4983-1-git-send-email-masashi.honma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-07-06  3:22   ` [RFC 0/7] netlink: Add allocation flag to netlink_unicast() David Miller
@ 2016-07-09  3:54   ` Masashi Honma
  3 siblings, 0 replies; 24+ messages in thread
From: Masashi Honma @ 2016-07-09  3:54 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA,
	netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-audit-H+wXaHxf7aLQT0dZR+AlfA,
	cluster-devel-H+wXaHxf7aLQT0dZR+AlfA
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, johannes-cdvu00un1VgdHxzADdlk8Q,
	pablo-Cap9r6Oaw4JrovVCs/uTlw, kaber-dcUjhNyLwpNeoWH0uzbU5w,
	kadlec-K40Dz/62t/MgiyqX0sVFJYdd74u8MsAO,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	paul-r2n+y4ga6xFZroRs9YW3xA, eparis-H+wXaHxf7aLQT0dZR+AlfA,
	zbr-i6C2adt8DTjR7s880joybQ, pshelar-l0M0P4e3n4LQT0dZR+AlfA,
	ccaulfie-H+wXaHxf7aLQT0dZR+AlfA, teigland-H+wXaHxf7aLQT0dZR+AlfA,
	bsingharora-Re5JQEeQqe8AvxtiuMwx3w

On 2016年07月06日 09:28, Masashi Honma wrote:
> Though netlink_broadcast() ...

Thanks for reply of David Miller, Eric Dumazet, David Teigrand.

On the basis of their comment, only rtnl_unicast() looks need to add gfp
flag
argument. So I will drop almost of patches except 0005.

I will send patch v2 to more limited destination.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 net-next] rtnl: Add GFP flag argument to rtnl_unicast()
  2016-07-06  0:28 [RFC 0/7] netlink: Add allocation flag to netlink_unicast() Masashi Honma
                   ` (6 preceding siblings ...)
       [not found] ` <1467764916-4983-1-git-send-email-masashi.honma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-07-09  3:59 ` Masashi Honma
  2016-07-11 20:01   ` David Miller
  7 siblings, 1 reply; 24+ messages in thread
From: Masashi Honma @ 2016-07-09  3:59 UTC (permalink / raw)
  To: eric.dumazet, davem; +Cc: netdev, Masashi Honma

This commit extends rtnl_unicast() to specify GFP flags.

This commit depends on Eric Dumazet's commits below.
	ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf()
	ipv6: do not abuse GFP_ATOMIC in inet6_netconf_notify_devconf()

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 include/linux/netlink.h   |  2 ++
 include/linux/rtnetlink.h |  3 ++-
 net/core/net_namespace.c  |  2 +-
 net/core/rtnetlink.c      | 16 +++++++++++-----
 net/dcb/dcbnl.c           |  2 +-
 net/decnet/dn_route.c     |  3 ++-
 net/ipv4/devinet.c        |  2 +-
 net/ipv4/ipmr.c           |  6 ++++--
 net/ipv4/route.c          |  2 +-
 net/ipv6/addrconf.c       |  4 ++--
 net/ipv6/addrlabel.c      |  2 +-
 net/ipv6/ip6mr.c          |  6 ++++--
 net/ipv6/route.c          |  2 +-
 net/netlink/af_netlink.c  | 12 +++++++++---
 net/sched/act_api.c       |  2 +-
 15 files changed, 43 insertions(+), 23 deletions(-)

diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index da14ab6..5b8e34d 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -69,6 +69,8 @@ extern void __netlink_clear_multicast_users(struct sock *sk, unsigned int group)
 extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
 extern int netlink_has_listeners(struct sock *sk, unsigned int group);
 
+extern int __netlink_unicast(struct sock *ssk, struct sk_buff *skb, u32 portid,
+			     int nonblock, gfp_t allocation);
 extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 portid, int nonblock);
 extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 portid,
 			     __u32 group, gfp_t allocation);
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 2daece8..132730f 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -8,7 +8,8 @@
 #include <uapi/linux/rtnetlink.h>
 
 extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
-extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid);
+extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid,
+			gfp_t flags);
 extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
 			u32 group, struct nlmsghdr *nlh, gfp_t flags);
 extern void rtnl_set_sk_err(struct net *net, u32 group, int error);
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 2c2eb1b..28eed58 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -646,7 +646,7 @@ static int rtnl_net_getid(struct sk_buff *skb, struct nlmsghdr *nlh)
 	if (err < 0)
 		goto err_out;
 
-	err = rtnl_unicast(msg, net, NETLINK_CB(skb).portid);
+	err = rtnl_unicast(msg, net, NETLINK_CB(skb).portid, GFP_KERNEL);
 	goto out;
 
 err_out:
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index eb49ca2..42e6c5c 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -653,11 +653,15 @@ int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int g
 	return err;
 }
 
-int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid)
+int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid, gfp_t flags)
 {
-	struct sock *rtnl = net->rtnl;
+	int err;
 
-	return nlmsg_unicast(rtnl, skb, pid);
+	err = __netlink_unicast(net->rtnl, skb, pid, MSG_DONTWAIT, flags);
+	if (err > 0)
+		err = 0;
+
+	return err;
 }
 EXPORT_SYMBOL(rtnl_unicast);
 
@@ -2565,7 +2569,8 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh)
 		WARN_ON(err == -EMSGSIZE);
 		kfree_skb(nskb);
 	} else
-		err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid);
+		err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid,
+				   GFP_KERNEL);
 
 	return err;
 }
@@ -3601,7 +3606,8 @@ static int rtnl_stats_get(struct sk_buff *skb, struct nlmsghdr *nlh)
 		WARN_ON(err == -EMSGSIZE);
 		kfree_skb(nskb);
 	} else {
-		err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid);
+		err = rtnl_unicast(nskb, net, NETLINK_CB(skb).portid,
+				   GFP_KERNEL);
 	}
 
 	return err;
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 4f6c186..e4de9fe 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1749,7 +1749,7 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
 
 	nlmsg_end(reply_skb, reply_nlh);
 
-	ret = rtnl_unicast(reply_skb, net, portid);
+	ret = rtnl_unicast(reply_skb, net, portid, GFP_KERNEL);
 out:
 	return ret;
 }
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index b1dc096..6fe02bb 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -1714,7 +1714,8 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 		goto out_free;
 	}
 
-	return rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).portid);
+	return rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).portid,
+			    GFP_KERNEL);
 
 out_free:
 	kfree_skb(skb);
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index e333bc8..12422c0 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1917,7 +1917,7 @@ static int inet_netconf_get_devconf(struct sk_buff *in_skb,
 		kfree_skb(skb);
 		goto errout;
 	}
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_KERNEL);
 errout:
 	return err;
 }
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 5ad48ec..c704a2a 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -654,7 +654,8 @@ static void ipmr_destroy_unres(struct mr_table *mrt, struct mfc_cache *c)
 			e->error = -ETIMEDOUT;
 			memset(&e->msg, 0, sizeof(e->msg));
 
-			rtnl_unicast(skb, net, NETLINK_CB(skb).portid);
+			rtnl_unicast(skb, net, NETLINK_CB(skb).portid,
+				     gfp_any());
 		} else {
 			kfree_skb(skb);
 		}
@@ -933,7 +934,8 @@ static void ipmr_cache_resolve(struct net *net, struct mr_table *mrt,
 				memset(&e->msg, 0, sizeof(e->msg));
 			}
 
-			rtnl_unicast(skb, net, NETLINK_CB(skb).portid);
+			rtnl_unicast(skb, net, NETLINK_CB(skb).portid,
+				     gfp_any());
 		} else {
 			ip_mr_forward(net, mrt, skb, c, 0);
 		}
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a1f2830..10cb0e0 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2621,7 +2621,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 	if (err < 0)
 		goto errout_free;
 
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_KERNEL);
 errout:
 	return err;
 
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index a1f6b7b..eb72512 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -628,7 +628,7 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
 		kfree_skb(skb);
 		goto errout;
 	}
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_KERNEL);
 errout:
 	return err;
 }
@@ -4824,7 +4824,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 		kfree_skb(skb);
 		goto errout_ifa;
 	}
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_KERNEL);
 errout_ifa:
 	in6_ifa_put(ifa);
 errout:
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c
index a8f6986..597e0eb 100644
--- a/net/ipv6/addrlabel.c
+++ b/net/ipv6/addrlabel.c
@@ -580,7 +580,7 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 		goto out;
 	}
 
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_KERNEL);
 out:
 	return err;
 }
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 487ef3b..135ba15 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -850,7 +850,8 @@ static void ip6mr_destroy_unres(struct mr6_table *mrt, struct mfc6_cache *c)
 			nlh->nlmsg_len = nlmsg_msg_size(sizeof(struct nlmsgerr));
 			skb_trim(skb, nlh->nlmsg_len);
 			((struct nlmsgerr *)nlmsg_data(nlh))->error = -ETIMEDOUT;
-			rtnl_unicast(skb, net, NETLINK_CB(skb).portid);
+			rtnl_unicast(skb, net, NETLINK_CB(skb).portid,
+				     gfp_any());
 		} else
 			kfree_skb(skb);
 	}
@@ -1114,7 +1115,8 @@ static void ip6mr_cache_resolve(struct net *net, struct mr6_table *mrt,
 				skb_trim(skb, nlh->nlmsg_len);
 				((struct nlmsgerr *)nlmsg_data(nlh))->error = -EMSGSIZE;
 			}
-			rtnl_unicast(skb, net, NETLINK_CB(skb).portid);
+			rtnl_unicast(skb, net, NETLINK_CB(skb).portid,
+				     gfp_any());
 		} else
 			ip6_mr_forward(net, mrt, skb, c);
 	}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 4981755..81318a8 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3367,7 +3367,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 		goto errout;
 	}
 
-	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
+	err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid, GFP_KERNEL);
 errout:
 	return err;
 }
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 627f898..9f2cde4 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1220,14 +1220,14 @@ static int netlink_unicast_kernel(struct sock *sk, struct sk_buff *skb,
 	return ret;
 }
 
-int netlink_unicast(struct sock *ssk, struct sk_buff *skb,
-		    u32 portid, int nonblock)
+int __netlink_unicast(struct sock *ssk, struct sk_buff *skb, u32 portid,
+		      int nonblock, gfp_t allocation)
 {
 	struct sock *sk;
 	int err;
 	long timeo;
 
-	skb = netlink_trim(skb, gfp_any());
+	skb = netlink_trim(skb, allocation);
 
 	timeo = sock_sndtimeo(ssk, nonblock);
 retry:
@@ -1254,6 +1254,12 @@ retry:
 
 	return netlink_sendskb(sk, skb);
 }
+
+int netlink_unicast(struct sock *ssk, struct sk_buff *skb,
+		    u32 portid, int nonblock)
+{
+	return __netlink_unicast(ssk, skb, portid, nonblock, gfp_any());
+}
 EXPORT_SYMBOL(netlink_unicast);
 
 int netlink_has_listeners(struct sock *sk, unsigned int group)
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 47ec230..b988a84 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -737,7 +737,7 @@ act_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,
 		return -EINVAL;
 	}
 
-	return rtnl_unicast(skb, net, portid);
+	return rtnl_unicast(skb, net, portid, GFP_KERNEL);
 }
 
 static struct tc_action *create_a(int i)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf()
  2016-07-08  3:18     ` [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf() Eric Dumazet
  2016-07-08  3:46       ` [PATCH net-next] ipv6: do not abuse GFP_ATOMIC in inet6_netconf_notify_devconf() Eric Dumazet
  2016-07-08  7:54       ` [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf() Nicolas Dichtel
@ 2016-07-09 22:12       ` David Miller
  2 siblings, 0 replies; 24+ messages in thread
From: David Miller @ 2016-07-09 22:12 UTC (permalink / raw)
  To: eric.dumazet; +Cc: masashi.honma, netdev, nicolas.dichtel

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 08 Jul 2016 05:18:24 +0200

> From: Eric Dumazet <edumazet@google.com>
> 
> inet_forward_change() runs with RTNL held.
> We are allowed to sleep if required.
> 
> If we use __in_dev_get_rtnl() instead of __in_dev_get_rcu(),
> we no longer have to use GFP_ATOMIC allocations in
> inet_netconf_notify_devconf(), meaning we are less likely to miss
> notifications under memory pressure, and wont touch precious memory
> reserves either and risk dropping incoming packets.
> 
> inet_netconf_get_devconf() can also use GFP_KERNEL allocation.
> 
> Fixes: edc9e748934c ("rtnl/ipv4: use netconf msg to advertise forwarding status")
> Fixes: 9e5511106f99 ("rtnl/ipv4: add support of RTM_GETNETCONF")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Applied.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH net-next] ipv6: do not abuse GFP_ATOMIC in inet6_netconf_notify_devconf()
  2016-07-08  3:46       ` [PATCH net-next] ipv6: do not abuse GFP_ATOMIC in inet6_netconf_notify_devconf() Eric Dumazet
  2016-07-08  7:58         ` Nicolas Dichtel
@ 2016-07-09 22:14         ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: David Miller @ 2016-07-09 22:14 UTC (permalink / raw)
  To: eric.dumazet; +Cc: masashi.honma, netdev, nicolas.dichtel

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 08 Jul 2016 05:46:04 +0200

> From: Eric Dumazet <edumazet@google.com>
> 
> All inet6_netconf_notify_devconf() callers are in process context,
> so we can use GFP_KERNEL allocations if we take care of not holding
> a rwlock while not needed in ip6mr (we hold RTNL there)
> 
> 
> Fixes: d67b8c616b48 ("netconf: advertise mc_forwarding status")
> Fixes: f3a1bfb11ccb ("rtnl/ipv6: use netconf msg to advertise forwarding status")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Applied.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 net-next] rtnl: Add GFP flag argument to rtnl_unicast()
  2016-07-09  3:59 ` [PATCH v2 net-next] rtnl: Add GFP flag argument to rtnl_unicast() Masashi Honma
@ 2016-07-11 20:01   ` David Miller
  2016-07-12  4:23     ` Masashi Honma
  0 siblings, 1 reply; 24+ messages in thread
From: David Miller @ 2016-07-11 20:01 UTC (permalink / raw)
  To: masashi.honma; +Cc: eric.dumazet, netdev

From: Masashi Honma <masashi.honma@gmail.com>
Date: Sat,  9 Jul 2016 12:59:04 +0900

> This commit extends rtnl_unicast() to specify GFP flags.
> 
> This commit depends on Eric Dumazet's commits below.
> 	ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf()
> 	ipv6: do not abuse GFP_ATOMIC in inet6_netconf_notify_devconf()
> 
> Signed-off-by: Masashi Honma <masashi.honma@gmail.com>

The code is correct and optimal as-is.  There is no gain to your
changes.  gfp_any() will do the right thing.

In fact, your change makes the code more error prone because if any
of these code paths get moved into an atomic context they will break
unless somone remembers to also fix up the GFP flags.

Meanwhile with the existing use of gfp_any() it will work
transparently in such a situation.

I'm not applying this.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 net-next] rtnl: Add GFP flag argument to rtnl_unicast()
  2016-07-11 20:01   ` David Miller
@ 2016-07-12  4:23     ` Masashi Honma
  0 siblings, 0 replies; 24+ messages in thread
From: Masashi Honma @ 2016-07-12  4:23 UTC (permalink / raw)
  To: David Miller; +Cc: eric.dumazet, netdev

On 2016年07月12日 05:01, David Miller wrote:

> The code is correct and optimal as-is.  There is no gain to your
> changes.  gfp_any() will do the right thing.
>
> In fact, your change makes the code more error prone because if any
> of these code paths get moved into an atomic context they will break
> unless somone remembers to also fix up the GFP flags.
>
> Meanwhile with the existing use of gfp_any() it will work
> transparently in such a situation.
>
> I'm not applying this.

I see. Thank you for reviewing.

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2016-07-12  4:23 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-06  0:28 [RFC 0/7] netlink: Add allocation flag to netlink_unicast() Masashi Honma
2016-07-06  0:28 ` [RFC 1/7] " Masashi Honma
2016-07-06  0:28 ` [RFC 2/7] netfilter: Add allocation flag to nfnetlink_unicast() Masashi Honma
2016-07-06  0:28 ` [RFC 3/7] netlink: Add allocation flag to nlmsg_unicast() Masashi Honma
2016-07-06  0:28 ` [RFC 4/7] infiniband: Add allocation flag to ibnl_unicast() Masashi Honma
2016-07-06  0:28 ` [RFC 5/7] net: Add allocation flag to rtnl_unicast() Masashi Honma
2016-07-08  2:56   ` Eric Dumazet
2016-07-08  3:15     ` Masashi Honma
     [not found]       ` <577F1AD7.8040800-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-07-08  4:00         ` Eric Dumazet
2016-07-08  3:18     ` [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf() Eric Dumazet
2016-07-08  3:46       ` [PATCH net-next] ipv6: do not abuse GFP_ATOMIC in inet6_netconf_notify_devconf() Eric Dumazet
2016-07-08  7:58         ` Nicolas Dichtel
2016-07-09 22:14         ` David Miller
2016-07-08  7:54       ` [PATCH net-next] ipv4: do not abuse GFP_ATOMIC in inet_netconf_notify_devconf() Nicolas Dichtel
2016-07-09 22:12       ` David Miller
2016-07-07  0:35 ` [RFC 0/7] netlink: Add allocation flag to netlink_unicast() Masashi Honma
     [not found]   ` <20160708160821.GA2048@redhat.com>
     [not found]     ` <20160708160821.GA2048-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-09  3:52       ` Masashi Honma
     [not found] ` <1467764916-4983-1-git-send-email-masashi.honma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-07-06  0:28   ` [RFC 6/7] genetlink: Add allocation flag to genlmsg_unicast() Masashi Honma
2016-07-06  0:28   ` [RFC 7/7] genetlink: Add allocation flag to genlmsg_reply() Masashi Honma
2016-07-06  3:22   ` [RFC 0/7] netlink: Add allocation flag to netlink_unicast() David Miller
2016-07-09  3:54   ` Masashi Honma
2016-07-09  3:59 ` [PATCH v2 net-next] rtnl: Add GFP flag argument to rtnl_unicast() Masashi Honma
2016-07-11 20:01   ` David Miller
2016-07-12  4:23     ` Masashi Honma

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).