From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 1F7495A027D for ; Thu, 21 Dec 2023 08:02:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1703142161; bh=gfbGAETUnU5zOvAausK/pH6/nDnqWtaDr2JC02V6j4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rZ4W6rO+8493yjgSXGmm8zA3GOMbs3AuWy/H3PAWl9nOHwTRe3MPLhQsA0kcl5Zmq AsKfBX9edxYkVEeD/bxMbM1/2iVG3gztCB0GblOurRANOX6cAHvwYAVJ/p3RaINa91 ldZ46Eut9MNH9vvvv+BKzf8CnHxa7eHjp73FdSj2NQXcy/2RVfvnnzKunR5Pq/Ki7h oEabUSV3IwznVP1/QR0ghh4570+Xb5+t13OYiX2ULzQnLKXHT0+jdYHqOH7mcGCri+ k4bmwIiMjLv6Y5+JqGn0aSFdTXGQNyjL7J+PpP5dZH3awQA6IJ4P61X2WaGuIq3Ccw Cihhno+75pVvA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SwhFs1qlsz4xSn; Thu, 21 Dec 2023 18:02:41 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v3 15/15] icmp: Eliminate icmp_id_map Date: Thu, 21 Dec 2023 18:02:37 +1100 Message-ID: <20231221070237.1422557-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221070237.1422557-1-david@gibson.dropbear.id.au> References: <20231221070237.1422557-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: JCOOFDWOIZASFU7CV7NNAE2YOFSHIXFW X-Message-ID-Hash: JCOOFDWOIZASFU7CV7NNAE2YOFSHIXFW X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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