From: Paul Gortmaker <paul.gortmaker@windriver.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Allan.Stephens@windriver.com,
Allan Stephens <allan.stephens@windriver.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>
Subject: [PATCH net-next 08/21] tipc: Fix issues with fragmentation of an existing message buffer
Date: Tue, 10 May 2011 16:44:24 -0400 [thread overview]
Message-ID: <1305060277-15600-9-git-send-email-paul.gortmaker@windriver.com> (raw)
In-Reply-To: <1305060277-15600-1-git-send-email-paul.gortmaker@windriver.com>
From: Allan Stephens <allan.stephens@windriver.com>
Modifies the routine that fragments an existing message buffer to
use similar logic to that used when generating fragments from an iovec.
The routine now creates a complete chain of fragments and adds them to
the link transmit queue as a unit, so that the link sends all fragments
or none; this prevents the incomplete transmission of a fragmented
message that might otherwise result because of link congestion or
memory exhaustion. This change also ensures that the counter recording
the number of fragmented messages sent by the link is now incremented
only if the message is actually sent.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/link.c | 37 +++++++++++++++++++++++--------------
1 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/net/tipc/link.c b/net/tipc/link.c
index ad356df..02b083e 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -2406,6 +2406,8 @@ void tipc_link_recv_bundle(struct sk_buff *buf)
*/
static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
{
+ struct sk_buff *buf_chain = NULL;
+ struct sk_buff *buf_chain_tail = (struct sk_buff *)&buf_chain;
struct tipc_msg *inmsg = buf_msg(buf);
struct tipc_msg fragm_hdr;
u32 insize = msg_size(inmsg);
@@ -2414,7 +2416,7 @@ static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
u32 rest = insize;
u32 pack_sz = l_ptr->max_pkt;
u32 fragm_sz = pack_sz - INT_H_SIZE;
- u32 fragm_no = 1;
+ u32 fragm_no = 0;
u32 destaddr;
if (msg_short(inmsg))
@@ -2426,9 +2428,6 @@ static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT,
INT_H_SIZE, destaddr);
- msg_set_long_msgno(&fragm_hdr, l_ptr->long_msg_seq_no++);
- msg_set_fragm_no(&fragm_hdr, fragm_no);
- l_ptr->stats.sent_fragmented++;
/* Chop up message: */
@@ -2441,27 +2440,37 @@ static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
}
fragm = tipc_buf_acquire(fragm_sz + INT_H_SIZE);
if (fragm == NULL) {
- warn("Link unable to fragment message\n");
- dsz = -ENOMEM;
- goto exit;
+ buf_discard(buf);
+ while (buf_chain) {
+ buf = buf_chain;
+ buf_chain = buf_chain->next;
+ buf_discard(buf);
+ }
+ return -ENOMEM;
}
msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE);
+ fragm_no++;
+ msg_set_fragm_no(&fragm_hdr, fragm_no);
skb_copy_to_linear_data(fragm, &fragm_hdr, INT_H_SIZE);
skb_copy_to_linear_data_offset(fragm, INT_H_SIZE, crs,
fragm_sz);
- /* Send queued messages first, if any: */
+ buf_chain_tail->next = fragm;
+ buf_chain_tail = fragm;
- l_ptr->stats.sent_fragments++;
- tipc_link_send_buf(l_ptr, fragm);
- if (!tipc_link_is_up(l_ptr))
- return dsz;
- msg_set_fragm_no(&fragm_hdr, ++fragm_no);
rest -= fragm_sz;
crs += fragm_sz;
msg_set_type(&fragm_hdr, FRAGMENT);
}
-exit:
buf_discard(buf);
+
+ /* Append chain of fragments to send queue & send them */
+
+ l_ptr->long_msg_seq_no++;
+ link_add_chain_to_outqueue(l_ptr, buf_chain, l_ptr->long_msg_seq_no);
+ l_ptr->stats.sent_fragments += fragm_no;
+ l_ptr->stats.sent_fragmented++;
+ tipc_link_push_queue(l_ptr);
+
return dsz;
}
--
1.7.4.4
next prev parent reply other threads:[~2011-05-10 20:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-10 20:44 [PATCH net-next 00/21] tipc updates for the next round Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 01/21] tipc: Drop __TIME__ usage Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 02/21] tipc: Update comments in message header include file Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 03/21] tipc: Eliminate unused routing message definitions Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 04/21] tipc: Cosmetic consolidation of internal message type definitions Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 05/21] tipc: Remove code to emulate loss of broadcast messages Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 06/21] tipc: Don't initialize link selector field in fragmented messages Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 07/21] tipc: Avoid pointless masking of fragmented message identifier Paul Gortmaker
2011-05-10 20:44 ` Paul Gortmaker [this message]
2011-05-10 20:44 ` [PATCH net-next 09/21] tipc: Set name lookup scope field properly in all data messages Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 10/21] tipc: Fix problem with bundled multicast message Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 11/21] tipc: Update destination node field on incoming multicast messages Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 12/21] tipc: Fix sk_buff leaks when link congestion is detected Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 13/21] tipc: make zone/cluster mask constants a define Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 14/21] tipc: Strengthen checks for neighboring node discovery Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 15/21] tipc: Abort excessive send requests as early as possible Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 16/21] tipc: Avoid recomputation of outgoing message length Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 17/21] tipc: Introduce routine to enqueue a chain of messages on link tx queue Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 18/21] tipc: Enhance handling of discovery object creation failures Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 19/21] tipc: Enhance sending of discovery object link request messages Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 20/21] tipc: Add monitoring of number of nodes discovered by bearer Paul Gortmaker
2011-05-10 20:44 ` [PATCH net-next 21/21] tipc: Revise timings used when sending link request messages Paul Gortmaker
2011-05-11 18:01 ` [PATCH net-next 00/21] tipc updates for the next round David Miller
2011-05-11 18:02 ` Stephens, Allan
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=1305060277-15600-9-git-send-email-paul.gortmaker@windriver.com \
--to=paul.gortmaker@windriver.com \
--cc=Allan.Stephens@windriver.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).