* SADB_ACQUIRE processing, * in first situation, is receiving * * from the ikmpd, and clear sequence of its secasvar entry. * * In second situation, is receiving * * from a user land process, and return * * to the socket. * *
| 6936 | * m will always be freed. |
| 6937 | */ |
| 6938 | static int |
| 6939 | key_acquire2(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
| 6940 | { |
| 6941 | SAHTREE_RLOCK_TRACKER; |
| 6942 | struct sadb_address *src0, *dst0; |
| 6943 | struct secasindex saidx; |
| 6944 | struct secashead *sah; |
| 6945 | uint32_t reqid; |
| 6946 | int error; |
| 6947 | uint8_t mode, proto; |
| 6948 | |
| 6949 | IPSEC_ASSERT(so != NULL, ("null socket")); |
| 6950 | IPSEC_ASSERT(m != NULL, ("null mbuf")); |
| 6951 | IPSEC_ASSERT(mhp != NULL, ("null msghdr")); |
| 6952 | IPSEC_ASSERT(mhp->msg != NULL, ("null msg")); |
| 6953 | |
| 6954 | /* |
| 6955 | * Error message from KMd. |
| 6956 | * We assume that if error was occurred in IKEd, the length of PFKEY |
| 6957 | * message is equal to the size of sadb_msg structure. |
| 6958 | * We do not raise error even if error occurred in this function. |
| 6959 | */ |
| 6960 | if (mhp->msg->sadb_msg_len == PFKEY_UNIT64(sizeof(struct sadb_msg))) { |
| 6961 | /* check sequence number */ |
| 6962 | if (mhp->msg->sadb_msg_seq == 0 || |
| 6963 | mhp->msg->sadb_msg_errno == 0) { |
| 6964 | ipseclog((LOG_DEBUG, "%s: must specify sequence " |
| 6965 | "number and errno.\n", __func__)); |
| 6966 | } else { |
| 6967 | /* |
| 6968 | * IKEd reported that error occurred. |
| 6969 | * XXXAE: what it expects from the kernel? |
| 6970 | * Probably we should send SADB_ACQUIRE again? |
| 6971 | * If so, reset ACQ's state. |
| 6972 | * XXXAE: it looks useless. |
| 6973 | */ |
| 6974 | key_acqreset(mhp->msg->sadb_msg_seq); |
| 6975 | } |
| 6976 | m_freem(m); |
| 6977 | return (0); |
| 6978 | } |
| 6979 | |
| 6980 | /* |
| 6981 | * This message is from user land. |
| 6982 | */ |
| 6983 | |
| 6984 | /* map satype to proto */ |
| 6985 | if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) { |
| 6986 | ipseclog((LOG_DEBUG, "%s: invalid satype is passed.\n", |
| 6987 | __func__)); |
| 6988 | return key_senderror(so, m, EINVAL); |
| 6989 | } |
| 6990 | |
| 6991 | if (SADB_CHECKHDR(mhp, SADB_EXT_ADDRESS_SRC) || |
| 6992 | SADB_CHECKHDR(mhp, SADB_EXT_ADDRESS_DST) || |
| 6993 | SADB_CHECKHDR(mhp, SADB_EXT_PROPOSAL)) { |
| 6994 | ipseclog((LOG_DEBUG, |
| 6995 | "%s: invalid message: missing required header.\n", |
nothing calls this directly
no test coverage detected