From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7C0141F44D for ; Sun, 24 Mar 2024 00:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yhbt.net; s=selector1; t=1711240013; bh=HH7OTXxsZgT+qFveYL5N44/zvHx+/FydLzUYODGGnwU=; h=Date:From:To:Subject:References:In-Reply-To:From; b=wb7zc6wNIFfDeHAKLKSvFHnQro7UFyQe0xPxcP4vfh3QNmBIoCai5dnfrGDBoXVQK 9WMODwR27aBefVACqEb6lJ2KgpTqa+AM0JSW6HQcPblCz3hM96R3ifGiibyfSzmpjM z5JNn5/y2WRNn3OL3nR9f44aIet1WsnwzF2vpSZc= Date: Sun, 24 Mar 2024 00:26:53 +0000 From: Eric Wong To: raindrops-public@yhbt.net Subject: [PATCH v2] linux_inet_diag: avoid errors for users compiling w/o assertions Message-ID: <20240324002653.M350077@dcvr> References: <20230930232640.27806-1-bofh@yhbt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230930232640.27806-1-bofh@yhbt.net> List-Id: We should warn gracefully when we hit IPv7+ or whatever... --- Rebased against khashl changes ext/raindrops/linux_inet_diag.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c index d0638d7..058936b 100644 --- a/ext/raindrops/linux_inet_diag.c +++ b/ext/raindrops/linux_inet_diag.c @@ -208,7 +208,9 @@ static struct listen_stats *stats_for(addr2stats *a2s, struct inet_diag_msg *r) break; } default: - assert(0 && "unsupported address family, could that be IPv7?!"); + fprintf(stderr, "unsupported .idiag_family: %u\n", + (unsigned)r->idiag_family); + return NULL; /* can't raise w/o GVL */ } if (!inet_ntop(r->idiag_family, src, host, hostlen)) { bug_warn_nogvl("BUG: inet_ntop: %s\n", strerror(errno)); @@ -228,7 +230,8 @@ static struct listen_stats *stats_for(addr2stats *a2s, struct inet_diag_msg *r) port = host + hostlen + 2; break; default: - assert(0 && "unsupported address family, could that be IPv7?!"); + assert(0 && "should never get here (returned above)"); + abort(); } n = snprintf(port, portlen, "%u", ntohs(r->id.idiag_sport)); @@ -278,12 +281,14 @@ static struct listen_stats *stats_for(addr2stats *a2s, struct inet_diag_msg *r) static void table_incr_active(addr2stats *a2s, struct inet_diag_msg *r) { struct listen_stats *stats = stats_for(a2s, r); + if (!stats) return; ++stats->active; } static void table_set_queued(addr2stats *a2s, struct inet_diag_msg *r) { struct listen_stats *stats = stats_for(a2s, r); + if (!stats) return; stats->listener_p = 1; stats->queued += r->idiag_rqueue; }