2 #include <linux/kernel.h>
3 #include <linux/netfilter.h>
4 #include <linux/netfilter_ipv4.h>
8 #include <linux/export.h>
17 struct net *
net = dev_net(skb_dst(skb)->
dev);
18 const struct iphdr *iph = ip_hdr(skb);
38 fl4.flowi4_oif = skb->
sk ? skb->
sk->sk_bound_dev_if : 0;
39 fl4.flowi4_mark = skb->
mark;
40 fl4.flowi4_flags =
flags;
41 rt = ip_route_output_key(net, &fl4);
47 skb_dst_set(skb, &rt->
dst);
49 if (skb_dst(skb)->
error)
54 xfrm_decode_session(skb, flowi4_to_flowi(&fl4),
AF_INET) == 0) {
56 skb_dst_set(skb,
NULL);
57 dst =
xfrm_lookup(net, dst, flowi4_to_flowi(&fl4), skb->
sk, 0);
60 skb_dst_set(skb, dst);
65 hh_len = skb_dst(skb)->dev->hard_header_len;
66 if (skb_headroom(skb) < hh_len &&
87 static void nf_ip_saveroute(
const struct sk_buff *
skb,
93 const struct iphdr *iph = ip_hdr(skb);
108 const struct iphdr *iph = ip_hdr(skb);
110 if (!(iph->
tos == rt_info->
tos &&
122 const struct iphdr *iph = ip_hdr(skb);
129 if ((protocol == 0 && !csum_fold(skb->
csum)) ||
131 skb->
len - dataoff, protocol,
151 unsigned int dataoff,
unsigned int len,
154 const struct iphdr *iph = ip_hdr(skb);
159 if (len == skb->
len - dataoff)
164 skb->
len - dataoff, 0);
174 struct rtable *rt = ip_route_output_key(net, &fl->
u.
ip4);
181 static const struct nf_afinfo nf_ip_afinfo = {
184 .checksum_partial = nf_ip_checksum_partial,
185 .route = nf_ip_route,
186 .saveroute = nf_ip_saveroute,
187 .reroute = nf_ip_reroute,
191 static int __init ipv4_netfilter_init(
void)
196 static void __exit ipv4_netfilter_fini(
void)