summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorDenys Fedoryshchenko <denys.f@collabora.com>2026-11-08 20:57:38 +0200
committerGitHub <noreply@github.com>2026-11-08 20:57:38 +0200
commitf1612eaefa648a4b6d6fab3c9541647625cf3062 (patch)
treeb2ecac80cf75ae63562934e1c2d24dfc19a74a05 /accel-pppd
parentdb64fd559adce94ad10b121649d87e250dbbf030 (diff)
parent0e4929acd386fd6911825b68d1791c2dd73d3d95 (diff)
downloadaccel-ppp-master.tar.gz
accel-ppp-master.zip
Merge pull request #379 from nuclearcat/fix-read-stats-netnsHEADmaster
session: read interface stats in the session's own netns
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/session.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/accel-pppd/session.c b/accel-pppd/session.c
index c16f68ae..c3e03bb6 100644
--- a/accel-pppd/session.c
+++ b/accel-pppd/session.c
@@ -431,6 +431,8 @@ static void generate_sessionid(struct ap_session *ses)
int __export ap_session_read_stats(struct ap_session *ses, struct rtnl_link_stats64 *stats)
{
struct rtnl_link_stats64 lstats;
+ struct ap_net *saved_net = net;
+ int r;
if (ses->ifindex == -1)
return -1;
@@ -438,7 +440,16 @@ int __export ap_session_read_stats(struct ap_session *ses, struct rtnl_link_stat
if (!stats)
stats = &lstats;
- if (iplink_get_stats(ses->ifindex, stats)) {
+ /* ses->ifindex is only valid inside the session's own network
+ * namespace, so query it through ses->net rather than the thread-local
+ * net. Within the session's context the two are the same, but callers
+ * such as the CLI run on an arbitrary triton thread where net may be
+ * NULL (never set) or still point at another session's namespace. */
+ net = ses->net;
+ r = iplink_get_stats(ses->ifindex, stats);
+ net = saved_net;
+
+ if (r) {
log_ppp_warn("failed to get interface statistics\n");
return -1;
}