12 #include <linux/errno.h>
13 #include <linux/module.h>
14 #include <linux/netdevice.h>
15 #include <linux/netfilter.h>
17 #include <linux/slab.h>
24 static int xfrm_skb_check_space(
struct sk_buff *
skb)
29 int ntail = dst->
dev->needed_tailroom - skb_tailroom(skb);
41 static int xfrm_output_one(
struct sk_buff *skb,
int err)
45 struct net *
net = xs_net(x);
51 err = xfrm_skb_check_space(skb);
63 spin_lock_bh(&x->
lock);
70 err = x->
repl->overflow(x, skb);
79 spin_unlock_bh(&x->
lock);
83 err = x->
type->output(x, skb);
93 dst = skb_dst_pop(skb);
99 skb_dst_set(skb, dst);
108 spin_unlock_bh(&x->
lock);
116 while (
likely((err = xfrm_output_one(skb, err)) == 0)) {
119 err = skb_dst(skb)->ops->local_out(skb);
123 if (!skb_dst(skb)->xfrm)
124 return dst_output(skb);
126 err = nf_hook(skb_dst(skb)->
ops->family,
128 NULL, skb_dst(skb)->
dev, xfrm_output2);
141 static int xfrm_output2(
struct sk_buff *skb)
146 static int xfrm_output_gso(
struct sk_buff *skb)
153 return PTR_ERR(segs);
160 err = xfrm_output2(segs);
163 while ((segs = nskb)) {
179 struct net *net = dev_net(skb_dst(skb)->
dev);
183 return xfrm_output_gso(skb);
194 return xfrm_output2(skb);
201 inner_mode = xfrm_ip2inner_mode(x,
202 xfrm_af2proto(skb_dst(skb)->
ops->family));
206 if (inner_mode ==
NULL)
208 return inner_mode->
afinfo->extract_output(x, skb);