@@ -139,95 +139,53 @@ static confd_dependency_t handle_dependencies(struct lyd_node **diff, struct lyd
139139 }
140140
141141 /* Check if any wifi-ap interface changed, add all wifi-ap interfaces and their radios to diff */
142- struct ly_set * diff_ifaces = lydx_find_xpathf (* diff , "/ietf-interfaces:interfaces/interface" );
143- if (diff_ifaces && diff_ifaces -> count > 0 ) {
144- bool has_wifi_ap_change = false;
145- uint32_t i ;
146-
147- /* Check if any changed interface is a wifi-ap interface */
148- for (i = 0 ; i < diff_ifaces -> count ; i ++ ) {
149- struct lyd_node * diff_iface = diff_ifaces -> dnodes [i ];
150- const char * ifname = lydx_get_cattr (diff_iface , "name" );
151- struct lyd_node * config_iface ;
152- const char * type = NULL ;
153-
154- if (!ifname )
155- continue ;
156-
157- /* Look up the interface in config to check its type */
158- config_iface = lydx_get_xpathf (config , "/ietf-interfaces:interfaces/interface[name='%s']" , ifname );
159- if (config_iface ) {
160- type = lydx_get_cattr (config_iface , "type" );
161- } else {
162- /* Interface not in config (being deleted), check diff node */
163- type = lydx_get_cattr (diff_iface , "type" );
164- }
165-
166- if (type && strstr (type , "wifi-ap" )) {
167- has_wifi_ap_change = true;
168- break ;
169- }
170- }
171-
172- if (has_wifi_ap_change ) {
173- /* Add all wifi-ap interfaces from config to diff */
174- struct ly_set * wifi_ap_ifaces = lydx_find_xpathf (config , "/ietf-interfaces:interfaces/interface[type='infix-if-type:wifi-ap']" );
175- for (i = 0 ; wifi_ap_ifaces && i < wifi_ap_ifaces -> count ; i ++ ) {
176- struct lyd_node * iface = wifi_ap_ifaces -> dnodes [i ];
177- struct lyd_node * wifi_node , * radio_node ;
178- const char * ifname , * radio_name ;
179- char xpath [256 ];
142+ struct ly_set * diff_ifaces = lydx_find_xpathf (* diff , "/ietf-interfaces:interfaces/interface[type='infix-if-type:wifi-ap']" );
143+ if (diff_ifaces ) {
144+ struct ly_set * wifi_ap_ifaces = lydx_find_xpathf (config , "/ietf-interfaces:interfaces/interface[type='infix-if-type:wifi-ap']" );
145+ size_t i ;
146+
147+ for (i = 0 ; wifi_ap_ifaces && i < wifi_ap_ifaces -> count ; i ++ ) {
148+ struct lyd_node * iface = wifi_ap_ifaces -> dnodes [i ];
149+ struct lyd_node * wifi_node , * radio_node ;
150+ const char * ifname , * radio_name ;
151+ char xpath [256 ];
152+
153+ ifname = lydx_get_cattr (iface , "name" );
154+ wifi_node = lydx_get_child (iface , "wifi" );
155+
156+ if (wifi_node ) {
157+ /* Add the radio attribute to the diff */
158+ radio_node = lydx_get_child (wifi_node , "radio" );
159+ radio_name = lyd_get_value (radio_node );
160+ /* Add radio attribute to wifi-ap interface in diff */
161+ snprintf (xpath , sizeof (xpath ),
162+ "/ietf-interfaces:interfaces/interface[name='%s']/infix-interfaces:wifi/radio" ,
163+ ifname );
164+ result = add_dependencies (diff , xpath , radio_name );
165+ if (result == CONFD_DEP_ERROR ) {
166+ ERROR ("Failed to add radio attribute to wifi-ap %s in diff" , ifname );
167+ ly_set_free (wifi_ap_ifaces , NULL );
168+ goto err ;
169+ }
180170
181- ifname = lydx_get_cattr (iface , "name" );
182- wifi_node = lydx_get_child (iface , "wifi" );
183-
184- if (wifi_node ) {
185- /* Add wifi node to trigger reprocessing of all wifi-ap interfaces */
186- snprintf (xpath , sizeof (xpath ),
187- "/ietf-interfaces:interfaces/interface[name='%s']/infix-interfaces:wifi" ,
188- ifname );
189- result = add_dependencies (diff , xpath , "" );
190- if (result == CONFD_DEP_ERROR ) {
191- ERROR ("Failed to add wifi-ap %s to diff" , ifname );
192- ly_set_free (wifi_ap_ifaces , NULL );
193- ly_set_free (diff_ifaces , NULL );
194- return result ;
195- }
196-
197- /* Add the radio attribute to the diff */
198- radio_node = lydx_get_child (wifi_node , "radio" );
199- radio_name = lyd_get_value (radio_node );
200- /* Add radio attribute to wifi-ap interface in diff */
201- snprintf (xpath , sizeof (xpath ),
202- "/ietf-interfaces:interfaces/interface[name='%s']/infix-interfaces:wifi/radio" ,
203- ifname );
204- result = add_dependencies (diff , xpath , radio_name );
205- if (result == CONFD_DEP_ERROR ) {
206- ERROR ("Failed to add radio attribute to wifi-ap %s in diff" , ifname );
207- ly_set_free (wifi_ap_ifaces , NULL );
208- ly_set_free (diff_ifaces , NULL );
209- return result ;
210- }
211-
212- /* Add the referenced radio interface (type wifi) to diff */
213- snprintf (xpath , sizeof (xpath ),
214- "/ietf-interfaces:interfaces/interface[name='%s']/infix-interfaces:wifi" ,
215- radio_name );
216- result = add_dependencies (diff , xpath , "" );
217- if (result == CONFD_DEP_ERROR ) {
218- ERROR ("Failed to add radio interface %s to diff" , radio_name );
219- ly_set_free (wifi_ap_ifaces , NULL );
220- ly_set_free (diff_ifaces , NULL );
221- return result ;
222- }
171+ /* Add the referenced radio interface (type wifi) to diff */
172+ snprintf (xpath , sizeof (xpath ),
173+ "/ietf-interfaces:interfaces/interface[name='%s']/infix-interfaces:wifi" ,
174+ radio_name );
175+ result = add_dependencies (diff , xpath , "" );
176+ if (result == CONFD_DEP_ERROR ) {
177+ ERROR ("Failed to add radio interface %s to diff" , radio_name );
178+ ly_set_free (wifi_ap_ifaces , NULL );
179+ goto err ;
223180 }
224181 }
225- if (wifi_ap_ifaces )
226- ly_set_free (wifi_ap_ifaces , NULL );
227182 }
228183
229- ly_set_free (diff_ifaces , NULL );
184+ if (wifi_ap_ifaces )
185+ ly_set_free (wifi_ap_ifaces , NULL );
230186 }
187+ err :
188+ ly_set_free (diff_ifaces , NULL );
231189
232190 return result ;
233191}
0 commit comments