]> git.proxmox.com Git - mirror_frr.git/blobdiff - ldpd/pfkey.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / ldpd / pfkey.c
index 906737217c0e0513a7279b6658f9f9dde1e2ca22..4bea2e1904376104786b485902673587948ae0d5 100644 (file)
@@ -1,22 +1,15 @@
+// SPDX-License-Identifier: ISC
 /*     $OpenBSD$ */
 
 /*
  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
  * Copyright (c) 2003, 2004 Markus Friedl <markus@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #ifdef __OpenBSD__
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -417,35 +410,33 @@ pfkey_md5sig_remove(struct nbr *nbr)
 int
 pfkey_establish(struct nbr *nbr, struct nbr_params *nbrp)
 {
-       if (nbrp->auth.method == AUTH_NONE)
-               return (0);
-
        switch (nbr->auth.method) {
        case AUTH_MD5SIG:
                strlcpy(nbr->auth.md5key, nbrp->auth.md5key,
                    sizeof(nbr->auth.md5key));
-               return (pfkey_md5sig_establish(nbr, nbrp));
-       default:
-               break;
+               return pfkey_md5sig_establish(nbr, nbrp);
+       case AUTH_NONE:
+               return 0;
        }
 
-       return (0);
+       assert(!"Reached end of function where we are not expecting to");
 }
 
 int
 pfkey_remove(struct nbr *nbr)
 {
-       if (nbr->auth.method == AUTH_NONE || !nbr->auth.established)
-               return (0);
+       if (!nbr->auth.established)
+               return 0;
 
        switch (nbr->auth.method) {
        case AUTH_MD5SIG:
-               return (pfkey_md5sig_remove(nbr));
-       default:
+               return pfkey_md5sig_remove(nbr);
+       case AUTH_NONE:
+               return 0;
                break;
        }
 
-       return (0);
+       assert(!"Reached end of function where we are not expecting to");
 }
 
 int