Page MenuHomeFreeBSD

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

Authored by glebius on Dec 15 2025, 7:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jan 18, 11:20 AM
Unknown Object (File)
Fri, Jan 16, 12:30 PM
Unknown Object (File)
Thu, Jan 15, 10:16 PM
Unknown Object (File)
Sat, Jan 10, 7:07 AM
Unknown Object (File)
Thu, Jan 8, 1:36 AM
Unknown Object (File)
Tue, Jan 6, 2:33 AM
Unknown Object (File)
Tue, Jan 6, 1:25 AM
Unknown Object (File)
Mon, Jan 5, 3:12 AM

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Dec 15 2025, 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.

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.

Nice explain!