From 5b69491c3f11d0b35ce792cf1cc4de515a25b29c Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 27 Apr 2021 11:11:51 -0400 Subject: [PATCH] TT#14008 fix seq_file usage If the seq_file buffer overflows, the printing of the last item is re-tried following a stop/start event on the seq_file. Therefore we cannot unconditionally increase the offset whenever our `next` method is called. closes #1244 Change-Id: I7026deeeb03423cc2da57b1e069019638cf734cf (cherry picked from commit 9d4b870b0f5b5e2f1547a93f2a040ebaf66bea44) --- kernel-module/xt_RTPENGINE.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel-module/xt_RTPENGINE.c b/kernel-module/xt_RTPENGINE.c index 962c02dcf..0a06affac 100644 --- a/kernel-module/xt_RTPENGINE.c +++ b/kernel-module/xt_RTPENGINE.c @@ -1283,7 +1283,6 @@ next_rda: *addr_bucket = ab; *port = (hi << 8) | lo; - (*port)++; return g; } @@ -1347,6 +1346,7 @@ static ssize_t proc_blist_read(struct file *f, char __user *b, size_t l, loff_t addr_bucket = ((int) *o) >> 17; port = ((int) *o) & 0x1ffff; g = find_next_target(t, &addr_bucket, &port); + port++; *o = (addr_bucket << 17) | port; err = 0; if (!g) @@ -1429,7 +1429,7 @@ static void *proc_list_start(struct seq_file *f, loff_t *o) { static void proc_list_stop(struct seq_file *f, void *v) { } -static void *proc_list_next(struct seq_file *f, void *v, loff_t *o) { /* v is invalid */ +static void *proc_list_next(struct seq_file *f, void *v, loff_t *o) { u_int32_t id = (u_int32_t) (unsigned long) f->private; struct rtpengine_table *t; struct rtpengine_target *g; @@ -1442,6 +1442,9 @@ static void *proc_list_next(struct seq_file *f, void *v, loff_t *o) { /* v is in if (!t) return NULL; + if (v) // this is a `next` call + port++; + g = find_next_target(t, &addr_bucket, &port); *o = (addr_bucket << 17) | port;