aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@ghostprotocols.net>2007-03-31 10:55:19 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:28:29 -0400
commit27d7ff46a3498d3debc6ba68fb8014c702b81170 (patch)
treeb5a0c617cf8339524d3b1f1633e08eae7b94cf86 /net/tipc
parent3dbad80ac7632f243b824d469301abb97ec634a1 (diff)
[SK_BUFF]: Introduce skb_copy_to_linear_data{_offset}
To clearly state the intent of copying to linear sk_buffs, _offset being a overly long variant but interesting for the sake of saving some bytes. Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/link.c46
-rw-r--r--net/tipc/msg.h7
-rw-r--r--net/tipc/port.c8
3 files changed, 32 insertions, 29 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 71c2f2fd405c..f3f99c8ea08a 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1001,7 +1001,7 @@ static int link_bundle_buf(struct link *l_ptr,
1001 return 0; 1001 return 0;
1002 1002
1003 skb_put(bundler, pad + size); 1003 skb_put(bundler, pad + size);
1004 memcpy(bundler->data + to_pos, buf->data, size); 1004 skb_copy_to_linear_data_offset(bundler, to_pos, buf->data, size);
1005 msg_set_size(bundler_msg, to_pos + size); 1005 msg_set_size(bundler_msg, to_pos + size);
1006 msg_set_msgcnt(bundler_msg, msg_msgcnt(bundler_msg) + 1); 1006 msg_set_msgcnt(bundler_msg, msg_msgcnt(bundler_msg) + 1);
1007 dbg("Packed msg # %u(%u octets) into pos %u in buf(#%u)\n", 1007 dbg("Packed msg # %u(%u octets) into pos %u in buf(#%u)\n",
@@ -1109,8 +1109,8 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
1109 if (bundler) { 1109 if (bundler) {
1110 msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG, 1110 msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG,
1111 TIPC_OK, INT_H_SIZE, l_ptr->addr); 1111 TIPC_OK, INT_H_SIZE, l_ptr->addr);
1112 memcpy(bundler->data, (unchar *)&bundler_hdr, 1112 skb_copy_to_linear_data(bundler, &bundler_hdr,
1113 INT_H_SIZE); 1113 INT_H_SIZE);
1114 skb_trim(bundler, INT_H_SIZE); 1114 skb_trim(bundler, INT_H_SIZE);
1115 link_bundle_buf(l_ptr, bundler, buf); 1115 link_bundle_buf(l_ptr, bundler, buf);
1116 buf = bundler; 1116 buf = bundler;
@@ -1383,9 +1383,9 @@ again:
1383 if (!buf) 1383 if (!buf)
1384 return -ENOMEM; 1384 return -ENOMEM;
1385 buf->next = NULL; 1385 buf->next = NULL;
1386 memcpy(buf->data, (unchar *)&fragm_hdr, INT_H_SIZE); 1386 skb_copy_to_linear_data(buf, &fragm_hdr, INT_H_SIZE);
1387 hsz = msg_hdr_sz(hdr); 1387 hsz = msg_hdr_sz(hdr);
1388 memcpy(buf->data + INT_H_SIZE, (unchar *)hdr, hsz); 1388 skb_copy_to_linear_data_offset(buf, INT_H_SIZE, hdr, hsz);
1389 msg_dbg(buf_msg(buf), ">BUILD>"); 1389 msg_dbg(buf_msg(buf), ">BUILD>");
1390 1390
1391 /* Chop up message: */ 1391 /* Chop up message: */
@@ -1416,8 +1416,8 @@ error:
1416 return -EFAULT; 1416 return -EFAULT;
1417 } 1417 }
1418 } else 1418 } else
1419 memcpy(buf->data + fragm_crs, sect_crs, sz); 1419 skb_copy_to_linear_data_offset(buf, fragm_crs,
1420 1420 sect_crs, sz);
1421 sect_crs += sz; 1421 sect_crs += sz;
1422 sect_rest -= sz; 1422 sect_rest -= sz;
1423 fragm_crs += sz; 1423 fragm_crs += sz;
@@ -1442,7 +1442,7 @@ error:
1442 1442
1443 buf->next = NULL; 1443 buf->next = NULL;
1444 prev->next = buf; 1444 prev->next = buf;
1445 memcpy(buf->data, (unchar *)&fragm_hdr, INT_H_SIZE); 1445 skb_copy_to_linear_data(buf, &fragm_hdr, INT_H_SIZE);
1446 fragm_crs = INT_H_SIZE; 1446 fragm_crs = INT_H_SIZE;
1447 fragm_rest = fragm_sz; 1447 fragm_rest = fragm_sz;
1448 msg_dbg(buf_msg(buf)," >BUILD>"); 1448 msg_dbg(buf_msg(buf)," >BUILD>");
@@ -2130,7 +2130,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
2130 buf = l_ptr->proto_msg_queue; 2130 buf = l_ptr->proto_msg_queue;
2131 if (!buf) 2131 if (!buf)
2132 return; 2132 return;
2133 memcpy(buf->data, (unchar *)msg, sizeof(l_ptr->proto_msg)); 2133 skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg));
2134 return; 2134 return;
2135 } 2135 }
2136 msg_set_timestamp(msg, jiffies_to_msecs(jiffies)); 2136 msg_set_timestamp(msg, jiffies_to_msecs(jiffies));
@@ -2143,7 +2143,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
2143 if (!buf) 2143 if (!buf)
2144 return; 2144 return;
2145 2145
2146 memcpy(buf->data, (unchar *)msg, sizeof(l_ptr->proto_msg)); 2146 skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg));
2147 msg_set_size(buf_msg(buf), msg_size); 2147 msg_set_size(buf_msg(buf), msg_size);
2148 2148
2149 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { 2149 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
@@ -2319,8 +2319,8 @@ void tipc_link_tunnel(struct link *l_ptr,
2319 "unable to send tunnel msg\n"); 2319 "unable to send tunnel msg\n");
2320 return; 2320 return;
2321 } 2321 }
2322 memcpy(buf->data, (unchar *)tunnel_hdr, INT_H_SIZE); 2322 skb_copy_to_linear_data(buf, tunnel_hdr, INT_H_SIZE);
2323 memcpy(buf->data + INT_H_SIZE, (unchar *)msg, length); 2323 skb_copy_to_linear_data_offset(buf, INT_H_SIZE, msg, length);
2324 dbg("%c->%c:", l_ptr->b_ptr->net_plane, tunnel->b_ptr->net_plane); 2324 dbg("%c->%c:", l_ptr->b_ptr->net_plane, tunnel->b_ptr->net_plane);
2325 msg_dbg(buf_msg(buf), ">SEND>"); 2325 msg_dbg(buf_msg(buf), ">SEND>");
2326 tipc_link_send_buf(tunnel, buf); 2326 tipc_link_send_buf(tunnel, buf);
@@ -2361,7 +2361,7 @@ void tipc_link_changeover(struct link *l_ptr)
2361 2361
2362 buf = buf_acquire(INT_H_SIZE); 2362 buf = buf_acquire(INT_H_SIZE);
2363 if (buf) { 2363 if (buf) {
2364 memcpy(buf->data, (unchar *)&tunnel_hdr, INT_H_SIZE); 2364 skb_copy_to_linear_data(buf, &tunnel_hdr, INT_H_SIZE);
2365 msg_set_size(&tunnel_hdr, INT_H_SIZE); 2365 msg_set_size(&tunnel_hdr, INT_H_SIZE);
2366 dbg("%c->%c:", l_ptr->b_ptr->net_plane, 2366 dbg("%c->%c:", l_ptr->b_ptr->net_plane,
2367 tunnel->b_ptr->net_plane); 2367 tunnel->b_ptr->net_plane);
@@ -2426,8 +2426,9 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel)
2426 "unable to send duplicate msg\n"); 2426 "unable to send duplicate msg\n");
2427 return; 2427 return;
2428 } 2428 }
2429 memcpy(outbuf->data, (unchar *)&tunnel_hdr, INT_H_SIZE); 2429 skb_copy_to_linear_data(outbuf, &tunnel_hdr, INT_H_SIZE);
2430 memcpy(outbuf->data + INT_H_SIZE, iter->data, length); 2430 skb_copy_to_linear_data_offset(outbuf, INT_H_SIZE, iter->data,
2431 length);
2431 dbg("%c->%c:", l_ptr->b_ptr->net_plane, 2432 dbg("%c->%c:", l_ptr->b_ptr->net_plane,
2432 tunnel->b_ptr->net_plane); 2433 tunnel->b_ptr->net_plane);
2433 msg_dbg(buf_msg(outbuf), ">SEND>"); 2434 msg_dbg(buf_msg(outbuf), ">SEND>");
@@ -2457,7 +2458,7 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos)
2457 2458
2458 eb = buf_acquire(size); 2459 eb = buf_acquire(size);
2459 if (eb) 2460 if (eb)
2460 memcpy(eb->data, (unchar *)msg, size); 2461 skb_copy_to_linear_data(eb, msg, size);
2461 return eb; 2462 return eb;
2462} 2463}
2463 2464
@@ -2631,9 +2632,9 @@ int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
2631 goto exit; 2632 goto exit;
2632 } 2633 }
2633 msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE); 2634 msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE);
2634 memcpy(fragm->data, (unchar *)&fragm_hdr, INT_H_SIZE); 2635 skb_copy_to_linear_data(fragm, &fragm_hdr, INT_H_SIZE);
2635 memcpy(fragm->data + INT_H_SIZE, crs, fragm_sz); 2636 skb_copy_to_linear_data_offset(fragm, INT_H_SIZE, crs,
2636 2637 fragm_sz);
2637 /* Send queued messages first, if any: */ 2638 /* Send queued messages first, if any: */
2638 2639
2639 l_ptr->stats.sent_fragments++; 2640 l_ptr->stats.sent_fragments++;
@@ -2733,8 +2734,8 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
2733 if (pbuf != NULL) { 2734 if (pbuf != NULL) {
2734 pbuf->next = *pending; 2735 pbuf->next = *pending;
2735 *pending = pbuf; 2736 *pending = pbuf;
2736 memcpy(pbuf->data, (unchar *)imsg, msg_data_sz(fragm)); 2737 skb_copy_to_linear_data(pbuf, imsg,
2737 2738 msg_data_sz(fragm));
2738 /* Prepare buffer for subsequent fragments. */ 2739 /* Prepare buffer for subsequent fragments. */
2739 2740
2740 set_long_msg_seqno(pbuf, long_msg_seq_no); 2741 set_long_msg_seqno(pbuf, long_msg_seq_no);
@@ -2750,7 +2751,8 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
2750 u32 fsz = get_fragm_size(pbuf); 2751 u32 fsz = get_fragm_size(pbuf);
2751 u32 crs = ((msg_fragm_no(fragm) - 1) * fsz); 2752 u32 crs = ((msg_fragm_no(fragm) - 1) * fsz);
2752 u32 exp_frags = get_expected_frags(pbuf) - 1; 2753 u32 exp_frags = get_expected_frags(pbuf) - 1;
2753 memcpy(pbuf->data + crs, msg_data(fragm), dsz); 2754 skb_copy_to_linear_data_offset(pbuf, crs,
2755 msg_data(fragm), dsz);
2754 buf_discard(fbuf); 2756 buf_discard(fbuf);
2755 2757
2756 /* Is message complete? */ 2758 /* Is message complete? */
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 62d549063604..aec7ce7af875 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -786,15 +786,16 @@ static inline int msg_build(struct tipc_msg *hdr,
786 *buf = buf_acquire(sz); 786 *buf = buf_acquire(sz);
787 if (!(*buf)) 787 if (!(*buf))
788 return -ENOMEM; 788 return -ENOMEM;
789 memcpy((*buf)->data, (unchar *)hdr, hsz); 789 skb_copy_to_linear_data(*buf, hdr, hsz);
790 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) { 790 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
791 if (likely(usrmem)) 791 if (likely(usrmem))
792 res = !copy_from_user((*buf)->data + pos, 792 res = !copy_from_user((*buf)->data + pos,
793 msg_sect[cnt].iov_base, 793 msg_sect[cnt].iov_base,
794 msg_sect[cnt].iov_len); 794 msg_sect[cnt].iov_len);
795 else 795 else
796 memcpy((*buf)->data + pos, msg_sect[cnt].iov_base, 796 skb_copy_to_linear_data_offset(*buf, pos,
797 msg_sect[cnt].iov_len); 797 msg_sect[cnt].iov_base,
798 msg_sect[cnt].iov_len);
798 pos += msg_sect[cnt].iov_len; 799 pos += msg_sect[cnt].iov_len;
799 } 800 }
800 if (likely(res)) 801 if (likely(res))
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 5f8217d4b452..bcd5da00737b 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -464,7 +464,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
464 msg_set_size(rmsg, data_sz + hdr_sz); 464 msg_set_size(rmsg, data_sz + hdr_sz);
465 msg_set_nametype(rmsg, msg_nametype(msg)); 465 msg_set_nametype(rmsg, msg_nametype(msg));
466 msg_set_nameinst(rmsg, msg_nameinst(msg)); 466 msg_set_nameinst(rmsg, msg_nameinst(msg));
467 memcpy(rbuf->data + hdr_sz, msg_data(msg), data_sz); 467 skb_copy_to_linear_data_offset(rbuf, hdr_sz, msg_data(msg), data_sz);
468 468
469 /* send self-abort message when rejecting on a connected port */ 469 /* send self-abort message when rejecting on a connected port */
470 if (msg_connected(msg)) { 470 if (msg_connected(msg)) {
@@ -1419,7 +1419,7 @@ int tipc_send_buf(u32 ref, struct sk_buff *buf, unsigned int dsz)
1419 return -ENOMEM; 1419 return -ENOMEM;
1420 1420
1421 skb_push(buf, hsz); 1421 skb_push(buf, hsz);
1422 memcpy(buf->data, (unchar *)msg, hsz); 1422 skb_copy_to_linear_data(buf, msg, hsz);
1423 destnode = msg_destnode(msg); 1423 destnode = msg_destnode(msg);
1424 p_ptr->publ.congested = 1; 1424 p_ptr->publ.congested = 1;
1425 if (!tipc_port_congested(p_ptr)) { 1425 if (!tipc_port_congested(p_ptr)) {
@@ -1555,7 +1555,7 @@ int tipc_forward_buf2name(u32 ref,
1555 if (skb_cow(buf, LONG_H_SIZE)) 1555 if (skb_cow(buf, LONG_H_SIZE))
1556 return -ENOMEM; 1556 return -ENOMEM;
1557 skb_push(buf, LONG_H_SIZE); 1557 skb_push(buf, LONG_H_SIZE);
1558 memcpy(buf->data, (unchar *)msg, LONG_H_SIZE); 1558 skb_copy_to_linear_data(buf, msg, LONG_H_SIZE);
1559 msg_dbg(buf_msg(buf),"PREP:"); 1559 msg_dbg(buf_msg(buf),"PREP:");
1560 if (likely(destport || destnode)) { 1560 if (likely(destport || destnode)) {
1561 p_ptr->sent++; 1561 p_ptr->sent++;
@@ -1679,7 +1679,7 @@ int tipc_forward_buf2port(u32 ref,
1679 return -ENOMEM; 1679 return -ENOMEM;
1680 1680
1681 skb_push(buf, DIR_MSG_H_SIZE); 1681 skb_push(buf, DIR_MSG_H_SIZE);
1682 memcpy(buf->data, (unchar *)msg, DIR_MSG_H_SIZE); 1682 skb_copy_to_linear_data(buf, msg, DIR_MSG_H_SIZE);
1683 msg_dbg(msg, "buf2port: "); 1683 msg_dbg(msg, "buf2port: ");
1684 p_ptr->sent++; 1684 p_ptr->sent++;
1685 if (dest->node == tipc_own_addr) 1685 if (dest->node == tipc_own_addr)