MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ipsec_deepcopy_pcbpolicy

Function ipsec_deepcopy_pcbpolicy

freebsd/netipsec/ipsec_pcb.c:187–222  ·  view source on GitHub ↗

Deep-copy a policy in PCB. */

Source from the content-addressed store, hash-verified

185
186/* Deep-copy a policy in PCB. */
187static struct secpolicy *
188ipsec_deepcopy_pcbpolicy(struct secpolicy *src)
189{
190 struct secpolicy *dst;
191 int i;
192
193 if (src == NULL)
194 return (NULL);
195
196 IPSEC_ASSERT(src->state == IPSEC_SPSTATE_PCB, ("SP isn't PCB"));
197
198 dst = key_newsp();
199 if (dst == NULL)
200 return (NULL);
201
202 /* spidx is not copied here */
203 dst->policy = src->policy;
204 dst->state = src->state;
205 dst->priority = src->priority;
206 /* Do not touch the refcnt field. */
207
208 /* Copy IPsec request chain. */
209 for (i = 0; i < src->tcount; i++) {
210 dst->req[i] = ipsec_newisr();
211 if (dst->req[i] == NULL) {
212 key_freesp(&dst);
213 return (NULL);
214 }
215 bcopy(src->req[i], dst->req[i], sizeof(struct ipsecrequest));
216 dst->tcount++;
217 }
218 KEYDBG(IPSEC_DUMP,
219 printf("%s: copied SP(%p) -> SP(%p)\n", __func__, src, dst);
220 kdebug_secpolicy(dst));
221 return (dst);
222}
223
224/*
225 * Copy IPsec policy from old INPCB into new.

Callers 1

ipsec_copy_pcbpolicyFunction · 0.85

Calls 5

key_newspFunction · 0.85
ipsec_newisrFunction · 0.85
key_freespFunction · 0.85
kdebug_secpolicyFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected