]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - net/ipv4/xfrm4_state.c
Merge branch 'for-rmk-realview' of git://linux-arm.org/linux-2.6 into devel
[mirror_ubuntu-eoan-kernel.git] / net / ipv4 / xfrm4_state.c
CommitLineData
1da177e4
LT
1/*
2 * xfrm4_state.c
3 *
4 * Changes:
5 * YOSHIFUJI Hideaki @USAGI
6 * Split up af-specific portion
7 *
8 */
9
dd87147e 10#include <net/ip.h>
1da177e4
LT
11#include <net/xfrm.h>
12#include <linux/pfkeyv2.h>
13#include <linux/ipsec.h>
862b82c6 14#include <linux/netfilter_ipv4.h>
1da177e4
LT
15
16static struct xfrm_state_afinfo xfrm4_state_afinfo;
17
dd87147e
HX
18static int xfrm4_init_flags(struct xfrm_state *x)
19{
20 if (ipv4_config.no_pmtu_disc)
21 x->props.flags |= XFRM_STATE_NOPMTUDISC;
22 return 0;
23}
24
1da177e4
LT
25static void
26__xfrm4_init_tempsel(struct xfrm_state *x, struct flowi *fl,
27 struct xfrm_tmpl *tmpl,
28 xfrm_address_t *daddr, xfrm_address_t *saddr)
29{
30 x->sel.daddr.a4 = fl->fl4_dst;
31 x->sel.saddr.a4 = fl->fl4_src;
32 x->sel.dport = xfrm_flowi_dport(fl);
8f83f23e 33 x->sel.dport_mask = htons(0xffff);
1da177e4 34 x->sel.sport = xfrm_flowi_sport(fl);
8f83f23e 35 x->sel.sport_mask = htons(0xffff);
79654a76 36 x->sel.family = AF_INET;
1da177e4
LT
37 x->sel.prefixlen_d = 32;
38 x->sel.prefixlen_s = 32;
39 x->sel.proto = fl->proto;
40 x->sel.ifindex = fl->oif;
41 x->id = tmpl->id;
42 if (x->id.daddr.a4 == 0)
43 x->id.daddr.a4 = daddr->a4;
44 x->props.saddr = tmpl->saddr;
45 if (x->props.saddr.a4 == 0)
46 x->props.saddr.a4 = saddr->a4;
47 x->props.mode = tmpl->mode;
48 x->props.reqid = tmpl->reqid;
49 x->props.family = AF_INET;
50}
51
36cf9acf
HX
52int xfrm4_extract_header(struct sk_buff *skb)
53{
54 struct iphdr *iph = ip_hdr(skb);
55
732c8bd5 56 XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph);
36cf9acf
HX
57 XFRM_MODE_SKB_CB(skb)->id = iph->id;
58 XFRM_MODE_SKB_CB(skb)->frag_off = iph->frag_off;
59 XFRM_MODE_SKB_CB(skb)->tos = iph->tos;
60 XFRM_MODE_SKB_CB(skb)->ttl = iph->ttl;
732c8bd5 61 XFRM_MODE_SKB_CB(skb)->optlen = iph->ihl * 4 - sizeof(*iph);
36cf9acf
HX
62 memset(XFRM_MODE_SKB_CB(skb)->flow_lbl, 0,
63 sizeof(XFRM_MODE_SKB_CB(skb)->flow_lbl));
64
65 return 0;
66}
67
1da177e4
LT
68static struct xfrm_state_afinfo xfrm4_state_afinfo = {
69 .family = AF_INET,
36cf9acf 70 .proto = IPPROTO_IPIP,
227620e2 71 .eth_proto = htons(ETH_P_IP),
17c2a42a 72 .owner = THIS_MODULE,
dd87147e 73 .init_flags = xfrm4_init_flags,
1da177e4 74 .init_tempsel = __xfrm4_init_tempsel,
cdca7265 75 .output = xfrm4_output,
227620e2 76 .extract_input = xfrm4_extract_input,
36cf9acf 77 .extract_output = xfrm4_extract_output,
716062fd 78 .transport_finish = xfrm4_transport_finish,
1da177e4
LT
79};
80
81void __init xfrm4_state_init(void)
82{
83 xfrm_state_register_afinfo(&xfrm4_state_afinfo);
84}
85
0742fd53 86#if 0
1da177e4
LT
87void __exit xfrm4_state_fini(void)
88{
89 xfrm_state_unregister_afinfo(&xfrm4_state_afinfo);
90}
0742fd53 91#endif /* 0 */
1da177e4 92