aboutgitcodebugslistschat
diff options
context:
space:
mode:
-rw-r--r--conf.c8
-rw-r--r--fwd.c15
-rw-r--r--fwd.h2
3 files changed, 10 insertions, 15 deletions
diff --git a/conf.c b/conf.c
index 6ca61b7..7a3085b 100644
--- a/conf.c
+++ b/conf.c
@@ -282,9 +282,7 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg,
*mode = FWD_MODE_ALL;
/* Exclude ephemeral ports */
- for (i = 0; i < NUM_PORTS; i++)
- if (fwd_port_is_ephemeral(i))
- bitmap_set(exclude, i);
+ fwd_port_map_ephemeral(exclude);
conf_ports_range_except(c, optname, optarg, fwd,
NULL, NULL,
@@ -376,9 +374,7 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg,
if (exclude_only) {
/* Exclude ephemeral ports */
- for (i = 0; i < NUM_PORTS; i++)
- if (fwd_port_is_ephemeral(i))
- bitmap_set(exclude, i);
+ fwd_port_map_ephemeral(exclude);
conf_ports_range_except(c, optname, optarg, fwd,
addr, ifname,
diff --git a/fwd.c b/fwd.c
index 03652b2..62d344c 100644
--- a/fwd.c
+++ b/fwd.c
@@ -319,16 +319,15 @@ static const union inany_addr *fwd_rule_addr(const struct fwd_rule *rule)
}
/**
- * fwd_port_is_ephemeral() - Is port number ephemeral?
- * @port: Port number
- *
- * Return: true if @port is ephemeral, that is may be allocated by the kernel as
- * a local port for outgoing connections or datagrams, but should not be
- * used for binding services to.
+ * fwd_port_map_ephemeral() - Mark ephemeral ports in a bitmap
+ * @map: Bitmap to update
*/
-bool fwd_port_is_ephemeral(in_port_t port)
+void fwd_port_map_ephemeral(uint8_t *map)
{
- return (port >= fwd_ephemeral_min) && (port <= fwd_ephemeral_max);
+ unsigned port;
+
+ for (port = fwd_ephemeral_min; port <= fwd_ephemeral_max; port++)
+ bitmap_set(map, port);
}
/* Forwarding table storage, generally accessed via pointers in struct ctx */
diff --git a/fwd.h b/fwd.h
index b387d92..f111e13 100644
--- a/fwd.h
+++ b/fwd.h
@@ -22,7 +22,7 @@ struct flowside;
#define NUM_PORTS (1U << 16)
void fwd_probe_ephemeral(void);
-bool fwd_port_is_ephemeral(in_port_t port);
+void fwd_port_map_ephemeral(uint8_t *map);
/**
* struct fwd_rule - Forwarding rule governing a range of ports