Finalizing Xmit of Compressed IP Header

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I'm implementing an IP header compression protocol as a loadable
kernel module that takes an IPv4 header and compresses it to smaller
header (let's call it "iphc" header).

To do this, for outgoing packets, i've used the NF_IP_POST_ROUTING
netfilter hook to grab the packet after routing decisions are done.
Then, i'd like to replace the IP header with an IPHC header
(compressed IP), change the ethertype to something else, send it down
the stack (to Ethernet) and out. From what i'm seeing, when i
intercept the packet at the NF_IP_POST_ROUTING hook, the MAC headers
have not been added yet.

A few questions i had:

1. Given that i'm replacing the IP header, will that affect Ethernet's
ability to find the MAC hardware address? I saw that in the
ip_finish_output2() function, they take the dst value in skbuff (using
skb_dst() function) to search the neighbor table for an ARP entry. If
i'm only swapping out the IP header with an IPHC header and changing
the protocol, will the ARP lookup fail? I don't think i've touched the
"dst" field in skbuff.

2. Is it enough for me to just replace the IP header with an IPHC
header, change the Ethertype, and send it back down the stack? Or
should i transmit it directly myself without it being returned to
ip_finish_output2

For some reason, if i do #2, my code crashes. Below is a sample of
what i'm trying to do after i hook into the NF_IP_POST_ROUTING
netfilter hook (skb is passed in):

struct iphc *my_hdr;

/* stripping the IPv4 header from skbuff */
skb_pull(skb, sizeof (struct iphdr));

/* adding my header skb */
skb_push(skb, IPHC_HDR_SIZE);

/* reset network header */
skb_reset_network_header(skb);

my_hdr = (struct iphc *)skb;

my_hdr->field1 = 1;
my_hdr->field2 = 2;

/* change ethertype */
skb->protocol = __constant_htons(ETH_P_IPHC);

return NF_ACCEPT;

Am i missing something here? Thanks!
--
To unsubscribe from this list: send the line "unsubscribe lartc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux