From: Jon Maloy <jon.maloy@ericsson.com>
To: davem@davemloft.net
Cc: Jon Maloy <jon.maloy@ericsson.com>,
netdev@vger.kernel.org,
Paul Gortmaker <paul.gortmaker@windriver.com>,
tipc-discussion@lists.sourceforge.net
Subject: [PATCH net-next 03/17] tipc: introduce new function tipc_msg_create()
Date: Fri, 22 Aug 2014 18:09:06 -0400 [thread overview]
Message-ID: <1408745360-23560-4-git-send-email-jon.maloy@ericsson.com> (raw)
In-Reply-To: <1408745360-23560-1-git-send-email-jon.maloy@ericsson.com>
The function tipc_msg_init() has turned out to be of limited value
in many cases. It take too few parameters to be usable for creating
a complete message, it makes too many assumptions about what the
message should be used for, and it does not allocate any buffer to
be returned to the caller.
Therefore, we now introduce the new function tipc_msg_create(), which
takes all the parameters needed to create a full message, and returns
a buffer of the requested size. The new function will be very useful
for the changes we will be doing in later commits in this series.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
---
net/tipc/msg.c | 31 +++++++++++++++++++++++++++++--
net/tipc/msg.h | 4 ++++
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index 9680be6..fdb92e2 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -56,8 +56,35 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize,
msg_set_size(m, hsize);
msg_set_prevnode(m, tipc_own_addr);
msg_set_type(m, type);
- msg_set_orignode(m, tipc_own_addr);
- msg_set_destnode(m, destnode);
+ if (hsize > SHORT_H_SIZE) {
+ msg_set_orignode(m, tipc_own_addr);
+ msg_set_destnode(m, destnode);
+ }
+}
+
+struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz,
+ uint data_sz, u32 dnode, u32 onode,
+ u32 dport, u32 oport, int errcode)
+{
+ struct tipc_msg *msg;
+ struct sk_buff *buf;
+
+ buf = tipc_buf_acquire(hdr_sz + data_sz);
+ if (unlikely(!buf))
+ return NULL;
+
+ msg = buf_msg(buf);
+ tipc_msg_init(msg, user, type, hdr_sz, dnode);
+ msg_set_size(msg, hdr_sz + data_sz);
+ msg_set_prevnode(msg, onode);
+ msg_set_origport(msg, oport);
+ msg_set_destport(msg, dport);
+ msg_set_errcode(msg, errcode);
+ if (hdr_sz > SHORT_H_SIZE) {
+ msg_set_orignode(msg, onode);
+ msg_set_destnode(msg, dnode);
+ }
+ return buf;
}
/* tipc_buf_append(): Append a buffer to the fragment list of another buffer
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 462fa19..3045b2c 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -732,6 +732,10 @@ int tipc_msg_eval(struct sk_buff *buf, u32 *dnode);
void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize,
u32 destnode);
+struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz,
+ uint data_sz, u32 dnode, u32 onode,
+ u32 dport, u32 oport, int errcode);
+
int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf);
bool tipc_msg_bundle(struct sk_buff *bbuf, struct sk_buff *buf, u32 mtu);
--
1.7.9.5
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
next prev parent reply other threads:[~2014-08-22 22:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-22 22:09 [PATCH net-next 00/17] tipc: Merge port and socket layer code Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 01/17] tipc: fix message importance range check Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 02/17] tipc: Fix build Jon Maloy
2014-08-25 10:21 ` Neil Horman
2014-08-25 18:44 ` David Miller
2014-08-26 13:15 ` Neil Horman
2014-08-22 22:09 ` Jon Maloy [this message]
2014-08-22 22:09 ` [PATCH net-next 04/17] tipc: use pseudo message to wake up sockets after link congestion Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 05/17] tipc: use message to abort connections when losing contact to node Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 06/17] tipc: clean up socket timer function Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 07/17] tipc: eliminate function tipc_port_shutdown() Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 08/17] tipc: eliminate port_connect()/port_disconnect() functions Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 09/17] tipc: redefine message acknowledge function Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 10/17] tipc: eliminate functions tipc_port_init and tipc_port_destroy Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 11/17] tipc: use registry when scanning sockets Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 12/17] tipc: replace port pointer with socket pointer in registry Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 13/17] tipc: remove port_lock Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 14/17] tipc: remove source file port.c Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 15/17] tipc: remove include file port.h Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 16/17] tipc: remove files ref.h and ref.c Jon Maloy
2014-08-22 22:09 ` [PATCH net-next 17/17] tipc: merge struct tipc_port into struct tipc_sock Jon Maloy
2014-08-23 18:19 ` [PATCH net-next 00/17] tipc: Merge port and socket layer code David Miller
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=1408745360-23560-4-git-send-email-jon.maloy@ericsson.com \
--to=jon.maloy@ericsson.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=tipc-discussion@lists.sourceforge.net \
/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).