xfrm6_output.c (5596732fa8c14139018ecda8356eabbfb599d830) xfrm6_output.c (aad88724c9d54acb1a9737cb6069d8470fa85f74)
1/*
2 * xfrm6_output.c - Common IPsec encapsulation code for IPv6.
3 * Copyright (C) 2002 USAGI/WIDE Project
4 * Copyright (c) 2004 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version

--- 100 unchanged lines hidden (view full) ---

109int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb)
110{
111 int err;
112
113 err = xfrm_inner_extract_output(x, skb);
114 if (err)
115 return err;
116
1/*
2 * xfrm6_output.c - Common IPsec encapsulation code for IPv6.
3 * Copyright (C) 2002 USAGI/WIDE Project
4 * Copyright (c) 2004 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version

--- 100 unchanged lines hidden (view full) ---

109int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb)
110{
111 int err;
112
113 err = xfrm_inner_extract_output(x, skb);
114 if (err)
115 return err;
116
117 memset(IP6CB(skb), 0, sizeof(*IP6CB(skb)));
118#ifdef CONFIG_NETFILTER
119 IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED;
120#endif
121
122 skb->protocol = htons(ETH_P_IPV6);
117 skb->local_df = 1;
118
119 return x->outer_mode->output2(x, skb);
120}
121EXPORT_SYMBOL(xfrm6_prepare_output);
122
123int xfrm6_output_finish(struct sk_buff *skb)
124{
123 skb->local_df = 1;
124
125 return x->outer_mode->output2(x, skb);
126}
127EXPORT_SYMBOL(xfrm6_prepare_output);
128
129int xfrm6_output_finish(struct sk_buff *skb)
130{
125 memset(IP6CB(skb), 0, sizeof(*IP6CB(skb)));
126 skb->protocol = htons(ETH_P_IPV6);
127
128#ifdef CONFIG_NETFILTER
129 IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED;
130#endif
131
131#ifdef CONFIG_NETFILTER
132 IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED;
133#endif
134
135 skb->protocol = htons(ETH_P_IPV6);
132 return xfrm_output(skb);
133}
134
135static int __xfrm6_output(struct sk_buff *skb)
136{
137 struct dst_entry *dst = skb_dst(skb);
138 struct xfrm_state *x = dst->xfrm;
139 int mtu;
140
136 return xfrm_output(skb);
137}
138
139static int __xfrm6_output(struct sk_buff *skb)
140{
141 struct dst_entry *dst = skb_dst(skb);
142 struct xfrm_state *x = dst->xfrm;
143 int mtu;
144
141#ifdef CONFIG_NETFILTER
142 if (!x) {
143 IP6CB(skb)->flags |= IP6SKB_REROUTED;
144 return dst_output(skb);
145 }
146#endif
147
148 if (skb->protocol == htons(ETH_P_IPV6))
149 mtu = ip6_skb_dst_mtu(skb);
150 else
151 mtu = dst_mtu(skb_dst(skb));
152
153 if (skb->len > mtu && xfrm6_local_dontfrag(skb)) {
154 xfrm6_local_rxpmtu(skb, mtu);
155 return -EMSGSIZE;

--- 5 unchanged lines hidden (view full) ---

161 if (x->props.mode == XFRM_MODE_TUNNEL &&
162 ((skb->len > mtu && !skb_is_gso(skb)) ||
163 dst_allfrag(skb_dst(skb)))) {
164 return ip6_fragment(skb, x->outer_mode->afinfo->output_finish);
165 }
166 return x->outer_mode->afinfo->output_finish(skb);
167}
168
145 if (skb->protocol == htons(ETH_P_IPV6))
146 mtu = ip6_skb_dst_mtu(skb);
147 else
148 mtu = dst_mtu(skb_dst(skb));
149
150 if (skb->len > mtu && xfrm6_local_dontfrag(skb)) {
151 xfrm6_local_rxpmtu(skb, mtu);
152 return -EMSGSIZE;

--- 5 unchanged lines hidden (view full) ---

158 if (x->props.mode == XFRM_MODE_TUNNEL &&
159 ((skb->len > mtu && !skb_is_gso(skb)) ||
160 dst_allfrag(skb_dst(skb)))) {
161 return ip6_fragment(skb, x->outer_mode->afinfo->output_finish);
162 }
163 return x->outer_mode->afinfo->output_finish(skb);
164}
165
169int xfrm6_output(struct sk_buff *skb)
166int xfrm6_output(struct sock *sk, struct sk_buff *skb)
170{
167{
171 return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING, skb,
172 NULL, skb_dst(skb)->dev, __xfrm6_output,
173 !(IP6CB(skb)->flags & IP6SKB_REROUTED));
168 return NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING, skb, NULL,
169 skb_dst(skb)->dev, __xfrm6_output);
174}
170}