diff options
| author | Mark Stapp <mjs@labn.net> | 2023-03-29 16:58:25 -0400 | 
|---|---|---|
| committer | Mark Stapp <mjs@labn.net> | 2023-04-11 10:16:07 -0400 | 
| commit | 04a0401f2de44feaadb8f90aae0f53f55580415e (patch) | |
| tree | 2977bbd8a315abd0b5389735360d2f80fbf68503 /ospfd/ospf_interface.c | |
| parent | e80c797a1f8f98c129a9605a174d451356dde008 (diff) | |
ospfd: support write socket per interface
Add support for a write socket per interface, enabled by
default at the ospf instance level. An ospf instance-level
config allows this to be disabled, reverting to the older
behavior where a single per-instance socket is used for
sending and receiving packets.
Signed-off-by: Mark Stapp <mjs@labn.net>
Diffstat (limited to 'ospfd/ospf_interface.c')
| -rw-r--r-- | ospfd/ospf_interface.c | 28 | 
1 files changed, 24 insertions, 4 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 649ba70e02..5742ece1f7 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -651,6 +651,8 @@ int ospf_if_new_hook(struct interface *ifp)  	ifp->info = XCALLOC(MTYPE_OSPF_IF_INFO, sizeof(struct ospf_if_info)); +	IF_OSPF_IF_INFO(ifp)->oii_fd = -1; +  	IF_OIFS(ifp) = route_table_init();  	IF_OIFS_PARAMS(ifp) = route_table_init(); @@ -691,6 +693,8 @@ static int ospf_if_delete_hook(struct interface *ifp)  {  	int rc = 0;  	struct route_node *rn; +	struct ospf_if_info *oii; +  	rc = ospf_opaque_del_if(ifp);  	/* @@ -707,6 +711,13 @@ static int ospf_if_delete_hook(struct interface *ifp)  	route_table_finish(IF_OIFS(ifp));  	route_table_finish(IF_OIFS_PARAMS(ifp)); +	/* Close per-interface socket */ +	oii = ifp->info; +	if (oii && oii->oii_fd > 0) { +		close(oii->oii_fd); +		oii->oii_fd = -1; +	} +  	XFREE(MTYPE_OSPF_IF_INFO, ifp->info);  	return rc; @@ -1367,6 +1378,16 @@ static int ospf_ifp_up(struct interface *ifp)  	struct ospf_interface *oi;  	struct route_node *rn;  	struct ospf_if_info *oii = ifp->info; +	struct ospf *ospf; + +	if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) +		zlog_debug("Zebra: Interface[%s] state change to up.", +			   ifp->name); + +	/* Open per-intf write socket if configured */ +	ospf = ifp->vrf->info; +	if (ospf && ospf->intf_socket_enabled) +		ospf_ifp_sock_init(ifp);  	ospf_if_recalculate_output_cost(ifp); @@ -1384,10 +1405,6 @@ static int ospf_ifp_up(struct interface *ifp)  		return 0;  	} -	if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) -		zlog_debug("Zebra: Interface[%s] state change to up.", -			   ifp->name); -  	for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {  		if ((oi = rn->info) == NULL)  			continue; @@ -1416,6 +1433,9 @@ static int ospf_ifp_down(struct interface *ifp)  		ospf_if_down(oi);  	} +	/* Close per-interface write socket if configured */ +	ospf_ifp_sock_close(ifp); +  	return 0;  }  | 
