Page MenuHomeFreeBSD

add ADDR_ADD and ADDR_DEL devctl event for IFNET
ClosedPublic

Authored by rozhuk.im-gmail.com on Jun 21 2021, 11:11 AM.

Details

Summary

Add devd event on network iface address add/remove.
Can be used to automate actions on any address change.

Test Plan

Apply patch, rebuild and reinstall kernel.

Run in terminal1:
cat /var/run/devd.pipe

In terminal2:
ifconfig lan0 alias 192.168.1.1/24
ifconfig lan0 -alias 192.168.1.1
ifconfig lan0 inet6 1111::

Result
terminal1 will produce output:
!system=IFNET subsystem=lan0 type=ADDR_ADD address=192.168.1.1
!system=IFNET subsystem=lan0 type=ADDR_DEL address=192.168.1.1
!system=IFNET subsystem=lan0 type=ADDR_ADD address=1111::

*lan0 must me replaced with real network interface name.

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

can you add the ADDR_ADD and ADDR_DEL to the table in sbin/devd/devd.conf.5 please?

Add "#if defined(INET) || defined(INET6)" for vars.

This revision is now accepted and ready to land.Jun 23 2021, 3:51 PM

Note: minor style tweaks I've noted here I've just done when landing.

sys/net/route.c
705

A blank line is needed before inet_ntoa_r.
Also, that can be on one line
Also, there's at least one extra set of parens here.

716

a blank line is needed between the strbuf and ip6_sprintf lines.