Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6f04e93 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'strp-generalization'



Tom Herbert says:

====================
strp: Generalize stream parser to work with other socket types

Add a read_sock protocol operation function that allows something like
tcp_read_sock to be called for other protocol types.

Specific changes in this patch set:
  - Add read_sock function to proto_ops. This has the same signature as
    tcp_read_sock. sk_read_actor_t is also defined in net.h.
  - Set peek_len and read_sock proto_op functions for TCPv4 and TCPv6
    stream ops.
  - Remove references to tcp in strparser.
  - Call peek_len and read_sock operations from strparser instead of
    calling TCP specific functions.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents e19ac157 96a59083
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <linux/kmemcheck.h>
#include <linux/rcupdate.h>
#include <linux/once.h>
#include <linux/fs.h>

#include <uapi/linux/net.h>

@@ -128,6 +129,9 @@ struct page;
struct sockaddr;
struct msghdr;
struct module;
struct sk_buff;
typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *,
			       unsigned int, size_t);

struct proto_ops {
	int		family;
@@ -186,6 +190,8 @@ struct proto_ops {
				       struct pipe_inode_info *pipe, size_t len, unsigned int flags);
	int		(*set_peek_off)(struct sock *sk, int val);
	int		(*peek_len)(struct socket *sock);
	int		(*read_sock)(struct sock *sk, read_descriptor_t *desc,
				     sk_read_actor_t recv_actor);
};

#define DECLARE_SOCKADDR(type, dst, src)	\
+1 −1
Original line number Diff line number Diff line
@@ -137,6 +137,6 @@ void strp_stop(struct strparser *strp);
void strp_check_rcv(struct strparser *strp);
int strp_init(struct strparser *strp, struct sock *csk,
	      struct strp_callbacks *cb);
void strp_tcp_data_ready(struct strparser *strp);
void strp_data_ready(struct strparser *strp);

#endif /* __NET_STRPARSER_H_ */
+2 −2
Original line number Diff line number Diff line
@@ -603,8 +603,6 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize)
void tcp_get_info(struct sock *, struct tcp_info *);

/* Read 'sendfile()'-style from a TCP socket */
typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *,
				unsigned int, size_t);
int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
		  sk_read_actor_t recv_actor);

@@ -1850,6 +1848,8 @@ static inline int tcp_inq(struct sock *sk)
	return answ;
}

int tcp_peek_len(struct socket *sock);

static inline void tcp_segs_in(struct tcp_sock *tp, const struct sk_buff *skb)
{
	u16 segs_in;
+2 −0
Original line number Diff line number Diff line
@@ -916,6 +916,8 @@ const struct proto_ops inet_stream_ops = {
	.mmap		   = sock_no_mmap,
	.sendpage	   = inet_sendpage,
	.splice_read	   = tcp_splice_read,
	.read_sock	   = tcp_read_sock,
	.peek_len	   = tcp_peek_len,
#ifdef CONFIG_COMPAT
	.compat_setsockopt = compat_sock_common_setsockopt,
	.compat_getsockopt = compat_sock_common_getsockopt,
+6 −0
Original line number Diff line number Diff line
@@ -1570,6 +1570,12 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
}
EXPORT_SYMBOL(tcp_read_sock);

int tcp_peek_len(struct socket *sock)
{
	return tcp_inq(sock->sk);
}
EXPORT_SYMBOL(tcp_peek_len);

/*
 *	This routine copies from a sock struct into the user buffer.
 *
Loading