Skip to content
Snippets Groups Projects
Commit 6985aaa3 authored by Aastha Mehta's avatar Aastha Mehta
Browse files

rx interception to remove padding and adjust copied_seq

parent ccb729fb
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,8 @@
struct ptcp_hook_heads ptcp_hook_heads = {
.print_sock_skb = LIST_HEAD_INIT(ptcp_hook_heads.print_sock_skb),
.handle_tcp_urg = LIST_HEAD_INIT(ptcp_hook_heads.handle_tcp_urg),
.rx_adjust_skb_size = LIST_HEAD_INIT(ptcp_hook_heads.rx_adjust_skb_size),
.rx_adjust_copied_seq = LIST_HEAD_INIT(ptcp_hook_heads.rx_adjust_copied_seq),
.tx_adjust_skb_size = LIST_HEAD_INIT(ptcp_hook_heads.tx_adjust_skb_size),
.tx_adjust_urg = LIST_HEAD_INIT(ptcp_hook_heads.tx_adjust_urg),
.tx_adjust_iphdr = LIST_HEAD_INIT(ptcp_hook_heads.tx_adjust_iphdr),
......@@ -54,6 +56,20 @@ int ptcp_handle_tcp_urg(struct sock *sk, struct sk_buff *skb, struct tcphdr *th)
}
EXPORT_SYMBOL(ptcp_handle_tcp_urg);
int ptcp_rx_adjust_skb_size(struct sock *sk, struct sk_buff *skb, int req_len,
int offset, int chunk, int copied, int flags)
{
return call_ptcp_int_hook(rx_adjust_skb_size, -1, sk, skb, req_len, offset, chunk,
copied, flags);
}
EXPORT_SYMBOL(ptcp_rx_adjust_skb_size);
int ptcp_rx_adjust_copied_seq(struct sock *sk, struct sk_buff *skb, int old_skb_len)
{
return call_ptcp_int_hook(rx_adjust_copied_seq, -1, sk, skb, old_skb_len);
}
EXPORT_SYMBOL(ptcp_rx_adjust_copied_seq);
int ptcp_tx_adjust_skb_size(struct sock *sk, int size, gfp_t gfp,
bool force_schedule)
{
......
......@@ -17,6 +17,10 @@
void ptcp_print_sock_skb(struct sock *sk, struct sk_buff *skb);
int ptcp_handle_tcp_urg(struct sock *sk, struct sk_buff *skb, struct tcphdr *th);
int ptcp_rx_adjust_skb_size(struct sock *sk, struct sk_buff *skb, int req_len,
int offset, int chunk, int copied, int flags);
int ptcp_rx_adjust_copied_seq(struct sock *sk, struct sk_buff *skb, int old_skb_len);
int ptcp_tx_adjust_skb_size(struct sock *sk, int size, gfp_t gfp,
bool force_schedule);
int ptcp_tx_adjust_urg(struct sock *sk, struct sk_buff *skb);
......
......@@ -36,6 +36,35 @@ ptcp_impl_handle_tcp_urg(struct sock *sk, struct sk_buff *skb, struct tcphdr *th
return -1;
}
int (*lnk_rx_adjust_skb_size) (struct sock *sk, struct sk_buff *skb, int req_len,
int offset, int chunk, int copied, int flags) = 0;
EXPORT_SYMBOL(lnk_rx_adjust_skb_size);
static int
ptcp_impl_rx_adjust_skb_size(struct sock *sk, struct sk_buff *skb, int req_len,
int offset, int chunk, int copied, int flags)
{
if (lnk_rx_adjust_skb_size) {
return lnk_rx_adjust_skb_size(sk, skb, req_len, offset, chunk,
copied, flags);
}
return -1;
}
int (*lnk_rx_adjust_copied_seq) (struct sock *sk, struct sk_buff *skb,
int old_skb_len) = 0;
EXPORT_SYMBOL(lnk_rx_adjust_copied_seq);
static int
ptcp_impl_rx_adjust_copied_seq (struct sock *sk, struct sk_buff *skb,
int old_skb_len)
{
if (lnk_rx_adjust_copied_seq) {
return lnk_rx_adjust_copied_seq(sk, skb, old_skb_len);
}
return -1;
}
int (*lnk_tx_adjust_skb_size) (struct sock *sk, int size, gfp_t gfp,
bool force_schedule) = 0;
EXPORT_SYMBOL(lnk_tx_adjust_skb_size);
......@@ -77,6 +106,8 @@ ptcp_impl_tx_adjust_iphdr(struct sock *sk, struct sk_buff *skb)
struct ptcp_hook_list ptcp_hooks[NUM_PTCP_HOOKS] = {
PTCP_HOOK_INIT(print_sock_skb, ptcp_impl_print_sock_skb),
PTCP_HOOK_INIT(handle_tcp_urg, ptcp_impl_handle_tcp_urg),
PTCP_HOOK_INIT(rx_adjust_skb_size, ptcp_impl_rx_adjust_skb_size),
PTCP_HOOK_INIT(rx_adjust_copied_seq, ptcp_impl_rx_adjust_copied_seq),
PTCP_HOOK_INIT(tx_adjust_skb_size, ptcp_impl_tx_adjust_skb_size),
PTCP_HOOK_INIT(tx_adjust_urg, ptcp_impl_tx_adjust_urg),
PTCP_HOOK_INIT(tx_adjust_iphdr, ptcp_impl_tx_adjust_iphdr),
......
......@@ -26,6 +26,9 @@
union ptcp_list_options {
void (*print_sock_skb) (struct sock *sk, struct sk_buff *skb);
int (*handle_tcp_urg) (struct sock *sk, struct sk_buff *skb, struct tcphdr *th);
int (*rx_adjust_skb_size) (struct sock *sk, struct sk_buff *skb, int req_len,
int offset, int chunk, int copied, int flags);
int (*rx_adjust_copied_seq) (struct sock *sk, struct sk_buff *skb, int old_skb_len);
int (*tx_adjust_skb_size) (struct sock *sk, int size, gfp_t gfp,
bool force_schedule);
int (*tx_adjust_urg) (struct sock *sk, struct sk_buff *skb);
......@@ -35,6 +38,8 @@ union ptcp_list_options {
struct ptcp_hook_heads {
struct list_head print_sock_skb;
struct list_head handle_tcp_urg;
struct list_head rx_adjust_skb_size;
struct list_head rx_adjust_copied_seq;
struct list_head tx_adjust_skb_size;
struct list_head tx_adjust_urg;
struct list_head tx_adjust_iphdr;
......@@ -50,7 +55,7 @@ struct ptcp_hook_list {
{ .head = &ptcp_hook_heads.HEAD, .hook = { . HEAD = HOOK } }
// increment this every time a new hook is added
#define NUM_PTCP_HOOKS 5
#define NUM_PTCP_HOOKS 7
extern struct ptcp_hook_heads ptcp_hook_heads;
extern struct ptcp_hook_list ptcp_hooks[NUM_PTCP_HOOKS];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment