diff options
| author | Russ White <russ@riw.us> | 2023-07-11 10:23:37 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-11 10:23:37 -0400 |
| commit | f46dc78367ec9554696dd8ef0e5e57c6ff94cf81 (patch) | |
| tree | 935ef41898e2346dc571c4cdef44c64ac568c36f /ospfd/ospf_interface.c | |
| parent | d602e0174512c77bc7c5884324a044e0faf878d4 (diff) | |
| parent | 60b77869e554b6d2b38ea507031926f4effe390a (diff) | |
Merge pull request #13880 from mjstapp/fix_ospf_intf_socket
ospfd: fix per-interface sockets
Diffstat (limited to 'ospfd/ospf_interface.c')
| -rw-r--r-- | ospfd/ospf_interface.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 9e6acdbf0d..840756c05c 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -271,6 +271,10 @@ struct ospf_interface *ospf_if_new(struct ospf *ospf, struct interface *ifp, QOBJ_REG(oi, ospf_interface); + /* If first oi, check per-intf write socket */ + if (ospf->oi_running && ospf->intf_socket_enabled) + ospf_ifp_sock_init(ifp); + if (IS_DEBUG_OSPF_EVENT) zlog_debug("%s: ospf interface %s vrf %s id %u created", __func__, ifp->name, ospf_get_name(ospf), @@ -327,6 +331,8 @@ void ospf_if_cleanup(struct ospf_interface *oi) void ospf_if_free(struct ospf_interface *oi) { + struct interface *ifp = oi->ifp; + ospf_if_down(oi); ospf_fifo_free(oi->obuf); @@ -361,6 +367,10 @@ void ospf_if_free(struct ospf_interface *oi) event_cancel_event(master, oi); + /* If last oi, close per-interface socket */ + if (ospf_oi_count(ifp) == 0) + ospf_ifp_sock_close(ifp); + memset(oi, 0, sizeof(*oi)); XFREE(MTYPE_OSPF_IF, oi); } @@ -1404,7 +1414,8 @@ static int ospf_ifp_up(struct interface *ifp) /* Open per-intf write socket if configured */ ospf = ifp->vrf->info; - if (ospf && ospf->intf_socket_enabled) + + if (ospf && ospf->oi_running && ospf->intf_socket_enabled) ospf_ifp_sock_init(ifp); ospf_if_recalculate_output_cost(ifp); |
