Lines 181-187
next:
Link Here
|
181 |
* IPsec output logic for IPv4. |
181 |
* IPsec output logic for IPv4. |
182 |
*/ |
182 |
*/ |
183 |
static int |
183 |
static int |
184 |
ipsec4_perform_request(struct mbuf *m, struct secpolicy *sp, u_int idx) |
184 |
ipsec4_perform_request(struct mbuf *m, struct secpolicy *sp, |
|
|
185 |
struct inpcb *inp, u_int idx) |
185 |
{ |
186 |
{ |
186 |
struct ipsec_ctx_data ctx; |
187 |
struct ipsec_ctx_data ctx; |
187 |
union sockaddr_union *dst; |
188 |
union sockaddr_union *dst; |
Lines 211-217
static int
Link Here
|
211 |
/* |
212 |
/* |
212 |
* XXXAE: most likely ip_sum at this point is wrong. |
213 |
* XXXAE: most likely ip_sum at this point is wrong. |
213 |
*/ |
214 |
*/ |
214 |
IPSEC_INIT_CTX(&ctx, &m, sav, AF_INET, IPSEC_ENC_BEFORE); |
215 |
IPSEC_INIT_CTX(&ctx, &m, inp, sav, AF_INET, IPSEC_ENC_BEFORE); |
215 |
if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) |
216 |
if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) |
216 |
goto bad; |
217 |
goto bad; |
217 |
|
218 |
|
Lines 235-243
static int
Link Here
|
235 |
/* XXXAE: IPSEC_OSTAT_INC(tunnel); */ |
236 |
/* XXXAE: IPSEC_OSTAT_INC(tunnel); */ |
236 |
goto bad; |
237 |
goto bad; |
237 |
} |
238 |
} |
|
|
239 |
inp = NULL; |
238 |
} |
240 |
} |
239 |
|
241 |
|
240 |
IPSEC_INIT_CTX(&ctx, &m, sav, dst->sa.sa_family, IPSEC_ENC_AFTER); |
242 |
IPSEC_INIT_CTX(&ctx, &m, inp, sav, dst->sa.sa_family, IPSEC_ENC_AFTER); |
241 |
if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) |
243 |
if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) |
242 |
goto bad; |
244 |
goto bad; |
243 |
|
245 |
|
Lines 285-291
ipsec4_process_packet(struct mbuf *m, struct secpo
Link Here
|
285 |
struct inpcb *inp) |
287 |
struct inpcb *inp) |
286 |
{ |
288 |
{ |
287 |
|
289 |
|
288 |
return (ipsec4_perform_request(m, sp, 0)); |
290 |
return (ipsec4_perform_request(m, sp, inp, 0)); |
289 |
} |
291 |
} |
290 |
|
292 |
|
291 |
static int |
293 |
static int |
Lines 491-497
next:
Link Here
|
491 |
* IPsec output logic for IPv6. |
493 |
* IPsec output logic for IPv6. |
492 |
*/ |
494 |
*/ |
493 |
static int |
495 |
static int |
494 |
ipsec6_perform_request(struct mbuf *m, struct secpolicy *sp, u_int idx) |
496 |
ipsec6_perform_request(struct mbuf *m, struct secpolicy *sp, |
|
|
497 |
struct inpcb *inp, u_int idx) |
495 |
{ |
498 |
{ |
496 |
struct ipsec_ctx_data ctx; |
499 |
struct ipsec_ctx_data ctx; |
497 |
union sockaddr_union *dst; |
500 |
union sockaddr_union *dst; |
Lines 514-520
static int
Link Here
|
514 |
ip6 = mtod(m, struct ip6_hdr *); |
517 |
ip6 = mtod(m, struct ip6_hdr *); |
515 |
ip6->ip6_plen = htons(m->m_pkthdr.len - sizeof(*ip6)); |
518 |
ip6->ip6_plen = htons(m->m_pkthdr.len - sizeof(*ip6)); |
516 |
|
519 |
|
517 |
IPSEC_INIT_CTX(&ctx, &m, sav, AF_INET6, IPSEC_ENC_BEFORE); |
520 |
IPSEC_INIT_CTX(&ctx, &m, inp, sav, AF_INET6, IPSEC_ENC_BEFORE); |
518 |
if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) |
521 |
if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) |
519 |
goto bad; |
522 |
goto bad; |
520 |
|
523 |
|
Lines 540-548
static int
Link Here
|
540 |
/* XXXAE: IPSEC_OSTAT_INC(tunnel); */ |
543 |
/* XXXAE: IPSEC_OSTAT_INC(tunnel); */ |
541 |
goto bad; |
544 |
goto bad; |
542 |
} |
545 |
} |
|
|
546 |
inp = NULL; |
543 |
} |
547 |
} |
544 |
|
548 |
|
545 |
IPSEC_INIT_CTX(&ctx, &m, sav, dst->sa.sa_family, IPSEC_ENC_AFTER); |
549 |
IPSEC_INIT_CTX(&ctx, &m, inp, sav, dst->sa.sa_family, IPSEC_ENC_AFTER); |
546 |
if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) |
550 |
if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) |
547 |
goto bad; |
551 |
goto bad; |
548 |
|
552 |
|
Lines 585-591
ipsec6_process_packet(struct mbuf *m, struct secpo
Link Here
|
585 |
struct inpcb *inp) |
589 |
struct inpcb *inp) |
586 |
{ |
590 |
{ |
587 |
|
591 |
|
588 |
return (ipsec6_perform_request(m, sp, 0)); |
592 |
return (ipsec6_perform_request(m, sp, inp, 0)); |
589 |
} |
593 |
} |
590 |
|
594 |
|
591 |
static int |
595 |
static int |
Lines 750-756
ipsec_process_done(struct mbuf *m, struct secpolic
Link Here
|
750 |
case AF_INET: |
754 |
case AF_INET: |
751 |
key_freesav(&sav); |
755 |
key_freesav(&sav); |
752 |
IPSECSTAT_INC(ips_out_bundlesa); |
756 |
IPSECSTAT_INC(ips_out_bundlesa); |
753 |
return (ipsec4_perform_request(m, sp, idx)); |
757 |
return (ipsec4_perform_request(m, sp, NULL, idx)); |
754 |
/* NOTREACHED */ |
758 |
/* NOTREACHED */ |
755 |
#endif |
759 |
#endif |
756 |
#ifdef INET6 |
760 |
#ifdef INET6 |
Lines 757-763
ipsec_process_done(struct mbuf *m, struct secpolic
Link Here
|
757 |
case AF_INET6: |
761 |
case AF_INET6: |
758 |
key_freesav(&sav); |
762 |
key_freesav(&sav); |
759 |
IPSEC6STAT_INC(ips_out_bundlesa); |
763 |
IPSEC6STAT_INC(ips_out_bundlesa); |
760 |
return (ipsec6_perform_request(m, sp, idx)); |
764 |
return (ipsec6_perform_request(m, sp, NULL, idx)); |
761 |
/* NOTREACHED */ |
765 |
/* NOTREACHED */ |
762 |
#endif /* INET6 */ |
766 |
#endif /* INET6 */ |
763 |
default: |
767 |
default: |