Hi. On Mon, Aug 27, 2018 at 11:46:37AM -0500, David Wright wrote: > On Mon 27 Aug 2018 at 19:24:01 (+0300), Reco wrote: > > Hi. > > > > On Mon, Aug 27, 2018 at 12:01:23PM -0400, Greg Wooledge wrote: > > > On Mon, Aug 27, 2018 at 06:41:25PM +0300, Reco wrote: > > > > Last sentence says to me that wordexp output should be always sorted. > > > > > > This only tells us that it *reads* the config files in glob-sorted order. > > > And peeking into the actual source code of ifupdown, yes, it appears to > > > do this. (File config.c starting at line 436, in the stretch source.) > > > It even uses wordexp() as advertised. > > > > > > What's less clear to me at this moment is what happens *after* the > > > interface configuration file(s) have been read into memory. > > > > > > Moving over to main.c, it looks like it reads the interfaces (line 639), > > > and that function was called from line 1190. After line 1190, it loops > > > over the "target_iface" array, and processes them in the order they appear > > > in that array. > > > > > > So... next question is how they get packed into that array. > > > > > > Returning to the select_interfaces function, it looks like the ordering > > > is created by a call to find_allowup. > > > > > > And... this is where I stopped reading, because it got confusing. Maybe > > > someone else can take a stab at deciphering that part. > > > > select_interfaces() is called on "ifup -a" invocation. > > read_interfaces() is called by it. > > read_interfaces() calls read_interfaces_defn(). > > read_interfaces_defn() parses "iface" and "source" directives, and calls > > read_interfaces_defn() once again on each file specified by "source" in > > order defined by wordexp(3). > > > > Therefore defn[] array should be filled in this order (assuming that one > > specifies "source" only at /e/n/i): > > > > 1) any interface definition at /e/n/i in order encountered, until > > "source" directive. > > 2) any interface definition provided by "source" directive in order > > defined by wordexp(3). > > 3) any interface definition at /e/n/i in order encountered, after the > > "source" directive. > > > > I'd use ltrace(1) to check it, but building test environment is > > something that I lack the time to do. > > That's still the order in which the stanzas are read. Don't we now > need to know what the contents of each stanza is, ie is it an "auto" > or an "allow-hotplug" stanza, etc?
I simplified things. After defn[] is filled at read_interfaces(), find_allowup() is called, defn[] being the first argument. find_allowup() iterates on defn[], using a pointer to defn->allowups. defn->allowups, unless I'm reading it wrong, is filled by the same read_interfaces_defn(), in the same order that /e/n/i and "source" are evaluated. This filling is done by add_allow_up() each time one specifies "auto" or "allow-" stanzas. Reco