aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2013-10-19 14:42:55 -0400
committerDavid S. Miller <davem@davemloft.net>2013-10-19 19:36:18 -0400
commit2d26f0a3c0e22f6b3096a2503d086e4b5e99d708 (patch)
tree181acb2d3453b54ece6941dbd0d5241345552557 /net
parent030737bcc3c404e273e97dbe06fe9561699a411b (diff)
ipv4: generalize gre_handle_offloads
This patch makes gre_handle_offloads() more generic and rename it to iptunnel_handle_offloads() This will be used to add GSO/TSO support to IPIP tunnels. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/gre_demux.c29
-rw-r--r--net/ipv4/ip_tunnel_core.c33
2 files changed, 33 insertions, 29 deletions
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index 736c9fc3ef93..5893e99e8299 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -93,35 +93,6 @@ void gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
93} 93}
94EXPORT_SYMBOL_GPL(gre_build_header); 94EXPORT_SYMBOL_GPL(gre_build_header);
95 95
96struct 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;
119error:
120 kfree_skb(skb);
121 return ERR_PTR(err);
122}
123EXPORT_SYMBOL_GPL(gre_handle_offloads);
124
125static __sum16 check_checksum(struct sk_buff *skb) 96static __sum16 check_checksum(struct sk_buff *skb)
126{ 97{
127 __sum16 csum = 0; 98 __sum16 csum = 0;
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index c31e3ad98ef2..42ffbc8d65c6 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -116,3 +116,36 @@ int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto)
116 return 0; 116 return 0;
117} 117}
118EXPORT_SYMBOL_GPL(iptunnel_pull_header); 118EXPORT_SYMBOL_GPL(iptunnel_pull_header);
119
120struct sk_buff *iptunnel_handle_offloads(struct sk_buff *skb,
121 bool csum_help,
122 int gso_type_mask)
123{
124 int err;
125
126 if (likely(!skb->encapsulation)) {
127 skb_reset_inner_headers(skb);
128 skb->encapsulation = 1;
129 }
130
131 if (skb_is_gso(skb)) {
132 err = skb_unclone(skb, GFP_ATOMIC);
133 if (unlikely(err))
134 goto error;
135 skb_shinfo(skb)->gso_type |= gso_type_mask;
136 return skb;
137 }
138
139 if (skb->ip_summed == CHECKSUM_PARTIAL && csum_help) {
140 err = skb_checksum_help(skb);
141 if (unlikely(err))
142 goto error;
143 } else if (skb->ip_summed != CHECKSUM_PARTIAL)
144 skb->ip_summed = CHECKSUM_NONE;
145
146 return skb;
147error:
148 kfree_skb(skb);
149 return ERR_PTR(err);
150}
151EXPORT_SYMBOL_GPL(iptunnel_handle_offloads);