Page MenuHomeFreeBSD

ng_iface: don't recursively enter epoch in the rcvdata method
AcceptedPublic

Authored by glebius on Mon, Dec 15, 7:50 PM.

Details

Reviewers
zlei
p.mousavizadeh_protonmail.com
Group Reviewers
network

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 69278
Build 66161: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Mon, Dec 15, 8:04 PM

I'm not familiar with netgraph. While I'm finding possible missing of net epoch context,

# grep -r 'ng_package_data' sys/netgraph
sys/netgraph/netflow/netflow.c:		item = ng_package_data(m, NG_NOFLAGS);
sys/netgraph/netflow/netflow_v9.c:		item = ng_package_data(m, NG_NOFLAGS);
sys/netgraph/netgraph.h:		if ((_item = ng_package_data((m), flags))) {		\
sys/netgraph/netgraph.h:item_p	ng_package_data(struct mbuf *m, int flags);
sys/netgraph/ng_ppp.c:				item = ng_package_data(m, NG_NOFLAGS);
sys/netgraph/ng_ppp.c:		if ((item = ng_package_data(m, NG_NOFLAGS)) != NULL) {
sys/netgraph/ng_ppp.c:				item = ng_package_data(m2, NG_NOFLAGS);
sys/netgraph/ng_base.c:ng_package_data(struct mbuf *m, int flags)
sys/netgraph/ng_socket.c:	item = ng_package_data(m, NG_WAITOK);
sys/netgraph/ng_socket.c:	 * Use ng_package_data() and ng_address_path() to do this.
sys/netgraph/ng_socket.c:	item = ng_package_data(NULL, NG_WAITOK);

It appears only ng_socket.c has done right. netflow.c, netflow_v9.c and ng_ppp.c lack proper net epoch context around NG_FWD_ITEM_HOOK(), then this change can lead regression and NET_EPOCH_ASSERT() will complain.

I'm not familiar with netgraph. While I'm finding possible missing of net epoch context,

Okay, here is a short description. When data travels through netgraph(4) the context SHALL be in the net epoch. Thus, any rcvdata method is entered with the epoch.

It appears only ng_socket.c has done right. netflow.c, netflow_v9.c and ng_ppp.c lack proper net epoch context around NG_FWD_ITEM_HOOK(), then this change can lead regression and NET_EPOCH_ASSERT() will complain.

The ng_socket.c is an edge type of a node. It means that it has one side facing into netgraph and one side facing into somewhere else (write(2) syscall in case of ng_socket(4). The edge nodes are responsible for entering epoch when they inject data into netgraph. The netflow and ppp nodes are not edge nodes.