From 9d4b870b0f5b5e2f1547a93f2a040ebaf66bea44 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 --- 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 53b042d6f..339e458a2 100644 --- a/kernel-module/xt_RTPENGINE.c +++ b/kernel-module/xt_RTPENGINE.c @@ -1319,7 +1319,6 @@ next_rda: *addr_bucket = ab; *port = (hi << 8) | lo; - (*port)++; return g; } @@ -1383,6 +1382,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) @@ -1465,7 +1465,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; @@ -1478,6 +1478,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;