aboutgitcodebugslistschat
path: root/conf.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-09-24 19:08:19 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-09-24 14:48:35 +0200
commitf5a31ee94c37f92729d458335705f5befa168151 (patch)
tree6710d5df183469d10d69c71e1d13ee04f01ba6ae /conf.c
parent1467a35b5af93a5f7c6678e1c6a8d9b4c191160c (diff)
downloadpasst-f5a31ee94c37f92729d458335705f5befa168151.tar
passt-f5a31ee94c37f92729d458335705f5befa168151.tar.gz
passt-f5a31ee94c37f92729d458335705f5befa168151.tar.bz2
passt-f5a31ee94c37f92729d458335705f5befa168151.tar.lz
passt-f5a31ee94c37f92729d458335705f5befa168151.tar.xz
passt-f5a31ee94c37f92729d458335705f5befa168151.tar.zst
passt-f5a31ee94c37f92729d458335705f5befa168151.zip
Don't use indirect remap functions for conf_ports()
Now that we've delayed initialization of the UDP specific "reverse" map until udp_init(), the only difference between the various 'remap' functions used in conf_ports() is which array they target. So, simplify by open coding the logic into conf_ports() with a pointer to the correct mapping array. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/conf.c b/conf.c
index 8940ec4..8424699 100644
--- a/conf.c
+++ b/conf.c
@@ -120,24 +120,24 @@ static int conf_ports(struct ctx *c, char optname, const char *optarg,
{
int start_src, end_src, start_dst, end_dst, exclude_only = 1, i, port;
char addr_buf[sizeof(struct in6_addr)] = { 0 }, *addr = addr_buf;
- void (*remap)(struct ctx *c, in_port_t port, in_port_t delta);
uint8_t exclude[PORT_BITMAP_SIZE] = { 0 };
char buf[BUFSIZ], *sep, *spec, *p;
sa_family_t af = AF_UNSPEC;
+ in_port_t *delta;
uint8_t *map;
if (optname == 't') {
map = c->tcp.fwd_in.map;
- remap = tcp_remap_to_tap;
+ delta = c->tcp.fwd_in.delta;
} else if (optname == 'T') {
map = c->tcp.fwd_out.map;
- remap = tcp_remap_to_init;
+ delta = c->tcp.fwd_out.delta;
} else if (optname == 'u') {
map = c->udp.fwd_in.f.map;
- remap = udp_remap_to_tap;
+ delta = c->udp.fwd_in.f.delta;
} else if (optname == 'U') {
map = c->udp.fwd_out.f.map;
- remap = udp_remap_to_init;
+ delta = c->udp.fwd_out.f.delta;
} else { /* For gcc -O3 */
return 0;
}
@@ -365,8 +365,8 @@ static int conf_ports(struct ctx *c, char optname, const char *optarg,
if (start_dst != -1) {
/* 80:8080 or 22-80:8080:8080 */
- remap(c, i, (in_port_t)(start_dst -
- start_src));
+ delta[i] = (in_port_t)(start_dst -
+ start_src);
}
if (optname == 't')