From nobody Tue Nov 28 04:12:41 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SfTZK4txVz52d8Q; Tue, 28 Nov 2023 04:12:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SfTZK4M95z4RBZ; Tue, 28 Nov 2023 04:12:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701144761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3UE1NJ0ghlMIcwOsMZGJm7Ct5Ma6aCmxe0IgXKDTQEs=; b=K+fkDPjprKh4G8xkRdc6ocwo7S3uNSGpybeJrbKOA1vPcb7rhLlq8xkBRpngxKTCFgKk/h JEyerfJ61UFSTmapFL4iWyePM3fMFQLNvkoqd/xMZ7+Z6pAprL2/olLX+c9nEDZq4ajYEh GUnVm6DgnVY3BO2GhcwYW2BDDkI2g1TIlAjzALl+t+F3k+GQVkezxQ2Ou59h4BDBxBkI/3 lumRvxJswhA1bloz9xBpfPHv4e2kXaPTIe6zK+y74P79OehM1d0wfkheNKVspuDRzI+oU4 qU5E+A5Ts7uI3Y8LmDR+QwATjlMzqVQ+OS1AL1zA6Zzla0HHZp+5lIfmr+ZmSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701144761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3UE1NJ0ghlMIcwOsMZGJm7Ct5Ma6aCmxe0IgXKDTQEs=; b=lqTzPRxxJ6vgpo2wpGC6tPs54yjtBwp21LgE7Wlf4zkbALxkuJww9B6NyRxJzVTLQBIXYJ Apy9xlz9mIFjlaDhnSPlJjQZimk/jaUTRhaOM+jOLHHyT984zAyGS2nRzuITxLhd+u/VZj VK0s5Bt/PnZHMt+4Us1QbxtMPsHJ2iuDiIoArgH8lhd64pzWhOK17jIzn/oENBEJ5xXzTp 5FAP4+0JUepYZMO3OY+2DD6y9DD2HUAiG30xIae5mA6vXkFYJdQ52SRbXuB9WOP+9ZqI8J HsDu1RMQlievFTI4+qK9B+gPPWTEgSuSrnPsmDZODooN7LLdCIBXS/ZpDXE/Zw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701144761; a=rsa-sha256; cv=none; b=Fz8FpZqlwK948HcikDQqKsfQGLQ5koubNQdhsJWeT9YXlWxP2FYKqDgOe7Xk8DRBGJEtXm PPNLxQZHCrxNwZFF5xDGxq42m70U8OcvEAHrK2IjQ2jx6zuqy6lap7w9Uvvy2b15A/5f+a uJyZliJ2T6ohDLyjq6urHvG6zvRMSz1AtXooB8Xj+k72M6BEMB5B1NH3AbWHFp5atfhThS 4JiWzO0rV6lJwM+6zOhSOc3H2u2AsNyu/Nk8JZZLdfb9uERJ3ZUxaIwskS9ksYe/aNXlLd rufS0Do528GrIVFxlETsKWLnlN44wGH3mbHCVMZlPAs6geOjnOSBSv5fPnbXzA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SfTZK3NpXz15rp; Tue, 28 Nov 2023 04:12:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AS4CfJK087267; Tue, 28 Nov 2023 04:12:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AS4CfUE087264; Tue, 28 Nov 2023 04:12:41 GMT (envelope-from git) Date: Tue, 28 Nov 2023 04:12:41 GMT Message-Id: <202311280412.3AS4CfUE087264@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: d2de66a90d01 - main - ng_socket: with getsockname() return node ID for unnamed node List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d2de66a90d01810b1869b7dcac290267f05e4b1d Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=d2de66a90d01810b1869b7dcac290267f05e4b1d commit d2de66a90d01810b1869b7dcac290267f05e4b1d Author: Gleb Smirnoff AuthorDate: 2023-11-28 04:11:38 +0000 Commit: Gleb Smirnoff CommitDate: 2023-11-28 04:11:38 +0000 ng_socket: with getsockname() return node ID for unnamed node Reviewed by: afedorov Differential Revision: https://reviews.freebsd.org/D42691 --- sys/netgraph/ng_socket.c | 3 +++ tests/sys/netgraph/socket.c | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c index 4afa46c3d0f0..8a8f127ee39b 100644 --- a/sys/netgraph/ng_socket.c +++ b/sys/netgraph/ng_socket.c @@ -523,6 +523,9 @@ ng_getsockaddr(struct socket *so, struct sockaddr **addr) if (NG_NODE_HAS_NAME(node)) bcopy(NG_NODE_NAME(node), sg->sg_data, strlen(NG_NODE_NAME(node))); + else + snprintf(sg->sg_data, sizeof(sg->sg_data), "[%x]", + ng_node2ID(node)); mtx_unlock(&pcbp->sockdata->mtx); sg->sg_len = sg_len; diff --git a/tests/sys/netgraph/socket.c b/tests/sys/netgraph/socket.c index bd40e4358866..1e5d68e1d21f 100644 --- a/tests/sys/netgraph/socket.c +++ b/tests/sys/netgraph/socket.c @@ -42,13 +42,12 @@ ATF_TC_BODY(getsockname, tc) char name[NG_NODESIZ] = NAME; int cs; -#if 0 - /* Unnamed node. */ + /* Unnamed node returns its ID as name. */ ATF_REQUIRE(NgMkSockNode(NULL, &cs, NULL) == 0); ATF_REQUIRE(getsockname(cs, (struct sockaddr *)&sg, &len) == 0); + ATF_REQUIRE(strspn(sg.sg_data, "[0123456789abcdef]") >= 3 && + sg.sg_data[strspn(sg.sg_data, "[0123456789abcdef]")] == '\0'); close(cs); - /* Unnamed node doesn't return any name/ID now. */ -#endif /* Named node. */ ATF_REQUIRE(NgMkSockNode(name, &cs, NULL) == 0);