From: Bart Van Assche <bvanassche@acm.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
Willem de Bruijn <willemb@google.com>
Subject: [PATCH 5/7] net/core: Allow the compiler to verify declaration and definition consistency
Date: Thu, 21 Mar 2019 15:19:44 -0700 [thread overview]
Message-ID: <20190321221946.163803-6-bvanassche@acm.org> (raw)
In-Reply-To: <20190321221946.163803-1-bvanassche@acm.org>
Instead of declaring a function in a .c file, declare it in a header
file and include that header file from the source files that define
and that use the function. That allows the compiler to verify
consistency of declaration and definition. See also commit
52267790ef52 ("sock: add MSG_ZEROCOPY") # v4.14.
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
net/core/datagram.c | 2 ++
net/core/datagram.h | 15 +++++++++++++++
net/core/skbuff.c | 5 ++---
3 files changed, 19 insertions(+), 3 deletions(-)
create mode 100644 net/core/datagram.h
diff --git a/net/core/datagram.c b/net/core/datagram.c
index b2651bb6d2a3..c42f1f0e62b6 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -61,6 +61,8 @@
#include <trace/events/skb.h>
#include <net/busy_poll.h>
+#include "datagram.h"
+
/*
* Is a socket 'connection oriented' ?
*/
diff --git a/net/core/datagram.h b/net/core/datagram.h
new file mode 100644
index 000000000000..bcfb75bfa3b2
--- /dev/null
+++ b/net/core/datagram.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _NET_CORE_DATAGRAM_H_
+#define _NET_CORE_DATAGRAM_H_
+
+#include <linux/types.h>
+
+struct sock;
+struct sk_buff;
+struct iov_iter;
+
+int __zerocopy_sg_from_iter(struct sock *sk, struct sk_buff *skb,
+ struct iov_iter *from, size_t length);
+
+#endif /* _NET_CORE_DATAGRAM_H_ */
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2415d9cb9b89..4782f9354dd1 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -77,6 +77,8 @@
#include <linux/capability.h>
#include <linux/user_namespace.h>
+#include "datagram.h"
+
struct kmem_cache *skbuff_head_cache __ro_after_init;
static struct kmem_cache *skbuff_fclone_cache __ro_after_init;
#ifdef CONFIG_SKB_EXTENSIONS
@@ -1105,9 +1107,6 @@ void sock_zerocopy_put_abort(struct ubuf_info *uarg, bool have_uref)
}
EXPORT_SYMBOL_GPL(sock_zerocopy_put_abort);
-extern int __zerocopy_sg_from_iter(struct sock *sk, struct sk_buff *skb,
- struct iov_iter *from, size_t length);
-
int skb_zerocopy_iter_dgram(struct sk_buff *skb, struct msghdr *msg, int len)
{
return __zerocopy_sg_from_iter(skb->sk, skb, &msg->msg_iter, len);
--
2.21.0.155.ge902e9bcae20
next prev parent reply other threads:[~2019-03-21 22:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-21 22:19 [PATCH 0/7] net/core patches for kernel v5.2 Bart Van Assche
2019-03-21 22:19 ` [PATCH 1/7] net/core: Document reuseport_add_sock() bind_inany argument Bart Van Assche
2019-03-21 22:19 ` [PATCH 2/7] net/core: Document all dev_ioctl() arguments Bart Van Assche
2019-03-21 22:19 ` [PATCH 3/7] net/core: Document __skb_flow_dissect() flags argument Bart Van Assche
2019-03-21 22:19 ` [PATCH 4/7] net/core: Fix rtnetlink kernel-doc headers Bart Van Assche
2019-03-21 22:19 ` Bart Van Assche [this message]
2019-03-21 22:19 ` [PATCH 6/7] net/core: Declare a local function 'static' Bart Van Assche
2019-03-21 22:25 ` Sagi Grimberg
2019-03-21 22:19 ` [PATCH 7/7] net/utils: Use strlcpy() instead of open-coding it Bart Van Assche
2019-03-21 22:24 ` Sagi Grimberg
2019-03-22 18:46 ` Rustad, Mark D
2019-03-25 15:55 ` Bart Van Assche
2019-03-24 0:47 ` [PATCH 0/7] net/core patches for kernel v5.2 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=20190321221946.163803-6-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.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 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).