All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Ying Xue <ying.xue@windriver.com>,
	Erik Hugne <erik.hugne@ericsson.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 27/72] tipc: allow connection shutdown callback to be invoked in advance
Date: Fri, 18 Apr 2014 11:22:00 +0200	[thread overview]
Message-ID: <1f92d32f63aef244e48d96b6d1abab64133b0d0c.1397812482.git.jslaby@suse.cz> (raw)
In-Reply-To: <3389f243c528afc7c7300c83b8f296290cd3656d.1397812482.git.jslaby@suse.cz>
In-Reply-To: <cover.1397812482.git.jslaby@suse.cz>

From: Ying Xue <ying.xue@windriver.com>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

[ Upstream commit 6d4ebeb4df0176b1973875840a9f7e91394c0685 ]

Currently connection shutdown callback function is called when
connection instance is released in tipc_conn_kref_release(), and
receiving packets and sending packets are running in different
threads. Even if connection is closed by the thread of receiving
packets, its shutdown callback may not be called immediately as
the connection reference count is non-zero at that moment. So,
although the connection is shut down by the thread of receiving
packets, the thread of sending packets doesn't know it. Before
its shutdown callback is invoked to tell the sending thread its
connection has been closed, the sending thread may deliver
messages by tipc_conn_sendmsg(), this is why the following error
information appears:

"Sending subscription event failed, no memory"

To eliminate it, allow connection shutdown callback function to
be called before connection id is removed in tipc_close_conn(),
which makes the sending thread know the truth in time that its
socket is closed so that it doesn't send message to it. We also
remove the "Sending XXX failed..." error reporting for topology
and config services.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/tipc/config.c | 9 ++-------
 net/tipc/server.c | 8 +++-----
 net/tipc/subscr.c | 8 ++------
 3 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/net/tipc/config.c b/net/tipc/config.c
index c301a9a592d8..5afe633114e0 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -376,7 +376,6 @@ static void cfg_conn_msg_event(int conid, struct sockaddr_tipc *addr,
 	struct tipc_cfg_msg_hdr *req_hdr;
 	struct tipc_cfg_msg_hdr *rep_hdr;
 	struct sk_buff *rep_buf;
-	int ret;
 
 	/* Validate configuration message header (ignore invalid message) */
 	req_hdr = (struct tipc_cfg_msg_hdr *)buf;
@@ -398,12 +397,8 @@ static void cfg_conn_msg_event(int conid, struct sockaddr_tipc *addr,
 		memcpy(rep_hdr, req_hdr, sizeof(*rep_hdr));
 		rep_hdr->tcm_len = htonl(rep_buf->len);
 		rep_hdr->tcm_flags &= htons(~TCM_F_REQUEST);
-
-		ret = tipc_conn_sendmsg(&cfgsrv, conid, addr, rep_buf->data,
-					rep_buf->len);
-		if (ret < 0)
-			pr_err("Sending cfg reply message failed, no memory\n");
-
+		tipc_conn_sendmsg(&cfgsrv, conid, addr, rep_buf->data,
+				  rep_buf->len);
 		kfree_skb(rep_buf);
 	}
 }
diff --git a/net/tipc/server.c b/net/tipc/server.c
index fd3fa57a410e..ae474479f12e 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -87,7 +87,6 @@ static void tipc_clean_outqueues(struct tipc_conn *con);
 static void tipc_conn_kref_release(struct kref *kref)
 {
 	struct tipc_conn *con = container_of(kref, struct tipc_conn, kref);
-	struct tipc_server *s = con->server;
 
 	if (con->sock) {
 		tipc_sock_release_local(con->sock);
@@ -95,10 +94,6 @@ static void tipc_conn_kref_release(struct kref *kref)
 	}
 
 	tipc_clean_outqueues(con);
-
-	if (con->conid)
-		s->tipc_conn_shutdown(con->conid, con->usr_data);
-
 	kfree(con);
 }
 
@@ -181,6 +176,9 @@ static void tipc_close_conn(struct tipc_conn *con)
 	struct tipc_server *s = con->server;
 
 	if (test_and_clear_bit(CF_CONNECTED, &con->flags)) {
+		if (con->conid)
+			s->tipc_conn_shutdown(con->conid, con->usr_data);
+
 		spin_lock_bh(&s->idr_lock);
 		idr_remove(&s->conn_idr, con->conid);
 		s->idr_in_use--;
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index d38bb45d82e9..13f48bb5e540 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -96,20 +96,16 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
 {
 	struct tipc_subscriber *subscriber = sub->subscriber;
 	struct kvec msg_sect;
-	int ret;
 
 	msg_sect.iov_base = (void *)&sub->evt;
 	msg_sect.iov_len = sizeof(struct tipc_event);
-
 	sub->evt.event = htohl(event, sub->swap);
 	sub->evt.found_lower = htohl(found_lower, sub->swap);
 	sub->evt.found_upper = htohl(found_upper, sub->swap);
 	sub->evt.port.ref = htohl(port_ref, sub->swap);
 	sub->evt.port.node = htohl(node, sub->swap);
-	ret = tipc_conn_sendmsg(&topsrv, subscriber->conid, NULL,
-				msg_sect.iov_base, msg_sect.iov_len);
-	if (ret < 0)
-		pr_err("Sending subscription event failed, no memory\n");
+	tipc_conn_sendmsg(&topsrv, subscriber->conid, NULL, msg_sect.iov_base,
+			  msg_sect.iov_len);
 }
 
 /**
-- 
1.9.2


  parent reply	other threads:[~2014-04-18  9:32 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-18  9:21 [PATCH 3.12 00/72] 3.12.18-stable review Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 01/72] powernow-k6: disable cache when changing frequency Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 02/72] powernow-k6: correctly initialize default parameters Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 03/72] powernow-k6: reorder frequencies Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 04/72] PCI: mvebu: move clock enable before register access Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 05/72] selinux: correctly label /proc inodes in use before the policy is loaded Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 06/72] futex: Allow architectures to skip futex_atomic_cmpxchg_inatomic() test Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 07/72] m68k: Skip " Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 08/72] Char: ipmi_bt_sm, fix infinite loop Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 09/72] nfs: initialize the ACL support bits to zero Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 10/72] NFSv3: Fix return value of nfs3_proc_setacls Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 11/72] SUNRPC: Fix potential memory scribble in xprt_free_bc_request() Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 12/72] ext4: Speedup WB_SYNC_ALL pass called from sync(2) Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 13/72] floppy: bail out in open() if drive is not responding to block0 read Jiri Slaby
2014-07-03 10:12   ` Olaf Hering
2014-07-04 21:22     ` Jiri Kosina
2014-04-18  9:21 ` [PATCH 3.12 14/72] drm/i915: Undo the PIPEA quirk for i845 Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 15/72] drm/cirrus: Fix cirrus drm driver for fbdev + qemu Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 16/72] drm/radeon: change audio enable logic Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 17/72] drm/radeon: enable speaker allocation setup on dce3.2 Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 18/72] drm: Prefer noninterlace cmdline mode unless explicitly specified Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 19/72] fb: reorder the lock sequence to fix potential dead lock Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 20/72] video/fb: Propagate error code from failing to unregister conflicting fb Jiri Slaby
2014-04-18  9:21   ` Jiri Slaby
2014-04-18  9:21   ` Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 21/72] fbdev: Make the switch from generic to native driver less alarming Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 22/72] drm: add drm_set_preferred_mode Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 23/72] drm/cirrus: use drm_set_preferred_mode Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 24/72] net: fix for a race condition in the inet frag code Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 25/72] net: sctp: fix skb leakage in COOKIE ECHO path of chunk->auth_chunk Jiri Slaby
2014-04-18  9:21 ` [PATCH 3.12 26/72] bridge: multicast: add sanity check for query source addresses Jiri Slaby
2014-04-18  9:22 ` Jiri Slaby [this message]
2014-04-18  9:22 ` [PATCH 3.12 28/72] tipc: fix connection refcount leak Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 29/72] tipc: drop subscriber connection id invalidation Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 30/72] tipc: fix memory leak during module removal Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 31/72] tipc: don't log disabled tasklet handler errors Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 32/72] inet: frag: make sure forced eviction removes all frags Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 33/72] net: unix: non blocking recvmsg() should not return -EINTR Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 34/72] ipv6: Fix exthdrs offload registration Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 35/72] ipv6: don't set DST_NOCOUNT for remotely added routes Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 36/72] bnx2: Fix shutdown sequence Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 37/72] pkt_sched: fq: do not hold qdisc lock while allocating memory Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 38/72] vlan: Set correct source MAC address with TX VLAN offload enabled Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 39/72] tcp: tcp_release_cb() should release socket ownership Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 40/72] bridge: multicast: add sanity check for general query destination Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 41/72] bridge: multicast: enable snooping on general queries only Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 42/72] net: socket: error on a negative msg_namelen Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 43/72] bonding: set correct vlan id for alb xmit path Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 44/72] eth: fec: Fix lost promiscuous mode after reconnecting cable Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 45/72] ipv6: Avoid unnecessary temporary addresses being generated Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 46/72] ipv6: ip6_append_data_mtu do not handle the mtu of the second fragment properly Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 47/72] vxlan: fix potential NULL dereference in arp_reduce() Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 48/72] vxlan: fix nonfunctional neigh_reduce() Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 49/72] tcp: syncookies: do not use getnstimeofday() Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 50/72] rtnetlink: fix fdb notification flags Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 51/72] ipmr: fix mfc " Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 52/72] ip6mr: " Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 53/72] net: micrel : ks8851-ml: add vdd-supply support Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 54/72] netpoll: fix the skb check in pkt_is_ns Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 55/72] tipc: fix spinlock recursion bug for failed subscriptions Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 56/72] ip_tunnel: Fix dst ref-count Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 57/72] tg3: Do not include vlan acceleration features in vlan_features Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 58/72] usbnet: include wait queue head in device structure Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 59/72] vlan: Set hard_header_len according to available acceleration Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 60/72] vhost: fix total length when packets are too short Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 61/72] vhost: validate vhost_get_vq_desc return value Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 62/72] xen-netback: remove pointless clause from if statement Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 63/72] ipv6: some ipv6 statistic counters failed to disable bh Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 64/72] netlink: don't compare the nul-termination in nla_strcmp Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 65/72] xen-netback: disable rogue vif in kthread context Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 66/72] net: vxlan: fix crash when interface is created with no group Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 67/72] isdnloop: Validate NUL-terminated strings from user Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 68/72] isdnloop: several buffer overflows Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 69/72] rds: prevent dereference of a NULL device in rds_iw_laddr_check Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 70/72] ARC: [nsimosci] Change .dts to use generic 8250 UART Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 71/72] ARC: [nsimosci] Unbork console Jiri Slaby
2014-04-18  9:22 ` [PATCH 3.12 72/72] crypto: ghash-clmulni-intel - use C implementation for setkey() Jiri Slaby
2014-04-18 19:18 ` [PATCH 3.12 00/72] 3.12.18-stable review Guenter Roeck
2014-04-18 22:12 ` Shuah Khan
2014-04-24  7:46   ` Jiri Slaby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1f92d32f63aef244e48d96b6d1abab64133b0d0c.1397812482.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=davem@davemloft.net \
    --cc=erik.hugne@ericsson.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=ying.xue@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.