Skip to content

Commit 45f2e99

Browse files
Pravin B Shelardavem330
authored andcommitted
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>
1 parent 752f36d commit 45f2e99

3 files changed

Lines changed: 32 additions & 32 deletions

File tree

‎include/net/gre.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ int gre_cisco_register(struct gre_cisco_protocol *proto);
3434
int gre_cisco_unregister(struct gre_cisco_protocol *proto);
3535
void gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
3636
int hdr_len);
37+
struct sk_buff *gre_handle_offloads(struct sk_buff *skb, bool gre_csum);
3738

3839
static inline int ip_gre_calc_hlen(__be16 o_flags)
3940
{

‎net/ipv4/gre.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,35 @@ void gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
9393
}
9494
EXPORT_SYMBOL_GPL(gre_build_header);
9595

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+
96125
static __sum16 check_checksum(struct sk_buff *skb)
97126
{
98127
__sum16 csum = 0;

‎net/ipv4/ip_gre.c‎

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -223,43 +223,13 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
223223
return PACKET_REJECT;
224224
}
225225

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-
251226
static void __gre_xmit(struct sk_buff *skb, struct net_device *dev,
252227
const struct iphdr *tnl_params,
253228
__be16 proto)
254229
{
255230
struct ip_tunnel *tunnel = netdev_priv(dev);
256231
struct tnl_ptk_info tpi;
257232

258-
if (likely(!skb->encapsulation)) {
259-
skb_reset_inner_headers(skb);
260-
skb->encapsulation = 1;
261-
}
262-
263233
tpi.flags = tunnel->parms.o_flags;
264234
tpi.proto = proto;
265235
tpi.key = tunnel->parms.o_key;
@@ -279,7 +249,7 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
279249
struct ip_tunnel *tunnel = netdev_priv(dev);
280250
const struct iphdr *tnl_params;
281251

282-
skb = handle_offloads(tunnel, skb);
252+
skb = gre_handle_offloads(skb, !!(tunnel->parms.o_flags&TUNNEL_CSUM));
283253
if (IS_ERR(skb))
284254
goto out;
285255

@@ -318,7 +288,7 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
318288
{
319289
struct ip_tunnel *tunnel = netdev_priv(dev);
320290

321-
skb = handle_offloads(tunnel, skb);
291+
skb = gre_handle_offloads(skb, !!(tunnel->parms.o_flags&TUNNEL_CSUM));
322292
if (IS_ERR(skb))
323293
goto out;
324294

0 commit comments

Comments
 (0)