public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] conf: Demote overlapping port ranges error to a warning
@ 2023-08-11  7:36 David Gibson
  2023-08-13 16:31 ` Stefano Brivio
  0 siblings, 1 reply; 2+ messages in thread
From: David Gibson @ 2023-08-11  7:36 UTC (permalink / raw)
  To: passt-dev, Stefano Brivio; +Cc: Daniel Rudolf, David Gibson

We give a fatal error if the port ranges from any port forwarding
specifiers overlap.  This occurs even if those port ranges are specifically
bound to different addresses, so there's not really any overlap.

Right now, we can't 100% handle this case correctly, because our data
structures don't have a way to represent per-address forwarding.  However,
there are a number of cases that will actually work just fine: e.g. mapping
the same port to the same port on two different addresses (say :: and
127.0.0.1).

We have long term plans to fix this properly, but that is still some time
away.  For the time being, demote this error to a warning so that the cases
that already work will be allowed.

Link: https://bugs.passt.top/show_bug.cgi?id=56

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 conf.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/conf.c b/conf.c
index 0631b00..0ad6e23 100644
--- a/conf.c
+++ b/conf.c
@@ -303,7 +303,7 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg,
 
 		for (i = xrange.first; i <= xrange.last; i++) {
 			if (bitmap_isset(exclude, i))
-				goto overlap;
+				die("Overlapping excluded ranges %s", optarg);
 
 			bitmap_set(exclude, i);
 		}
@@ -370,7 +370,8 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg,
 
 		for (i = orig_range.first; i <= orig_range.last; i++) {
 			if (bitmap_isset(fwd->map, i))
-				goto overlap;
+				warn(
+"Altering mapping of already mapped port number: %s", optarg);
 
 			if (bitmap_isset(exclude, i))
 				continue;
@@ -406,8 +407,6 @@ enfile:
 	die("Can't open enough sockets for port specifier: %s", optarg);
 bad:
 	die("Invalid port specifier %s", optarg);
-overlap:
-	die("Overlapping port specifier %s", optarg);
 mode_conflict:
 	die("Port forwarding mode '%s' conflicts with previous mode", optarg);
 bind_fail:
-- 
@@ -303,7 +303,7 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg,
 
 		for (i = xrange.first; i <= xrange.last; i++) {
 			if (bitmap_isset(exclude, i))
-				goto overlap;
+				die("Overlapping excluded ranges %s", optarg);
 
 			bitmap_set(exclude, i);
 		}
@@ -370,7 +370,8 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg,
 
 		for (i = orig_range.first; i <= orig_range.last; i++) {
 			if (bitmap_isset(fwd->map, i))
-				goto overlap;
+				warn(
+"Altering mapping of already mapped port number: %s", optarg);
 
 			if (bitmap_isset(exclude, i))
 				continue;
@@ -406,8 +407,6 @@ enfile:
 	die("Can't open enough sockets for port specifier: %s", optarg);
 bad:
 	die("Invalid port specifier %s", optarg);
-overlap:
-	die("Overlapping port specifier %s", optarg);
 mode_conflict:
 	die("Port forwarding mode '%s' conflicts with previous mode", optarg);
 bind_fail:
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] conf: Demote overlapping port ranges error to a warning
  2023-08-11  7:36 [PATCH] conf: Demote overlapping port ranges error to a warning David Gibson
@ 2023-08-13 16:31 ` Stefano Brivio
  0 siblings, 0 replies; 2+ messages in thread
From: Stefano Brivio @ 2023-08-13 16:31 UTC (permalink / raw)
  To: David Gibson; +Cc: passt-dev, Daniel Rudolf

On Fri, 11 Aug 2023 17:36:00 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:

> We give a fatal error if the port ranges from any port forwarding
> specifiers overlap.  This occurs even if those port ranges are specifically
> bound to different addresses, so there's not really any overlap.
> 
> Right now, we can't 100% handle this case correctly, because our data
> structures don't have a way to represent per-address forwarding.  However,
> there are a number of cases that will actually work just fine: e.g. mapping
> the same port to the same port on two different addresses (say :: and
> 127.0.0.1).
> 
> We have long term plans to fix this properly, but that is still some time
> away.  For the time being, demote this error to a warning so that the cases
> that already work will be allowed.
> 
> Link: https://bugs.passt.top/show_bug.cgi?id=56
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Also applied.

-- 
Stefano


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-13 16:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-11  7:36 [PATCH] conf: Demote overlapping port ranges error to a warning David Gibson
2023-08-13 16:31 ` Stefano Brivio

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).