aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/xfrm4_state.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-08-24 03:13:10 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 18:08:38 -0400
commit2770834c9f44afd1bfa13914c7285470775af657 (patch)
tree40191fdc632e572bc7878f57dc8fb385109a3aa8 /net/ipv4/xfrm4_state.c
parent64d9fdda8e1bdf416b2d9203c3ad9c249ea301be (diff)
[XFRM]: Pull xfrm_state_bydst hash table knowledge out of afinfo.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/xfrm4_state.c')
-rw-r--r--net/ipv4/xfrm4_state.c53
1 files changed, 0 insertions, 53 deletions
diff --git a/net/ipv4/xfrm4_state.c b/net/ipv4/xfrm4_state.c
index 616be131b4e3..9dc1afc17b6d 100644
--- a/net/ipv4/xfrm4_state.c
+++ b/net/ipv4/xfrm4_state.c
@@ -88,65 +88,12 @@ __xfrm4_state_lookup_byaddr(xfrm_address_t *daddr, xfrm_address_t *saddr,
88 return NULL; 88 return NULL;
89} 89}
90 90
91static struct xfrm_state *
92__xfrm4_find_acq(u8 mode, u32 reqid, u8 proto,
93 xfrm_address_t *daddr, xfrm_address_t *saddr,
94 int create)
95{
96 struct xfrm_state *x, *x0;
97 unsigned h = __xfrm4_dst_hash(daddr);
98
99 x0 = NULL;
100
101 list_for_each_entry(x, xfrm4_state_afinfo.state_bydst+h, bydst) {
102 if (x->props.family == AF_INET &&
103 daddr->a4 == x->id.daddr.a4 &&
104 mode == x->props.mode &&
105 proto == x->id.proto &&
106 saddr->a4 == x->props.saddr.a4 &&
107 reqid == x->props.reqid &&
108 x->km.state == XFRM_STATE_ACQ &&
109 !x->id.spi) {
110 x0 = x;
111 break;
112 }
113 }
114 if (!x0 && create && (x0 = xfrm_state_alloc()) != NULL) {
115 x0->sel.daddr.a4 = daddr->a4;
116 x0->sel.saddr.a4 = saddr->a4;
117 x0->sel.prefixlen_d = 32;
118 x0->sel.prefixlen_s = 32;
119 x0->props.saddr.a4 = saddr->a4;
120 x0->km.state = XFRM_STATE_ACQ;
121 x0->id.daddr.a4 = daddr->a4;
122 x0->id.proto = proto;
123 x0->props.family = AF_INET;
124 x0->props.mode = mode;
125 x0->props.reqid = reqid;
126 x0->props.family = AF_INET;
127 x0->lft.hard_add_expires_seconds = XFRM_ACQ_EXPIRES;
128 xfrm_state_hold(x0);
129 x0->timer.expires = jiffies + XFRM_ACQ_EXPIRES*HZ;
130 add_timer(&x0->timer);
131 xfrm_state_hold(x0);
132 list_add_tail(&x0->bydst, xfrm4_state_afinfo.state_bydst+h);
133 h = __xfrm4_src_hash(saddr);
134 xfrm_state_hold(x0);
135 list_add_tail(&x0->bysrc, xfrm4_state_afinfo.state_bysrc+h);
136 wake_up(&km_waitq);
137 }
138 if (x0)
139 xfrm_state_hold(x0);
140 return x0;
141}
142
143static struct xfrm_state_afinfo xfrm4_state_afinfo = { 91static struct xfrm_state_afinfo xfrm4_state_afinfo = {
144 .family = AF_INET, 92 .family = AF_INET,
145 .init_flags = xfrm4_init_flags, 93 .init_flags = xfrm4_init_flags,
146 .init_tempsel = __xfrm4_init_tempsel, 94 .init_tempsel = __xfrm4_init_tempsel,
147 .state_lookup = __xfrm4_state_lookup, 95 .state_lookup = __xfrm4_state_lookup,
148 .state_lookup_byaddr = __xfrm4_state_lookup_byaddr, 96 .state_lookup_byaddr = __xfrm4_state_lookup_byaddr,
149 .find_acq = __xfrm4_find_acq,
150}; 97};
151 98
152void __init xfrm4_state_init(void) 99void __init xfrm4_state_init(void)