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

Function key_delete

freebsd/netipsec/key.c:5952–6050  ·  view source on GitHub ↗

* SADB_DELETE processing * receive * * from the ikmpd, and set SADB_SASTATE_DEAD, * and send, * * to the ikmpd. * * m will always be freed. */

Source from the content-addressed store, hash-verified

5950 * m will always be freed.
5951 */
5952static int
5953key_delete(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp)
5954{
5955 struct secasindex saidx;
5956 struct sadb_address *src0, *dst0;
5957 struct secasvar *sav;
5958 struct sadb_sa *sa0;
5959 uint8_t proto;
5960
5961 IPSEC_ASSERT(so != NULL, ("null socket"));
5962 IPSEC_ASSERT(m != NULL, ("null mbuf"));
5963 IPSEC_ASSERT(mhp != NULL, ("null msghdr"));
5964 IPSEC_ASSERT(mhp->msg != NULL, ("null msg"));
5965
5966 /* map satype to proto */
5967 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
5968 ipseclog((LOG_DEBUG, "%s: invalid satype is passed.\n",
5969 __func__));
5970 return key_senderror(so, m, EINVAL);
5971 }
5972
5973 if (SADB_CHECKHDR(mhp, SADB_EXT_ADDRESS_SRC) ||
5974 SADB_CHECKHDR(mhp, SADB_EXT_ADDRESS_DST) ||
5975 SADB_CHECKLEN(mhp, SADB_EXT_ADDRESS_SRC) ||
5976 SADB_CHECKLEN(mhp, SADB_EXT_ADDRESS_DST)) {
5977 ipseclog((LOG_DEBUG, "%s: invalid message is passed.\n",
5978 __func__));
5979 return key_senderror(so, m, EINVAL);
5980 }
5981
5982 src0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_SRC]);
5983 dst0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_DST]);
5984
5985 if (key_checksockaddrs((struct sockaddr *)(src0 + 1),
5986 (struct sockaddr *)(dst0 + 1)) != 0) {
5987 ipseclog((LOG_DEBUG, "%s: invalid sockaddr.\n", __func__));
5988 return (key_senderror(so, m, EINVAL));
5989 }
5990 KEY_SETSECASIDX(proto, IPSEC_MODE_ANY, 0, src0 + 1, dst0 + 1, &saidx);
5991 if (SADB_CHECKHDR(mhp, SADB_EXT_SA)) {
5992 /*
5993 * Caller wants us to delete all non-LARVAL SAs
5994 * that match the src/dst. This is used during
5995 * IKE INITIAL-CONTACT.
5996 * XXXAE: this looks like some extension to RFC2367.
5997 */
5998 ipseclog((LOG_DEBUG, "%s: doing delete all.\n", __func__));
5999 return (key_delete_all(so, m, mhp, &saidx));
6000 }
6001 if (SADB_CHECKLEN(mhp, SADB_EXT_SA)) {
6002 ipseclog((LOG_DEBUG,
6003 "%s: invalid message: wrong header size.\n", __func__));
6004 return (key_senderror(so, m, EINVAL));
6005 }
6006 sa0 = (struct sadb_sa *)mhp->ext[SADB_EXT_SA];
6007 if (proto == IPPROTO_TCP)
6008 sav = key_getsav_tcpmd5(&saidx, NULL);
6009 else

Callers

nothing calls this directly

Calls 15

key_satype2protoFunction · 0.85
key_senderrorFunction · 0.85
key_checksockaddrsFunction · 0.85
key_delete_allFunction · 0.85
key_getsav_tcpmd5Function · 0.85
key_getsavbyspiFunction · 0.85
key_cmpsaidxFunction · 0.85
key_freesavFunction · 0.85
kdebug_secasvFunction · 0.85
key_unlinksavFunction · 0.85
key_gather_mbufFunction · 0.85
m_pullupFunction · 0.85

Tested by

no test coverage detected