aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2011-10-25 10:44:35 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2012-02-06 16:59:15 -0500
commit8809b255a9fca8c3179491d3bc9268c42e23ba97 (patch)
treea4ce31a49a14f41fe5899aff951c853ce6629793 /net/tipc
parent3238a9be4d7ad95c741bcfe6c147406eeef62d95 (diff)
tipc: improve the link deferred queue insertion algorithm
Re-code the algorithm for inserting an out-of-sequence message into a unicast or broadcast link's deferred message queue. It remains functionally equivalent but should be easier to understand/maintain. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/link.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index ac1832a66f8a..c317abf74a78 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1853,17 +1853,16 @@ cont:
1853} 1853}
1854 1854
1855/* 1855/*
1856 * link_defer_buf(): Sort a received out-of-sequence packet 1856 * tipc_link_defer_pkt - Add out-of-sequence message to deferred reception queue
1857 * into the deferred reception queue. 1857 *
1858 * Returns the increase of the queue length,i.e. 0 or 1 1858 * Returns increase in queue length (i.e. 0 or 1)
1859 */ 1859 */
1860 1860
1861u32 tipc_link_defer_pkt(struct sk_buff **head, 1861u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail,
1862 struct sk_buff **tail,
1863 struct sk_buff *buf) 1862 struct sk_buff *buf)
1864{ 1863{
1865 struct sk_buff *prev = NULL; 1864 struct sk_buff *queue_buf;
1866 struct sk_buff *crs = *head; 1865 struct sk_buff **prev;
1867 u32 seq_no = buf_seqno(buf); 1866 u32 seq_no = buf_seqno(buf);
1868 1867
1869 buf->next = NULL; 1868 buf->next = NULL;
@@ -1881,31 +1880,30 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
1881 return 1; 1880 return 1;
1882 } 1881 }
1883 1882
1884 /* Scan through queue and sort it in */ 1883 /* Locate insertion point in queue, then insert; discard if duplicate */
1885 do { 1884 prev = head;
1886 struct tipc_msg *msg = buf_msg(crs); 1885 queue_buf = *head;
1886 for (;;) {
1887 u32 curr_seqno = buf_seqno(queue_buf);
1887 1888
1888 if (less(seq_no, msg_seqno(msg))) { 1889 if (seq_no == curr_seqno) {
1889 buf->next = crs; 1890 buf_discard(buf);
1890 if (prev) 1891 return 0;
1891 prev->next = buf;
1892 else
1893 *head = buf;
1894 return 1;
1895 } 1892 }
1896 if (seq_no == msg_seqno(msg)) 1893
1894 if (less(seq_no, curr_seqno))
1897 break; 1895 break;
1898 prev = crs;
1899 crs = crs->next;
1900 } while (crs);
1901 1896
1902 /* Message is a duplicate of an existing message */ 1897 prev = &queue_buf->next;
1898 queue_buf = queue_buf->next;
1899 }
1903 1900
1904 buf_discard(buf); 1901 buf->next = queue_buf;
1905 return 0; 1902 *prev = buf;
1903 return 1;
1906} 1904}
1907 1905
1908/** 1906/*
1909 * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet 1907 * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet
1910 */ 1908 */
1911 1909