0001
0002
0003
0004
0005
0006
0007 #include <linux/if_ether.h>
0008 #include <linux/kernel.h>
0009 #include <linux/module.h>
0010 #include <linux/skbuff.h>
0011 #include <linux/netfilter_ipv4.h>
0012 #include <net/dst.h>
0013 #include <net/ip.h>
0014 #include <net/xfrm.h>
0015 #include <net/icmp.h>
0016
0017 static int __xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
0018 {
0019 #ifdef CONFIG_NETFILTER
0020 struct xfrm_state *x = skb_dst(skb)->xfrm;
0021
0022 if (!x) {
0023 IPCB(skb)->flags |= IPSKB_REROUTED;
0024 return dst_output(net, sk, skb);
0025 }
0026 #endif
0027
0028 return xfrm_output(sk, skb);
0029 }
0030
0031 int xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
0032 {
0033 return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
0034 net, sk, skb, skb->dev, skb_dst(skb)->dev,
0035 __xfrm4_output,
0036 !(IPCB(skb)->flags & IPSKB_REROUTED));
0037 }
0038
0039 void xfrm4_local_error(struct sk_buff *skb, u32 mtu)
0040 {
0041 struct iphdr *hdr;
0042
0043 hdr = skb->encapsulation ? inner_ip_hdr(skb) : ip_hdr(skb);
0044 ip_local_error(skb->sk, EMSGSIZE, hdr->daddr,
0045 inet_sk(skb->sk)->inet_dport, mtu);
0046 }