| 1011 | } |
| 1012 | |
| 1013 | static int |
| 1014 | ipsec_set_tunnel(struct ipsec_softc *sc, struct sockaddr *src, |
| 1015 | struct sockaddr *dst, uint32_t reqid) |
| 1016 | { |
| 1017 | struct secpolicy *sp[IPSEC_SPCOUNT]; |
| 1018 | int i; |
| 1019 | |
| 1020 | sx_assert(&ipsec_ioctl_sx, SA_XLOCKED); |
| 1021 | |
| 1022 | /* Allocate SP with new addresses. */ |
| 1023 | if (ipsec_newpolicies(sc, sp, src, dst, reqid) == 0) { |
| 1024 | /* Add new policies to SPDB */ |
| 1025 | if (key_register_ifnet(sp, IPSEC_SPCOUNT) != 0) { |
| 1026 | for (i = 0; i < IPSEC_SPCOUNT; i++) |
| 1027 | key_freesp(&sp[i]); |
| 1028 | return (EAGAIN); |
| 1029 | } |
| 1030 | if (sc->family != 0) |
| 1031 | ipsec_delete_tunnel(sc); |
| 1032 | for (i = 0; i < IPSEC_SPCOUNT; i++) |
| 1033 | sc->sp[i] = sp[i]; |
| 1034 | sc->family = src->sa_family; |
| 1035 | CK_LIST_INSERT_HEAD(ipsec_srchash(src), sc, srchash); |
| 1036 | } else { |
| 1037 | sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING; |
| 1038 | return (ENOMEM); |
| 1039 | } |
| 1040 | ipsec_set_running(sc); |
| 1041 | return (0); |
| 1042 | } |
| 1043 | |
| 1044 | static void |
| 1045 | ipsec_delete_tunnel(struct ipsec_softc *sc) |
no test coverage detected