ifconfig patch that introduces --libxo

Paige Thompson <[email protected]> Sun, 26 Jul 2026 22:54:30 +0000
Newsgroups gmane.os.freebsd.devel.hackers
Message-ID <CACF2tH97GaQ9T+oZ-ApzRe3py5GyBbDL+KJx3AUx_ixEp1bvDg@mail.gmail.com>
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.