From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21AA28839 for ; Mon, 24 Jul 2023 15:23:48 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F534E57 for ; Mon, 24 Jul 2023 08:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690212225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ytLMoP/npcxxhxeVQxkd3GLmDI++qSW8yF2vJW6Ep9k=; b=ZZgntlXXU5ypRTknNCj5B9olgQO9Ql3g4KP7y5b7a8TJUmmiJiqIn7MLPnY3n/cvYbH4sF wiZVez0i631w/THgh00oJUga5Cxw+vqzybkz/rVWeHXC7nKA/bNx9WaUfC5iQ1TTkLMV/Q pXJUvu80k8HFs0mIqAnOEm38BNPI6vw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-503-28ZiyXuuNkqZ17LzhKCIgQ-1; Mon, 24 Jul 2023 11:23:44 -0400 X-MC-Unique: 28ZiyXuuNkqZ17LzhKCIgQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4A928030AC; Mon, 24 Jul 2023 15:23:43 +0000 (UTC) Received: from RHTPC1VM0NT (unknown [10.22.33.15]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F485C2C856; Mon, 24 Jul 2023 15:23:43 +0000 (UTC) From: Aaron Conole To: Adrian Moreno Cc: netdev@vger.kernel.org, dev@openvswitch.org, i.maximets@ovn.org, eric@garver.life Subject: Re: [PATCH net-next 4/7] net: openvswitch: add misc error drop reasons References: <20230722094238.2520044-1-amorenoz@redhat.com> <20230722094238.2520044-5-amorenoz@redhat.com> Date: Mon, 24 Jul 2023 11:23:42 -0400 In-Reply-To: <20230722094238.2520044-5-amorenoz@redhat.com> (Adrian Moreno's message of "Sat, 22 Jul 2023 11:42:34 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Adrian Moreno writes: > Use drop reasons from include/net/dropreason-core.h when a reasonable > candidate exists. > > Signed-off-by: Adrian Moreno > --- > net/openvswitch/actions.c | 17 ++++++++++------- > net/openvswitch/conntrack.c | 3 ++- > net/openvswitch/drop.h | 6 ++++++ > 3 files changed, 18 insertions(+), 8 deletions(-) > > diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c > index 9279bb186e9f..42fa1e7eb912 100644 > --- a/net/openvswitch/actions.c > +++ b/net/openvswitch/actions.c Did you consider putting in a drop reason when one of the actions fails setting err? For example, if dec_ttl fails with some error other than EHOSTUNREACH, it will drop into the kfree_skb() case... maybe we should have an action_failed drop reason that can be passed there. > @@ -782,7 +782,7 @@ static int ovs_vport_output(struct net *net, struct sock *sk, > struct vport *vport = data->vport; > > if (skb_cow_head(skb, data->l2_len) < 0) { > - kfree_skb(skb); > + kfree_skb_reason(skb, SKB_DROP_REASON_NOMEM); > return -ENOMEM; > } > > @@ -853,6 +853,7 @@ static void ovs_fragment(struct net *net, struct vport *vport, > struct sk_buff *skb, u16 mru, > struct sw_flow_key *key) > { > + enum ovs_drop_reason reason; > u16 orig_network_offset = 0; > > if (eth_p_mpls(skb->protocol)) { > @@ -862,6 +863,7 @@ static void ovs_fragment(struct net *net, struct vport *vport, > > if (skb_network_offset(skb) > MAX_L2_LEN) { > OVS_NLERR(1, "L2 header too long to fragment"); > + reason = OVS_DROP_FRAG_L2_TOO_LONG; > goto err; > } > > @@ -902,12 +904,13 @@ static void ovs_fragment(struct net *net, struct vport *vport, > WARN_ONCE(1, "Failed fragment ->%s: eth=%04x, MRU=%d, MTU=%d.", > ovs_vport_name(vport), ntohs(key->eth.type), mru, > vport->dev->mtu); > + reason = OVS_DROP_FRAG_INVALID_PROTO; > goto err; > } > > return; > err: > - kfree_skb(skb); > + kfree_skb_reason(skb, reason); > } > > static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port, > @@ -934,10 +937,10 @@ static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port, > > ovs_fragment(net, vport, skb, mru, key); > } else { > - kfree_skb(skb); > + kfree_skb_reason(skb, SKB_DROP_REASON_PKT_TOO_BIG); > } > } else { > - kfree_skb(skb); > + kfree_skb_reason(skb, SKB_DROP_REASON_DEV_READY); > } > } > > @@ -1011,7 +1014,7 @@ static int dec_ttl_exception_handler(struct datapath *dp, struct sk_buff *skb, > return clone_execute(dp, skb, key, 0, nla_data(actions), > nla_len(actions), true, false); > > - consume_skb(skb); > + kfree_skb_reason(skb, OVS_DROP_IP_TTL); > return 0; > } > > @@ -1564,7 +1567,7 @@ static int clone_execute(struct datapath *dp, struct sk_buff *skb, > /* Out of per CPU action FIFO space. Drop the 'skb' and > * log an error. > */ > - kfree_skb(skb); > + kfree_skb_reason(skb, OVS_DROP_DEFERRED_LIMIT); > > if (net_ratelimit()) { > if (actions) { /* Sample action */ > @@ -1616,7 +1619,7 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb, > if (unlikely(level > OVS_RECURSION_LIMIT)) { > net_crit_ratelimited("ovs: recursion limit reached on datapath %s, probable configuration error\n", > ovs_dp_name(dp)); > - kfree_skb(skb); > + kfree_skb_reason(skb, OVS_DROP_RECURSION_LIMIT); > err = -ENETDOWN; > goto out; > } > diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c > index fa955e892210..b03ebd4a8fae 100644 > --- a/net/openvswitch/conntrack.c > +++ b/net/openvswitch/conntrack.c > @@ -29,6 +29,7 @@ > #include > > #include "datapath.h" > +#include "drop.h" > #include "conntrack.h" > #include "flow.h" > #include "flow_netlink.h" > @@ -1035,7 +1036,7 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb, > > skb_push_rcsum(skb, nh_ofs); > if (err) > - kfree_skb(skb); > + kfree_skb_reason(skb, OVS_DROP_CONNTRACK); > return err; > } > > diff --git a/net/openvswitch/drop.h b/net/openvswitch/drop.h > index 2440c836727f..744b8d1b93a3 100644 > --- a/net/openvswitch/drop.h > +++ b/net/openvswitch/drop.h > @@ -12,6 +12,12 @@ > R(OVS_DROP_EXPLICIT_ACTION) \ > R(OVS_DROP_EXPLICIT_ACTION_ERROR) \ > R(OVS_DROP_METER) \ > + R(OVS_DROP_RECURSION_LIMIT) \ > + R(OVS_DROP_DEFERRED_LIMIT) \ > + R(OVS_DROP_FRAG_L2_TOO_LONG) \ > + R(OVS_DROP_FRAG_INVALID_PROTO) \ > + R(OVS_DROP_CONNTRACK) \ > + R(OVS_DROP_IP_TTL) \ > /* deliberate comment for trailing \ */ > > enum ovs_drop_reason {