From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 51D935A02FF for ; Fri, 3 May 2024 03:11:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1714698697; bh=ObcFN5Q11caSEYfgEfClI3/ehZcD7W4yLSfrvjJ8tbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W71KLSapWp6Wm8wXUy/KqYVTSHsI5kRKLrr9kY0qsXBClrrY/losck1Q6AE/pPCli tXR4DD/QJM6Q7/gjJR8z0+NXKVhrwEFFXCoGH9XN0sjrSHQgsBk5+b5O6tdI50DGhf Q8BuLvYtdX4kyBfqMNiK9RA8q+W6/6VtFSwYjVoIbLXtqi+zxph/XF40jbzrWvUmdP 0vNCWWyfrh4Y4R/nm05njr+hBnSsNL6WlqomDi4IhriFNN8Gs4Zzs1F1xztV/krvui YQ43/sCXwWW6UAlNC7fxhymb73vkQk+M6wDZYRnYMnlpiw6y+9j+Zlx29FoJ94By4M j6HgA2K1X7RTQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4VVt6x6WLbz4xPf; Fri, 3 May 2024 11:11:37 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v4 14/16] icmp: Eliminate icmp_id_map Date: Fri, 3 May 2024 11:11:33 +1000 Message-ID: <20240503011135.2924437-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240503011135.2924437-1-david@gibson.dropbear.id.au> References: <20240503011135.2924437-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 4PAEYICDXZRTVNPGPCJCZX7OZ5DKZAOS X-Message-ID-Hash: 4PAEYICDXZRTVNPGPCJCZX7OZ5DKZAOS 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 | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/icmp.c b/icmp.c index 3b8f282..6a76d05 100644 --- a/icmp.c +++ b/icmp.c @@ -51,9 +51,6 @@ #define PINGF(idx) (&(FLOW(idx)->ping)) -/* 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 @@ -141,22 +138,14 @@ unexpected: static void icmp_ping_close(const struct ctx *c, const struct icmp_ping_flow *pingf) { - uint16_t id = pingf->f.side[TAPSIDE].eport; - 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][id] = NULL; - else - icmp_id_map[V6][id] = NULL; } /** * icmp_ping_new() - Prepare a new ping socket for a new id * @c: Execution context - * @id_sock: Pointer to ping flow entry slot in icmp_id_map[] to update * @af: Address family, AF_INET or AF_INET6 * @id: ICMP id for the new socket * @pif: pif originating the ping request @@ -166,7 +155,6 @@ static void icmp_ping_close(const struct ctx *c, * 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_sock, sa_family_t af, uint16_t id, uint8_t pif, const void *saddr, const void *daddr) @@ -215,7 +203,6 @@ static struct icmp_ping_flow *icmp_ping_new(const struct ctx *c, flow_dbg(pingf, "new socket %i for echo ID %"PRIu16, pingf->sock, id); flow_hash_insert(c, FLOW_SIDX(pingf, TAPSIDE)); - *id_sock = pingf; return pingf; @@ -240,8 +227,8 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, const void *saddr, const void *daddr, const struct pool *p, const struct timespec *now) { - struct icmp_ping_flow *pingf, **id_sock; const struct flowside *sockside; + struct icmp_ping_flow *pingf; union sockaddr_inany sa; size_t dlen, l4len; uint16_t id, seq; @@ -266,7 +253,6 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, proto = IPPROTO_ICMP; id = ntohs(ih->un.echo.id); - id_sock = &icmp_id_map[V4][id]; seq = ntohs(ih->un.echo.sequence); } else if (af == AF_INET6) { const struct icmp6hdr *ih; @@ -282,7 +268,6 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, proto = IPPROTO_ICMPV6; id = ntohs(ih->icmp6_identifier); - id_sock = &icmp_id_map[V6][id]; seq = ntohs(ih->icmp6_sequence); } else { ASSERT(0); @@ -293,7 +278,7 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, if (flow) pingf = &flow->ping; - else if (!(pingf = icmp_ping_new(c, id_sock, af, id, pif, saddr, daddr))) + else if (!(pingf = icmp_ping_new(c, af, id, pif, saddr, daddr))) return 1; sockside = &pingf->f.side[SOCKSIDE]; -- 2.44.0