xfrm4_mode_transport.c 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * xfrm4_mode_transport.c - Transport mode encapsulation for IPv4.
 *
 * Copyright (c) 2004-2006 Herbert Xu <herbert@gondor.apana.org.au>
 */

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/stringify.h>
#include <net/dst.h>
#include <net/ip.h>
#include <net/xfrm.h>
15
#include <net/protocol.h>
16

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
static struct sk_buff *xfrm4_transport_gso_segment(struct xfrm_state *x,
						   struct sk_buff *skb,
						   netdev_features_t features)
{
	const struct net_offload *ops;
	struct sk_buff *segs = ERR_PTR(-EINVAL);
	struct xfrm_offload *xo = xfrm_offload(skb);

	skb->transport_header += x->props.header_len;
	ops = rcu_dereference(inet_offloads[xo->proto]);
	if (likely(ops && ops->callbacks.gso_segment))
		segs = ops->callbacks.gso_segment(skb, features);

	return segs;
}

33
static struct xfrm_mode xfrm4_transport_mode = {
34
	.gso_segment = xfrm4_transport_gso_segment,
35 36
	.owner = THIS_MODULE,
	.encap = XFRM_MODE_TRANSPORT,
37
	.family = AF_INET,
38 39 40 41
};

static int __init xfrm4_transport_init(void)
{
42
	return xfrm_register_mode(&xfrm4_transport_mode);
43 44 45 46
}

static void __exit xfrm4_transport_exit(void)
{
47
	xfrm_unregister_mode(&xfrm4_transport_mode);
48 49 50 51 52 53
}

module_init(xfrm4_transport_init);
module_exit(xfrm4_transport_exit);
MODULE_LICENSE("GPL");
MODULE_ALIAS_XFRM_MODE(AF_INET, XFRM_MODE_TRANSPORT);