Lines 418-435
static struct secpolicy *key_getspbyid(u
Link Here
|
418 |
static u_int32_t key_newreqid(void); |
418 |
static u_int32_t key_newreqid(void); |
419 |
static struct mbuf *key_gather_mbuf(struct mbuf *, |
419 |
static struct mbuf *key_gather_mbuf(struct mbuf *, |
420 |
const struct sadb_msghdr *, int, int, ...); |
420 |
const struct sadb_msghdr *, int, int, ...); |
421 |
static int key_spdadd(struct socket *, struct mbuf *, |
421 |
static int key_spdadd(const struct socket *, struct mbuf *, |
422 |
const struct sadb_msghdr *); |
422 |
const struct sadb_msghdr *); |
423 |
static u_int32_t key_getnewspid(void); |
423 |
static u_int32_t key_getnewspid(void); |
424 |
static int key_spddelete(struct socket *, struct mbuf *, |
424 |
static int key_spddelete(const struct socket *, struct mbuf *, |
425 |
const struct sadb_msghdr *); |
425 |
const struct sadb_msghdr *); |
426 |
static int key_spddelete2(struct socket *, struct mbuf *, |
426 |
static int key_spddelete2(const struct socket *, struct mbuf *, |
427 |
const struct sadb_msghdr *); |
427 |
const struct sadb_msghdr *); |
428 |
static int key_spdget(struct socket *, struct mbuf *, |
428 |
static int key_spdget(const struct socket *, struct mbuf *, |
429 |
const struct sadb_msghdr *); |
429 |
const struct sadb_msghdr *); |
430 |
static int key_spdflush(struct socket *, struct mbuf *, |
430 |
static int key_spdflush(const struct socket *, struct mbuf *, |
431 |
const struct sadb_msghdr *); |
431 |
const struct sadb_msghdr *); |
432 |
static int key_spddump(struct socket *, struct mbuf *, |
432 |
static int key_spddump(const struct socket *, struct mbuf *, |
433 |
const struct sadb_msghdr *); |
433 |
const struct sadb_msghdr *); |
434 |
static struct mbuf *key_setdumpsp(struct secpolicy *, |
434 |
static struct mbuf *key_setdumpsp(struct secpolicy *, |
435 |
u_int8_t, u_int32_t, u_int32_t); |
435 |
u_int8_t, u_int32_t, u_int32_t); |
Lines 491-516
static int key_bbcmp(const void *, const
Link Here
|
491 |
static u_int16_t key_satype2proto(u_int8_t); |
491 |
static u_int16_t key_satype2proto(u_int8_t); |
492 |
static u_int8_t key_proto2satype(u_int16_t); |
492 |
static u_int8_t key_proto2satype(u_int16_t); |
493 |
|
493 |
|
494 |
static int key_getspi(struct socket *, struct mbuf *, |
494 |
static int key_getspi(const struct socket *, struct mbuf *, |
495 |
const struct sadb_msghdr *); |
495 |
const struct sadb_msghdr *); |
496 |
static u_int32_t key_do_getnewspi(struct sadb_spirange *, |
496 |
static u_int32_t key_do_getnewspi(struct sadb_spirange *, |
497 |
struct secasindex *); |
497 |
struct secasindex *); |
498 |
static int key_update(struct socket *, struct mbuf *, |
498 |
static int key_update(const struct socket *, struct mbuf *, |
499 |
const struct sadb_msghdr *); |
499 |
const struct sadb_msghdr *); |
500 |
#ifdef IPSEC_DOSEQCHECK |
500 |
#ifdef IPSEC_DOSEQCHECK |
501 |
static struct secasvar *key_getsavbyseq(struct secashead *, u_int32_t); |
501 |
static struct secasvar *key_getsavbyseq(struct secashead *, u_int32_t); |
502 |
#endif |
502 |
#endif |
503 |
static int key_add(struct socket *, struct mbuf *, |
503 |
static int key_add(const struct socket *, struct mbuf *, |
504 |
const struct sadb_msghdr *); |
504 |
const struct sadb_msghdr *); |
505 |
static int key_setident(struct secashead *, struct mbuf *, |
505 |
static int key_setident(struct secashead *, struct mbuf *, |
506 |
const struct sadb_msghdr *); |
506 |
const struct sadb_msghdr *); |
507 |
static struct mbuf *key_getmsgbuf_x1(struct mbuf *, |
507 |
static struct mbuf *key_getmsgbuf_x1(struct mbuf *, |
508 |
const struct sadb_msghdr *); |
508 |
const struct sadb_msghdr *); |
509 |
static int key_delete(struct socket *, struct mbuf *, |
509 |
static int key_delete(const struct socket *, struct mbuf *, |
510 |
const struct sadb_msghdr *); |
510 |
const struct sadb_msghdr *); |
511 |
static int key_delete_all(struct socket *, struct mbuf *, |
511 |
static int key_delete_all(const struct socket *, struct mbuf *, |
512 |
const struct sadb_msghdr *, u_int16_t); |
512 |
const struct sadb_msghdr *, u_int16_t); |
513 |
static int key_get(struct socket *, struct mbuf *, |
513 |
static int key_get(const struct socket *, struct mbuf *, |
514 |
const struct sadb_msghdr *); |
514 |
const struct sadb_msghdr *); |
515 |
|
515 |
|
516 |
static void key_getcomb_setlifetime(struct sadb_comb *); |
516 |
static void key_getcomb_setlifetime(struct sadb_comb *); |
Lines 525-542
static struct secacq *key_getacq(const s
Link Here
|
525 |
static struct secacq *key_getacqbyseq(u_int32_t); |
525 |
static struct secacq *key_getacqbyseq(u_int32_t); |
526 |
static struct secspacq *key_newspacq(struct secpolicyindex *); |
526 |
static struct secspacq *key_newspacq(struct secpolicyindex *); |
527 |
static struct secspacq *key_getspacq(struct secpolicyindex *); |
527 |
static struct secspacq *key_getspacq(struct secpolicyindex *); |
528 |
static int key_acquire2(struct socket *, struct mbuf *, |
528 |
static int key_acquire2(const struct socket *, struct mbuf *, |
529 |
const struct sadb_msghdr *); |
529 |
const struct sadb_msghdr *); |
530 |
static int key_register(struct socket *, struct mbuf *, |
530 |
static int key_register(const struct socket *, struct mbuf *, |
531 |
const struct sadb_msghdr *); |
531 |
const struct sadb_msghdr *); |
532 |
static int key_expire(struct secasvar *, int); |
532 |
static int key_expire(struct secasvar *, int); |
533 |
static int key_flush(struct socket *, struct mbuf *, |
533 |
static int key_flush(const struct socket *, struct mbuf *, |
534 |
const struct sadb_msghdr *); |
534 |
const struct sadb_msghdr *); |
535 |
static int key_dump(struct socket *, struct mbuf *, |
535 |
static int key_dump(const struct socket *, struct mbuf *, |
536 |
const struct sadb_msghdr *); |
536 |
const struct sadb_msghdr *); |
537 |
static int key_promisc(struct socket *, struct mbuf *, |
537 |
static int key_promisc(const struct socket *, struct mbuf *, |
538 |
const struct sadb_msghdr *); |
538 |
const struct sadb_msghdr *); |
539 |
static int key_senderror(struct socket *, struct mbuf *, int); |
539 |
static int key_senderror(const struct socket *, struct mbuf *, int); |
540 |
static int key_validate_ext(const struct sadb_ext *, int); |
540 |
static int key_validate_ext(const struct sadb_ext *, int); |
541 |
static int key_align(struct mbuf *, struct sadb_msghdr *); |
541 |
static int key_align(struct mbuf *, struct sadb_msghdr *); |
542 |
static struct mbuf *key_setlifetime(struct seclifetime *src, |
542 |
static struct mbuf *key_setlifetime(struct seclifetime *src, |
Lines 1192-1198
_key_freesp(struct secpolicy **spp, cons
Link Here
|
1192 |
* For the packet with socket. |
1192 |
* For the packet with socket. |
1193 |
*/ |
1193 |
*/ |
1194 |
void |
1194 |
void |
1195 |
key_freeso(struct socket *so) |
1195 |
key_freeso(const struct socket *so) |
1196 |
{ |
1196 |
{ |
1197 |
IPSEC_ASSERT(so != NULL, ("null so")); |
1197 |
IPSEC_ASSERT(so != NULL, ("null so")); |
1198 |
|
1198 |
|
Lines 1776-1782
fail:
Link Here
|
1776 |
* m will always be freed. |
1776 |
* m will always be freed. |
1777 |
*/ |
1777 |
*/ |
1778 |
static int |
1778 |
static int |
1779 |
key_spdadd(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
1779 |
key_spdadd(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
1780 |
{ |
1780 |
{ |
1781 |
struct sadb_address *src0, *dst0; |
1781 |
struct sadb_address *src0, *dst0; |
1782 |
struct sadb_x_policy *xpl0, *xpl; |
1782 |
struct sadb_x_policy *xpl0, *xpl; |
Lines 2038-2044
key_getnewspid()
Link Here
|
2038 |
* m will always be freed. |
2038 |
* m will always be freed. |
2039 |
*/ |
2039 |
*/ |
2040 |
static int |
2040 |
static int |
2041 |
key_spddelete(struct socket *so, struct mbuf *m, |
2041 |
key_spddelete(const struct socket *so, struct mbuf *m, |
2042 |
const struct sadb_msghdr *mhp) |
2042 |
const struct sadb_msghdr *mhp) |
2043 |
{ |
2043 |
{ |
2044 |
struct sadb_address *src0, *dst0; |
2044 |
struct sadb_address *src0, *dst0; |
Lines 2146-2152
key_spddelete(struct socket *so, struct
Link Here
|
2146 |
* m will always be freed. |
2146 |
* m will always be freed. |
2147 |
*/ |
2147 |
*/ |
2148 |
static int |
2148 |
static int |
2149 |
key_spddelete2(struct socket *so, struct mbuf *m, |
2149 |
key_spddelete2(const struct socket *so, struct mbuf *m, |
2150 |
const struct sadb_msghdr *mhp) |
2150 |
const struct sadb_msghdr *mhp) |
2151 |
{ |
2151 |
{ |
2152 |
u_int32_t id; |
2152 |
u_int32_t id; |
Lines 2238-2244
key_spddelete2(struct socket *so, struct
Link Here
|
2238 |
* m will always be freed. |
2238 |
* m will always be freed. |
2239 |
*/ |
2239 |
*/ |
2240 |
static int |
2240 |
static int |
2241 |
key_spdget(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
2241 |
key_spdget(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
2242 |
{ |
2242 |
{ |
2243 |
u_int32_t id; |
2243 |
u_int32_t id; |
2244 |
struct secpolicy *sp; |
2244 |
struct secpolicy *sp; |
Lines 2350-2356
key_spdacquire(struct secpolicy *sp)
Link Here
|
2350 |
* m will always be freed. |
2350 |
* m will always be freed. |
2351 |
*/ |
2351 |
*/ |
2352 |
static int |
2352 |
static int |
2353 |
key_spdflush(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
2353 |
key_spdflush(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
2354 |
{ |
2354 |
{ |
2355 |
struct sadb_msg *newmsg; |
2355 |
struct sadb_msg *newmsg; |
2356 |
struct secpolicy *sp; |
2356 |
struct secpolicy *sp; |
Lines 2399-2405
key_spdflush(struct socket *so, struct m
Link Here
|
2399 |
* m will always be freed. |
2399 |
* m will always be freed. |
2400 |
*/ |
2400 |
*/ |
2401 |
static int |
2401 |
static int |
2402 |
key_spddump(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
2402 |
key_spddump(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
2403 |
{ |
2403 |
{ |
2404 |
struct secpolicy *sp; |
2404 |
struct secpolicy *sp; |
2405 |
int cnt; |
2405 |
int cnt; |
Lines 4554-4560
key_proto2satype(u_int16_t proto)
Link Here
|
4554 |
* other if success, return pointer to the message to send. |
4554 |
* other if success, return pointer to the message to send. |
4555 |
*/ |
4555 |
*/ |
4556 |
static int |
4556 |
static int |
4557 |
key_getspi(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
4557 |
key_getspi(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
4558 |
{ |
4558 |
{ |
4559 |
struct sadb_address *src0, *dst0; |
4559 |
struct sadb_address *src0, *dst0; |
4560 |
struct secasindex saidx; |
4560 |
struct secasindex saidx; |
Lines 4864-4870
key_do_getnewspi(struct sadb_spirange *s
Link Here
|
4864 |
* m will always be freed. |
4864 |
* m will always be freed. |
4865 |
*/ |
4865 |
*/ |
4866 |
static int |
4866 |
static int |
4867 |
key_update(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
4867 |
key_update(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
4868 |
{ |
4868 |
{ |
4869 |
struct sadb_sa *sa0; |
4869 |
struct sadb_sa *sa0; |
4870 |
struct sadb_address *src0, *dst0; |
4870 |
struct sadb_address *src0, *dst0; |
Lines 5149-5155
key_getsavbyseq(struct secashead *sah, u
Link Here
|
5149 |
* m will always be freed. |
5149 |
* m will always be freed. |
5150 |
*/ |
5150 |
*/ |
5151 |
static int |
5151 |
static int |
5152 |
key_add(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
5152 |
key_add(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
5153 |
{ |
5153 |
{ |
5154 |
struct sadb_sa *sa0; |
5154 |
struct sadb_sa *sa0; |
5155 |
struct sadb_address *src0, *dst0; |
5155 |
struct sadb_address *src0, *dst0; |
Lines 5475-5481
key_getmsgbuf_x1(struct mbuf *m, const s
Link Here
|
5475 |
* m will always be freed. |
5475 |
* m will always be freed. |
5476 |
*/ |
5476 |
*/ |
5477 |
static int |
5477 |
static int |
5478 |
key_delete(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
5478 |
key_delete(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
5479 |
{ |
5479 |
{ |
5480 |
struct sadb_sa *sa0; |
5480 |
struct sadb_sa *sa0; |
5481 |
struct sadb_address *src0, *dst0; |
5481 |
struct sadb_address *src0, *dst0; |
Lines 5619-5625
key_delete(struct socket *so, struct mbu
Link Here
|
5619 |
* delete all SAs for src/dst. Called from key_delete(). |
5619 |
* delete all SAs for src/dst. Called from key_delete(). |
5620 |
*/ |
5620 |
*/ |
5621 |
static int |
5621 |
static int |
5622 |
key_delete_all(struct socket *so, struct mbuf *m, |
5622 |
key_delete_all(const struct socket *so, struct mbuf *m, |
5623 |
const struct sadb_msghdr *mhp, u_int16_t proto) |
5623 |
const struct sadb_msghdr *mhp, u_int16_t proto) |
5624 |
{ |
5624 |
{ |
5625 |
struct sadb_address *src0, *dst0; |
5625 |
struct sadb_address *src0, *dst0; |
Lines 5740-5746
key_delete_all(struct socket *so, struct
Link Here
|
5740 |
* m will always be freed. |
5740 |
* m will always be freed. |
5741 |
*/ |
5741 |
*/ |
5742 |
static int |
5742 |
static int |
5743 |
key_get(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
5743 |
key_get(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
5744 |
{ |
5744 |
{ |
5745 |
struct sadb_sa *sa0; |
5745 |
struct sadb_sa *sa0; |
5746 |
struct sadb_address *src0, *dst0; |
5746 |
struct sadb_address *src0, *dst0; |
Lines 6481-6487
key_getspacq(struct secpolicyindex *spid
Link Here
|
6481 |
* m will always be freed. |
6481 |
* m will always be freed. |
6482 |
*/ |
6482 |
*/ |
6483 |
static int |
6483 |
static int |
6484 |
key_acquire2(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
6484 |
key_acquire2(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
6485 |
{ |
6485 |
{ |
6486 |
const struct sadb_address *src0, *dst0; |
6486 |
const struct sadb_address *src0, *dst0; |
6487 |
struct secasindex saidx; |
6487 |
struct secasindex saidx; |
Lines 6636-6642
key_acquire2(struct socket *so, struct m
Link Here
|
6636 |
* m will always be freed. |
6636 |
* m will always be freed. |
6637 |
*/ |
6637 |
*/ |
6638 |
static int |
6638 |
static int |
6639 |
key_register(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
6639 |
key_register(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
6640 |
{ |
6640 |
{ |
6641 |
struct secreg *reg, *newreg = 0; |
6641 |
struct secreg *reg, *newreg = 0; |
6642 |
|
6642 |
|
Lines 6790-6796
key_register(struct socket *so, struct m
Link Here
|
6790 |
* XXX: I want to do free a socket marked done SADB_RESIGER to socket. |
6790 |
* XXX: I want to do free a socket marked done SADB_RESIGER to socket. |
6791 |
*/ |
6791 |
*/ |
6792 |
void |
6792 |
void |
6793 |
key_freereg(struct socket *so) |
6793 |
key_freereg(const struct socket *so) |
6794 |
{ |
6794 |
{ |
6795 |
struct secreg *reg; |
6795 |
struct secreg *reg; |
6796 |
int i; |
6796 |
int i; |
Lines 6964-6970
key_expire(struct secasvar *sav, int har
Link Here
|
6964 |
* m will always be freed. |
6964 |
* m will always be freed. |
6965 |
*/ |
6965 |
*/ |
6966 |
static int |
6966 |
static int |
6967 |
key_flush(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
6967 |
key_flush(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
6968 |
{ |
6968 |
{ |
6969 |
struct sadb_msg *newmsg; |
6969 |
struct sadb_msg *newmsg; |
6970 |
struct secashead *sah, *nextsah; |
6970 |
struct secashead *sah, *nextsah; |
Lines 7044-7050
key_flush(struct socket *so, struct mbuf
Link Here
|
7044 |
* m will always be freed. |
7044 |
* m will always be freed. |
7045 |
*/ |
7045 |
*/ |
7046 |
static int |
7046 |
static int |
7047 |
key_dump(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
7047 |
key_dump(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
7048 |
{ |
7048 |
{ |
7049 |
struct secashead *sah; |
7049 |
struct secashead *sah; |
7050 |
struct secasvar *sav; |
7050 |
struct secasvar *sav; |
Lines 7133-7139
key_dump(struct socket *so, struct mbuf
Link Here
|
7133 |
* m will always be freed. |
7133 |
* m will always be freed. |
7134 |
*/ |
7134 |
*/ |
7135 |
static int |
7135 |
static int |
7136 |
key_promisc(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
7136 |
key_promisc(const struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
7137 |
{ |
7137 |
{ |
7138 |
int olen; |
7138 |
int olen; |
7139 |
|
7139 |
|
Lines 7180-7186
key_promisc(struct socket *so, struct mb
Link Here
|
7180 |
} |
7180 |
} |
7181 |
} |
7181 |
} |
7182 |
|
7182 |
|
7183 |
static int (*key_typesw[])(struct socket *, struct mbuf *, |
7183 |
static int (*key_typesw[])(const struct socket *, struct mbuf *, |
7184 |
const struct sadb_msghdr *) = { |
7184 |
const struct sadb_msghdr *) = { |
7185 |
NULL, /* SADB_RESERVED */ |
7185 |
NULL, /* SADB_RESERVED */ |
7186 |
key_getspi, /* SADB_GETSPI */ |
7186 |
key_getspi, /* SADB_GETSPI */ |
Lines 7213-7225
static int (*key_typesw[])(struct socket
Link Here
|
7213 |
* I think to be dealed with mbuf directly. |
7213 |
* I think to be dealed with mbuf directly. |
7214 |
* IN: |
7214 |
* IN: |
7215 |
* msgp : pointer to pointer to a received buffer pulluped. |
7215 |
* msgp : pointer to pointer to a received buffer pulluped. |
7216 |
* This is rewrited to response. |
7216 |
* This is rewritten in response. |
7217 |
* so : pointer to socket. |
7217 |
* so : pointer to socket. |
7218 |
* OUT: |
7218 |
* OUT: |
7219 |
* length for buffer to send to user process. |
7219 |
* length for buffer to send to user process. |
7220 |
*/ |
7220 |
*/ |
7221 |
int |
7221 |
int |
7222 |
key_parse(struct mbuf *m, struct socket *so) |
7222 |
key_parse(struct mbuf *m, const struct socket *so) |
7223 |
{ |
7223 |
{ |
7224 |
struct sadb_msg *msg; |
7224 |
struct sadb_msg *msg; |
7225 |
struct sadb_msghdr mh; |
7225 |
struct sadb_msghdr mh; |
Lines 7245-7253
key_parse(struct mbuf *m, struct socket
Link Here
|
7245 |
orglen = PFKEY_UNUNIT64(msg->sadb_msg_len); |
7245 |
orglen = PFKEY_UNUNIT64(msg->sadb_msg_len); |
7246 |
target = KEY_SENDUP_ONE; |
7246 |
target = KEY_SENDUP_ONE; |
7247 |
|
7247 |
|
7248 |
if ((m->m_flags & M_PKTHDR) == 0 || |
7248 |
if ((m->m_flags & M_PKTHDR) == 0) { |
7249 |
m->m_pkthdr.len != m->m_pkthdr.len) { |
7249 |
ipseclog((LOG_DEBUG, "%s: invalid message length.\n", __func__)); |
7250 |
ipseclog((LOG_DEBUG, "%s: invalid message length.\n",__func__)); |
|
|
7251 |
PFKEYSTAT_INC(out_invlen); |
7250 |
PFKEYSTAT_INC(out_invlen); |
7252 |
error = EINVAL; |
7251 |
error = EINVAL; |
7253 |
goto senderror; |
7252 |
goto senderror; |
Lines 7467-7473
senderror:
Link Here
|
7467 |
} |
7466 |
} |
7468 |
|
7467 |
|
7469 |
static int |
7468 |
static int |
7470 |
key_senderror(struct socket *so, struct mbuf *m, int code) |
7469 |
key_senderror(const struct socket *so, struct mbuf *m, int code) |
7471 |
{ |
7470 |
{ |
7472 |
struct sadb_msg *msg; |
7471 |
struct sadb_msg *msg; |
7473 |
|
7472 |
|