On Wednesday 02 May 2007 15:13, Natanael Copa wrote:
> On Wed, 2007-05-02 at 02:38 +0200, Denis Vlasenko wrote: 
> > On Tuesday 01 May 2007 02:27, Nathan Angelacos wrote:
> > > Hello,
> > > 
> > > The ifupdown applet in 1.5.0 appears to have a bug that was not present
> > > in 1.4.1.  The bug is that /var/run/ifstate is not updated with all
> > > interfaces if an interface stanza calls ifup statement to bring up a
> > > second interface.
> ... 
> > You can attempt to go after these solutions:
> > 
> > (a) provide a patch for ifupdown to read/write
> >     /var/run/ifstate AFTER child if done.
> 
> 
> Attatched.
> 
> The patch also removes this dead code (and memory leak):
> -                     /* iface_down */
> -                     const llist_t *list = state_list;
> -                     while (list) {
> -                             llist_add_to_end(&target_list, 
> xstrdup(list->data));
> -                             list = list->link;
> -                     }
> -                     target_list = defn->autointerfaces;
> 
> (first copy state_list to target_list and next second just reassign
> target_list???)

Probably last line was a leftover...
But I think you code looks better anyway.

Nathan, care to test Natanael's patch?


> It would be nice if patch could go into 1.5.1.


Small question: after else below, we build new list,
write it out if !NO_ACT, and then delete.

If NO_ACT is true, then list is build and then deleted
without any useful effect.

Should we replace "else {...}" with "else if (!NO_ACT) {...}" ?

                if (!okay && !FORCE) {
                        bb_error_msg("ignoring unknown interface %s", liface);
                        any_failures = 1;
                } else {
                        /* update the state file */
                        llist_t *state_list = read_iface_state();
                        llist_t *iface_state = find_iface_state(state_list, 
iface);

                        if (cmds == iface_up) {
                                char * const newiface = xasprintf("%s=%s", 
iface, liface);
                                if (iface_state == NULL) {
                                        llist_add_to_end(&state_list, newiface);
                                } else {
                                        free(iface_state->data);
                                        iface_state->data = newiface;
                                }
                        } else {
                                /* Remove an interface from state_list */
                                llist_unlink(&state_list, iface_state);
                                free(llist_pop(&iface_state));
                        }

                        /* Actually write the new state */
                        if (!NO_ACT) {
                                FILE *state_fp = xfopen("/var/run/ifstate", 
"w");
                                llist_t *state = state_list;
                                while (state) {
                                        if (state->data) {
                                                fprintf(state_fp, "%s\n", 
state->data);
                                        }
                                        state = state->link;
                                }
                                fclose(state_fp);
                        }
                        llist_free(state_list, free);
                }


--
vda
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to