With previous reworks the icmp_id_map data structure is now maintained, but
never used for anything. Eliminate it.
Signed-off-by: David Gibson
---
icmp.c | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/icmp.c b/icmp.c
index 272edae..4db8003 100644
--- a/icmp.c
+++ b/icmp.c
@@ -51,9 +51,6 @@
#define TAPFSIDE(pingf) (&(pingf)->f.side[TAPSIDE])
#define SOCKFSIDE(pingf) (&(pingf)->f.side[SOCKSIDE])
-/* Indexed by ICMP echo identifier */
-static struct icmp_ping_flow *icmp_id_map[IP_VERSIONS][ICMP_NUM_IDS];
-
/**
* icmp_sock_handler() - Handle new data from ICMP or ICMPv6 socket
* @c: Execution context
@@ -147,17 +144,11 @@ static void icmp_ping_close(const struct ctx *c, struct icmp_ping_flow *pingf)
epoll_ctl(c->epollfd, EPOLL_CTL_DEL, pingf->sock, NULL);
close(pingf->sock);
flow_hash_remove(c, FLOW_SIDX(pingf, TAPSIDE));
-
- if (pingf->f.type == FLOW_PING4)
- icmp_id_map[V4][pingf->id] = NULL;
- else
- icmp_id_map[V6][pingf->id] = NULL;
}
/**
* icmp_ping_new() - Prepare a new ping socket for a new id
* @c: Execution context
- * @id_map: id map entry of the sequence to open
* @af: Address family, AF_INET or AF_INET6
* @id: ICMP id for the new sequence
* @saddr: Source address
@@ -166,7 +157,6 @@ static void icmp_ping_close(const struct ctx *c, struct icmp_ping_flow *pingf)
* Return: Newly opened ping flow, or NULL on failure
*/
static struct icmp_ping_flow *icmp_ping_new(const struct ctx *c,
- struct icmp_ping_flow **id_map,
int af, uint16_t id,
const void *saddr, const void *daddr)
{
@@ -209,8 +199,6 @@ static struct icmp_ping_flow *icmp_ping_new(const struct ctx *c,
pingf->sock = s;
pingf->id = id;
- *id_map = pingf;
-
debug("%s: new socket %i for echo ID %"PRIu16, pname, s, id);
flowside_from_af(TAPFSIDE(pingf), PIF_TAP, af, daddr, id, saddr, id);
@@ -249,7 +237,7 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af,
struct sockaddr_in6 sa6;
} sa = { .sa.sa_family = af };
const socklen_t sl = af == AF_INET ? sizeof(sa.sa4) : sizeof(sa.sa6);
- struct icmp_ping_flow *pingf, **id_map;
+ struct icmp_ping_flow *pingf;
union flow *flow;
uint16_t id, seq;
uint8_t proto;
@@ -274,7 +262,6 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af,
proto = IPPROTO_ICMP;
id = ntohs(ih->un.echo.id);
- id_map = &icmp_id_map[V4][id];
seq = ntohs(ih->un.echo.sequence);
sa.sa4.sin_addr = *(struct in_addr *)daddr;
} else if (af == AF_INET6) {
@@ -288,7 +275,6 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af,
proto = IPPROTO_ICMPV6;
id = ntohs(ih->icmp6_identifier);
- id_map = &icmp_id_map[V6][id];
seq = ntohs(ih->icmp6_sequence);
sa.sa6.sin6_addr = *(struct in6_addr *)daddr;
sa.sa6.sin6_scope_id = c->ifi6;
@@ -301,7 +287,7 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af,
if (flow)
pingf = &flow->ping;
- else if (!(pingf = icmp_ping_new(c, id_map, af, id, saddr, daddr)))
+ else if (!(pingf = icmp_ping_new(c, af, id, saddr, daddr)))
return 1;
ASSERT(flow_proto[pingf->f.type] == proto);
--
2.43.0