Skip to content

Commit

Permalink
net/core: Allow the compiler to verify declaration and definition con…
Browse files Browse the repository at this point in the history
…sistency

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
5226779 ("sock: add MSG_ZEROCOPY") # v4.14.

Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Bart Van Assche authored and David S. Miller committed Mar 27, 2019
1 parent a986967 commit 7b7ed88
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions net/core/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#include <trace/events/skb.h>
#include <net/busy_poll.h>

#include "datagram.h"

/*
* Is a socket 'connection oriented' ?
*/
Expand Down
15 changes: 15 additions & 0 deletions net/core/datagram.h
Original file line number Diff line number Diff line change
@@ -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_ */
5 changes: 2 additions & 3 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7b7ed88

Please sign in to comment.