Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7354358ybl; Tue, 24 Dec 2019 00:42:57 -0800 (PST) X-Google-Smtp-Source: APXvYqxekD9orQDT3qsBs9XVdpzOMMdQCy49hdPJZn6txyQuknhatITDO7CCRYQsUiCJK5JzPMHQ X-Received: by 2002:a9d:6a41:: with SMTP id h1mr5642700otn.279.1577176977623; Tue, 24 Dec 2019 00:42:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577176977; cv=none; d=google.com; s=arc-20160816; b=VS/rQj++vbqmo7LPGozvZY/op7nbrXSAV+FWQiCxwGudn/wTbBByDdu+iii/LtnTPL 88qRH+GvVZfjaKRLcyZUMyaNmC6l0N7tOB0iqQ/72khZd9m4SMyKrKUVb2rpFbRs8Jxa ggw2cPl0sOSlXy1oIqGRYWk6WIydZYxABAp/MoWJtVVaQ25atRMkN+GusKeK7OkMGoJm CZwEdg1Jo4IMOFB/OrczzHwmO2ASh8cESEw/1GWNHb9k+R4ctMrjgqkXCXUeoEb/vOG4 mp9vSjwEvIcOnmfIU7w7RKzU99Wr/SJXQIpdNr2iMOX+RBbxLLfU1DbvzfXetXSceDGS 95RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=BUrzHnGWsCvRbYqfGz7mzn9PEmCOLtCvRNjYsu70LCU=; b=G5EmXN9CtlrZNaMiBgkm+7GR6n4ogt4DlYEm8VcMostWxqgBPDKv6uNThahz7zbwPs Bt9UPB8DVS6LZyho3+YZ5csrwRuRZ+foSc4exYQwU6QySfJHWKdZCDVXpUDfUK1LUEBC WQvmoaKJpfNDdy17akCKSi08B7ARE0MkfQGRCP5U9dXzm4AoSiXcrAFy4uMYp4ygIfSv bRx7C4SHtG10R2eGaS1wM68CPTXAU+pu3dFeUTwB9d8RL6GH7+voeJ9X7oxDm2rmqFSs NB0qOYSVtuzw7k0SEJ3dmnYC/ie2IuovfYYTrGZwvft3NMSxd9GkoPSTGoAh/zd78KjZ eNRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TjcNAuSz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i20si6192021oie.119.2019.12.24.00.42.45; Tue, 24 Dec 2019 00:42:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TjcNAuSz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726178AbfLXImE (ORCPT + 99 others); Tue, 24 Dec 2019 03:42:04 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43483 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726068AbfLXImE (ORCPT ); Tue, 24 Dec 2019 03:42:04 -0500 Received: by mail-lf1-f65.google.com with SMTP id 9so14581826lfq.10; Tue, 24 Dec 2019 00:42:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BUrzHnGWsCvRbYqfGz7mzn9PEmCOLtCvRNjYsu70LCU=; b=TjcNAuSz8FRQTvnBNT4Mi9cXoiQFY24AK+G4GnqivWsBRc+hcAcjF0A3IfXuDEqY35 NtSqIgKijH1yptSgKocyiQCokDpDd5N/TYH/Gtvf+Aw5L+2O2oN5CZo49aWTilo5Oz2Q Pvmwue3yAnnujo0yC0u15A/1edzSiKDILNElGoHUG3niV0glvN7vlz/oxpLQ2iHP8lma gOmohbFb4z/e6AAmLqNt6umtLb1RbfWoshLT7EOK6T68f9XlEx2c4X01/dYCx8kmp/x6 fMaWPVQLQob5SYiXl+xSdF6ZNnAatcs2y00iJEuHOXLNwHX3KdZksHi5x3Yyl+NdiwvY emyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BUrzHnGWsCvRbYqfGz7mzn9PEmCOLtCvRNjYsu70LCU=; b=th5H6H4orsxMLMyPrV5NXFm19rC+i4COiKvg0nUODEkSovWb34cm76VANJecnefGnK Vv/vua41aLyt2OHTAWSNXJdYJE+jEDTjEkpKKH64/Dqbsz9RbPBN49PiSX5ltb6LdQlF VSTmoUXCe6ERC71jh0aHVGA8lVlmqjCF0yV8X2S7qiKIwiS0A2g6xgGr0ufOiOXajfPH rTJCjtPDHDxSClIjG5zoW+/ifBYN2uwsFhCpUKBfUO9ASC158jR7o+wiu5PqgFqYDkOh BGBvSC7HFgQYzN+JZYjLVX/8MzFL/uMkSavwFxkA0dXieUG2nRcPROlhkPLOI8OaxhZl boog== X-Gm-Message-State: APjAAAWbU8beCDTVJV9Vx/rx5kemolExt1hTGZJD7i6zXx5daFZISePH bi20S7L1S54TFMvWwEs3EYrxXhUmxerAKWC25qw= X-Received: by 2002:ac2:47e6:: with SMTP id b6mr18967553lfp.96.1577176921418; Tue, 24 Dec 2019 00:42:01 -0800 (PST) MIME-Version: 1.0 References: <20191217155102.46039-1-mcroce@redhat.com> In-Reply-To: From: Tonghao Zhang Date: Tue, 24 Dec 2019 16:41:25 +0800 Message-ID: Subject: Re: [ovs-dev] [PATCH net-next v2] openvswitch: add TTL decrement action To: Matteo Croce Cc: Nikolay Aleksandrov , ovs dev , netdev , LKML , Bindiya Kurle , Simon Horman , "David S. Miller" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Matteo, Did you have plan to implement the TTL decrement action in userspace datapath(with dpdk), I am doing some research offloading about TTL decrement action, and may sent patch TTL decrement offload action, using dpdk rte_flow. On Fri, Dec 20, 2019 at 8:37 PM Matteo Croce wrote: > > On Tue, Dec 17, 2019 at 5:30 PM Nikolay Aleksandrov > wrote: > > > > On 17/12/2019 17:51, Matteo Croce wrote: > > > New action to decrement TTL instead of setting it to a fixed value. > > > This action will decrement the TTL and, in case of expired TTL, drop it > > > or execute an action passed via a nested attribute. > > > The default TTL expired action is to drop the packet. > > > > > > Supports both IPv4 and IPv6 via the ttl and hop_limit fields, respectively. > > > > > > Tested with a corresponding change in the userspace: > > > > > > # ovs-dpctl dump-flows > > > in_port(2),eth(),eth_type(0x0800), packets:0, bytes:0, used:never, actions:dec_ttl{ttl<=1 action:(drop)},1,1 > > > in_port(1),eth(),eth_type(0x0800), packets:0, bytes:0, used:never, actions:dec_ttl{ttl<=1 action:(drop)},1,2 > > > in_port(1),eth(),eth_type(0x0806), packets:0, bytes:0, used:never, actions:2 > > > in_port(2),eth(),eth_type(0x0806), packets:0, bytes:0, used:never, actions:1 > > > > > > # ping -c1 192.168.0.2 -t 42 > > > IP (tos 0x0, ttl 41, id 61647, offset 0, flags [DF], proto ICMP (1), length 84) > > > 192.168.0.1 > 192.168.0.2: ICMP echo request, id 386, seq 1, length 64 > > > # ping -c1 192.168.0.2 -t 120 > > > IP (tos 0x0, ttl 119, id 62070, offset 0, flags [DF], proto ICMP (1), length 84) > > > 192.168.0.1 > 192.168.0.2: ICMP echo request, id 388, seq 1, length 64 > > > # ping -c1 192.168.0.2 -t 1 > > > # > > > > > > Co-authored-by: Bindiya Kurle > > > Signed-off-by: Bindiya Kurle > > > Signed-off-by: Matteo Croce > > > --- > > > include/uapi/linux/openvswitch.h | 22 +++++++ > > > net/openvswitch/actions.c | 71 +++++++++++++++++++++ > > > net/openvswitch/flow_netlink.c | 105 +++++++++++++++++++++++++++++++ > > > 3 files changed, 198 insertions(+) > > > > > > > Hi Matteo, > > > > [snip] > > > +} > > > + > > > /* When 'last' is true, sample() should always consume the 'skb'. > > > * Otherwise, sample() should keep 'skb' intact regardless what > > > * actions are executed within sample(). > > > @@ -1176,6 +1201,44 @@ static int execute_check_pkt_len(struct datapath *dp, struct sk_buff *skb, > > > nla_len(actions), last, clone_flow_key); > > > } > > > > > > +static int execute_dec_ttl(struct sk_buff *skb, struct sw_flow_key *key) > > > +{ > > > + int err; > > > + > > > + if (skb->protocol == htons(ETH_P_IPV6)) { > > > + struct ipv6hdr *nh = ipv6_hdr(skb); > > > + > > > + err = skb_ensure_writable(skb, skb_network_offset(skb) + > > > + sizeof(*nh)); > > > > skb_ensure_writable() calls pskb_may_pull() which may reallocate so nh might become invalid. > > It seems the IPv4 version below is ok as the ptr is reloaded. > > > > Right > > > One q as I don't know ovs that much - can this action be called only with > > skb->protocol == ETH_P_IP/IPV6 ? I.e. Are we sure that if it's not v6, then it must be v4 ? > > > > I'm adding a check in validate_and_copy_dec_ttl() so only ipv4/ipv6 > packet will pass. > > Thanks, > > -- > Matteo Croce > per aspera ad upstream > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev