Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Jul 2026 20:30:26 +0000
From:      Paige Thompson <paigeadele@gmail.com>
To:        Adrian Chadd <adrian@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: ifconfig patch that introduces --libxo
Message-ID:  <CACF2tH-tUj1NDsg%2B_TJ0ZmDfHkhECP7%2BBXHJuwdH9JEyhR9JEg@mail.gmail.com>
In-Reply-To: <CAJ-VmokGLQ4Eu72GFDZ43_0rWJ3ZRRcn4XjBkGkWLtNnJT98cQ@mail.gmail.com>
References:  <CACF2tH97GaQ9T%2BoZ-ApzRe3py5GyBbDL%2BKJx3AUx_ixEp1bvDg@mail.gmail.com> <CAJ-VmokGLQ4Eu72GFDZ43_0rWJ3ZRRcn4XjBkGkWLtNnJT98cQ@mail.gmail.com>

index | next in thread | previous in thread | raw e-mail

Hey Adrian,

Absolutely I am fine with this taking as much time as it needs because
I want it to succeed but also the value that it's adding long term I
think is pretty substantial. For regression testing like I used:

bash -c 'diff -y <(ifconfig) <(./ifconfig)' and I've most of them, I
still need to see about fully configured tunnels and CARP interfaces,
and possibly some others;

I also just discovered that there is a perl script that you can use to
lint the formatter strings:

../../contrib/libxo/xolint/xolint.pl:

xolint [options] files ...
    -c    invoke 'cpp' on input
    -C flags   Pass flags to cpp
    -d         Show debug output
    -D         Extract xolint documentation
    -I         Print xo_info_t data
    -p         Print input data on errors
    -V         Print vocabulary (list of tags)
    -X         Print examples of invalid use

[sq@msi /usr/src/sbin/ifconfig]$ perl ../../contrib/libxo/xolint/xolint.pl *.c
af_inet.c: 96: error: use hyphens, not underscores, for value field name
af_inet.c: 96: error: value field name contains invalid character (inet_addr)
af_inet.c: 115: error: use hyphens, not underscores, for value field name

which actually brings me to the next thing that I was going to ask
about but it sounds like based on the linter I should probably use
hyphens instead of underscores xD

I'll can come up with some tests in /usr/src/sbin/ifconfig/tests, one
that uses the linter tool provided and the regression in terms of how
I'm doing it now would be pretty ineffective after the changes are in
place (it assumes host's ifconfig hasn't yet been replaced by the one
that uses libxo.)

>  If you're interested in pushing this up for review, I suggest thinking about how to do it piecemeal.

Definitely, I have an account on reviews.freebsd.org but I don't
currently have permissions for anything so I'm not sure that I can do
much with it except for viewing:
https://reviews.freebsd.org/p/paige_paige.bio/ and I just verified an
updated email for it so it should be good to go if that's the thing I
need to use I just need permissions. Could you help me with that or to
find the right place if not reviews?

Thank you,

-Paige

On Tue, Jul 28, 2026 at 3:58 PM Adrian Chadd <adrian@freebsd.org> wrote:
>
> This is pretty neat, thanks!
>
> I think the next step here (and it's bitten us before, heh) is some
> way to validate the libxo output and
> that we haven't regressed (too badly) the output of ifconfig.
>
> It's also an interesting deep dive into ifconfig to see what stuff in
> ifconfig should really be moved into
> libraries that do work (like what we're slowly doing with 802.11 stuff
> into its own library).
>
> If you're interested in pushing this up for review, I suggest thinking
> about how to do it
> piecemeal. Eg, maybe add the basic libxo helper stuff first, add
> whatever refactoring bits
> you need, and then individual commits for each part of ifconfig
> (bridge, wifi, vlan, ethernet,
> etc) so they can be individually reviewed by a smaller set of people
> who focus on those areas.
>
>
>
> -adrian
>
> On Sun, 26 Jul 2026 at 15:54, Paige Thompson <paigeadele@gmail.com> wrote:
> >
> > Hi,
> >
> > I have a patch for sbin/ifconfig in the works that I'd like to
> > eventually submit at some point. The patch covers the full summary of
> > interfaces and allows you to export interface data as JSON, XML or
> > HTML. It uses a library that is already in-tree and used by netstat
> > (you can export route tables in JSON / XML or HTML already. This patch
> > does pretty much the same thing for ifconfig but it's obviously a
> > little more complicated considering the number of options it had to
> > cover:
> >
> > fconfig_libxo_support.patch:
> > https://gist.github.com/paigeadelethompson/5dd1b998d599ed7d147fd37a6aa90b2e
> >
> > I've also done my best to ensure that it doesn't change how ifconfig
> > normally displays summaries; it still uses libxo but defaults to
> > --libxo text if you don't specify --libxo as an argument and I've
> > maintained the same output format that it had with all of the printf
> > statements.
> >
> > I've been testing it thoroughly, and all of the work I'm doing going
> > forward I've been tracking on this gist, I've also updated the
> > original patch file a couple of times. I've never submitted a patch to
> > FreeBSD before, but I'm really okay with this taking as long as it
> > needs to because I think it's particularly useful and I'd prefer to
> > get it right the first time rather than have it ruin somebody's day.
> > I'm also interested in submitting two other patches that I haven't
> > started yet:
> >
> > - Another for ifconfig; specifically one that would allow you to
> > configure networking interfaces from an XML file (it would use the
> > expat / bsdxml.h parser to read in ifconfig data exported with
> > `ifconfig --libxo xml` (example: https://termbin.com/efqhl )
> >
> > - a patch for route which can restore routing tables; I made a little
> > proof of concept that kind of does this with netstat / jq awhile ago:
> > https://gist.github.com/paigeadelethompson/d99e6bb0aab4ae2fa6a066217831840c
> > but rather the way I have in mind would essentially be:
> >
> > netstat --libxo xml -nr -F 1 > 1.xml
> > route --restore-from 1.xml
> >
> > and the patch to route would also use the in-tree expat (bsdxml.h)
> > parser that's available.
> >
> > The problem that it solves from my perspective is that its a step
> > towards eliminating the amount of complex networking configuration
> > that I have to maintain in my rc.conf which for me and I'm sure for
> > anybody who has tried to build segmented networks for jails, and
> > virtual machines it has potential to get pretty ridiculous, especially
> > routes: https://termbin.com/lrt80
> >
> > And even if I didn't have to use epairs and could use something like
> > say... if_mpe if it existed, rc.conf would still be less than ideal
> > for static protocol routing; BGP isn't even an option here yet that's
> > something else I want to work towards.
> >
> > I have to run, I've been working on this all morning, and made lots of
> > progress testing. I'll follow up this evening.
> >


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACF2tH-tUj1NDsg%2B_TJ0ZmDfHkhECP7%2BBXHJuwdH9JEyhR9JEg>