I am working on a TCP congestion control algorithm for a Linux kernel, which I understand as a kernel module. In the code, I want to access the tcp header and use the following function for this.
void get_hdr(struct sock *sk){ struct sk_buff *skb; skb = skb_peek_tail(&sk->sk_receive_queue); if (skb != NULL) printk(KERN_INFO "skb address: %p", skb); struct tcphdr *tcp_header = tcp_hdr(skb); if(tcp_header != 0) printk(KERN_INFO "tcp_header address: %p", tcp_header); else printk(KERN_INFO "tcp_header is NULL"); }
I think this should basically work, as it is done here inside the kernel .
Hower, looking at my kern.log, I see the following:
skb address: dbd94501 tcp_header address is NULL
Apparently, the call to tcp_hdr (skb) fails.
I do not know why this should be. Does anyone have an inspiring hint where I should look or what I need to change to return the tcp header?
Greetings
Stephen
source share