summaryrefslogtreecommitdiffstats
path: root/net/ipv4/gre.c
diff options
context:
space:
mode:
authorPravin B Shelar <pshelar@nicira.com>2013-06-17 17:49:51 -0700
committerDavid S. Miller <davem@davemloft.net>2013-06-19 18:07:41 -0700
commit45f2e9976cb6fc3f1cc533fd53fe74da5a9dbce4 (patch)
treeb3d9024dcadfbd9443ac50047c6643754c0d435b /net/ipv4/gre.c
parent752f36da68e9136df8918461d651723a43627e04 (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/gre.c')
-rw-r--r--net/ipv4/gre.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c
index 1cbc46536d1..5ecc9c49b4d 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,
}
EXPORT_SYMBOL_GPL(gre_build_header);
+struct sk_buff *gre_handle_offloads(struct sk_buff *skb, bool gre_csum)
+{
+ int err;
+
+ if (likely(!skb->encapsulation)) {
+ skb_reset_inner_headers(skb);
+ skb->encapsulation = 1;
+ }
+
+ if (skb_is_gso(skb)) {
+ err = skb_unclone(skb, GFP_ATOMIC);
+ if (unlikely(err))
+ goto error;
+ skb_shinfo(skb)->gso_type |= SKB_GSO_GRE;
+ return skb;
+ } else if (skb->ip_summed == CHECKSUM_PARTIAL && gre_csum) {
+ err = skb_checksum_help(skb);
+ if (unlikely(err))
+ goto error;
+ } else if (skb->ip_summed != CHECKSUM_PARTIAL)
+ skb->ip_summed = CHECKSUM_NONE;
+
+ return skb;
+error:
+ kfree_skb(skb);
+ return ERR_PTR(err);
+}
+EXPORT_SYMBOL_GPL(gre_handle_offloads);
+
static __sum16 check_checksum(struct sk_buff *skb)
{
__sum16 csum = 0;