diff options
author | Pravin B Shelar <pshelar@nicira.com> | 2013-06-17 20:49:51 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-19 21:07:41 -0400 |
commit | 45f2e9976cb6fc3f1cc533fd53fe74da5a9dbce4 (patch) | |
tree | b3d9024dcadfbd9443ac50047c6643754c0d435b /net/ipv4 | |
parent | 752f36da68e9136df8918461d651723a43627e04 (diff) |
gre: export gre_handle_offloads() function.
This is required for OVS GRE offloading.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/gre.c | 29 | ||||
-rw-r--r-- | net/ipv4/ip_gre.c | 34 |
2 files changed, 31 insertions, 32 deletions
diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c index 1cbc46536d1f..5ecc9c49b4dc 100644 --- a/net/ipv4/gre.c +++ b/net/ipv4/gre.c | |||
@@ -93,6 +93,35 @@ void gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi, | |||
93 | } | 93 | } |
94 | EXPORT_SYMBOL_GPL(gre_build_header); | 94 | EXPORT_SYMBOL_GPL(gre_build_header); |
95 | 95 | ||
96 | struct sk_buff *gre_handle_offloads(struct sk_buff *skb, bool gre_csum) | ||
97 | { | ||
98 | int err; | ||
99 | |||
100 | if (likely(!skb->encapsulation)) { | ||
101 | skb_reset_inner_headers(skb); | ||
102 | skb->encapsulation = 1; | ||
103 | } | ||
104 | |||
105 | if (skb_is_gso(skb)) { | ||
106 | err = skb_unclone(skb, GFP_ATOMIC); | ||
107 | if (unlikely(err)) | ||
108 | goto error; | ||
109 | skb_shinfo(skb)->gso_type |= SKB_GSO_GRE; | ||
110 | return skb; | ||
111 | } else if (skb->ip_summed == CHECKSUM_PARTIAL && gre_csum) { | ||
112 | err = skb_checksum_help(skb); | ||
113 | if (unlikely(err)) | ||
114 | goto error; | ||
115 | } else if (skb->ip_summed != CHECKSUM_PARTIAL) | ||
116 | skb->ip_summed = CHECKSUM_NONE; | ||
117 | |||
118 | return skb; | ||
119 | error: | ||
120 | kfree_skb(skb); | ||
121 | return ERR_PTR(err); | ||
122 | } | ||
123 | EXPORT_SYMBOL_GPL(gre_handle_offloads); | ||
124 | |||
96 | static __sum16 check_checksum(struct sk_buff *skb) | 125 | static __sum16 check_checksum(struct sk_buff *skb) |
97 | { | 126 | { |
98 | __sum16 csum = 0; | 127 | __sum16 csum = 0; |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 362c7c4c13ca..c326e869993a 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -223,31 +223,6 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi) | |||
223 | return PACKET_REJECT; | 223 | return PACKET_REJECT; |
224 | } | 224 | } |
225 | 225 | ||
226 | static struct sk_buff *handle_offloads(struct ip_tunnel *tunnel, struct sk_buff *skb) | ||
227 | { | ||
228 | int err; | ||
229 | |||
230 | if (skb_is_gso(skb)) { | ||
231 | err = skb_unclone(skb, GFP_ATOMIC); | ||
232 | if (unlikely(err)) | ||
233 | goto error; | ||
234 | skb_shinfo(skb)->gso_type |= SKB_GSO_GRE; | ||
235 | return skb; | ||
236 | } else if (skb->ip_summed == CHECKSUM_PARTIAL && | ||
237 | tunnel->parms.o_flags&TUNNEL_CSUM) { | ||
238 | err = skb_checksum_help(skb); | ||
239 | if (unlikely(err)) | ||
240 | goto error; | ||
241 | } else if (skb->ip_summed != CHECKSUM_PARTIAL) | ||
242 | skb->ip_summed = CHECKSUM_NONE; | ||
243 | |||
244 | return skb; | ||
245 | |||
246 | error: | ||
247 | kfree_skb(skb); | ||
248 | return ERR_PTR(err); | ||
249 | } | ||
250 | |||
251 | static void __gre_xmit(struct sk_buff *skb, struct net_device *dev, | 226 | static void __gre_xmit(struct sk_buff *skb, struct net_device *dev, |
252 | const struct iphdr *tnl_params, | 227 | const struct iphdr *tnl_params, |
253 | __be16 proto) | 228 | __be16 proto) |
@@ -255,11 +230,6 @@ static void __gre_xmit(struct sk_buff *skb, struct net_device *dev, | |||
255 | struct ip_tunnel *tunnel = netdev_priv(dev); | 230 | struct ip_tunnel *tunnel = netdev_priv(dev); |
256 | struct tnl_ptk_info tpi; | 231 | struct tnl_ptk_info tpi; |
257 | 232 | ||
258 | if (likely(!skb->encapsulation)) { | ||
259 | skb_reset_inner_headers(skb); | ||
260 | skb->encapsulation = 1; | ||
261 | } | ||
262 | |||
263 | tpi.flags = tunnel->parms.o_flags; | 233 | tpi.flags = tunnel->parms.o_flags; |
264 | tpi.proto = proto; | 234 | tpi.proto = proto; |
265 | tpi.key = tunnel->parms.o_key; | 235 | tpi.key = tunnel->parms.o_key; |
@@ -279,7 +249,7 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb, | |||
279 | struct ip_tunnel *tunnel = netdev_priv(dev); | 249 | struct ip_tunnel *tunnel = netdev_priv(dev); |
280 | const struct iphdr *tnl_params; | 250 | const struct iphdr *tnl_params; |
281 | 251 | ||
282 | skb = handle_offloads(tunnel, skb); | 252 | skb = gre_handle_offloads(skb, !!(tunnel->parms.o_flags&TUNNEL_CSUM)); |
283 | if (IS_ERR(skb)) | 253 | if (IS_ERR(skb)) |
284 | goto out; | 254 | goto out; |
285 | 255 | ||
@@ -318,7 +288,7 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb, | |||
318 | { | 288 | { |
319 | struct ip_tunnel *tunnel = netdev_priv(dev); | 289 | struct ip_tunnel *tunnel = netdev_priv(dev); |
320 | 290 | ||
321 | skb = handle_offloads(tunnel, skb); | 291 | skb = gre_handle_offloads(skb, !!(tunnel->parms.o_flags&TUNNEL_CSUM)); |
322 | if (IS_ERR(skb)) | 292 | if (IS_ERR(skb)) |
323 | goto out; | 293 | goto out; |
324 | 294 | ||