Page MenuHomeFreeBSD

sbin/ifconfig: Use libifconfig to get bridge status
ClosedPublic

Authored by freqlabs on Feb 26 2021, 11:17 PM.

Details

Summary

We're already using libifconfig in ifconfig, so this is a fairly simple change.

Test Plan
# ifconfig bridge0 | tee /tmp/a
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	ether 58:9c:fc:10:d9:02
	inet 192.168.1.74 netmask 0xffffff00 broadcast 192.168.1.255
	id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
	maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
	root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
	member: lagg0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
	        ifmaxaddr 0 port 8 priority 128 path cost 2000000
	groups: bridge
	nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
# git stash pop && make -C sbin/ifconfig && make -C sbin/ifconfig install
<snip>
# ifconfig bridge0 | tee /tmp/b
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	ether 58:9c:fc:10:d9:02
	inet 192.168.1.74 netmask 0xffffff00 broadcast 192.168.1.255
	id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
	maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
	root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
	member: lagg0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
	        ifmaxaddr 0 port 8 priority 128 path cost 2000000
	groups: bridge
	nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
# cmp /tmp/a /tmp/b && echo nailed it
nailed it

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

freqlabs created this revision.
sbin/ifconfig/ifbridge.c
166–167

At what point to we switch to a single global lifh variable throughout ifconfig?

175–227

I think style(9) still wants us to put those at the top of the block.

201

bridge->members[i]?

freqlabs added inline comments.
sbin/ifconfig/ifbridge.c
166–167

My thinking is that eventually it will be possible to replace the socket parameter s with a lifh parameter for the handle for all these command handlers. A global handle could work in the meantime.

kp added inline comments.
sbin/ifconfig/ifbridge.c
166–167

Yeah, that works too.

ifconfig is mostly old, and in desperate need of some more cleanup. Hopefully moving things in libifconfig will make that easier.

This revision is now accepted and ready to land.Feb 28 2021, 4:01 PM