if_ipsec.c (662c13053f4bf2d6245ba7e2b66c10d1cd5c1fb9) if_ipsec.c (c8ee75f2315e8267ad814dc5b4645ef205f0e0e1)
1/*-
2 * Copyright (c) 2016-2018 Yandex LLC
3 * Copyright (c) 2016-2018 Andrey V. Elsukov <ae@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 1000 unchanged lines hidden (view full) ---

1009 return (EEXIST);
1010 return (ipsec_set_tunnel(sc, src, dst, sc->reqid));
1011}
1012
1013static int
1014ipsec_set_tunnel(struct ipsec_softc *sc, struct sockaddr *src,
1015 struct sockaddr *dst, uint32_t reqid)
1016{
1/*-
2 * Copyright (c) 2016-2018 Yandex LLC
3 * Copyright (c) 2016-2018 Andrey V. Elsukov <ae@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 1000 unchanged lines hidden (view full) ---

1009 return (EEXIST);
1010 return (ipsec_set_tunnel(sc, src, dst, sc->reqid));
1011}
1012
1013static int
1014ipsec_set_tunnel(struct ipsec_softc *sc, struct sockaddr *src,
1015 struct sockaddr *dst, uint32_t reqid)
1016{
1017 struct epoch_tracker et;
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 */

--- 7 unchanged lines hidden (view full) ---

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 }
1018 struct secpolicy *sp[IPSEC_SPCOUNT];
1019 int i;
1020
1021 sx_assert(&ipsec_ioctl_sx, SA_XLOCKED);
1022
1023 /* Allocate SP with new addresses. */
1024 if (ipsec_newpolicies(sc, sp, src, dst, reqid) == 0) {
1025 /* Add new policies to SPDB */

--- 7 unchanged lines hidden (view full) ---

1033 for (i = 0; i < IPSEC_SPCOUNT; i++)
1034 sc->sp[i] = sp[i];
1035 sc->family = src->sa_family;
1036 CK_LIST_INSERT_HEAD(ipsec_srchash(src), sc, srchash);
1037 } else {
1038 sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
1039 return (ENOMEM);
1040 }
1041 NET_EPOCH_ENTER(et);
1040 ipsec_set_running(sc);
1042 ipsec_set_running(sc);
1043 NET_EPOCH_EXIT(et);
1041 return (0);
1042}
1043
1044static void
1045ipsec_delete_tunnel(struct ipsec_softc *sc)
1046{
1047 int i;
1048

--- 17 unchanged lines hidden ---
1044 return (0);
1045}
1046
1047static void
1048ipsec_delete_tunnel(struct ipsec_softc *sc)
1049{
1050 int i;
1051

--- 17 unchanged lines hidden ---