Page MenuHomeFreeBSD

WIP ifnet: Introduce and use ifnet_byindex_attached() for outpath
Needs ReviewPublic

Authored by zlei on Fri, Mar 21, 5:24 PM.

Details

Reviewers
glebius
markj
melifaro
Group Reviewers
network
transport
Summary

An interface will be removed from the global network interface list when
is requested to be detached, either by user or by a hardware event. Once
detached, network applications or sysadmin tools, e.g. ifmcstat(8) and
ifconfig(8), shall make reference to it.

As for moving interface between vnet jails, the interface will be
detached from one jail and later be attached to another. An interface
belongs only to one vnet jail at the same time, so the above statement
still applies.

There're reports that show races between the teardown process and output
path. That, a thread on output path is entering net epoch and is
referencing a detached interface, while the detaching thread is
deallocating resources binded to the interface, notably the address
family dependent data, e.g., if_afdata[AF_INET6]. That will lead to
either NULL pointer derefence or accessing to freed memory.

There're still cases to make references to an interface, so leave
ifnet_byindex() unchanged but introduce a _attached variant. It filter
only attached ifnet. The _ref variant is redireced to use the _attached
variant. The outpaths are all converted to use the _attached or the _ref
variant.

PR: 279653
PR: 285129
MFC after: 1 month

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

zlei requested review of this revision.Fri, Mar 21, 5:24 PM

This is still WIP, but I want it open for discussing. ifnet_byindex() is renamed to ifnet_byindex_ori() only to show clearly all its usage. Will not be in the final revision.

zlei retitled this revision from ifnet: Introduce and use ifnet_byindex_attached() for outpath to WIP ifnet: Introduce and use ifnet_byindex_attached() for outpath.Fri, Mar 21, 5:27 PM

So instead of a lockless check for IFF_DYING you use lockless check for presence in STAILQ. I don't see a principal change here, but it could make the races less probable.

Do I understand it right that the goal is for the output path to stop "seeing" an interface that is being detached earlier?