From patchwork Tue Oct 8 12:21:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13826413 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B9D31DEFCF; Tue, 8 Oct 2024 12:21:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728390106; cv=none; b=AbxsXuJPcEdL3yupqu9ycUvxuEFbF6SMJXQAWXg6Cob8PKvwPL3qMJch+06g84Pcl7HZQ++8bnAI5OqU4qAa1EvDzNNf/CWow+utq8Ix9/39tzSGNekxizIA1E9lHaLiMsic28lULF+ovP9MwdWCBHtTzsscHxMkKv2h18IGph0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728390106; c=relaxed/simple; bh=sqhgYCxFuTkVsFmP1HNPMt2rIfrZun5s0g/k+WRejo0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=meOxeDjndw1Bf67mRrWdSNK5eSiC6JRwI0QrFmWpgIVuweRGZ0WsKFW5qCG4L+rk8WufnmA81BA707+3FQ+YamQr/2I8TQOX+P2Lfjbtqj0duERjCIsTZtWi4fY6KLiRQjJ6GEv2LQldiXTYbPRCOPhS/+aHtRByL+HQj7GeaF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ezSZizVk; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ezSZizVk" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20c544d345cso4441795ad.1; Tue, 08 Oct 2024 05:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728390104; x=1728994904; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Rhnd7an3fFD1i9UA4CB9lXLmhhSXpvyBfaplEmuqQys=; b=ezSZizVkw9k6mvbklPNTO5Hklywi6MLBo1vXW+cKXappmk5qaHzGjQ3mb/vriElPk1 hmYTg0R0dwEINSwcMGKHpZuHN9AbAqoQruxQJ302TrCxngRv2fm58uYWwVO+ZxZjbhv/ gSYjkwJkt/r4LrWlQBIu5AXCHk0F1TMmkQCA8ZzOa63Ld/DqS1qmVuIqsvaUdPhRl+Un Wb156yrd4AjL6xOgQ+Ug7JoHxrtp3zcKafXS1tPaEOxVusvw/Agikf1sF+jTNiPraey8 5FwgUO3Fbjr1m9QbBpyKb6AVUmhPFU6uL84DAsuSj09GQQ0K2QHs/a5w/d9KOW3Wz01J 6Swg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728390104; x=1728994904; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rhnd7an3fFD1i9UA4CB9lXLmhhSXpvyBfaplEmuqQys=; b=Lb8jy2YKJOBOBJCEKXq0hXFI4HctXhMsf0KjJzKZzX4AlVARdzbMBQsM8sN7PodAQG XeHqDBHYggMebIkdyf6HUgaryGs5ImkvNOBzmeSSY25ZcGKa/v2UKEtN7ndQ1FplqUSt qTfVx+V1tP1KVoAC9sP0KICS+98dVNJHkmnmO9QwHcKnDJ+/gYYXsgriUvUUQewk1Jb3 7vKF8rBJokRiMo8cx8i17jjiLrZ/WhFSYuKk2kDEVoIFllDxEfeHP7g7saD8nTOj7DcJ N567oVLviA+k0KV0kcHVIMpbXtm8yBwARTa7jfNv0cbiHHifzyeapzTER0k3nLqx+3GP dsBw== X-Forwarded-Encrypted: i=1; AJvYcCUmIuEjay31uRcqgdIqzZceQyOYUr7zCugMHNnHlXPOOIhrVSXMKorpavO1+4Y5rMFcUdN69vXEpB2Lm5c=@vger.kernel.org X-Gm-Message-State: AOJu0Yzzp4hxfX0LvAS2Pc1D3dR9TNHh7vJhA2KwA+E2l0o/JWhIKUKs x714acQM04T0Agt4Y9UWN2uWicI0J4ELEXqBtwqsRQcI6oDgFKBms6iKJkX0 X-Google-Smtp-Source: AGHT+IFKDhuhEOXGjDNugiywUgPBT9flDfwGC0KH7iRkjtLfUwBHpszDiLRpCwR61toT2FyO5mK5nw== X-Received: by 2002:a17:902:ecd2:b0:20b:46c6:3e47 with SMTP id d9443c01a7336-20c4e387b19mr57807315ad.29.1728390104159; Tue, 08 Oct 2024 05:21:44 -0700 (PDT) Received: from fedora.dns.podman ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1393175csm54737175ad.140.2024.10.08.05.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 05:21:43 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Shannon Nelson , Jiri Pirko , linux-kernel@vger.kernel.org, Hangbin Liu Subject: [PATCH net-next 1/2] netdevsim: print human readable IP address Date: Tue, 8 Oct 2024 12:21:33 +0000 Message-ID: <20241008122134.4343-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241008122134.4343-1-liuhangbin@gmail.com> References: <20241008122134.4343-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Currently, IPSec addresses are printed in hexadecimal format, which is not user-friendly. e.g. # cat /sys/kernel/debug/netdevsim/netdevsim0/ports/0/ipsec SA count=2 tx=20 sa[0] rx ipaddr=0x00000000 00000000 00000000 0100a8c0 sa[0] spi=0x00000101 proto=0x32 salt=0x0adecc3a crypt=1 sa[0] key=0x3167608a ca4f1397 43565909 941fa627 sa[1] tx ipaddr=0x00000000 00000000 00000000 00000000 sa[1] spi=0x00000100 proto=0x32 salt=0x0adecc3a crypt=1 sa[1] key=0x3167608a ca4f1397 43565909 941fa627 This patch updates the code to print the IPSec address in a human-readable format for easier debug. e.g. # cat /sys/kernel/debug/netdevsim/netdevsim0/ports/0/ipsec SA count=4 tx=40 sa[0] tx ipaddr=0.0.0.0 sa[0] spi=0x00000100 proto=0x32 salt=0x0adecc3a crypt=1 sa[0] key=0x3167608a ca4f1397 43565909 941fa627 sa[1] rx ipaddr=192.168.0.1 sa[1] spi=0x00000101 proto=0x32 salt=0x0adecc3a crypt=1 sa[1] key=0x3167608a ca4f1397 43565909 941fa627 sa[2] tx ipaddr=:: sa[2] spi=0x00000100 proto=0x32 salt=0x0adecc3a crypt=1 sa[2] key=0x3167608a ca4f1397 43565909 941fa627 sa[3] rx ipaddr=2000::1 sa[3] spi=0x00000101 proto=0x32 salt=0x0adecc3a crypt=1 sa[3] key=0x3167608a ca4f1397 43565909 941fa627 Signed-off-by: Hangbin Liu Reviewed-by: Simon Horman --- drivers/net/netdevsim/ipsec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/netdevsim/ipsec.c b/drivers/net/netdevsim/ipsec.c index f0d58092e7e9..102b0955eb04 100644 --- a/drivers/net/netdevsim/ipsec.c +++ b/drivers/net/netdevsim/ipsec.c @@ -39,10 +39,14 @@ static ssize_t nsim_dbg_netdev_ops_read(struct file *filp, if (!sap->used) continue; - p += scnprintf(p, bufsize - (p - buf), - "sa[%i] %cx ipaddr=0x%08x %08x %08x %08x\n", - i, (sap->rx ? 'r' : 't'), sap->ipaddr[0], - sap->ipaddr[1], sap->ipaddr[2], sap->ipaddr[3]); + if (sap->xs->props.family == AF_INET6) + p += scnprintf(p, bufsize - (p - buf), + "sa[%i] %cx ipaddr=%pI6c\n", + i, (sap->rx ? 'r' : 't'), &sap->ipaddr); + else + p += scnprintf(p, bufsize - (p - buf), + "sa[%i] %cx ipaddr=%pI4\n", + i, (sap->rx ? 'r' : 't'), &sap->ipaddr[3]); p += scnprintf(p, bufsize - (p - buf), "sa[%i] spi=0x%08x proto=0x%x salt=0x%08x crypt=%d\n", i, be32_to_cpu(sap->xs->id.spi), From patchwork Tue Oct 8 12:21:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13826414 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CFCB1DEFE3; Tue, 8 Oct 2024 12:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728390109; cv=none; b=UiSz0/FhAuEzYaIQTFwBaYKIgnMQJkjTr34BKTwjy3UvF9fLOExbrZP0L/DaBHncHQikc3LplKDXJv9PlFRV4Aol9NO2RrsFLfkMoLRmncoRNabpKvzdM3JbdjZJmQEK9DAUCWMPCK3ge3Pl36IA5yxPKnc1PVEvepbOYLNrlV8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728390109; c=relaxed/simple; bh=8Zz5iuoVqBXnmoZlhFKseth5oPQfJGWObYTalDjnUO0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SZjD4tszg3WkkoKgmcjhpkHYEhjqbnWa42IFkwdYCWijHAzyeYNVJGdyOvsEebIC6D65k42uTCUiOjkR0YHn60mqbtJQx1jtgANTyEMlt5+A0l7LPi2v9tan1H1UQACleD3riaSZq8diLxTobQ8a+oIb8K7JaJvOC7M8cBGucTU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dcA6uv8Y; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dcA6uv8Y" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20b78ee6298so35403595ad.2; Tue, 08 Oct 2024 05:21:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728390107; x=1728994907; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j6n89iXl4sTBj8JpdXByeqakCgAbxJDxDCdZbwUfb1A=; b=dcA6uv8Y50Uh8rttLDdrMkY6/VMy/ujjNnMueXJZAiRWWCHxym3Oh3pvCRKfCopdil o8mDsG2EqafLeBKsQAEFJHUsozF0qtjwkXVmPHY67TtVOfUwu0qFpXZ/BDiW7mIHeCSg FCvRl+YM+kg2zUJYXVjMvTiLlYva/dkWd+q0GTcxIZ0hPuPNe35UG6i7q8+4bJPyes3q BScCOiwIQ1PRnXB7ykKBcVYgNrNtX6/dhSci7FQgS0BsNxdq2jYXLu7Lc8rpEk98ezRt VfuMXxCYpDmSND8GMgwjK1EJkCe9PPPg61dxeZR1O2g0r775vz9319oZc1r44Y7sCrWI cziw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728390107; x=1728994907; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j6n89iXl4sTBj8JpdXByeqakCgAbxJDxDCdZbwUfb1A=; b=MEUzSkzUxqa8HUMuF94xmWwMuuKnWo5IRBLbD6N/6UZaap/ovnlk6DnRrgFxj+Hzet e0HYtCVr8SqmmKN/6v9kpzNst7xVDr/edDaJPifo0Osv8UhaQA/TRD5p0SYbsPUXo9Jj 7KjwTGJ3eWnRYEs+SLpBzJt0SSsorUelopnfClGUb1YWTTVrnA6uptWoPmhsADYSa15k wdQpSbaFxkj3P7MIJzuEIJyG48auHQ0xtue5CcfISObfvC9R14ogXb6kFh2xFtpB+GY6 CSP3N/jAHkKCbD6sIsAJPwl4xGPASIkvBAGeRB9Sg+Q5uBa/evcOTm6JNEcZCFOGznuU p7RQ== X-Forwarded-Encrypted: i=1; AJvYcCX+k7iZCQttHWqhzmfWnv4qthXfB3i3wRbBfsQ3WQt7zMwSskqSjPKz6LbadDi4tJSn7NQ7Tp4WQVdzw2M=@vger.kernel.org X-Gm-Message-State: AOJu0Yxg2O7u6GwfSFdSsWcp3pO5zf+af11gtkAZPvqE6//UCjjm1kBA E+e1niRo/Vm7sZIgJy0zeGSOn0OgRXmBdAGOTOk3m8WxzPZnONHZJWU+1QKx X-Google-Smtp-Source: AGHT+IGXaAVBfD0w5JeLhbNwr/MIxhyRI6PLBppgFJpDpzXw9LujtG8/vAz6aQtg7XvbTbQS7+wFEw== X-Received: by 2002:a17:903:4408:b0:20b:775f:506d with SMTP id d9443c01a7336-20bfe0412d0mr194566305ad.34.1728390107313; Tue, 08 Oct 2024 05:21:47 -0700 (PDT) Received: from fedora.dns.podman ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1393175csm54737175ad.140.2024.10.08.05.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 05:21:47 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Shannon Nelson , Jiri Pirko , linux-kernel@vger.kernel.org, Hangbin Liu Subject: [PATCH net-next 2/2] netdevsim: copy addresses for both in and out paths Date: Tue, 8 Oct 2024 12:21:34 +0000 Message-ID: <20241008122134.4343-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241008122134.4343-1-liuhangbin@gmail.com> References: <20241008122134.4343-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The current code only copies the address for the in path, leaving the out path address set to 0. This patch corrects the issue by copying the addresses for both the in and out paths. Before this patch: # cat /sys/kernel/debug/netdevsim/netdevsim0/ports/0/ipsec SA count=2 tx=20 sa[0] tx ipaddr=0.0.0.0 sa[0] spi=0x00000100 proto=0x32 salt=0x0adecc3a crypt=1 sa[0] key=0x3167608a ca4f1397 43565909 941fa627 sa[1] rx ipaddr=192.168.0.1 sa[1] spi=0x00000101 proto=0x32 salt=0x0adecc3a crypt=1 sa[1] key=0x3167608a ca4f1397 43565909 941fa627 After this patch: = cat /sys/kernel/debug/netdevsim/netdevsim0/ports/0/ipsec SA count=2 tx=20 sa[0] tx ipaddr=192.168.0.2 sa[0] spi=0x00000100 proto=0x32 salt=0x0adecc3a crypt=1 sa[0] key=0x3167608a ca4f1397 43565909 941fa627 sa[1] rx ipaddr=192.168.0.1 sa[1] spi=0x00000101 proto=0x32 salt=0x0adecc3a crypt=1 sa[1] key=0x3167608a ca4f1397 43565909 941fa627 Fixes: 7699353da875 ("netdevsim: add ipsec offload testing") Signed-off-by: Hangbin Liu Reviewed-by: Simon Horman --- drivers/net/netdevsim/ipsec.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/netdevsim/ipsec.c b/drivers/net/netdevsim/ipsec.c index 102b0955eb04..88187dd4eb2d 100644 --- a/drivers/net/netdevsim/ipsec.c +++ b/drivers/net/netdevsim/ipsec.c @@ -180,14 +180,13 @@ static int nsim_ipsec_add_sa(struct xfrm_state *xs, return ret; } - if (xs->xso.dir == XFRM_DEV_OFFLOAD_IN) { + if (xs->xso.dir == XFRM_DEV_OFFLOAD_IN) sa.rx = true; - if (xs->props.family == AF_INET6) - memcpy(sa.ipaddr, &xs->id.daddr.a6, 16); - else - memcpy(&sa.ipaddr[3], &xs->id.daddr.a4, 4); - } + if (xs->props.family == AF_INET6) + memcpy(sa.ipaddr, &xs->id.daddr.a6, 16); + else + memcpy(&sa.ipaddr[3], &xs->id.daddr.a4, 4); /* the preparations worked, so save the info */ memcpy(&ipsec->sa[sa_idx], &sa, sizeof(sa));