conntrack: Don't override mark in non-list mode
PATCH 1/1 conntrack: Don't override mark in non-list mode
When creating new rules with (e.g. with conntrack -I -m 123 -u UNSET ...), the mark from -m was overriden by value from -u. Additional condition ensures that this happens only in list mode.
This behavior was introduced in 1a5828f491c6a1593f30cb5f1551fe9f9cf76a8d ("conntrack: enable kernel-based status filtering with -L -u STATUS") for filtering the output of -L option but caused a regression in other cases.
--- src/conntrack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
src/conntrack.c +3 -1
@@ -3007,7 +3007,9 @@ static void do_parse(struct ct_cmd *ct_cmd, int argc, char *argv[])if (tmpl->filter_status_kernel.mask ==0 ) tmpl->filter_status_kernel.mask = status; - tmpl->mark.value = status; +// set mark only in list mode to not override value from -m +if (command &CT_LIST ) + tmpl->mark.value = status; tmpl->filter_status_kernel.val = tmpl->mark.value; tmpl->filter_status_kernel_set = true;break ;
Signature · 1 line
2.35.3
Pablo Neira Ayuso
maintainerHi,
Cc'ing Florian.
Quoted 7 lines · Jacek Tomasiak
When creating new rules with (e.g. with
conntrack -I -m 123 -u UNSET ...), the mark from-mwas overriden by value from-u. Additional condition ensures that this happens only in list mode.This behavior was introduced in
1a5828f491c6a1593f30cb5f1551fe9f9cf76a8d("conntrack: enable kernel-based status filtering with -L -u STATUS") for filtering the output of-Loption but caused a regression in other cases.
In 1a5828f491c6a:
tmpl->mark.value = status;
tmpl->filter_status_kernel.val = tmpl->mark.value;Not sure what the mark has to do this the -L -u STATUS filtering.
Quoted 11 lines
Signed-off-by Jacek Tomasiak <[email protected]>Signed-off-by Jacek Tomasiak <[email protected]>--- src/conntrack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)src/conntrack.c +0
-0
src/conntrack.c static void do_parse(struct ct_cmd *ct_cmd, int argc, char *argv[]) · line 3012
Quoted 7 lines
src/conntrack.c +3
-1@@ -3007,7 +3007,9 @@ static void do_parse(struct ct_cmd *ct_cmd, int argc, char *argv[])if (tmpl->filter_status_kernel.mask ==0 ) tmpl->filter_status_kernel.mask = status; - tmpl->mark.value = status; +// set mark only in list mode to not override value from -m +if (command &CT_LIST ) + tmpl->mark.value = status;
The existing code also means that -L -u STATUS cannot be combined with -L -m mark, right?
Quoted 6 lines
src/conntrack.c +0
-0tmpl->filter_status_kernel.val = tmpl->mark.value; tmpl->filter_status_kernel_set = true;break ;Signature · 1 line
2.35.3
Florian Westphal
maintainerQuoted 34 lines · Pablo Neira Ayuso
Hi,
Cc'ing Florian.
Quoted 7 lines · Jacek Tomasiak
When creating new rules with (e.g. with
conntrack -I -m 123 -u UNSET ...), the mark from-mwas overriden by value from-u. Additional condition ensures that this happens only in list mode.This behavior was introduced in
1a5828f491c6a1593f30cb5f1551fe9f9cf76a8d("conntrack: enable kernel-based status filtering with -L -u STATUS") for filtering the output of-Loption but caused a regression in other cases.In
1a5828f491c6a:tmpl->mark.value = status; tmpl->filter_status_kernel.val = tmpl->mark.value;Not sure what the mark has to do this the -L -u STATUS filtering.
Quoted 14 lines
Signed-off-by Jacek Tomasiak <[email protected]>Signed-off-by Jacek Tomasiak <[email protected]>--- src/conntrack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)src/conntrack.c +0
-0@@ -3007,7 +3007,9 @@ static void do_parse(struct ct_cmd *ct_cmd, int argc, char *argv[])if (tmpl->filter_status_kernel.mask ==0 ) tmpl->filter_status_kernel.mask = status;
Quoted 4 lines
src/conntrack.c static void do_parse(struct ct_cmd *ct_cmd, int argc, char *argv[]) · line 3012
Quoted 4 lines
src/conntrack.c +3
-1- tmpl->mark.value = status; +// set mark only in list mode to not override value from -m +if (command &CT_LIST ) + tmpl->mark.value = status;
This should be
- tmpl->mark.value = status;
- tmpl->filter_status_kernel.val = tmpl->mark.value;
+ tmpl->filter_status_kernel.val = status;
tmpl->filter_status_kernel_set = true;Quoted 2 lines
The existing code also means that -L -u STATUS cannot be combined with -L -m mark, right?
This is a bug.
conntrack -L -u status -m 1 will work, -m 1 -u status won't work.
The clobbering of mark utterly bogus.
Florian Westphal
maintainersrc/conntrack.c static void do_parse(struct ct_cmd *ct_cmd, int argc, char *argv[]) · line 3014
Quoted 6 lines · Florian Westphal
This should be
src/conntrack.c +1
-2- tmpl->mark.value = status; - tmpl->filter_status_kernel.val = tmpl->mark.value; + tmpl->filter_status_kernel.val = status; tmpl->filter_status_kernel_set = true;
I've pushed Jaceks patch with the content amended as above.
Jan, please report if that doesn't resolve the bug you reported.
Thanks everyone.