From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (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 9C86E19E7F7 for ; Tue, 12 May 2026 00:25:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778545549; cv=none; b=No2xnMRrBsnuUW6L7pTD8u95A1c0kiwDE0LDXeBEkVPqjwSfNv124WRbcKonYFVjPq982EUOSTS9ofZOToa9MkpgeZObd5F9iAdn6S9/Mq8ivGC9iRGTCgSJ85S5h5AaJCaFHLpP/U3Pm5EWvXZEMP51CS8hZBdWdRJakJPB59k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778545549; c=relaxed/simple; bh=b4skspkKKTQIX++fmWMFle7wB2PRvfsctqBNoBPSajs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mX4hrnuNPHicjJeQ0iRvE8gFbiHp/L0srZ3fD54psabR47pDL+Gs+VLKqoJWSMWnneuRLCzSszRlHhgjDdaHLum0PBp4reScKwcLa9AhSypFGo4iA8w8heg1n0PZqPOU2gjIO0dmY/0mGufoU6PpFyqM4cAQsbuRhQJvlmLA/Ic= 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=P59+1gkp; arc=none smtp.client-ip=209.85.160.176 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="P59+1gkp" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-50e5eb0fabaso49234701cf.0 for ; Mon, 11 May 2026 17:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778545546; x=1779150346; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=KYweTmMqrk2Rteck6hihBJf+aeEAyEgXbVoomeow8eg=; b=P59+1gkpjhrxhVdWL/B61v+6dlSiSXupkry30OF+9IXCxAMOfW9PAD3n8Fscb4mHyk 89ksnoyKrywORNO+Z3Fti4wv7cTAa2rhPA65qSCIWL/q4Fd6fFHxMQiHJJx9dv/ebO4C EJwGmOS1rqTnBFMskh1UVuyXkWJgQErDU2+ViTUGSNm+Fz0adKQActV7mAGRQmeVmh8v 73eB/w5lMVXMreMc/mcke34dJbJaBEtvf2DKIpUwXG3wLxBX5iZJK5o7HFhD/6Q7gGI4 kz9MptG7urLssu9PcoLYxHGlMghtaJAdFLDGkH2Xf+NnE/1Ucqaei9W8qjvmAZqp3Xiw 2EPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778545546; x=1779150346; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KYweTmMqrk2Rteck6hihBJf+aeEAyEgXbVoomeow8eg=; b=iNr39L201+FSznIAmkpnrQfr7MPVRQUUtShtws3JA7uSFrqa6fLXqnbWSa6pNMEth2 K6bH6TEF+iBvs8avps7wm2D/iRPVEzWjlq497sCgK8Ef1p8DVFWCDDJys+JMi7DU4wV9 hQTesmAX5wz6gWiWmP+JggA3EI5cDEIZ2PULciZz0h9DX9RcItW6SIZR5o+lbjNX/EZn W85sxd7VjN1+zMizgszwxcooGzKrM7IF1/3Fok0K7k8QGMH+x1dkYbZBe1N4YPxTb2g0 +0zuZZLs5pLUbeAeeKTzGSWtapo99KVyd+H+lcUchEREnY2NdDVbZ5i89RuCGjbfnvRQ V+WQ== X-Forwarded-Encrypted: i=1; AFNElJ+SZp6lhtT6DowyjPTM1lf7AOJjnvYX4zvWBKUuzOPUuzAhEGldt05bh3i0a23s5+aq6KT4niTSXn7IZ3w=@vger.kernel.org X-Gm-Message-State: AOJu0Yxt3JaT1bieKH9d1vWyx3oNXYQ/ZU+2Fc1aoOaQ6QR1rKk+mnrj PnvYt8KBw1xODpw2ffir7d60JGswrcHw4gb8aLH+Ucl9q2M3YUd0Ot46 X-Gm-Gg: Acq92OFudWEA/QrConNelo3H90FXhzkVHKB3PJu6rTNaVwlxzSLuzPXQiRSeK6VjthK ZStu2KsAlFY0Du4VMlzJa99gZfnsEESBiNDvKeq74ivKsBDOcsMLFa+3A2PwkFHF/yBPlzAvnUW 0occU2SVGfXbBR7y+kpfkK+IeBws42q1y06CNEImGcon/RXwYwPd4s7uW/8oYPjOuxZhowSNeW2 Aw4iWSGNK5icfmC8EeoNhb7wFWG2KgSB55xpAgF2sBlJItnZ4RRIsEkh0RepNP8m573/eLi48XZ EDgMVmK7KiJBF3DRG+1Zbos7fCXgTRInCxK+e3Ruy34zwJiL/UzL1aPAx/zhcOuJGLiZY6BKoyu ib5ps6h3/4JKp1YlfgmKlmclQLXAPxec4BY3ycb0Z+ME8mkTwY+CBD7RY9xQLGnTwO/68pVfi9X NqcV+gG4VtuIMmSUfLoulN2CSqLfjGYTLhxRM+76AK2RH9IlvkKn5toplz96ngZsVe2WUzg2jhA 7Bf53Um X-Received: by 2002:ac8:5fc2:0:b0:50f:dd9f:1223 with SMTP id d75a77b69052e-514d2237cf5mr13871101cf.44.1778545546582; Mon, 11 May 2026 17:25:46 -0700 (PDT) Received: from ?IPV6:2620:10d:c0a8:11d1::1011? ([2620:10d:c091:400::5:9448]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5148e7e3f4fsm102040911cf.21.2026.05.11.17.25.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 May 2026 17:25:45 -0700 (PDT) Message-ID: Date: Mon, 11 May 2026 20:25:44 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next 3/6] netdevsim: psp: move rx processing into nsim_poll() To: Willem de Bruijn , Jakub Kicinski , Andrew Lunn , "David S. Miller" , Eric Dumazet , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260508-nsim-psp-crypto-v1-0-4b50ed09b794@gmail.com> <20260508-nsim-psp-crypto-v1-3-4b50ed09b794@gmail.com> Content-Language: en-US From: Daniel Zahka In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 5/11/26 4:03 PM, Willem de Bruijn wrote: > Daniel Zahka wrote: >> nsim_do_psp() does PSP decap and skb extension creation in the tx >> path. This has the slightly undesirable property of not allowing the >> psp rx code to run on PSP packets cooked up in userspace and >> transmitted on a packet socket from the peer dev (e.g. packetdrill). > Whether this happens in the nsim_start_xmit tx side handler directly > or is deferred to nsim_napi_rx is irrelevant, isn't it? You're right. The way netdevsim works, it is entirely immaterial. I'll correct the erroneous commit message, but I still think having the decap code in the napi_poll side makes a little bit more logical sense here. >> +/* Returns true if skb was consumed, false otherwise. */ >> +bool nsim_psp_handle_rx(struct netdevsim *ns, struct sk_buff *skb) >> +{ >> + struct psp_dev *psd; >> + struct psphdr *psph; >> + struct udphdr *uh; >> + int payload_len; >> + u32 versions; >> + int psp_off; >> + bool is_udp; >> + int l3_hlen; >> + u8 version; >> + u32 psd_id; >> + int err; >> + >> + if (skb->protocol == htons(ETH_P_IP)) { >> + struct iphdr *iph; >> + >> + if (!pskb_may_pull(skb, sizeof(struct iphdr))) >> + return false; >> + >> + iph = (struct iphdr *)skb->data; >> + if (iph->ihl < 5) >> + return false; >> + >> + is_udp = iph->protocol == IPPROTO_UDP; >> + l3_hlen = iph->ihl * 4; >> + } else if (skb->protocol == htons(ETH_P_IPV6)) { >> + struct ipv6hdr *ip6h; >> + >> + if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) >> + return false; >> + ip6h = (struct ipv6hdr *)skb->data; >> + is_udp = ip6h->nexthdr == IPPROTO_UDP; >> + l3_hlen = sizeof(struct ipv6hdr); >> + } else { >> + return false; >> + } >> + >> + if (!is_udp) >> + return false; >> + >> + if (!pskb_may_pull(skb, l3_hlen + sizeof(struct udphdr) + PSP_HDR_SIZE)) >> + return false; >> + >> + uh = (struct udphdr *)(skb->data + l3_hlen); >> + if (uh->dest != htons(PSP_DEFAULT_UDP_PORT)) >> + return false; >> + >> + psph = (struct psphdr *)(uh + 1); >> + version = FIELD_GET(PSPHDR_VERFL_VERSION, psph->verfl); > This seems to reimplement a lot of psp_dev_rcv. Is that needed? > > Is it a hint that this psp driver API needs some work? It could be. I'd have to split the parsing from the decap logic in psp_dev_rcv(). I just wonder if another user of the two separate halves other than netdevsim will come along. >> + rcu_read_lock(); >> + psd = rcu_dereference(ns->psp.dev); >> + if (psd) { >> + versions = READ_ONCE(psd->config.versions); >> + psd_id = psd->id; >> + } >> + rcu_read_unlock(); >> + >> + if (!psd || !(versions & (1 << version))) { >> + skb->ip_summed = CHECKSUM_NONE; >> + return false; >> + } >> + >> + psp_off = l3_hlen + sizeof(struct udphdr); >> + payload_len = skb->len - psp_off - PSP_HDR_SIZE - PSP_TRL_SIZE; >> + if (payload_len < 0) >> + goto drop; >> + >> + skb_push(skb, ETH_HLEN); >> + skb->mac_len = ETH_HLEN; >> + err = psp_dev_rcv(skb, psd_id, 0, false); >> + if (err) >> + goto drop; >> + >> + skb_reset_mac_header(skb); >> + skb_pull(skb, ETH_HLEN); > Similarly this is a bit of a hack, pushing and pulling a fake Ethernet > offset. > > And is this skb_reset_mac_header needed? skb_reset_mac_header() is needed because psp_dev_rcv() shifts the l2 and l3 headers forward, and the mac header has already been set. psp_dev_rcv() expects the mac header to be there. I hear what you're saying though. The driver api could probably handle these for us, but I also didn't want to overfit to netdevsim without another user. I'll explore some options before I post this again.