Re: [ovs-dev] [PATCH] dpif-netlink-rtnl: Fix netdev leak in out-of-tree tunnels probe.

2024-07-12 Thread Eric Garver
On Fri, Jul 12, 2024 at 10:30:23AM +0200, David Marchand wrote:
> Caught by code review, calling netdev_open works in pair of netdev_close
> when no reference to a netdev must be kept.
> 
> Fixes: 921c370a9df5 ("dpif-netlink: Probe for out-of-tree tunnels, decides 
> used interface")
> Signed-off-by: David Marchand 
> ---
>  lib/dpif-netlink-rtnl.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/dpif-netlink-rtnl.c b/lib/dpif-netlink-rtnl.c
> index 5788294ae0..f7035333e6 100644
> --- a/lib/dpif-netlink-rtnl.c
> +++ b/lib/dpif-netlink-rtnl.c
> @@ -566,6 +566,7 @@ dpif_netlink_rtnl_probe_oot_tunnels(void)
>  
>  tnl_cfg = netdev_get_tunnel_config(netdev);
>  if (!tnl_cfg) {
> +netdev_close(netdev);
>  return true;
>  }
>  

IIRC, the out-of-tree modules have been removed since 3.0. I think this
probe could be removed entirely.

At any rate, giving my ACK for this patch.

Acked-by: Eric Garver 

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v14 4/6] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-04-05 Thread Eric Garver
On Fri, Apr 05, 2024 at 11:39:58AM +0200, Eelco Chaudron wrote:
> 
> 
> On 3 Apr 2024, at 16:35, Eric Garver wrote:
> 
> > Kernel support has been added for this action. As such, we need to probe
> > the datapath for support.
> >
> > Signed-off-by: Eric Garver 
> > ---
> >  include/linux/openvswitch.h |  2 +-
> >  lib/dpif.c  |  6 ++-
> >  lib/dpif.h  |  2 +-
> >  ofproto/ofproto-dpif.c  | 77 ++---
> >  ofproto/ofproto-dpif.h  |  4 +-
> >  5 files changed, 81 insertions(+), 10 deletions(-)
> >
> > diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
> > index d18754c84f62..d9fb991ef234 100644
> > --- a/include/linux/openvswitch.h
> > +++ b/include/linux/openvswitch.h
> > @@ -1086,11 +1086,11 @@ enum ovs_action_attr {
> > OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
> > OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
> > OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
> > +   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
> >
> >  #ifndef __KERNEL__
> > OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
> > OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
> > -   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
> > OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
> >  #endif
> > __OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
> > diff --git a/lib/dpif.c b/lib/dpif.c
> > index 0f480bec48d0..23eb18495a66 100644
> > --- a/lib/dpif.c
> > +++ b/lib/dpif.c
> > @@ -28,6 +28,7 @@
> >  #include "dpctl.h"
> >  #include "dpif-netdev.h"
> >  #include "flow.h"
> > +#include "netdev-offload.h"
> >  #include "netdev-provider.h"
> >  #include "netdev.h"
> >  #include "netlink.h"
> > @@ -1935,9 +1936,10 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
> >  }
> >
> >  bool
> > -dpif_supports_explicit_drop_action(const struct dpif *dpif)
> > +dpif_may_support_explicit_drop_action(const struct dpif *dpif)
> >  {
> > -return dpif_is_netdev(dpif);
> > +/* TC does not support offloading this action. */
> > +return dpif_is_netdev(dpif) || !netdev_is_flow_api_enabled();
> >  }
> >
> >  bool
> > diff --git a/lib/dpif.h b/lib/dpif.h
> > index 0f2dc2ef3c55..a764e8a592bd 100644
> > --- a/lib/dpif.h
> > +++ b/lib/dpif.h
> > @@ -940,7 +940,7 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
> > odp_port_t port_no,
> >
> >  char *dpif_get_dp_version(const struct dpif *);
> >  bool dpif_supports_tnl_push_pop(const struct dpif *);
> > -bool dpif_supports_explicit_drop_action(const struct dpif *);
> > +bool dpif_may_support_explicit_drop_action(const struct dpif *);
> >  bool dpif_synced_dp_layers(struct dpif *);
> >
> >  /* Log functions. */
> > diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> > index c4e2e867ecdc..32d037be607c 100644
> > --- a/ofproto/ofproto-dpif.c
> > +++ b/ofproto/ofproto-dpif.c
> > @@ -221,6 +221,7 @@ static void ct_zone_config_init(struct dpif_backer 
> > *backer);
> >  static void ct_zone_config_uninit(struct dpif_backer *backer);
> >  static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
> >  static void ct_zone_limits_commit(struct dpif_backer *backer);
> > +static bool recheck_support_explicit_drop_action(struct dpif_backer 
> > *backer);
> >
> >  static inline struct ofproto_dpif *
> >  ofproto_dpif_cast(const struct ofproto *ofproto)
> > @@ -391,6 +392,10 @@ type_run(const char *type)
> >  udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
> >  }
> >
> > +if (recheck_support_explicit_drop_action(backer)) {
> > +backer->need_revalidate = REV_RECONFIGURE;
> > +}
> > +
> >  if (backer->need_revalidate) {
> >  struct ofproto_dpif *ofproto;
> >  struct simap_node *node;
> > @@ -855,7 +860,11 @@ ovs_native_tunneling_is_on(struct ofproto_dpif 
> > *ofproto)
> >  bool
> >  ovs_explicit_drop_action_supported(struct ofproto_dpif *ofproto)
> >  {
> > -return ofproto->backer->rt_support.explicit_drop_action;
> > +bool value;
> > +
> > +atomic_read_relaxed(&ofproto->backer->rt_support.explicit_drop_action,
> > +&value);
> > +retu

[ovs-dev] [PATCH v14 5/6] tests: system-traffic: Add coverage for drop action.

2024-04-03 Thread Eric Garver
Exercise the drop action in the datapath. This specific tests triggers
an xlate_error.

For the kernel datapath skb drop reasons can then be seen while this
test runs.

 # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
   0.000 ping/1275884 skb:kfree_skb(skbaddr: 0x8acd76546000, \
  location: 0xc0ee3634, protocol: 2048, reason: 196611)

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 +++
 2 files changed, 35 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 01ebe364ee7c..2a68cd664e5c 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -374,3 +374,7 @@ m4_define([OVS_CHECK_CT_CLEAR],
 # OVS_CHECK_GITHUB_ACTION
 m4_define([OVS_CHECK_GITHUB_ACTION],
 [AT_SKIP_IF([test "$GITHUB_ACTIONS" = "true"])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports explicit drop action" 
ovs-vswitchd.log])])
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 2d12d558ec2f..cc0d294a0525 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2231,6 +2231,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  strip_ptype | strip_eth | strip_recirc | strip_stats | 
dnl
+  strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_TRAFFIC_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v14 0/6] dpif: probe support for OVS_ACTION_ATTR_DROP

2024-04-03 Thread Eric Garver
v14:
  - remove atomic_init()
  - add bogus dl_type to feature probe
  - ovs_assert() that check_drop_action() returns false when expected
  - add and use missing enum ovs_dec_ttl_attr
v13:
  - use macros strip_ptype and strip_eth in test
v12:
  - new patch to verify re-probe
  - don't mention hw offload in the probe
  - changed log message to not mention HW offload
v11:
  - move netdev and flow API check to lib
  - tweaked log message
  - use atomic store instead of cmpx
  - copy odp in copy_support()
v10:
  - fix a sparse error in show_dp_feature_atomic_bool()
v9:
  - new patch make get_datapath_cap() access support by pointer
  - fix a clang warning in copy_support()
v8:
  - new patch to support atomic_bool dpif field types
  - re-add re-probe of support
  - use atomic_bool type for explicit_drop_action
v7:
  - remove re-probe of support as Ilya is working on a generic solution
v6:
  - improve log if hw-offload enabled
  - re-probe support if hw-offload set true at runtime
v5:
  - combine patches 3 and 4
  - add description to combined patch 3
v4:
  - avoid passing action to datapath if TC offload in use
v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (6):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Make get_datapath_cap() access support by pointer.
  dpif: Support atomic_bool field type.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  tests: system-traffic: Add coverage for drop action.
  tests: system-offload-traffic: Verify re-probe of drop action.

 include/linux/openvswitch.h  |  11 +-
 lib/dpif-netdev.c|   1 +
 lib/dpif.c   |   7 +-
 lib/dpif.h   |   2 +-
 lib/odp-execute.c|   2 +
 lib/odp-util.c   |  23 
 ofproto/ofproto-dpif-ipfix.c |   1 +
 ofproto/ofproto-dpif-sflow.c |   1 +
 ofproto/ofproto-dpif.c   | 186 ---
 ofproto/ofproto-dpif.h   |   4 +-
 tests/system-common-macros.at|   4 +
 tests/system-offloads-traffic.at |  12 ++
 tests/system-traffic.at  |  31 ++
 13 files changed, 240 insertions(+), 45 deletions(-)

-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v14 2/6] dpif: Make get_datapath_cap() access support by pointer.

2024-04-03 Thread Eric Garver
This avoids copying the support struct onto the stack.

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 59 +-
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index fe034f9717b5..8ff165d1ec44 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -5694,47 +5694,46 @@ ct_zone_limit_protection_update(const char 
*datapath_type, bool protected)
 static void
 get_datapath_cap(const char *datapath_type, struct smap *cap)
 {
-struct odp_support odp;
-struct dpif_backer_support s;
+struct dpif_backer_support *s;
 struct dpif_backer *backer = shash_find_data(&all_dpif_backers,
  datapath_type);
 if (!backer) {
 return;
 }
-s = backer->rt_support;
-odp = s.odp;
+s = &backer->rt_support;
 
 /* ODP_SUPPORT_FIELDS */
 smap_add_format(cap, "max_vlan_headers", "%"PRIuSIZE,
-odp.max_vlan_headers);
-smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, odp.max_mpls_depth);
-smap_add(cap, "recirc", odp.recirc ? "true" : "false");
-smap_add(cap, "ct_state", odp.ct_state ? "true" : "false");
-smap_add(cap, "ct_zone", odp.ct_zone ? "true" : "false");
-smap_add(cap, "ct_mark", odp.ct_mark ? "true" : "false");
-smap_add(cap, "ct_label", odp.ct_label ? "true" : "false");
-smap_add(cap, "ct_state_nat", odp.ct_state_nat ? "true" : "false");
-smap_add(cap, "ct_orig_tuple", odp.ct_orig_tuple ? "true" : "false");
-smap_add(cap, "ct_orig_tuple6", odp.ct_orig_tuple6 ? "true" : "false");
-smap_add(cap, "nd_ext", odp.nd_ext ? "true" : "false");
+s->odp.max_vlan_headers);
+smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, s->odp.max_mpls_depth);
+smap_add(cap, "recirc", s->odp.recirc ? "true" : "false");
+smap_add(cap, "ct_state", s->odp.ct_state ? "true" : "false");
+smap_add(cap, "ct_zone", s->odp.ct_zone ? "true" : "false");
+smap_add(cap, "ct_mark", s->odp.ct_mark ? "true" : "false");
+smap_add(cap, "ct_label", s->odp.ct_label ? "true" : "false");
+smap_add(cap, "ct_state_nat", s->odp.ct_state_nat ? "true" : "false");
+smap_add(cap, "ct_orig_tuple", s->odp.ct_orig_tuple ? "true" : "false");
+smap_add(cap, "ct_orig_tuple6", s->odp.ct_orig_tuple6 ? "true" : "false");
+smap_add(cap, "nd_ext", s->odp.nd_ext ? "true" : "false");
 
 /* DPIF_SUPPORT_FIELDS */
-smap_add(cap, "masked_set_action", s.masked_set_action ? "true" : "false");
-smap_add(cap, "tnl_push_pop", s.tnl_push_pop ? "true" : "false");
-smap_add(cap, "ufid", s.ufid ? "true" : "false");
-smap_add(cap, "trunc", s.trunc ? "true" : "false");
-smap_add(cap, "clone", s.clone ? "true" : "false");
-smap_add(cap, "sample_nesting", s.sample_nesting ? "true" : "false");
-smap_add(cap, "ct_eventmask", s.ct_eventmask ? "true" : "false");
-smap_add(cap, "ct_clear", s.ct_clear ? "true" : "false");
-smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s.max_hash_alg);
-smap_add(cap, "check_pkt_len", s.check_pkt_len ? "true" : "false");
-smap_add(cap, "ct_timeout", s.ct_timeout ? "true" : "false");
+smap_add(cap, "masked_set_action",
+ s->masked_set_action ? "true" : "false");
+smap_add(cap, "tnl_push_pop", s->tnl_push_pop ? "true" : "false");
+smap_add(cap, "ufid", s->ufid ? "true" : "false");
+smap_add(cap, "trunc", s->trunc ? "true" : "false");
+smap_add(cap, "clone", s->clone ? "true" : "false");
+smap_add(cap, "sample_nesting", s->sample_nesting ? "true" : "false");
+smap_add(cap, "ct_eventmask", s->ct_eventmask ? "true" : "false");
+smap_add(cap, "ct_clear", s->ct_clear ? "true" : "false");
+smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s->max_hash_alg);
+smap_add(cap, "check_pkt_len", s->check_pkt_len ? "true" : "false");
+smap_add(cap, "ct_timeout", s->ct_timeout ? "true" : "false");
 smap_add(cap, "explicit_drop_action",
- s.explicit_drop_action ? "true" :"false");
-smap_add(cap, "lb_output_action", s.lb_output_action ? "true" : "false");
-smap_add(cap, "ct_zero_snat", s.ct_zero_snat ? "true" : "false");
-smap_add(cap, "add_mpls", s.add_mpls ? "true" : "false");
+ s->explicit_drop_action ? "true" :"false");
+smap_add(cap, "lb_output_action", s->lb_output_action ? "true" : "false");
+smap_add(cap, "ct_zero_snat", s->ct_zero_snat ? "true" : "false");
+smap_add(cap, "add_mpls", s->add_mpls ? "true" : "false");
 
 /* The ct_tuple_flush is implemented on dpif level, so it is supported
  * for all backers. */
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v14 6/6] tests: system-offload-traffic: Verify re-probe of drop action.

2024-04-03 Thread Eric Garver
Verify that the explicit drop action is re-probed if the hw-offload flag
is changed.

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 tests/system-offloads-traffic.at | 12 
 1 file changed, 12 insertions(+)

diff --git a/tests/system-offloads-traffic.at b/tests/system-offloads-traffic.at
index 6bd49a3eef30..899a8e9bca2f 100644
--- a/tests/system-offloads-traffic.at
+++ b/tests/system-offloads-traffic.at
@@ -921,3 +921,15 @@ AT_CHECK([tc -d filter show dev ovs-p0 ingress | grep -q 
"csum (iph)"], [0])
 
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([offloads - re-probe drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+dnl trigger a re-probe of the explicit drop action
+AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=true])
+OVS_WAIT_UNTIL([grep -q "Datapath does not support explicit drop action" 
ovs-vswitchd.log])
+
+OVS_TRAFFIC_VSWITCHD_STOP
+AT_CLEANUP
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v14 3/6] dpif: Support atomic_bool field type.

2024-04-03 Thread Eric Garver
The next commit will convert a dp feature from bool to atomic_bool. As
such we have to add support to the macros and functions. We must pass by
reference instead of pass by value because all the atomic operations
require a reference.

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 54 --
 1 file changed, 47 insertions(+), 7 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 8ff165d1ec44..c4e2e867ecdc 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -717,6 +717,8 @@ close_dpif_backer(struct dpif_backer *backer, bool del)
 }
 
 static void check_support(struct dpif_backer *backer);
+static void copy_support(struct dpif_backer_support *dst,
+ struct dpif_backer_support *src);
 
 static int
 open_dpif_backer(const char *type, struct dpif_backer **backerp)
@@ -837,7 +839,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
  * 'boottime_support' can be checked to prevent 'support' to be changed
  * beyond the datapath capabilities. In case 'support' is changed by
  * the user, 'boottime_support' can be used to restore it.  */
-backer->bt_support = backer->rt_support;
+copy_support(&backer->bt_support, &backer->rt_support);
 
 return error;
 }
@@ -1611,6 +1613,24 @@ CHECK_FEATURE__(ct_orig_tuple6, ct_orig_tuple6, 
ct_nw_proto, 1, ETH_TYPE_IPV6)
 #undef CHECK_FEATURE
 #undef CHECK_FEATURE__
 
+static void
+copy_support(struct dpif_backer_support *dst, struct dpif_backer_support *src)
+{
+#define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
+if (!strcmp(#TYPE, "atomic_bool")) { \
+bool value; \
+atomic_read_relaxed((atomic_bool *) &src->NAME, &value); \
+atomic_store_relaxed((atomic_bool *) &dst->NAME, value); \
+} else { \
+dst->NAME = src->NAME; \
+}
+
+DPIF_SUPPORT_FIELDS
+#undef DPIF_SUPPORT_FIELD
+
+dst->odp = src->odp;
+}
+
 static void
 check_support(struct dpif_backer *backer)
 {
@@ -6254,20 +6274,30 @@ ofproto_unixctl_dpif_dump_dps(struct unixctl_conn 
*conn, int argc OVS_UNUSED,
 }
 
 static void
-show_dp_feature_bool(struct ds *ds, const char *feature, bool b)
+show_dp_feature_bool(struct ds *ds, const char *feature, const bool *b)
 {
-ds_put_format(ds, "%s: %s\n", feature, b ? "Yes" : "No");
+ds_put_format(ds, "%s: %s\n", feature, *b ? "Yes" : "No");
+}
+
+static void OVS_UNUSED
+show_dp_feature_atomic_bool(struct ds *ds, const char *feature,
+const atomic_bool *b)
+{
+bool value;
+atomic_read_relaxed((atomic_bool *) b, &value);
+ds_put_format(ds, "%s: %s\n", feature, value ? "Yes" : "No");
 }
 
 static void
-show_dp_feature_size_t(struct ds *ds, const char *feature, size_t s)
+show_dp_feature_size_t(struct ds *ds, const char *feature, const size_t *s)
 {
-ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, s);
+ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, *s);
 }
 
 enum dpif_support_field_type {
 DPIF_SUPPORT_FIELD_bool,
 DPIF_SUPPORT_FIELD_size_t,
+DPIF_SUPPORT_FIELD_atomic_bool,
 };
 
 struct dpif_support_field {
@@ -6284,12 +6314,12 @@ static void
 dpif_show_support(const struct dpif_backer_support *support, struct ds *ds)
 {
 #define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->NAME);
+show_dp_feature_##TYPE (ds, TITLE, &support->NAME);
 DPIF_SUPPORT_FIELDS
 #undef DPIF_SUPPORT_FIELD
 
 #define ODP_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->odp.NAME );
+show_dp_feature_##TYPE (ds, TITLE, &support->odp.NAME );
 ODP_SUPPORT_FIELDS
 #undef ODP_SUPPORT_FIELD
 }
@@ -6308,6 +6338,16 @@ display_support_field(const char *name,
   b ? "true" : "false");
 break;
 }
+case DPIF_SUPPORT_FIELD_atomic_bool: {
+bool b, v;
+
+atomic_read_relaxed((atomic_bool *) field->rt_ptr, &v);
+atomic_read_relaxed((atomic_bool *) field->bt_ptr, &b);
+ds_put_format(ds, "%s (%s) : [run time]:%s, [boot time]:%s\n", name,
+  field->title, v ? "true" : "false",
+  b ? "true" : "false");
+break;
+}
 case DPIF_SUPPORT_FIELD_size_t:
 ds_put_format(ds, "%s (%s) : [run time]:%"PRIuSIZE
   ", [boot time]:%"PRIuSIZE"\n", name,
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v14 4/6] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-04-03 Thread Eric Garver
Kernel support has been added for this action. As such, we need to probe
the datapath for support.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 ++-
 lib/dpif.h  |  2 +-
 ofproto/ofproto-dpif.c  | 77 ++---
 ofproto/ofproto-dpif.h  |  4 +-
 5 files changed, 81 insertions(+), 10 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index d18754c84f62..d9fb991ef234 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index 0f480bec48d0..23eb18495a66 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -28,6 +28,7 @@
 #include "dpctl.h"
 #include "dpif-netdev.h"
 #include "flow.h"
+#include "netdev-offload.h"
 #include "netdev-provider.h"
 #include "netdev.h"
 #include "netlink.h"
@@ -1935,9 +1936,10 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 }
 
 bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
+dpif_may_support_explicit_drop_action(const struct dpif *dpif)
 {
-return dpif_is_netdev(dpif);
+/* TC does not support offloading this action. */
+return dpif_is_netdev(dpif) || !netdev_is_flow_api_enabled();
 }
 
 bool
diff --git a/lib/dpif.h b/lib/dpif.h
index 0f2dc2ef3c55..a764e8a592bd 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,7 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
+bool dpif_may_support_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index c4e2e867ecdc..32d037be607c 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -221,6 +221,7 @@ static void ct_zone_config_init(struct dpif_backer *backer);
 static void ct_zone_config_uninit(struct dpif_backer *backer);
 static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
 static void ct_zone_limits_commit(struct dpif_backer *backer);
+static bool recheck_support_explicit_drop_action(struct dpif_backer *backer);
 
 static inline struct ofproto_dpif *
 ofproto_dpif_cast(const struct ofproto *ofproto)
@@ -391,6 +392,10 @@ type_run(const char *type)
 udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
 }
 
+if (recheck_support_explicit_drop_action(backer)) {
+backer->need_revalidate = REV_RECONFIGURE;
+}
+
 if (backer->need_revalidate) {
 struct ofproto_dpif *ofproto;
 struct simap_node *node;
@@ -855,7 +860,11 @@ ovs_native_tunneling_is_on(struct ofproto_dpif *ofproto)
 bool
 ovs_explicit_drop_action_supported(struct ofproto_dpif *ofproto)
 {
-return ofproto->backer->rt_support.explicit_drop_action;
+bool value;
+
+atomic_read_relaxed(&ofproto->backer->rt_support.explicit_drop_action,
+&value);
+return value;
 }
 
 bool
@@ -1379,6 +1388,40 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+bool supported;
+
+struct flow flow = {
+.dl_type = CONSTANT_HTONS(0x1234), /* bogus */
+};
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_ATTR_DROP, XLATE_OK);
+
+supported = dpif_may_support_explicit_drop_action(backer->dpif) &&
+dpif_probe_feature(backer->dpif, "drop", &key, &actions, NULL);
+
+VLOG_INFO("%s: Datapath %s explicit drop action",
+

[ovs-dev] [PATCH v14 1/6] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2024-04-03 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  9 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 38 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..d18754c84f62 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
@@ -1183,6 +1184,14 @@ struct ovs_zone_limit {
__u32 count;
 };
 
+enum ovs_dec_ttl_attr {
+   OVS_DEC_TTL_ATTR_UNSPEC,
+   OVS_DEC_TTL_ATTR_ACTION,/* Nested struct nlattr */
+   __OVS_DEC_TTL_ATTR_MAX
+};
+
+#define OVS_DEC_TTL_ATTR_MAX (__OVS_DEC_TTL_ATTR_MAX - 1)
+
 #define OVS_CLONE_ATTR_EXEC  0   /* Specify an u32 value. When nonzero,
  * actions in clone will not change flow
  * keys. False otherwise.
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index e6c53937d8b9..89b0d1d6b4aa 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9489,6 +9489,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index d07241f1e7cd..0f480bec48d0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1289,6 +1289,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index eb03b57c42ec..081e4d43268a 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -837,6 +837,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1227,6 +1228,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 9306c9b4d47a..21f34d95571c 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_DEC_TTL_ATTR_ACTION) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_

Re: [ovs-dev] [PATCH v13 4/6] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-04-03 Thread Eric Garver
On Wed, Apr 03, 2024 at 12:42:25AM +0200, Ilya Maximets wrote:
> On 4/3/24 00:28, Eric Garver wrote:
> > On Fri, Mar 29, 2024 at 12:26:11AM +0100, Ilya Maximets wrote:
> >> On 3/22/24 14:54, Eric Garver wrote:
> > [..]
> >>> @@ -1649,8 +1693,8 @@ check_support(struct dpif_backer *backer)
> >>>  backer->rt_support.max_hash_alg = check_max_dp_hash_alg(backer);
> >>>  backer->rt_support.check_pkt_len = check_check_pkt_len(backer);
> >>>  backer->rt_support.ct_timeout = check_ct_timeout_policy(backer);
> >>> -backer->rt_support.explicit_drop_action =
> >>> -dpif_supports_explicit_drop_action(backer->dpif);
> >>> +atomic_store_relaxed(&backer->rt_support.explicit_drop_action,
> >>> + check_drop_action(backer));
> >>>  backer->rt_support.lb_output_action =
> >>>  dpif_supports_lb_output_action(backer->dpif);
> >>>  backer->rt_support.ct_zero_snat = dpif_supports_ct_zero_snat(backer);
> >>> @@ -1667,6 +1711,28 @@ check_support(struct dpif_backer *backer)
> >>>  backer->rt_support.odp.nd_ext = check_nd_extensions(backer);
> >>>  }
> >>>  
> >>> +/* TC does not support offloading the explicit drop action. As such we 
> >>> need to
> >>> + * re-probe the datapath if hw-offload has been modified.
> >>> + * Note: We don't support true --> false transition as that requires a 
> >>> restart.
> >>> + * See netdev_set_flow_api_enabled(). */
> >>> +static bool
> >>> +recheck_support_explicit_drop_action(struct dpif_backer *backer)
> >>> +{
> >>> +bool explicit_drop_action;
> >>> +
> >>> +atomic_read_relaxed(&backer->rt_support.explicit_drop_action,
> >>> +&explicit_drop_action);
> >>> +
> >>> +if (explicit_drop_action
> >>> +&& !dpif_may_support_explicit_drop_action(backer->dpif)
> >>> +&& !check_drop_action(backer)) {
> >>
> >> Shouldn't last two conditions be || instad of && ?
> > 
> > Assuming you mean:
> > 
> > if (explicit_drop_action &&
> > (!dpif_may_support_explicit_drop_action(backer->dpif) ||
> >  !check_drop_action(backer))) {
> > 
> > Then I don't think so. This function is periodically called from
> > type_run(). If we use || here, then the usual case is that
> > dpif_may_support_explicit_drop_action() will return true, i.e.
> > hw-offload=false. That would force check_drop_action() to be called.
> > 
> > Basically we want to avoid calling check_drop_action() by guarding it
> > with the much cheaper dpif_may_support_explicit_drop_action().
> 
> Hmm, OK.  But why do we call check_drop_action() here at all then?
> Just for the log message?

Yeah, I guess just for the log.

> Maybe it's better then to do something like:
> 
> if (explicit_drop_action &&
> && !dpif_may_support_explicit_drop_action(backer->dpif)) {
> ovs_assert(!check_drop_action(backer));
> atomic_store_relaxed( ..., false);
> return true;
> }
> 
> What do you think?

That will work. Alternatively we could add a VLOG_INFO() here. I like
the assert though as it keeps everything neatly in check_drop_action().

> Best regards, Ilya Maximets.
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> 

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v13 4/6] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-04-02 Thread Eric Garver
On Fri, Mar 29, 2024 at 12:26:11AM +0100, Ilya Maximets wrote:
> On 3/22/24 14:54, Eric Garver wrote:
[..]
> > @@ -1649,8 +1693,8 @@ check_support(struct dpif_backer *backer)
> >  backer->rt_support.max_hash_alg = check_max_dp_hash_alg(backer);
> >  backer->rt_support.check_pkt_len = check_check_pkt_len(backer);
> >  backer->rt_support.ct_timeout = check_ct_timeout_policy(backer);
> > -backer->rt_support.explicit_drop_action =
> > -dpif_supports_explicit_drop_action(backer->dpif);
> > +atomic_store_relaxed(&backer->rt_support.explicit_drop_action,
> > + check_drop_action(backer));
> >  backer->rt_support.lb_output_action =
> >  dpif_supports_lb_output_action(backer->dpif);
> >  backer->rt_support.ct_zero_snat = dpif_supports_ct_zero_snat(backer);
> > @@ -1667,6 +1711,28 @@ check_support(struct dpif_backer *backer)
> >  backer->rt_support.odp.nd_ext = check_nd_extensions(backer);
> >  }
> >  
> > +/* TC does not support offloading the explicit drop action. As such we 
> > need to
> > + * re-probe the datapath if hw-offload has been modified.
> > + * Note: We don't support true --> false transition as that requires a 
> > restart.
> > + * See netdev_set_flow_api_enabled(). */
> > +static bool
> > +recheck_support_explicit_drop_action(struct dpif_backer *backer)
> > +{
> > +bool explicit_drop_action;
> > +
> > +atomic_read_relaxed(&backer->rt_support.explicit_drop_action,
> > +&explicit_drop_action);
> > +
> > +if (explicit_drop_action
> > +&& !dpif_may_support_explicit_drop_action(backer->dpif)
> > +&& !check_drop_action(backer)) {
> 
> Shouldn't last two conditions be || instad of && ?

Assuming you mean:

if (explicit_drop_action &&
(!dpif_may_support_explicit_drop_action(backer->dpif) ||
 !check_drop_action(backer))) {

Then I don't think so. This function is periodically called from
type_run(). If we use || here, then the usual case is that
dpif_may_support_explicit_drop_action() will return true, i.e.
hw-offload=false. That would force check_drop_action() to be called.

Basically we want to avoid calling check_drop_action() by guarding it
with the much cheaper dpif_may_support_explicit_drop_action().

> > +atomic_store_relaxed(&backer->rt_support.explicit_drop_action, 
> > false);
> > +return true;
> > +}
> > +
> > +return false;
> > +}
> > +
[..]

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v13 4/6] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-04-02 Thread Eric Garver
On Fri, Mar 29, 2024 at 12:26:11AM +0100, Ilya Maximets wrote:
> On 3/22/24 14:54, Eric Garver wrote:
> > Kernel support has been added for this action. As such, we need to probe
> > the datapath for support.
> > 
> > Acked-by: Eelco Chaudron 
> > Signed-off-by: Eric Garver 
> > ---
> >  include/linux/openvswitch.h |  2 +-
> >  lib/dpif.c  |  6 ++-
> >  lib/dpif.h  |  2 +-
> >  ofproto/ofproto-dpif.c  | 78 ++---
> >  ofproto/ofproto-dpif.h  |  4 +-
> >  5 files changed, 82 insertions(+), 10 deletions(-)
> > 
> > diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
> > index a265e05ad253..fce6456f47c8 100644
> > --- a/include/linux/openvswitch.h
> > +++ b/include/linux/openvswitch.h
> > @@ -1086,11 +1086,11 @@ enum ovs_action_attr {
> > OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
> > OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
> > OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
> > +   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
> >  
> >  #ifndef __KERNEL__
> > OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
> > OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
> > -   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
> > OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
> >  #endif
> > __OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
> > diff --git a/lib/dpif.c b/lib/dpif.c
> > index 0f480bec48d0..23eb18495a66 100644
> > --- a/lib/dpif.c
> > +++ b/lib/dpif.c
> > @@ -28,6 +28,7 @@
> >  #include "dpctl.h"
> >  #include "dpif-netdev.h"
> >  #include "flow.h"
> > +#include "netdev-offload.h"
> >  #include "netdev-provider.h"
> >  #include "netdev.h"
> >  #include "netlink.h"
> > @@ -1935,9 +1936,10 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
> >  }
> >  
> >  bool
> > -dpif_supports_explicit_drop_action(const struct dpif *dpif)
> > +dpif_may_support_explicit_drop_action(const struct dpif *dpif)
> >  {
> > -return dpif_is_netdev(dpif);
> > +/* TC does not support offloading this action. */
> > +return dpif_is_netdev(dpif) || !netdev_is_flow_api_enabled();
> >  }
> >  
> >  bool
> > diff --git a/lib/dpif.h b/lib/dpif.h
> > index 0f2dc2ef3c55..a764e8a592bd 100644
> > --- a/lib/dpif.h
> > +++ b/lib/dpif.h
> > @@ -940,7 +940,7 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
> > odp_port_t port_no,
> >  
> >  char *dpif_get_dp_version(const struct dpif *);
> >  bool dpif_supports_tnl_push_pop(const struct dpif *);
> > -bool dpif_supports_explicit_drop_action(const struct dpif *);
> > +bool dpif_may_support_explicit_drop_action(const struct dpif *);
> >  bool dpif_synced_dp_layers(struct dpif *);
> >  
> >  /* Log functions. */
> > diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> > index c4e2e867ecdc..b854ba3636ed 100644
> > --- a/ofproto/ofproto-dpif.c
> > +++ b/ofproto/ofproto-dpif.c
> > @@ -221,6 +221,7 @@ static void ct_zone_config_init(struct dpif_backer 
> > *backer);
> >  static void ct_zone_config_uninit(struct dpif_backer *backer);
> >  static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
> >  static void ct_zone_limits_commit(struct dpif_backer *backer);
> > +static bool recheck_support_explicit_drop_action(struct dpif_backer 
> > *backer);
> >  
> >  static inline struct ofproto_dpif *
> >  ofproto_dpif_cast(const struct ofproto *ofproto)
> > @@ -391,6 +392,10 @@ type_run(const char *type)
> >  udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
> >  }
> >  
> > +if (recheck_support_explicit_drop_action(backer)) {
> > +backer->need_revalidate = REV_RECONFIGURE;
> > +}
> > +
> >  if (backer->need_revalidate) {
> >  struct ofproto_dpif *ofproto;
> >  struct simap_node *node;
> > @@ -807,6 +812,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
> > **backerp)
> >  
> >  shash_add(&all_dpif_backers, type, backer);
> >  
> > +atomic_init(&backer->rt_support.explicit_drop_action, false);
> 
> This initialization seems unnecessary since the field will be initialized
> in the check_support() right after.  And it also a bit out of place, since

Re: [ovs-dev] [PATCH v13 1/6] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2024-04-02 Thread Eric Garver
On Thu, Mar 28, 2024 at 11:13:13PM +0100, Ilya Maximets wrote:
> On 3/22/24 14:54, Eric Garver wrote:
> > This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
> > action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
> > to make -Werror happy we must add a case to all existing switches.
> > 
> > Acked-by: Eelco Chaudron 
> > Signed-off-by: Eric Garver 
> > ---
> >  include/linux/openvswitch.h  |  1 +
> >  lib/dpif-netdev.c|  1 +
> >  lib/dpif.c   |  1 +
> >  lib/odp-execute.c|  2 ++
> >  lib/odp-util.c   | 23 +++
> >  ofproto/ofproto-dpif-ipfix.c |  1 +
> >  ofproto/ofproto-dpif-sflow.c |  1 +
> >  7 files changed, 30 insertions(+)
> > 
> > diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
> > index e305c331516b..a265e05ad253 100644
> > --- a/include/linux/openvswitch.h
> > +++ b/include/linux/openvswitch.h
> > @@ -1085,6 +1085,7 @@ enum ovs_action_attr {
> > OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
> > OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
> > OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
> > +   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
> >  
> >  #ifndef __KERNEL__
> > OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
> > diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> > index e6c53937d8b9..89b0d1d6b4aa 100644
> > --- a/lib/dpif-netdev.c
> > +++ b/lib/dpif-netdev.c
> > @@ -9489,6 +9489,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
> > *packets_,
> >  case OVS_ACTION_ATTR_CHECK_PKT_LEN:
> >  case OVS_ACTION_ATTR_DROP:
> >  case OVS_ACTION_ATTR_ADD_MPLS:
> > +case OVS_ACTION_ATTR_DEC_TTL:
> >  case __OVS_ACTION_ATTR_MAX:
> >  OVS_NOT_REACHED();
> >  }
> > diff --git a/lib/dpif.c b/lib/dpif.c
> > index d07241f1e7cd..0f480bec48d0 100644
> > --- a/lib/dpif.c
> > +++ b/lib/dpif.c
> > @@ -1289,6 +1289,7 @@ dpif_execute_helper_cb(void *aux_, struct 
> > dp_packet_batch *packets_,
> >  case OVS_ACTION_ATTR_CHECK_PKT_LEN:
> >  case OVS_ACTION_ATTR_DROP:
> >  case OVS_ACTION_ATTR_ADD_MPLS:
> > +case OVS_ACTION_ATTR_DEC_TTL:
> >  case __OVS_ACTION_ATTR_MAX:
> >  OVS_NOT_REACHED();
> >  }
> > diff --git a/lib/odp-execute.c b/lib/odp-execute.c
> > index eb03b57c42ec..081e4d43268a 100644
> > --- a/lib/odp-execute.c
> > +++ b/lib/odp-execute.c
> > @@ -837,6 +837,7 @@ requires_datapath_assistance(const struct nlattr *a)
> >  case OVS_ACTION_ATTR_CT_CLEAR:
> >  case OVS_ACTION_ATTR_CHECK_PKT_LEN:
> >  case OVS_ACTION_ATTR_ADD_MPLS:
> > +case OVS_ACTION_ATTR_DEC_TTL:
> >  case OVS_ACTION_ATTR_DROP:
> >  return false;
> >  
> > @@ -1227,6 +1228,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
> > *batch, bool steal,
> >  case OVS_ACTION_ATTR_RECIRC:
> >  case OVS_ACTION_ATTR_CT:
> >  case OVS_ACTION_ATTR_UNSPEC:
> > +case OVS_ACTION_ATTR_DEC_TTL:
> >  case __OVS_ACTION_ATTR_MAX:
> >  /* The following actions are handled by the scalar implementation. 
> > */
> >  case OVS_ACTION_ATTR_POP_VLAN:
> > diff --git a/lib/odp-util.c b/lib/odp-util.c
> > index 9306c9b4d47a..f4c492f2ae6f 100644
> > --- a/lib/odp-util.c
> > +++ b/lib/odp-util.c
> > @@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
> >  case OVS_ACTION_ATTR_POP_NSH: return 0;
> >  case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
> >  case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct 
> > ovs_action_add_mpls);
> > +case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
> >  case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
> >  
> >  case OVS_ACTION_ATTR_UNSPEC:
> > @@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
> > struct nlattr *attr,
> >  ds_put_cstr(ds, "))");
> >  }
> >  
> > +static void
> > +format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
> > +  const struct hmap *portno_names)
> > +{
> > +const struct nlattr *a;
> > +unsigned int left;
> > +
> > +ds_put_cstr(ds,"dec_ttl(le_1(");
> > +NL_ATTR_FOR_EACH (a, left,
> > +  nl_attr_get(attr), nl_attr_get_size(attr)) {
> > +if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
> 
> Hmm.  This doesn't seem correct.  There should be OVS_DEC_TTL_ATTR_ACTION
> instead of OVS_ACTION_ATTR_DEC_TTL.   And we're missing the definition
> of the enum ovs_dec_ttl_attr in openvswitch.h.

Right! Thanks for catching this.

> I know this implementation is not going to be actually used in most cases,
> unless someone manually adds the flow to the kernel, but we shouldn't have
> incorrect code anyway.

[..]

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v13 5/6] tests: system-traffic: Add coverage for drop action.

2024-03-22 Thread Eric Garver
Exercise the drop action in the datapath. This specific tests triggers
an xlate_error.

For the kernel datapath skb drop reasons can then be seen while this
test runs.

 # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
   0.000 ping/1275884 skb:kfree_skb(skbaddr: 0x8acd76546000, \
  location: 0xc0ee3634, protocol: 2048, reason: 196611)

Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 +++
 2 files changed, 35 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 01ebe364ee7c..2a68cd664e5c 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -374,3 +374,7 @@ m4_define([OVS_CHECK_CT_CLEAR],
 # OVS_CHECK_GITHUB_ACTION
 m4_define([OVS_CHECK_GITHUB_ACTION],
 [AT_SKIP_IF([test "$GITHUB_ACTIONS" = "true"])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports explicit drop action" 
ovs-vswitchd.log])])
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 2d12d558ec2f..cc0d294a0525 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2231,6 +2231,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  strip_ptype | strip_eth | strip_recirc | strip_stats | 
dnl
+  strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_TRAFFIC_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v13 3/6] dpif: Support atomic_bool field type.

2024-03-22 Thread Eric Garver
The next commit will convert a dp feature from bool to atomic_bool. As
such we have to add support to the macros and functions. We must pass by
reference instead of pass by value because all the atomic operations
require a reference.

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 54 --
 1 file changed, 47 insertions(+), 7 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 8ff165d1ec44..c4e2e867ecdc 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -717,6 +717,8 @@ close_dpif_backer(struct dpif_backer *backer, bool del)
 }
 
 static void check_support(struct dpif_backer *backer);
+static void copy_support(struct dpif_backer_support *dst,
+ struct dpif_backer_support *src);
 
 static int
 open_dpif_backer(const char *type, struct dpif_backer **backerp)
@@ -837,7 +839,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
  * 'boottime_support' can be checked to prevent 'support' to be changed
  * beyond the datapath capabilities. In case 'support' is changed by
  * the user, 'boottime_support' can be used to restore it.  */
-backer->bt_support = backer->rt_support;
+copy_support(&backer->bt_support, &backer->rt_support);
 
 return error;
 }
@@ -1611,6 +1613,24 @@ CHECK_FEATURE__(ct_orig_tuple6, ct_orig_tuple6, 
ct_nw_proto, 1, ETH_TYPE_IPV6)
 #undef CHECK_FEATURE
 #undef CHECK_FEATURE__
 
+static void
+copy_support(struct dpif_backer_support *dst, struct dpif_backer_support *src)
+{
+#define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
+if (!strcmp(#TYPE, "atomic_bool")) { \
+bool value; \
+atomic_read_relaxed((atomic_bool *) &src->NAME, &value); \
+atomic_store_relaxed((atomic_bool *) &dst->NAME, value); \
+} else { \
+dst->NAME = src->NAME; \
+}
+
+DPIF_SUPPORT_FIELDS
+#undef DPIF_SUPPORT_FIELD
+
+dst->odp = src->odp;
+}
+
 static void
 check_support(struct dpif_backer *backer)
 {
@@ -6254,20 +6274,30 @@ ofproto_unixctl_dpif_dump_dps(struct unixctl_conn 
*conn, int argc OVS_UNUSED,
 }
 
 static void
-show_dp_feature_bool(struct ds *ds, const char *feature, bool b)
+show_dp_feature_bool(struct ds *ds, const char *feature, const bool *b)
 {
-ds_put_format(ds, "%s: %s\n", feature, b ? "Yes" : "No");
+ds_put_format(ds, "%s: %s\n", feature, *b ? "Yes" : "No");
+}
+
+static void OVS_UNUSED
+show_dp_feature_atomic_bool(struct ds *ds, const char *feature,
+const atomic_bool *b)
+{
+bool value;
+atomic_read_relaxed((atomic_bool *) b, &value);
+ds_put_format(ds, "%s: %s\n", feature, value ? "Yes" : "No");
 }
 
 static void
-show_dp_feature_size_t(struct ds *ds, const char *feature, size_t s)
+show_dp_feature_size_t(struct ds *ds, const char *feature, const size_t *s)
 {
-ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, s);
+ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, *s);
 }
 
 enum dpif_support_field_type {
 DPIF_SUPPORT_FIELD_bool,
 DPIF_SUPPORT_FIELD_size_t,
+DPIF_SUPPORT_FIELD_atomic_bool,
 };
 
 struct dpif_support_field {
@@ -6284,12 +6314,12 @@ static void
 dpif_show_support(const struct dpif_backer_support *support, struct ds *ds)
 {
 #define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->NAME);
+show_dp_feature_##TYPE (ds, TITLE, &support->NAME);
 DPIF_SUPPORT_FIELDS
 #undef DPIF_SUPPORT_FIELD
 
 #define ODP_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->odp.NAME );
+show_dp_feature_##TYPE (ds, TITLE, &support->odp.NAME );
 ODP_SUPPORT_FIELDS
 #undef ODP_SUPPORT_FIELD
 }
@@ -6308,6 +6338,16 @@ display_support_field(const char *name,
   b ? "true" : "false");
 break;
 }
+case DPIF_SUPPORT_FIELD_atomic_bool: {
+bool b, v;
+
+atomic_read_relaxed((atomic_bool *) field->rt_ptr, &v);
+atomic_read_relaxed((atomic_bool *) field->bt_ptr, &b);
+ds_put_format(ds, "%s (%s) : [run time]:%s, [boot time]:%s\n", name,
+  field->title, v ? "true" : "false",
+  b ? "true" : "false");
+break;
+}
 case DPIF_SUPPORT_FIELD_size_t:
 ds_put_format(ds, "%s (%s) : [run time]:%"PRIuSIZE
   ", [boot time]:%"PRIuSIZE"\n", name,
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v13 4/6] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-03-22 Thread Eric Garver
Kernel support has been added for this action. As such, we need to probe
the datapath for support.

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 ++-
 lib/dpif.h  |  2 +-
 ofproto/ofproto-dpif.c  | 78 ++---
 ofproto/ofproto-dpif.h  |  4 +-
 5 files changed, 82 insertions(+), 10 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index 0f480bec48d0..23eb18495a66 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -28,6 +28,7 @@
 #include "dpctl.h"
 #include "dpif-netdev.h"
 #include "flow.h"
+#include "netdev-offload.h"
 #include "netdev-provider.h"
 #include "netdev.h"
 #include "netlink.h"
@@ -1935,9 +1936,10 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 }
 
 bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
+dpif_may_support_explicit_drop_action(const struct dpif *dpif)
 {
-return dpif_is_netdev(dpif);
+/* TC does not support offloading this action. */
+return dpif_is_netdev(dpif) || !netdev_is_flow_api_enabled();
 }
 
 bool
diff --git a/lib/dpif.h b/lib/dpif.h
index 0f2dc2ef3c55..a764e8a592bd 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,7 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
+bool dpif_may_support_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index c4e2e867ecdc..b854ba3636ed 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -221,6 +221,7 @@ static void ct_zone_config_init(struct dpif_backer *backer);
 static void ct_zone_config_uninit(struct dpif_backer *backer);
 static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
 static void ct_zone_limits_commit(struct dpif_backer *backer);
+static bool recheck_support_explicit_drop_action(struct dpif_backer *backer);
 
 static inline struct ofproto_dpif *
 ofproto_dpif_cast(const struct ofproto *ofproto)
@@ -391,6 +392,10 @@ type_run(const char *type)
 udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
 }
 
+if (recheck_support_explicit_drop_action(backer)) {
+backer->need_revalidate = REV_RECONFIGURE;
+}
+
 if (backer->need_revalidate) {
 struct ofproto_dpif *ofproto;
 struct simap_node *node;
@@ -807,6 +812,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
 
 shash_add(&all_dpif_backers, type, backer);
 
+atomic_init(&backer->rt_support.explicit_drop_action, false);
 check_support(backer);
 atomic_count_init(&backer->tnl_count, 0);
 
@@ -855,7 +861,12 @@ ovs_native_tunneling_is_on(struct ofproto_dpif *ofproto)
 bool
 ovs_explicit_drop_action_supported(struct ofproto_dpif *ofproto)
 {
-return ofproto->backer->rt_support.explicit_drop_action;
+bool value;
+
+atomic_read_relaxed(&ofproto->backer->rt_support.explicit_drop_action,
+&value);
+
+return value;
 }
 
 bool
@@ -1379,6 +1390,39 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&

[ovs-dev] [PATCH v13 6/6] tests: system-offload-traffic: Verify re-probe of drop action.

2024-03-22 Thread Eric Garver
Verify that the explicit drop action is re-probed if the hw-offload flag
is changed.

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 tests/system-offloads-traffic.at | 12 
 1 file changed, 12 insertions(+)

diff --git a/tests/system-offloads-traffic.at b/tests/system-offloads-traffic.at
index 6bd49a3eef30..899a8e9bca2f 100644
--- a/tests/system-offloads-traffic.at
+++ b/tests/system-offloads-traffic.at
@@ -921,3 +921,15 @@ AT_CHECK([tc -d filter show dev ovs-p0 ingress | grep -q 
"csum (iph)"], [0])
 
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([offloads - re-probe drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+dnl trigger a re-probe of the explicit drop action
+AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=true])
+OVS_WAIT_UNTIL([grep -q "Datapath does not support explicit drop action" 
ovs-vswitchd.log])
+
+OVS_TRAFFIC_VSWITCHD_STOP
+AT_CLEANUP
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v13 0/6] dpif: probe support for OVS_ACTION_ATTR_DROP

2024-03-22 Thread Eric Garver
v13:
  - use macros strip_ptype and strip_eth in test
v12:
  - new patch to verify re-probe
  - don't mention hw offload in the probe
  - changed log message to not mention HW offload
v11:
  - move netdev and flow API check to lib
  - tweaked log message
  - use atomic store instead of cmpx
  - copy odp in copy_support()
v10:
  - fix a sparse error in show_dp_feature_atomic_bool()
v9:
  - new patch make get_datapath_cap() access support by pointer
  - fix a clang warning in copy_support()
v8:
  - new patch to support atomic_bool dpif field types
  - re-add re-probe of support
  - use atomic_bool type for explicit_drop_action
v7:
  - remove re-probe of support as Ilya is working on a generic solution
v6:
  - improve log if hw-offload enabled
  - re-probe support if hw-offload set true at runtime
v5:
  - combine patches 3 and 4
  - add description to combined patch 3
v4:
  - avoid passing action to datapath if TC offload in use
v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (6):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Make get_datapath_cap() access support by pointer.
  dpif: Support atomic_bool field type.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  tests: system-traffic: Add coverage for drop action.
  tests: system-offload-traffic: Verify re-probe of drop action.

 include/linux/openvswitch.h  |   3 +-
 lib/dpif-netdev.c|   1 +
 lib/dpif.c   |   7 +-
 lib/dpif.h   |   2 +-
 lib/odp-execute.c|   2 +
 lib/odp-util.c   |  23 
 ofproto/ofproto-dpif-ipfix.c |   1 +
 ofproto/ofproto-dpif-sflow.c |   1 +
 ofproto/ofproto-dpif.c   | 187 ---
 ofproto/ofproto-dpif.h   |   4 +-
 tests/system-common-macros.at|   4 +
 tests/system-offloads-traffic.at |  12 ++
 tests/system-traffic.at  |  31 +
 13 files changed, 233 insertions(+), 45 deletions(-)

-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v13 1/6] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2024-03-22 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  1 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 30 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index e6c53937d8b9..89b0d1d6b4aa 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9489,6 +9489,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index d07241f1e7cd..0f480bec48d0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1289,6 +1289,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index eb03b57c42ec..081e4d43268a 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -837,6 +837,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1227,6 +1228,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 9306c9b4d47a..f4c492f2ae6f 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_names);
+break;
 case OVS_ACTION_ATTR_DROP:
 ds_put_cstr(ds, "drop");
 break;
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..cd65dae7e18a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3135,6 +3135,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_D

[ovs-dev] [PATCH v13 2/6] dpif: Make get_datapath_cap() access support by pointer.

2024-03-22 Thread Eric Garver
This avoids copying the support struct onto the stack.

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 59 +-
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index fe034f9717b5..8ff165d1ec44 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -5694,47 +5694,46 @@ ct_zone_limit_protection_update(const char 
*datapath_type, bool protected)
 static void
 get_datapath_cap(const char *datapath_type, struct smap *cap)
 {
-struct odp_support odp;
-struct dpif_backer_support s;
+struct dpif_backer_support *s;
 struct dpif_backer *backer = shash_find_data(&all_dpif_backers,
  datapath_type);
 if (!backer) {
 return;
 }
-s = backer->rt_support;
-odp = s.odp;
+s = &backer->rt_support;
 
 /* ODP_SUPPORT_FIELDS */
 smap_add_format(cap, "max_vlan_headers", "%"PRIuSIZE,
-odp.max_vlan_headers);
-smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, odp.max_mpls_depth);
-smap_add(cap, "recirc", odp.recirc ? "true" : "false");
-smap_add(cap, "ct_state", odp.ct_state ? "true" : "false");
-smap_add(cap, "ct_zone", odp.ct_zone ? "true" : "false");
-smap_add(cap, "ct_mark", odp.ct_mark ? "true" : "false");
-smap_add(cap, "ct_label", odp.ct_label ? "true" : "false");
-smap_add(cap, "ct_state_nat", odp.ct_state_nat ? "true" : "false");
-smap_add(cap, "ct_orig_tuple", odp.ct_orig_tuple ? "true" : "false");
-smap_add(cap, "ct_orig_tuple6", odp.ct_orig_tuple6 ? "true" : "false");
-smap_add(cap, "nd_ext", odp.nd_ext ? "true" : "false");
+s->odp.max_vlan_headers);
+smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, s->odp.max_mpls_depth);
+smap_add(cap, "recirc", s->odp.recirc ? "true" : "false");
+smap_add(cap, "ct_state", s->odp.ct_state ? "true" : "false");
+smap_add(cap, "ct_zone", s->odp.ct_zone ? "true" : "false");
+smap_add(cap, "ct_mark", s->odp.ct_mark ? "true" : "false");
+smap_add(cap, "ct_label", s->odp.ct_label ? "true" : "false");
+smap_add(cap, "ct_state_nat", s->odp.ct_state_nat ? "true" : "false");
+smap_add(cap, "ct_orig_tuple", s->odp.ct_orig_tuple ? "true" : "false");
+smap_add(cap, "ct_orig_tuple6", s->odp.ct_orig_tuple6 ? "true" : "false");
+smap_add(cap, "nd_ext", s->odp.nd_ext ? "true" : "false");
 
 /* DPIF_SUPPORT_FIELDS */
-smap_add(cap, "masked_set_action", s.masked_set_action ? "true" : "false");
-smap_add(cap, "tnl_push_pop", s.tnl_push_pop ? "true" : "false");
-smap_add(cap, "ufid", s.ufid ? "true" : "false");
-smap_add(cap, "trunc", s.trunc ? "true" : "false");
-smap_add(cap, "clone", s.clone ? "true" : "false");
-smap_add(cap, "sample_nesting", s.sample_nesting ? "true" : "false");
-smap_add(cap, "ct_eventmask", s.ct_eventmask ? "true" : "false");
-smap_add(cap, "ct_clear", s.ct_clear ? "true" : "false");
-smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s.max_hash_alg);
-smap_add(cap, "check_pkt_len", s.check_pkt_len ? "true" : "false");
-smap_add(cap, "ct_timeout", s.ct_timeout ? "true" : "false");
+smap_add(cap, "masked_set_action",
+ s->masked_set_action ? "true" : "false");
+smap_add(cap, "tnl_push_pop", s->tnl_push_pop ? "true" : "false");
+smap_add(cap, "ufid", s->ufid ? "true" : "false");
+smap_add(cap, "trunc", s->trunc ? "true" : "false");
+smap_add(cap, "clone", s->clone ? "true" : "false");
+smap_add(cap, "sample_nesting", s->sample_nesting ? "true" : "false");
+smap_add(cap, "ct_eventmask", s->ct_eventmask ? "true" : "false");
+smap_add(cap, "ct_clear", s->ct_clear ? "true" : "false");
+smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s->max_hash_alg);
+smap_add(cap, "check_pkt_len", s->check_pkt_len ? "true" : "false");
+smap_add(cap, "ct_timeout", s->ct_timeout ? "true" : "false");
 smap_add(cap, "explicit_drop_action",
- s.explicit_drop_action ? "true" :"false");
-smap_add(cap, "lb_output_action", s.lb_output_action ? "true" : "false");
-smap_add(cap, "ct_zero_snat", s.ct_zero_snat ? "true" : "false");
-smap_add(cap, "add_mpls", s.add_mpls ? "true" : "false");
+ s->explicit_drop_action ? "true" :"false");
+smap_add(cap, "lb_output_action", s->lb_output_action ? "true" : "false");
+smap_add(cap, "ct_zero_snat", s->ct_zero_snat ? "true" : "false");
+smap_add(cap, "add_mpls", s->add_mpls ? "true" : "false");
 
 /* The ct_tuple_flush is implemented on dpif level, so it is supported
  * for all backers. */
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v12 3/6] dpif: Support atomic_bool field type.

2024-03-15 Thread Eric Garver
The next commit will convert a dp feature from bool to atomic_bool. As
such we have to add support to the macros and functions. We must pass by
reference instead of pass by value because all the atomic operations
require a reference.

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 54 --
 1 file changed, 47 insertions(+), 7 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index d732198de5ea..2ec1cd1854ab 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -717,6 +717,8 @@ close_dpif_backer(struct dpif_backer *backer, bool del)
 }
 
 static void check_support(struct dpif_backer *backer);
+static void copy_support(struct dpif_backer_support *dst,
+ struct dpif_backer_support *src);
 
 static int
 open_dpif_backer(const char *type, struct dpif_backer **backerp)
@@ -837,7 +839,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
  * 'boottime_support' can be checked to prevent 'support' to be changed
  * beyond the datapath capabilities. In case 'support' is changed by
  * the user, 'boottime_support' can be used to restore it.  */
-backer->bt_support = backer->rt_support;
+copy_support(&backer->bt_support, &backer->rt_support);
 
 return error;
 }
@@ -1611,6 +1613,24 @@ CHECK_FEATURE__(ct_orig_tuple6, ct_orig_tuple6, 
ct_nw_proto, 1, ETH_TYPE_IPV6)
 #undef CHECK_FEATURE
 #undef CHECK_FEATURE__
 
+static void
+copy_support(struct dpif_backer_support *dst, struct dpif_backer_support *src)
+{
+#define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
+if (!strcmp(#TYPE, "atomic_bool")) { \
+bool value; \
+atomic_read_relaxed((atomic_bool *) &src->NAME, &value); \
+atomic_store_relaxed((atomic_bool *) &dst->NAME, value); \
+} else { \
+dst->NAME = src->NAME; \
+}
+
+DPIF_SUPPORT_FIELDS
+#undef DPIF_SUPPORT_FIELD
+
+dst->odp = src->odp;
+}
+
 static void
 check_support(struct dpif_backer *backer)
 {
@@ -6248,20 +6268,30 @@ ofproto_unixctl_dpif_dump_dps(struct unixctl_conn 
*conn, int argc OVS_UNUSED,
 }
 
 static void
-show_dp_feature_bool(struct ds *ds, const char *feature, bool b)
+show_dp_feature_bool(struct ds *ds, const char *feature, const bool *b)
 {
-ds_put_format(ds, "%s: %s\n", feature, b ? "Yes" : "No");
+ds_put_format(ds, "%s: %s\n", feature, *b ? "Yes" : "No");
+}
+
+static void OVS_UNUSED
+show_dp_feature_atomic_bool(struct ds *ds, const char *feature,
+const atomic_bool *b)
+{
+bool value;
+atomic_read_relaxed((atomic_bool *) b, &value);
+ds_put_format(ds, "%s: %s\n", feature, value ? "Yes" : "No");
 }
 
 static void
-show_dp_feature_size_t(struct ds *ds, const char *feature, size_t s)
+show_dp_feature_size_t(struct ds *ds, const char *feature, const size_t *s)
 {
-ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, s);
+ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, *s);
 }
 
 enum dpif_support_field_type {
 DPIF_SUPPORT_FIELD_bool,
 DPIF_SUPPORT_FIELD_size_t,
+DPIF_SUPPORT_FIELD_atomic_bool,
 };
 
 struct dpif_support_field {
@@ -6278,12 +6308,12 @@ static void
 dpif_show_support(const struct dpif_backer_support *support, struct ds *ds)
 {
 #define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->NAME);
+show_dp_feature_##TYPE (ds, TITLE, &support->NAME);
 DPIF_SUPPORT_FIELDS
 #undef DPIF_SUPPORT_FIELD
 
 #define ODP_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->odp.NAME );
+show_dp_feature_##TYPE (ds, TITLE, &support->odp.NAME );
 ODP_SUPPORT_FIELDS
 #undef ODP_SUPPORT_FIELD
 }
@@ -6302,6 +6332,16 @@ display_support_field(const char *name,
   b ? "true" : "false");
 break;
 }
+case DPIF_SUPPORT_FIELD_atomic_bool: {
+bool b, v;
+
+atomic_read_relaxed((atomic_bool *) field->rt_ptr, &v);
+atomic_read_relaxed((atomic_bool *) field->bt_ptr, &b);
+ds_put_format(ds, "%s (%s) : [run time]:%s, [boot time]:%s\n", name,
+  field->title, v ? "true" : "false",
+  b ? "true" : "false");
+break;
+}
 case DPIF_SUPPORT_FIELD_size_t:
 ds_put_format(ds, "%s (%s) : [run time]:%"PRIuSIZE
   ", [boot time]:%"PRIuSIZE"\n", name,
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v12 5/6] tests: system-traffic: Add coverage for drop action.

2024-03-15 Thread Eric Garver
Exercise the drop action in the datapath. This specific tests triggers
an xlate_error.

For the kernel datapath skb drop reasons can then be seen while this
test runs.

 # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
   0.000 ping/1275884 skb:kfree_skb(skbaddr: 0x8acd76546000, \
  location: 0xc0ee3634, protocol: 2048, reason: 196611)

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 +++
 2 files changed, 35 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 01ebe364ee7c..2a68cd664e5c 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -374,3 +374,7 @@ m4_define([OVS_CHECK_CT_CLEAR],
 # OVS_CHECK_GITHUB_ACTION
 m4_define([OVS_CHECK_GITHUB_ACTION],
 [AT_SKIP_IF([test "$GITHUB_ACTIONS" = "true"])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports explicit drop action" 
ovs-vswitchd.log])])
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 2d12d558ec2f..2ddb4921c60e 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2231,6 +2231,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl
+  strip_recirc | strip_stats | strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_TRAFFIC_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v12 6/6] tests: system-offload-traffic: Verify re-probe of drop action.

2024-03-15 Thread Eric Garver
Verify that the explicit drop action is re-probed if the hw-offload flag
is changed.

Signed-off-by: Eric Garver 
---
 tests/system-offloads-traffic.at | 12 
 1 file changed, 12 insertions(+)

diff --git a/tests/system-offloads-traffic.at b/tests/system-offloads-traffic.at
index 6bd49a3eef30..899a8e9bca2f 100644
--- a/tests/system-offloads-traffic.at
+++ b/tests/system-offloads-traffic.at
@@ -921,3 +921,15 @@ AT_CHECK([tc -d filter show dev ovs-p0 ingress | grep -q 
"csum (iph)"], [0])
 
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([offloads - re-probe drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+dnl trigger a re-probe of the explicit drop action
+AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=true])
+OVS_WAIT_UNTIL([grep -q "Datapath does not support explicit drop action" 
ovs-vswitchd.log])
+
+OVS_TRAFFIC_VSWITCHD_STOP
+AT_CLEANUP
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v12 0/6] dpif: probe support for OVS_ACTION_ATTR_DROP

2024-03-15 Thread Eric Garver
v12:
  - new patch to verify re-probe
  - don't mention hw offload in the probe
  - changed log message to not mention HW offload
v11:
  - move netdev and flow API check to lib
  - tweaked log message
  - use atomic store instead of cmpx
  - copy odp in copy_support()
v10:
  - fix a sparse error in show_dp_feature_atomic_bool()
v9:
  - new patch make get_datapath_cap() access support by pointer
  - fix a clang warning in copy_support()
v8:
  - new patch to support atomic_bool dpif field types
  - re-add re-probe of support
  - use atomic_bool type for explicit_drop_action
v7:
  - remove re-probe of support as Ilya is working on a generic solution
v6:
  - improve log if hw-offload enabled
  - re-probe support if hw-offload set true at runtime
v5:
  - combine patches 3 and 4
  - add description to combined patch 3
v4:
  - avoid passing action to datapath if TC offload in use
v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (6):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Make get_datapath_cap() access support by pointer.
  dpif: Support atomic_bool field type.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  tests: system-traffic: Add coverage for drop action.
  tests: system-offload-traffic: Verify re-probe of drop action.

 include/linux/openvswitch.h  |   3 +-
 lib/dpif-netdev.c|   1 +
 lib/dpif.c   |   7 +-
 lib/dpif.h   |   2 +-
 lib/odp-execute.c|   2 +
 lib/odp-util.c   |  23 
 ofproto/ofproto-dpif-ipfix.c |   1 +
 ofproto/ofproto-dpif-sflow.c |   1 +
 ofproto/ofproto-dpif.c   | 187 ---
 ofproto/ofproto-dpif.h   |   4 +-
 tests/system-common-macros.at|   4 +
 tests/system-offloads-traffic.at |  12 ++
 tests/system-traffic.at  |  31 +
 13 files changed, 233 insertions(+), 45 deletions(-)

-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v12 4/6] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-03-15 Thread Eric Garver
Kernel support has been added for this action. As such, we need to probe
the datapath for support.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 ++-
 lib/dpif.h  |  2 +-
 ofproto/ofproto-dpif.c  | 78 ++---
 ofproto/ofproto-dpif.h  |  4 +-
 5 files changed, 82 insertions(+), 10 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index 0f480bec48d0..23eb18495a66 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -28,6 +28,7 @@
 #include "dpctl.h"
 #include "dpif-netdev.h"
 #include "flow.h"
+#include "netdev-offload.h"
 #include "netdev-provider.h"
 #include "netdev.h"
 #include "netlink.h"
@@ -1935,9 +1936,10 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 }
 
 bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
+dpif_may_support_explicit_drop_action(const struct dpif *dpif)
 {
-return dpif_is_netdev(dpif);
+/* TC does not support offloading this action. */
+return dpif_is_netdev(dpif) || !netdev_is_flow_api_enabled();
 }
 
 bool
diff --git a/lib/dpif.h b/lib/dpif.h
index 0f2dc2ef3c55..a764e8a592bd 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,7 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
+bool dpif_may_support_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 2ec1cd1854ab..dcef9ade5c2e 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -221,6 +221,7 @@ static void ct_zone_config_init(struct dpif_backer *backer);
 static void ct_zone_config_uninit(struct dpif_backer *backer);
 static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
 static void ct_zone_limits_commit(struct dpif_backer *backer);
+static bool recheck_support_explicit_drop_action(struct dpif_backer *backer);
 
 static inline struct ofproto_dpif *
 ofproto_dpif_cast(const struct ofproto *ofproto)
@@ -391,6 +392,10 @@ type_run(const char *type)
 udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
 }
 
+if (recheck_support_explicit_drop_action(backer)) {
+backer->need_revalidate = REV_RECONFIGURE;
+}
+
 if (backer->need_revalidate) {
 struct ofproto_dpif *ofproto;
 struct simap_node *node;
@@ -807,6 +812,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
 
 shash_add(&all_dpif_backers, type, backer);
 
+atomic_init(&backer->rt_support.explicit_drop_action, false);
 check_support(backer);
 atomic_count_init(&backer->tnl_count, 0);
 
@@ -855,7 +861,12 @@ ovs_native_tunneling_is_on(struct ofproto_dpif *ofproto)
 bool
 ovs_explicit_drop_action_supported(struct ofproto_dpif *ofproto)
 {
-return ofproto->backer->rt_support.explicit_drop_action;
+bool value;
+
+atomic_read_relaxed(&ofproto->backer->rt_support.explicit_drop_action,
+&value);
+
+return value;
 }
 
 bool
@@ -1379,6 +1390,39 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_

[ovs-dev] [PATCH v12 2/6] dpif: Make get_datapath_cap() access support by pointer.

2024-03-15 Thread Eric Garver
This avoids copying the support struct onto the stack.

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 59 +-
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index f59d69c4d1e8..d732198de5ea 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -5688,47 +5688,46 @@ ct_zone_limit_protection_update(const char 
*datapath_type, bool protected)
 static void
 get_datapath_cap(const char *datapath_type, struct smap *cap)
 {
-struct odp_support odp;
-struct dpif_backer_support s;
+struct dpif_backer_support *s;
 struct dpif_backer *backer = shash_find_data(&all_dpif_backers,
  datapath_type);
 if (!backer) {
 return;
 }
-s = backer->rt_support;
-odp = s.odp;
+s = &backer->rt_support;
 
 /* ODP_SUPPORT_FIELDS */
 smap_add_format(cap, "max_vlan_headers", "%"PRIuSIZE,
-odp.max_vlan_headers);
-smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, odp.max_mpls_depth);
-smap_add(cap, "recirc", odp.recirc ? "true" : "false");
-smap_add(cap, "ct_state", odp.ct_state ? "true" : "false");
-smap_add(cap, "ct_zone", odp.ct_zone ? "true" : "false");
-smap_add(cap, "ct_mark", odp.ct_mark ? "true" : "false");
-smap_add(cap, "ct_label", odp.ct_label ? "true" : "false");
-smap_add(cap, "ct_state_nat", odp.ct_state_nat ? "true" : "false");
-smap_add(cap, "ct_orig_tuple", odp.ct_orig_tuple ? "true" : "false");
-smap_add(cap, "ct_orig_tuple6", odp.ct_orig_tuple6 ? "true" : "false");
-smap_add(cap, "nd_ext", odp.nd_ext ? "true" : "false");
+s->odp.max_vlan_headers);
+smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, s->odp.max_mpls_depth);
+smap_add(cap, "recirc", s->odp.recirc ? "true" : "false");
+smap_add(cap, "ct_state", s->odp.ct_state ? "true" : "false");
+smap_add(cap, "ct_zone", s->odp.ct_zone ? "true" : "false");
+smap_add(cap, "ct_mark", s->odp.ct_mark ? "true" : "false");
+smap_add(cap, "ct_label", s->odp.ct_label ? "true" : "false");
+smap_add(cap, "ct_state_nat", s->odp.ct_state_nat ? "true" : "false");
+smap_add(cap, "ct_orig_tuple", s->odp.ct_orig_tuple ? "true" : "false");
+smap_add(cap, "ct_orig_tuple6", s->odp.ct_orig_tuple6 ? "true" : "false");
+smap_add(cap, "nd_ext", s->odp.nd_ext ? "true" : "false");
 
 /* DPIF_SUPPORT_FIELDS */
-smap_add(cap, "masked_set_action", s.masked_set_action ? "true" : "false");
-smap_add(cap, "tnl_push_pop", s.tnl_push_pop ? "true" : "false");
-smap_add(cap, "ufid", s.ufid ? "true" : "false");
-smap_add(cap, "trunc", s.trunc ? "true" : "false");
-smap_add(cap, "clone", s.clone ? "true" : "false");
-smap_add(cap, "sample_nesting", s.sample_nesting ? "true" : "false");
-smap_add(cap, "ct_eventmask", s.ct_eventmask ? "true" : "false");
-smap_add(cap, "ct_clear", s.ct_clear ? "true" : "false");
-smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s.max_hash_alg);
-smap_add(cap, "check_pkt_len", s.check_pkt_len ? "true" : "false");
-smap_add(cap, "ct_timeout", s.ct_timeout ? "true" : "false");
+smap_add(cap, "masked_set_action",
+ s->masked_set_action ? "true" : "false");
+smap_add(cap, "tnl_push_pop", s->tnl_push_pop ? "true" : "false");
+smap_add(cap, "ufid", s->ufid ? "true" : "false");
+smap_add(cap, "trunc", s->trunc ? "true" : "false");
+smap_add(cap, "clone", s->clone ? "true" : "false");
+smap_add(cap, "sample_nesting", s->sample_nesting ? "true" : "false");
+smap_add(cap, "ct_eventmask", s->ct_eventmask ? "true" : "false");
+smap_add(cap, "ct_clear", s->ct_clear ? "true" : "false");
+smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s->max_hash_alg);
+smap_add(cap, "check_pkt_len", s->check_pkt_len ? "true" : "false");
+smap_add(cap, "ct_timeout", s->ct_timeout ? "true" : "false");
 smap_add(cap, "explicit_drop_action",
- s.explicit_drop_action ? "true" :"false");
-smap_add(cap, "lb_output_action", s.lb_output_action ? "true" : "false");
-smap_add(cap, "ct_zero_snat", s.ct_zero_snat ? "true" : "false");
-smap_add(cap, "add_mpls", s.add_mpls ? "true" : "false");
+ s->explicit_drop_action ? "true" :"false");
+smap_add(cap, "lb_output_action", s->lb_output_action ? "true" : "false");
+smap_add(cap, "ct_zero_snat", s->ct_zero_snat ? "true" : "false");
+smap_add(cap, "add_mpls", s->add_mpls ? "true" : "false");
 
 /* The ct_tuple_flush is implemented on dpif level, so it is supported
  * for all backers. */
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v12 1/6] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2024-03-15 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  1 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 30 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index e6c53937d8b9..89b0d1d6b4aa 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9489,6 +9489,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index d07241f1e7cd..0f480bec48d0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1289,6 +1289,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index eb03b57c42ec..081e4d43268a 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -837,6 +837,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1227,6 +1228,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 9306c9b4d47a..f4c492f2ae6f 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_names);
+break;
 case OVS_ACTION_ATTR_DROP:
 ds_put_cstr(ds, "drop");
 break;
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..cd65dae7e18a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3135,6 +3135,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_D

Re: [ovs-dev] [PATCH v11 4/5] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-03-15 Thread Eric Garver
On Fri, Mar 15, 2024 at 12:37:54PM -0400, Eric Garver wrote:
> On Fri, Mar 15, 2024 at 04:55:50PM +0100, Eelco Chaudron wrote:
> > 
> > 
> > On 11 Mar 2024, at 18:51, Eric Garver wrote:
> > 
> > > Kernel support has been added for this action. As such, we need to probe
> > > the datapath for support.
> > >
> > > Signed-off-by: Eric Garver 
> > 
> > Thanks for submitting the changes requested. Some comments below.
> > 
> > Cheers,
> > 
> > Eelco
> > 
> > 
> > > ---
> > >  include/linux/openvswitch.h |  2 +-
> > >  lib/dpif.c  |  6 ++-
> > >  lib/dpif.h  |  2 +-
> > >  ofproto/ofproto-dpif.c  | 77 ++---
> > >  ofproto/ofproto-dpif.h  |  4 +-
> > >  5 files changed, 81 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
> > > index a265e05ad253..fce6456f47c8 100644
> > > --- a/include/linux/openvswitch.h
> > > +++ b/include/linux/openvswitch.h
> > > @@ -1086,11 +1086,11 @@ enum ovs_action_attr {
> > >   OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
> > >   OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
> > >   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
> > > + OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
> > >
> > >  #ifndef __KERNEL__
> > >   OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
> > >   OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
> > > - OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
> > >   OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
> > >  #endif
> > >   __OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
> > > diff --git a/lib/dpif.c b/lib/dpif.c
> > > index 0f480bec48d0..23eb18495a66 100644
> > > --- a/lib/dpif.c
> > > +++ b/lib/dpif.c
> > > @@ -28,6 +28,7 @@
> > >  #include "dpctl.h"
> > >  #include "dpif-netdev.h"
> > >  #include "flow.h"
> > > +#include "netdev-offload.h"
> > >  #include "netdev-provider.h"
> > >  #include "netdev.h"
> > >  #include "netlink.h"
> > > @@ -1935,9 +1936,10 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
> > >  }
> > >
> > >  bool
> > > -dpif_supports_explicit_drop_action(const struct dpif *dpif)
> > > +dpif_may_support_explicit_drop_action(const struct dpif *dpif)
> > >  {
> > > -return dpif_is_netdev(dpif);
> > > +/* TC does not support offloading this action. */
> > > +return dpif_is_netdev(dpif) || !netdev_is_flow_api_enabled();
> > >  }
> > >
> > >  bool
> > > diff --git a/lib/dpif.h b/lib/dpif.h
> > > index 0f2dc2ef3c55..a764e8a592bd 100644
> > > --- a/lib/dpif.h
> > > +++ b/lib/dpif.h
> > > @@ -940,7 +940,7 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
> > > odp_port_t port_no,
> > >
> > >  char *dpif_get_dp_version(const struct dpif *);
> > >  bool dpif_supports_tnl_push_pop(const struct dpif *);
> > > -bool dpif_supports_explicit_drop_action(const struct dpif *);
> > > +bool dpif_may_support_explicit_drop_action(const struct dpif *);
> > >  bool dpif_synced_dp_layers(struct dpif *);
> > >
> > >  /* Log functions. */
> > > diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> > > index 2ec1cd1854ab..7bacd2120c78 100644
> > > --- a/ofproto/ofproto-dpif.c
> > > +++ b/ofproto/ofproto-dpif.c
> > > @@ -221,6 +221,7 @@ static void ct_zone_config_init(struct dpif_backer 
> > > *backer);
> > >  static void ct_zone_config_uninit(struct dpif_backer *backer);
> > >  static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
> > >  static void ct_zone_limits_commit(struct dpif_backer *backer);
> > > +static bool recheck_support_explicit_drop_action(struct dpif_backer 
> > > *backer);
> > >
> > >  static inline struct ofproto_dpif *
> > >  ofproto_dpif_cast(const struct ofproto *ofproto)
> > > @@ -391,6 +392,10 @@ type_run(const char *type)
> > >  udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
> > >  }
> > >
> > > +if (recheck_support_explicit_drop_action(backer)) {
> > > +

Re: [ovs-dev] [PATCH v11 4/5] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-03-15 Thread Eric Garver
On Fri, Mar 15, 2024 at 04:55:50PM +0100, Eelco Chaudron wrote:
> 
> 
> On 11 Mar 2024, at 18:51, Eric Garver wrote:
> 
> > Kernel support has been added for this action. As such, we need to probe
> > the datapath for support.
> >
> > Signed-off-by: Eric Garver 
> 
> Thanks for submitting the changes requested. Some comments below.
> 
> Cheers,
> 
> Eelco
> 
> 
> > ---
> >  include/linux/openvswitch.h |  2 +-
> >  lib/dpif.c  |  6 ++-
> >  lib/dpif.h  |  2 +-
> >  ofproto/ofproto-dpif.c  | 77 ++---
> >  ofproto/ofproto-dpif.h  |  4 +-
> >  5 files changed, 81 insertions(+), 10 deletions(-)
> >
> > diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
> > index a265e05ad253..fce6456f47c8 100644
> > --- a/include/linux/openvswitch.h
> > +++ b/include/linux/openvswitch.h
> > @@ -1086,11 +1086,11 @@ enum ovs_action_attr {
> > OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
> > OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
> > OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
> > +   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
> >
> >  #ifndef __KERNEL__
> > OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
> > OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
> > -   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
> > OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
> >  #endif
> > __OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
> > diff --git a/lib/dpif.c b/lib/dpif.c
> > index 0f480bec48d0..23eb18495a66 100644
> > --- a/lib/dpif.c
> > +++ b/lib/dpif.c
> > @@ -28,6 +28,7 @@
> >  #include "dpctl.h"
> >  #include "dpif-netdev.h"
> >  #include "flow.h"
> > +#include "netdev-offload.h"
> >  #include "netdev-provider.h"
> >  #include "netdev.h"
> >  #include "netlink.h"
> > @@ -1935,9 +1936,10 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
> >  }
> >
> >  bool
> > -dpif_supports_explicit_drop_action(const struct dpif *dpif)
> > +dpif_may_support_explicit_drop_action(const struct dpif *dpif)
> >  {
> > -return dpif_is_netdev(dpif);
> > +/* TC does not support offloading this action. */
> > +return dpif_is_netdev(dpif) || !netdev_is_flow_api_enabled();
> >  }
> >
> >  bool
> > diff --git a/lib/dpif.h b/lib/dpif.h
> > index 0f2dc2ef3c55..a764e8a592bd 100644
> > --- a/lib/dpif.h
> > +++ b/lib/dpif.h
> > @@ -940,7 +940,7 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
> > odp_port_t port_no,
> >
> >  char *dpif_get_dp_version(const struct dpif *);
> >  bool dpif_supports_tnl_push_pop(const struct dpif *);
> > -bool dpif_supports_explicit_drop_action(const struct dpif *);
> > +bool dpif_may_support_explicit_drop_action(const struct dpif *);
> >  bool dpif_synced_dp_layers(struct dpif *);
> >
> >  /* Log functions. */
> > diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> > index 2ec1cd1854ab..7bacd2120c78 100644
> > --- a/ofproto/ofproto-dpif.c
> > +++ b/ofproto/ofproto-dpif.c
> > @@ -221,6 +221,7 @@ static void ct_zone_config_init(struct dpif_backer 
> > *backer);
> >  static void ct_zone_config_uninit(struct dpif_backer *backer);
> >  static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
> >  static void ct_zone_limits_commit(struct dpif_backer *backer);
> > +static bool recheck_support_explicit_drop_action(struct dpif_backer 
> > *backer);
> >
> >  static inline struct ofproto_dpif *
> >  ofproto_dpif_cast(const struct ofproto *ofproto)
> > @@ -391,6 +392,10 @@ type_run(const char *type)
> >  udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
> >  }
> >
> > +if (recheck_support_explicit_drop_action(backer)) {
> > +backer->need_revalidate = REV_RECONFIGURE;
> > +}
> > +
> >  if (backer->need_revalidate) {
> >  struct ofproto_dpif *ofproto;
> >  struct simap_node *node;
> > @@ -807,6 +812,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
> > **backerp)
> >
> >  shash_add(&all_dpif_backers, type, backer);
> >
> > +atomic_init(&backer->rt_support.explicit_drop_action, false);
> >  check_support(backer);
> >  atomic_count_init(&backer->

[ovs-dev] [PATCH v11 1/5] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2024-03-11 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  1 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 30 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index e6c53937d8b9..89b0d1d6b4aa 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9489,6 +9489,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index d07241f1e7cd..0f480bec48d0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1289,6 +1289,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index eb03b57c42ec..081e4d43268a 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -837,6 +837,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1227,6 +1228,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 9306c9b4d47a..f4c492f2ae6f 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_names);
+break;
 case OVS_ACTION_ATTR_DROP:
 ds_put_cstr(ds, "drop");
 break;
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..cd65dae7e18a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3135,6 +3135,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 c

[ovs-dev] [PATCH v11 5/5] tests: system-traffic: Add coverage for drop action.

2024-03-11 Thread Eric Garver
Exercise the drop action in the datapath. This specific tests triggers
an xlate_error.

For the kernel datapath skb drop reasons can then be seen while this
test runs.

 # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
   0.000 ping/1275884 skb:kfree_skb(skbaddr: 0x8acd76546000, \
  location: 0xc0ee3634, protocol: 2048, reason: 196611)

Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 +++
 2 files changed, 35 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 01ebe364ee7c..2a68cd664e5c 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -374,3 +374,7 @@ m4_define([OVS_CHECK_CT_CLEAR],
 # OVS_CHECK_GITHUB_ACTION
 m4_define([OVS_CHECK_GITHUB_ACTION],
 [AT_SKIP_IF([test "$GITHUB_ACTIONS" = "true"])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports explicit drop action" 
ovs-vswitchd.log])])
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 2d12d558ec2f..94ca78915069 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2231,6 +2231,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl
+  strip_recirc | strip_stats | strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v11 4/5] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-03-11 Thread Eric Garver
Kernel support has been added for this action. As such, we need to probe
the datapath for support.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 ++-
 lib/dpif.h  |  2 +-
 ofproto/ofproto-dpif.c  | 77 ++---
 ofproto/ofproto-dpif.h  |  4 +-
 5 files changed, 81 insertions(+), 10 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index 0f480bec48d0..23eb18495a66 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -28,6 +28,7 @@
 #include "dpctl.h"
 #include "dpif-netdev.h"
 #include "flow.h"
+#include "netdev-offload.h"
 #include "netdev-provider.h"
 #include "netdev.h"
 #include "netlink.h"
@@ -1935,9 +1936,10 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 }
 
 bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
+dpif_may_support_explicit_drop_action(const struct dpif *dpif)
 {
-return dpif_is_netdev(dpif);
+/* TC does not support offloading this action. */
+return dpif_is_netdev(dpif) || !netdev_is_flow_api_enabled();
 }
 
 bool
diff --git a/lib/dpif.h b/lib/dpif.h
index 0f2dc2ef3c55..a764e8a592bd 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,7 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
+bool dpif_may_support_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 2ec1cd1854ab..7bacd2120c78 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -221,6 +221,7 @@ static void ct_zone_config_init(struct dpif_backer *backer);
 static void ct_zone_config_uninit(struct dpif_backer *backer);
 static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
 static void ct_zone_limits_commit(struct dpif_backer *backer);
+static bool recheck_support_explicit_drop_action(struct dpif_backer *backer);
 
 static inline struct ofproto_dpif *
 ofproto_dpif_cast(const struct ofproto *ofproto)
@@ -391,6 +392,10 @@ type_run(const char *type)
 udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
 }
 
+if (recheck_support_explicit_drop_action(backer)) {
+backer->need_revalidate = REV_RECONFIGURE;
+}
+
 if (backer->need_revalidate) {
 struct ofproto_dpif *ofproto;
 struct simap_node *node;
@@ -807,6 +812,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
 
 shash_add(&all_dpif_backers, type, backer);
 
+atomic_init(&backer->rt_support.explicit_drop_action, false);
 check_support(backer);
 atomic_count_init(&backer->tnl_count, 0);
 
@@ -855,7 +861,10 @@ ovs_native_tunneling_is_on(struct ofproto_dpif *ofproto)
 bool
 ovs_explicit_drop_action_supported(struct ofproto_dpif *ofproto)
 {
-return ofproto->backer->rt_support.explicit_drop_action;
+bool value;
+atomic_read_relaxed(&ofproto->backer->rt_support.explicit_drop_action,
+&value);
+return value;
 }
 
 bool
@@ -1379,6 +1388,41 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+bool hw_offload;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl

[ovs-dev] [PATCH v11 0/5] dpif: probe support for OVS_ACTION_ATTR_DROP

2024-03-11 Thread Eric Garver
v11:
  - move netdev and flow API check to lib
  - tweaked log message
  - use atomic store instead of cmpx
  - copy odp in copy_support()
v10:
  - fix a sparse error in show_dp_feature_atomic_bool()
v9:
  - new patch make get_datapath_cap() access support by pointer
  - fix a clang warning in copy_support()
v8:
  - new patch to support atomic_bool dpif field types
  - re-add re-probe of support
  - use atomic_bool type for explicit_drop_action
v7:
  - remove re-probe of support as Ilya is working on a generic solution
v6:
  - improve log if hw-offload enabled
  - re-probe support if hw-offload set true at runtime
v5:
  - combine patches 3 and 4
  - add description to combined patch 3
v4:
  - avoid passing action to datapath if TC offload in use
v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (5):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Make get_datapath_cap() access support by pointer.
  dpif: Support atomic_bool field type.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  tests: system-traffic: Add coverage for drop action.

 include/linux/openvswitch.h   |   3 +-
 lib/dpif-netdev.c |   1 +
 lib/dpif.c|   7 +-
 lib/dpif.h|   2 +-
 lib/odp-execute.c |   2 +
 lib/odp-util.c|  23 +
 ofproto/ofproto-dpif-ipfix.c  |   1 +
 ofproto/ofproto-dpif-sflow.c  |   1 +
 ofproto/ofproto-dpif.c| 186 ++
 ofproto/ofproto-dpif.h|   4 +-
 tests/system-common-macros.at |   4 +
 tests/system-traffic.at   |  31 ++
 12 files changed, 220 insertions(+), 45 deletions(-)

-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v11 3/5] dpif: Support atomic_bool field type.

2024-03-11 Thread Eric Garver
The next commit will convert a dp feature from bool to atomic_bool. As
such we have to add support to the macros and functions. We must pass by
reference instead of pass by value because all the atomic operations
require a reference.

Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 54 --
 1 file changed, 47 insertions(+), 7 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index d732198de5ea..2ec1cd1854ab 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -717,6 +717,8 @@ close_dpif_backer(struct dpif_backer *backer, bool del)
 }
 
 static void check_support(struct dpif_backer *backer);
+static void copy_support(struct dpif_backer_support *dst,
+ struct dpif_backer_support *src);
 
 static int
 open_dpif_backer(const char *type, struct dpif_backer **backerp)
@@ -837,7 +839,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
  * 'boottime_support' can be checked to prevent 'support' to be changed
  * beyond the datapath capabilities. In case 'support' is changed by
  * the user, 'boottime_support' can be used to restore it.  */
-backer->bt_support = backer->rt_support;
+copy_support(&backer->bt_support, &backer->rt_support);
 
 return error;
 }
@@ -1611,6 +1613,24 @@ CHECK_FEATURE__(ct_orig_tuple6, ct_orig_tuple6, 
ct_nw_proto, 1, ETH_TYPE_IPV6)
 #undef CHECK_FEATURE
 #undef CHECK_FEATURE__
 
+static void
+copy_support(struct dpif_backer_support *dst, struct dpif_backer_support *src)
+{
+#define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
+if (!strcmp(#TYPE, "atomic_bool")) { \
+bool value; \
+atomic_read_relaxed((atomic_bool *) &src->NAME, &value); \
+atomic_store_relaxed((atomic_bool *) &dst->NAME, value); \
+} else { \
+dst->NAME = src->NAME; \
+}
+
+DPIF_SUPPORT_FIELDS
+#undef DPIF_SUPPORT_FIELD
+
+dst->odp = src->odp;
+}
+
 static void
 check_support(struct dpif_backer *backer)
 {
@@ -6248,20 +6268,30 @@ ofproto_unixctl_dpif_dump_dps(struct unixctl_conn 
*conn, int argc OVS_UNUSED,
 }
 
 static void
-show_dp_feature_bool(struct ds *ds, const char *feature, bool b)
+show_dp_feature_bool(struct ds *ds, const char *feature, const bool *b)
 {
-ds_put_format(ds, "%s: %s\n", feature, b ? "Yes" : "No");
+ds_put_format(ds, "%s: %s\n", feature, *b ? "Yes" : "No");
+}
+
+static void OVS_UNUSED
+show_dp_feature_atomic_bool(struct ds *ds, const char *feature,
+const atomic_bool *b)
+{
+bool value;
+atomic_read_relaxed((atomic_bool *) b, &value);
+ds_put_format(ds, "%s: %s\n", feature, value ? "Yes" : "No");
 }
 
 static void
-show_dp_feature_size_t(struct ds *ds, const char *feature, size_t s)
+show_dp_feature_size_t(struct ds *ds, const char *feature, const size_t *s)
 {
-ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, s);
+ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, *s);
 }
 
 enum dpif_support_field_type {
 DPIF_SUPPORT_FIELD_bool,
 DPIF_SUPPORT_FIELD_size_t,
+DPIF_SUPPORT_FIELD_atomic_bool,
 };
 
 struct dpif_support_field {
@@ -6278,12 +6308,12 @@ static void
 dpif_show_support(const struct dpif_backer_support *support, struct ds *ds)
 {
 #define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->NAME);
+show_dp_feature_##TYPE (ds, TITLE, &support->NAME);
 DPIF_SUPPORT_FIELDS
 #undef DPIF_SUPPORT_FIELD
 
 #define ODP_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->odp.NAME );
+show_dp_feature_##TYPE (ds, TITLE, &support->odp.NAME );
 ODP_SUPPORT_FIELDS
 #undef ODP_SUPPORT_FIELD
 }
@@ -6302,6 +6332,16 @@ display_support_field(const char *name,
   b ? "true" : "false");
 break;
 }
+case DPIF_SUPPORT_FIELD_atomic_bool: {
+bool b, v;
+
+atomic_read_relaxed((atomic_bool *) field->rt_ptr, &v);
+atomic_read_relaxed((atomic_bool *) field->bt_ptr, &b);
+ds_put_format(ds, "%s (%s) : [run time]:%s, [boot time]:%s\n", name,
+  field->title, v ? "true" : "false",
+  b ? "true" : "false");
+break;
+}
 case DPIF_SUPPORT_FIELD_size_t:
 ds_put_format(ds, "%s (%s) : [run time]:%"PRIuSIZE
   ", [boot time]:%"PRIuSIZE"\n", name,
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v11 2/5] dpif: Make get_datapath_cap() access support by pointer.

2024-03-11 Thread Eric Garver
This avoids copying the support struct onto the stack.

Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 59 +-
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index f59d69c4d1e8..d732198de5ea 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -5688,47 +5688,46 @@ ct_zone_limit_protection_update(const char 
*datapath_type, bool protected)
 static void
 get_datapath_cap(const char *datapath_type, struct smap *cap)
 {
-struct odp_support odp;
-struct dpif_backer_support s;
+struct dpif_backer_support *s;
 struct dpif_backer *backer = shash_find_data(&all_dpif_backers,
  datapath_type);
 if (!backer) {
 return;
 }
-s = backer->rt_support;
-odp = s.odp;
+s = &backer->rt_support;
 
 /* ODP_SUPPORT_FIELDS */
 smap_add_format(cap, "max_vlan_headers", "%"PRIuSIZE,
-odp.max_vlan_headers);
-smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, odp.max_mpls_depth);
-smap_add(cap, "recirc", odp.recirc ? "true" : "false");
-smap_add(cap, "ct_state", odp.ct_state ? "true" : "false");
-smap_add(cap, "ct_zone", odp.ct_zone ? "true" : "false");
-smap_add(cap, "ct_mark", odp.ct_mark ? "true" : "false");
-smap_add(cap, "ct_label", odp.ct_label ? "true" : "false");
-smap_add(cap, "ct_state_nat", odp.ct_state_nat ? "true" : "false");
-smap_add(cap, "ct_orig_tuple", odp.ct_orig_tuple ? "true" : "false");
-smap_add(cap, "ct_orig_tuple6", odp.ct_orig_tuple6 ? "true" : "false");
-smap_add(cap, "nd_ext", odp.nd_ext ? "true" : "false");
+s->odp.max_vlan_headers);
+smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, s->odp.max_mpls_depth);
+smap_add(cap, "recirc", s->odp.recirc ? "true" : "false");
+smap_add(cap, "ct_state", s->odp.ct_state ? "true" : "false");
+smap_add(cap, "ct_zone", s->odp.ct_zone ? "true" : "false");
+smap_add(cap, "ct_mark", s->odp.ct_mark ? "true" : "false");
+smap_add(cap, "ct_label", s->odp.ct_label ? "true" : "false");
+smap_add(cap, "ct_state_nat", s->odp.ct_state_nat ? "true" : "false");
+smap_add(cap, "ct_orig_tuple", s->odp.ct_orig_tuple ? "true" : "false");
+smap_add(cap, "ct_orig_tuple6", s->odp.ct_orig_tuple6 ? "true" : "false");
+smap_add(cap, "nd_ext", s->odp.nd_ext ? "true" : "false");
 
 /* DPIF_SUPPORT_FIELDS */
-smap_add(cap, "masked_set_action", s.masked_set_action ? "true" : "false");
-smap_add(cap, "tnl_push_pop", s.tnl_push_pop ? "true" : "false");
-smap_add(cap, "ufid", s.ufid ? "true" : "false");
-smap_add(cap, "trunc", s.trunc ? "true" : "false");
-smap_add(cap, "clone", s.clone ? "true" : "false");
-smap_add(cap, "sample_nesting", s.sample_nesting ? "true" : "false");
-smap_add(cap, "ct_eventmask", s.ct_eventmask ? "true" : "false");
-smap_add(cap, "ct_clear", s.ct_clear ? "true" : "false");
-smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s.max_hash_alg);
-smap_add(cap, "check_pkt_len", s.check_pkt_len ? "true" : "false");
-smap_add(cap, "ct_timeout", s.ct_timeout ? "true" : "false");
+smap_add(cap, "masked_set_action",
+ s->masked_set_action ? "true" : "false");
+smap_add(cap, "tnl_push_pop", s->tnl_push_pop ? "true" : "false");
+smap_add(cap, "ufid", s->ufid ? "true" : "false");
+smap_add(cap, "trunc", s->trunc ? "true" : "false");
+smap_add(cap, "clone", s->clone ? "true" : "false");
+smap_add(cap, "sample_nesting", s->sample_nesting ? "true" : "false");
+smap_add(cap, "ct_eventmask", s->ct_eventmask ? "true" : "false");
+smap_add(cap, "ct_clear", s->ct_clear ? "true" : "false");
+smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s->max_hash_alg);
+smap_add(cap, "check_pkt_len", s->check_pkt_len ? "true" : "false");
+smap_add(cap, "ct_timeout", s->ct_timeout ? "true" : "false");
 smap_add(cap, "explicit_drop_action",
- s.explicit_drop_action ? "true" :"false");
-smap_add(cap, "lb_output_action", s.lb_output_action ? "true" : "false");
-smap_add(cap, "ct_zero_snat", s.ct_zero_snat ? "true" : "false");
-smap_add(cap, "add_mpls", s.add_mpls ? "true" : "false");
+ s->explicit_drop_action ? "true" :"false");
+smap_add(cap, "lb_output_action", s->lb_output_action ? "true" : "false");
+smap_add(cap, "ct_zero_snat", s->ct_zero_snat ? "true" : "false");
+smap_add(cap, "add_mpls", s->add_mpls ? "true" : "false");
 
 /* The ct_tuple_flush is implemented on dpif level, so it is supported
  * for all backers. */
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v10 4/5] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-03-07 Thread Eric Garver
On Thu, Mar 07, 2024 at 08:35:30PM +0100, Ilya Maximets wrote:
> On 3/7/24 18:08, Eric Garver wrote:
> > Kernel support has been added for this action. As such, we need to probe
> > the datapath for support.
> > 
> > Signed-off-by: Eric Garver 
> > ---
> >  include/linux/openvswitch.h |  2 +-
> >  lib/dpif.c  |  6 ---
> >  lib/dpif.h  |  1 -
> >  ofproto/ofproto-dpif.c  | 89 +++--
> >  ofproto/ofproto-dpif.h  |  4 +-
> >  5 files changed, 89 insertions(+), 13 deletions(-)
> 
> Not a full review, but a few comments inline.
> 
> This patch will need to remove the OVS_UNUSED mark.
> 
> > 
> > diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
> > index a265e05ad253..fce6456f47c8 100644
> > --- a/include/linux/openvswitch.h
> > +++ b/include/linux/openvswitch.h
> > @@ -1086,11 +1086,11 @@ enum ovs_action_attr {
> > OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
> > OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
> > OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
> > +   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
> >  
> >  #ifndef __KERNEL__
> > OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
> > OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
> > -   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
> > OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
> >  #endif
> > __OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
> > diff --git a/lib/dpif.c b/lib/dpif.c
> > index 0f480bec48d0..28fa40879655 100644
> > --- a/lib/dpif.c
> > +++ b/lib/dpif.c
> > @@ -1934,12 +1934,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
> >  return dpif_is_netdev(dpif);
> >  }
> >  
> > -bool
> > -dpif_supports_explicit_drop_action(const struct dpif *dpif)
> > -{
> > -return dpif_is_netdev(dpif);
> > -}
> 
> I'm not sure if calling dpif_is_netdev() from ofproto-dpif layer
> is a good idea.  Maybe add the hwol check into this function and
> rename it into dpif_may_support_explicit_drop_action()?
> 
> And call this from two places in ofproto-dpif.c below.
> 
> What do you think?

Makes sense. I'll give it a try.

> > -
> >  bool
> >  dpif_supports_lb_output_action(const struct dpif *dpif)
> >  {
> > diff --git a/lib/dpif.h b/lib/dpif.h
> > index 0f2dc2ef3c55..8dc5da45b3ef 100644
> > --- a/lib/dpif.h
> > +++ b/lib/dpif.h
> > @@ -940,7 +940,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
> > odp_port_t port_no,
> >  
> >  char *dpif_get_dp_version(const struct dpif *);
> >  bool dpif_supports_tnl_push_pop(const struct dpif *);
> > -bool dpif_supports_explicit_drop_action(const struct dpif *);
> >  bool dpif_synced_dp_layers(struct dpif *);
> >  
> >  /* Log functions. */
> > diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> > index 4e22ee0e8045..b9d35d6efa62 100644
> > --- a/ofproto/ofproto-dpif.c
> > +++ b/ofproto/ofproto-dpif.c
> > @@ -72,6 +72,8 @@
> >  #include "util.h"
> >  #include "uuid.h"
> >  #include "vlan-bitmap.h"
> > +#include "dpif-netdev.h"
> > +#include "netdev-offload.h"
> 
> Moving the checks back to dpif.c will get rid of these strange
> includes.

ACK

> >  
> >  VLOG_DEFINE_THIS_MODULE(ofproto_dpif);
> >  
> > @@ -221,6 +223,8 @@ static void ct_zone_config_init(struct dpif_backer 
> > *backer);
> >  static void ct_zone_config_uninit(struct dpif_backer *backer);
> >  static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
> >  static void ct_zone_limits_commit(struct dpif_backer *backer);
> > +static bool check_drop_action(struct dpif_backer *backer);
> > +static bool recheck_support_explicit_drop_action(struct dpif_backer 
> > *backer);
> >  
> >  static inline struct ofproto_dpif *
> >  ofproto_dpif_cast(const struct ofproto *ofproto)
> > @@ -391,6 +395,10 @@ type_run(const char *type)
> >  udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
> >  }
> >  
> > +if (recheck_support_explicit_drop_action(backer)) {
> > +backer->need_revalidate = REV_RECONFIGURE;
> > +}
> > +
> >  if (backer->need_revalidate) {
> >  struct ofproto_dpif *ofproto;
> >  struct simap_node *node;
> > @@ -807,6 +815,7 @@ open_

[ovs-dev] [PATCH v10 3/5] dpif: Support atomic_bool field type.

2024-03-07 Thread Eric Garver
The next commit will convert a dp feature from bool to atomic_bool. As
such we have to add support to the macros and functions. We must pass by
reference instead of pass by value because all the atomic operations
require a reference.

Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 52 --
 1 file changed, 45 insertions(+), 7 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index d732198de5ea..4e22ee0e8045 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -717,6 +717,8 @@ close_dpif_backer(struct dpif_backer *backer, bool del)
 }
 
 static void check_support(struct dpif_backer *backer);
+static void copy_support(struct dpif_backer_support *dst,
+ struct dpif_backer_support *src);
 
 static int
 open_dpif_backer(const char *type, struct dpif_backer **backerp)
@@ -837,7 +839,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
  * 'boottime_support' can be checked to prevent 'support' to be changed
  * beyond the datapath capabilities. In case 'support' is changed by
  * the user, 'boottime_support' can be used to restore it.  */
-backer->bt_support = backer->rt_support;
+copy_support(&backer->bt_support, &backer->rt_support);
 
 return error;
 }
@@ -1611,6 +1613,22 @@ CHECK_FEATURE__(ct_orig_tuple6, ct_orig_tuple6, 
ct_nw_proto, 1, ETH_TYPE_IPV6)
 #undef CHECK_FEATURE
 #undef CHECK_FEATURE__
 
+static void
+copy_support(struct dpif_backer_support *dst, struct dpif_backer_support *src)
+{
+#define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
+if (!strcmp(#TYPE, "atomic_bool")) { \
+bool value; \
+atomic_read_relaxed((atomic_bool *) &src->NAME, &value); \
+atomic_store_relaxed((atomic_bool *) &dst->NAME, value); \
+} else { \
+dst->NAME = src->NAME; \
+}
+
+DPIF_SUPPORT_FIELDS
+#undef DPIF_SUPPORT_FIELD
+}
+
 static void
 check_support(struct dpif_backer *backer)
 {
@@ -6248,20 +6266,30 @@ ofproto_unixctl_dpif_dump_dps(struct unixctl_conn 
*conn, int argc OVS_UNUSED,
 }
 
 static void
-show_dp_feature_bool(struct ds *ds, const char *feature, bool b)
+show_dp_feature_bool(struct ds *ds, const char *feature, const bool *b)
 {
-ds_put_format(ds, "%s: %s\n", feature, b ? "Yes" : "No");
+ds_put_format(ds, "%s: %s\n", feature, *b ? "Yes" : "No");
 }
 
 static void
-show_dp_feature_size_t(struct ds *ds, const char *feature, size_t s)
+show_dp_feature_atomic_bool(struct ds *ds, const char *feature,
+const atomic_bool *b)
 {
-ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, s);
+bool value;
+atomic_read_relaxed((atomic_bool *) b, &value);
+ds_put_format(ds, "%s: %s\n", feature, value ? "Yes" : "No");
+}
+
+static void
+show_dp_feature_size_t(struct ds *ds, const char *feature, const size_t *s)
+{
+ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, *s);
 }
 
 enum dpif_support_field_type {
 DPIF_SUPPORT_FIELD_bool,
 DPIF_SUPPORT_FIELD_size_t,
+DPIF_SUPPORT_FIELD_atomic_bool,
 };
 
 struct dpif_support_field {
@@ -6278,12 +6306,12 @@ static void
 dpif_show_support(const struct dpif_backer_support *support, struct ds *ds)
 {
 #define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->NAME);
+show_dp_feature_##TYPE (ds, TITLE, &support->NAME);
 DPIF_SUPPORT_FIELDS
 #undef DPIF_SUPPORT_FIELD
 
 #define ODP_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->odp.NAME );
+show_dp_feature_##TYPE (ds, TITLE, &support->odp.NAME );
 ODP_SUPPORT_FIELDS
 #undef ODP_SUPPORT_FIELD
 }
@@ -6302,6 +6330,16 @@ display_support_field(const char *name,
   b ? "true" : "false");
 break;
 }
+case DPIF_SUPPORT_FIELD_atomic_bool: {
+bool v;
+bool b;
+atomic_read_relaxed((atomic_bool *) field->rt_ptr, &v);
+atomic_read_relaxed((atomic_bool *) field->bt_ptr, &b);
+ds_put_format(ds, "%s (%s) : [run time]:%s, [boot time]:%s\n", name,
+  field->title, v ? "true" : "false",
+  b ? "true" : "false");
+break;
+}
 case DPIF_SUPPORT_FIELD_size_t:
 ds_put_format(ds, "%s (%s) : [run time]:%"PRIuSIZE
   ", [boot time]:%"PRIuSIZE"\n", name,
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v10 0/5] dpif: probe support for OVS_ACTION_ATTR_DROP

2024-03-07 Thread Eric Garver
v10:
  - fix a sparse error in show_dp_feature_atomic_bool()
v9:
  - new patch make get_datapath_cap() access support by pointer
  - fix a clang warning in copy_support()
v8:
  - new patch to support atomic_bool dpif field types
  - re-add re-probe of support
  - use atomic_bool type for explicit_drop_action
v7:
  - remove re-probe of support as Ilya is working on a generic solution
v6:
  - improve log if hw-offload enabled
  - re-probe support if hw-offload set true at runtime
v5:
  - combine patches 3 and 4
  - add description to combined patch 3
v4:
  - avoid passing action to datapath if TC offload in use
v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (5):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Make get_datapath_cap() access support by pointer.
  dpif: Support atomic_bool field type.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  tests: system-traffic: Add coverage for drop action.

 include/linux/openvswitch.h   |   3 +-
 lib/dpif-netdev.c |   1 +
 lib/dpif.c|   7 +-
 lib/dpif.h|   1 -
 lib/odp-execute.c |   2 +
 lib/odp-util.c|  23 
 ofproto/ofproto-dpif-ipfix.c  |   1 +
 ofproto/ofproto-dpif-sflow.c  |   1 +
 ofproto/ofproto-dpif.c| 198 +++---
 ofproto/ofproto-dpif.h|   4 +-
 tests/system-common-macros.at |   4 +
 tests/system-traffic.at   |  31 ++
 12 files changed, 227 insertions(+), 49 deletions(-)

-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v10 1/5] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2024-03-07 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  1 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 30 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index e6c53937d8b9..89b0d1d6b4aa 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9489,6 +9489,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index d07241f1e7cd..0f480bec48d0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1289,6 +1289,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index eb03b57c42ec..081e4d43268a 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -837,6 +837,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1227,6 +1228,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 9306c9b4d47a..f4c492f2ae6f 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_names);
+break;
 case OVS_ACTION_ATTR_DROP:
 ds_put_cstr(ds, "drop");
 break;
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..cd65dae7e18a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3135,6 +3135,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 c

[ovs-dev] [PATCH v10 5/5] tests: system-traffic: Add coverage for drop action.

2024-03-07 Thread Eric Garver
Exercise the drop action in the datapath. This specific tests triggers
an xlate_error.

For the kernel datapath skb drop reasons can then be seen while this
test runs.

 # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
   0.000 ping/1275884 skb:kfree_skb(skbaddr: 0x8acd76546000, \
  location: 0xc0ee3634, protocol: 2048, reason: 196611)

Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 +++
 2 files changed, 35 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 01ebe364ee7c..564bc163945e 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -374,3 +374,7 @@ m4_define([OVS_CHECK_CT_CLEAR],
 # OVS_CHECK_GITHUB_ACTION
 m4_define([OVS_CHECK_GITHUB_ACTION],
 [AT_SKIP_IF([test "$GITHUB_ACTIONS" = "true"])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports drop action" ovs-vswitchd.log])])
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 07d09b912e0b..d7673ecac8c9 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2231,6 +2231,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl
+  strip_recirc | strip_stats | strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v10 4/5] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-03-07 Thread Eric Garver
Kernel support has been added for this action. As such, we need to probe
the datapath for support.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 ---
 lib/dpif.h  |  1 -
 ofproto/ofproto-dpif.c  | 89 +++--
 ofproto/ofproto-dpif.h  |  4 +-
 5 files changed, 89 insertions(+), 13 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index 0f480bec48d0..28fa40879655 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1934,12 +1934,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 return dpif_is_netdev(dpif);
 }
 
-bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
-{
-return dpif_is_netdev(dpif);
-}
-
 bool
 dpif_supports_lb_output_action(const struct dpif *dpif)
 {
diff --git a/lib/dpif.h b/lib/dpif.h
index 0f2dc2ef3c55..8dc5da45b3ef 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 4e22ee0e8045..b9d35d6efa62 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -72,6 +72,8 @@
 #include "util.h"
 #include "uuid.h"
 #include "vlan-bitmap.h"
+#include "dpif-netdev.h"
+#include "netdev-offload.h"
 
 VLOG_DEFINE_THIS_MODULE(ofproto_dpif);
 
@@ -221,6 +223,8 @@ static void ct_zone_config_init(struct dpif_backer *backer);
 static void ct_zone_config_uninit(struct dpif_backer *backer);
 static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
 static void ct_zone_limits_commit(struct dpif_backer *backer);
+static bool check_drop_action(struct dpif_backer *backer);
+static bool recheck_support_explicit_drop_action(struct dpif_backer *backer);
 
 static inline struct ofproto_dpif *
 ofproto_dpif_cast(const struct ofproto *ofproto)
@@ -391,6 +395,10 @@ type_run(const char *type)
 udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
 }
 
+if (recheck_support_explicit_drop_action(backer)) {
+backer->need_revalidate = REV_RECONFIGURE;
+}
+
 if (backer->need_revalidate) {
 struct ofproto_dpif *ofproto;
 struct simap_node *node;
@@ -807,6 +815,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
 
 shash_add(&all_dpif_backers, type, backer);
 
+atomic_init(&backer->rt_support.explicit_drop_action, false);
 check_support(backer);
 atomic_count_init(&backer->tnl_count, 0);
 
@@ -855,7 +864,10 @@ ovs_native_tunneling_is_on(struct ofproto_dpif *ofproto)
 bool
 ovs_explicit_drop_action_supported(struct ofproto_dpif *ofproto)
 {
-return ofproto->backer->rt_support.explicit_drop_action;
+bool value;
+atomic_read_relaxed(&ofproto->backer->rt_support.explicit_drop_action,
+&value);
+return value;
 }
 
 bool
@@ -1379,6 +1391,43 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+bool hw_offload;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_ATTR_DROP, XLATE_OK);
+
+supported = dpif_probe_feature(backer->dpif, "drop", &ke

[ovs-dev] [PATCH v10 2/5] dpif: Make get_datapath_cap() access support by pointer.

2024-03-07 Thread Eric Garver
This avoids copying the support struct onto the stack.

Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 59 +-
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index f59d69c4d1e8..d732198de5ea 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -5688,47 +5688,46 @@ ct_zone_limit_protection_update(const char 
*datapath_type, bool protected)
 static void
 get_datapath_cap(const char *datapath_type, struct smap *cap)
 {
-struct odp_support odp;
-struct dpif_backer_support s;
+struct dpif_backer_support *s;
 struct dpif_backer *backer = shash_find_data(&all_dpif_backers,
  datapath_type);
 if (!backer) {
 return;
 }
-s = backer->rt_support;
-odp = s.odp;
+s = &backer->rt_support;
 
 /* ODP_SUPPORT_FIELDS */
 smap_add_format(cap, "max_vlan_headers", "%"PRIuSIZE,
-odp.max_vlan_headers);
-smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, odp.max_mpls_depth);
-smap_add(cap, "recirc", odp.recirc ? "true" : "false");
-smap_add(cap, "ct_state", odp.ct_state ? "true" : "false");
-smap_add(cap, "ct_zone", odp.ct_zone ? "true" : "false");
-smap_add(cap, "ct_mark", odp.ct_mark ? "true" : "false");
-smap_add(cap, "ct_label", odp.ct_label ? "true" : "false");
-smap_add(cap, "ct_state_nat", odp.ct_state_nat ? "true" : "false");
-smap_add(cap, "ct_orig_tuple", odp.ct_orig_tuple ? "true" : "false");
-smap_add(cap, "ct_orig_tuple6", odp.ct_orig_tuple6 ? "true" : "false");
-smap_add(cap, "nd_ext", odp.nd_ext ? "true" : "false");
+s->odp.max_vlan_headers);
+smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, s->odp.max_mpls_depth);
+smap_add(cap, "recirc", s->odp.recirc ? "true" : "false");
+smap_add(cap, "ct_state", s->odp.ct_state ? "true" : "false");
+smap_add(cap, "ct_zone", s->odp.ct_zone ? "true" : "false");
+smap_add(cap, "ct_mark", s->odp.ct_mark ? "true" : "false");
+smap_add(cap, "ct_label", s->odp.ct_label ? "true" : "false");
+smap_add(cap, "ct_state_nat", s->odp.ct_state_nat ? "true" : "false");
+smap_add(cap, "ct_orig_tuple", s->odp.ct_orig_tuple ? "true" : "false");
+smap_add(cap, "ct_orig_tuple6", s->odp.ct_orig_tuple6 ? "true" : "false");
+smap_add(cap, "nd_ext", s->odp.nd_ext ? "true" : "false");
 
 /* DPIF_SUPPORT_FIELDS */
-smap_add(cap, "masked_set_action", s.masked_set_action ? "true" : "false");
-smap_add(cap, "tnl_push_pop", s.tnl_push_pop ? "true" : "false");
-smap_add(cap, "ufid", s.ufid ? "true" : "false");
-smap_add(cap, "trunc", s.trunc ? "true" : "false");
-smap_add(cap, "clone", s.clone ? "true" : "false");
-smap_add(cap, "sample_nesting", s.sample_nesting ? "true" : "false");
-smap_add(cap, "ct_eventmask", s.ct_eventmask ? "true" : "false");
-smap_add(cap, "ct_clear", s.ct_clear ? "true" : "false");
-smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s.max_hash_alg);
-smap_add(cap, "check_pkt_len", s.check_pkt_len ? "true" : "false");
-smap_add(cap, "ct_timeout", s.ct_timeout ? "true" : "false");
+smap_add(cap, "masked_set_action",
+ s->masked_set_action ? "true" : "false");
+smap_add(cap, "tnl_push_pop", s->tnl_push_pop ? "true" : "false");
+smap_add(cap, "ufid", s->ufid ? "true" : "false");
+smap_add(cap, "trunc", s->trunc ? "true" : "false");
+smap_add(cap, "clone", s->clone ? "true" : "false");
+smap_add(cap, "sample_nesting", s->sample_nesting ? "true" : "false");
+smap_add(cap, "ct_eventmask", s->ct_eventmask ? "true" : "false");
+smap_add(cap, "ct_clear", s->ct_clear ? "true" : "false");
+smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s->max_hash_alg);
+smap_add(cap, "check_pkt_len", s->check_pkt_len ? "true" : "false");
+smap_add(cap, "ct_timeout", s->ct_timeout ? "true" : "false");
 smap_add(cap, "explicit_drop_action",
- s.explicit_drop_action ? "true" :"false");
-smap_add(cap, "lb_output_action", s.lb_output_action ? "true" : "false");
-smap_add(cap, "ct_zero_snat", s.ct_zero_snat ? "true" : "false");
-smap_add(cap, "add_mpls", s.add_mpls ? "true" : "false");
+ s->explicit_drop_action ? "true" :"false");
+smap_add(cap, "lb_output_action", s->lb_output_action ? "true" : "false");
+smap_add(cap, "ct_zero_snat", s->ct_zero_snat ? "true" : "false");
+smap_add(cap, "add_mpls", s->add_mpls ? "true" : "false");
 
 /* The ct_tuple_flush is implemented on dpif level, so it is supported
  * for all backers. */
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v9 0/5] dpif: probe support for OVS_ACTION_ATTR_DROP

2024-03-07 Thread Eric Garver
v9:
  - new patch make get_datapath_cap() access support by pointer
  - fix a clang warning in copy_support()
v8:
  - new patch to support atomic_bool dpif field types
  - re-add re-probe of support
  - use atomic_bool type for explicit_drop_action
v7:
  - remove re-probe of support as Ilya is working on a generic solution
v6:
  - improve log if hw-offload enabled
  - re-probe support if hw-offload set true at runtime
v5:
  - combine patches 3 and 4
  - add description to combined patch 3
v4:
  - avoid passing action to datapath if TC offload in use
v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (5):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Make get_datapath_cap() access support by pointer.
  dpif: Support atomic_bool field type.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  tests: system-traffic: Add coverage for drop action.

 include/linux/openvswitch.h   |   3 +-
 lib/dpif-netdev.c |   1 +
 lib/dpif.c|   7 +-
 lib/dpif.h|   1 -
 lib/odp-execute.c |   2 +
 lib/odp-util.c|  23 
 ofproto/ofproto-dpif-ipfix.c  |   1 +
 ofproto/ofproto-dpif-sflow.c  |   1 +
 ofproto/ofproto-dpif.c| 198 +++---
 ofproto/ofproto-dpif.h|   4 +-
 tests/system-common-macros.at |   4 +
 tests/system-traffic.at   |  31 ++
 12 files changed, 227 insertions(+), 49 deletions(-)

-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v9 2/5] dpif: Make get_datapath_cap() access support by pointer.

2024-03-07 Thread Eric Garver
This avoids copying the support struct onto the stack.

Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 59 +-
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index f59d69c4d1e8..d732198de5ea 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -5688,47 +5688,46 @@ ct_zone_limit_protection_update(const char 
*datapath_type, bool protected)
 static void
 get_datapath_cap(const char *datapath_type, struct smap *cap)
 {
-struct odp_support odp;
-struct dpif_backer_support s;
+struct dpif_backer_support *s;
 struct dpif_backer *backer = shash_find_data(&all_dpif_backers,
  datapath_type);
 if (!backer) {
 return;
 }
-s = backer->rt_support;
-odp = s.odp;
+s = &backer->rt_support;
 
 /* ODP_SUPPORT_FIELDS */
 smap_add_format(cap, "max_vlan_headers", "%"PRIuSIZE,
-odp.max_vlan_headers);
-smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, odp.max_mpls_depth);
-smap_add(cap, "recirc", odp.recirc ? "true" : "false");
-smap_add(cap, "ct_state", odp.ct_state ? "true" : "false");
-smap_add(cap, "ct_zone", odp.ct_zone ? "true" : "false");
-smap_add(cap, "ct_mark", odp.ct_mark ? "true" : "false");
-smap_add(cap, "ct_label", odp.ct_label ? "true" : "false");
-smap_add(cap, "ct_state_nat", odp.ct_state_nat ? "true" : "false");
-smap_add(cap, "ct_orig_tuple", odp.ct_orig_tuple ? "true" : "false");
-smap_add(cap, "ct_orig_tuple6", odp.ct_orig_tuple6 ? "true" : "false");
-smap_add(cap, "nd_ext", odp.nd_ext ? "true" : "false");
+s->odp.max_vlan_headers);
+smap_add_format(cap, "max_mpls_depth", "%"PRIuSIZE, s->odp.max_mpls_depth);
+smap_add(cap, "recirc", s->odp.recirc ? "true" : "false");
+smap_add(cap, "ct_state", s->odp.ct_state ? "true" : "false");
+smap_add(cap, "ct_zone", s->odp.ct_zone ? "true" : "false");
+smap_add(cap, "ct_mark", s->odp.ct_mark ? "true" : "false");
+smap_add(cap, "ct_label", s->odp.ct_label ? "true" : "false");
+smap_add(cap, "ct_state_nat", s->odp.ct_state_nat ? "true" : "false");
+smap_add(cap, "ct_orig_tuple", s->odp.ct_orig_tuple ? "true" : "false");
+smap_add(cap, "ct_orig_tuple6", s->odp.ct_orig_tuple6 ? "true" : "false");
+smap_add(cap, "nd_ext", s->odp.nd_ext ? "true" : "false");
 
 /* DPIF_SUPPORT_FIELDS */
-smap_add(cap, "masked_set_action", s.masked_set_action ? "true" : "false");
-smap_add(cap, "tnl_push_pop", s.tnl_push_pop ? "true" : "false");
-smap_add(cap, "ufid", s.ufid ? "true" : "false");
-smap_add(cap, "trunc", s.trunc ? "true" : "false");
-smap_add(cap, "clone", s.clone ? "true" : "false");
-smap_add(cap, "sample_nesting", s.sample_nesting ? "true" : "false");
-smap_add(cap, "ct_eventmask", s.ct_eventmask ? "true" : "false");
-smap_add(cap, "ct_clear", s.ct_clear ? "true" : "false");
-smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s.max_hash_alg);
-smap_add(cap, "check_pkt_len", s.check_pkt_len ? "true" : "false");
-smap_add(cap, "ct_timeout", s.ct_timeout ? "true" : "false");
+smap_add(cap, "masked_set_action",
+ s->masked_set_action ? "true" : "false");
+smap_add(cap, "tnl_push_pop", s->tnl_push_pop ? "true" : "false");
+smap_add(cap, "ufid", s->ufid ? "true" : "false");
+smap_add(cap, "trunc", s->trunc ? "true" : "false");
+smap_add(cap, "clone", s->clone ? "true" : "false");
+smap_add(cap, "sample_nesting", s->sample_nesting ? "true" : "false");
+smap_add(cap, "ct_eventmask", s->ct_eventmask ? "true" : "false");
+smap_add(cap, "ct_clear", s->ct_clear ? "true" : "false");
+smap_add_format(cap, "max_hash_alg", "%"PRIuSIZE, s->max_hash_alg);
+smap_add(cap, "check_pkt_len", s->check_pkt_len ? "true" : "false");
+smap_add(cap, "ct_timeout", s->ct_timeout ? "true" : "false");
 smap_add(cap, "explicit_drop_action",
- s.explicit_drop_action ? "true" :"false");
-smap_add(cap, "lb_output_action", s.lb_output_action ? "true" : "false");
-smap_add(cap, "ct_zero_snat", s.ct_zero_snat ? "true" : "false");
-smap_add(cap, "add_mpls", s.add_mpls ? "true" : "false");
+ s->explicit_drop_action ? "true" :"false");
+smap_add(cap, "lb_output_action", s->lb_output_action ? "true" : "false");
+smap_add(cap, "ct_zero_snat", s->ct_zero_snat ? "true" : "false");
+smap_add(cap, "add_mpls", s->add_mpls ? "true" : "false");
 
 /* The ct_tuple_flush is implemented on dpif level, so it is supported
  * for all backers. */
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v9 4/5] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-03-07 Thread Eric Garver
Kernel support has been added for this action. As such, we need to probe
the datapath for support.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 ---
 lib/dpif.h  |  1 -
 ofproto/ofproto-dpif.c  | 89 +++--
 ofproto/ofproto-dpif.h  |  4 +-
 5 files changed, 89 insertions(+), 13 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index 0f480bec48d0..28fa40879655 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1934,12 +1934,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 return dpif_is_netdev(dpif);
 }
 
-bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
-{
-return dpif_is_netdev(dpif);
-}
-
 bool
 dpif_supports_lb_output_action(const struct dpif *dpif)
 {
diff --git a/lib/dpif.h b/lib/dpif.h
index 0f2dc2ef3c55..8dc5da45b3ef 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 718cc7bfd254..0c500fe5d8a6 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -72,6 +72,8 @@
 #include "util.h"
 #include "uuid.h"
 #include "vlan-bitmap.h"
+#include "dpif-netdev.h"
+#include "netdev-offload.h"
 
 VLOG_DEFINE_THIS_MODULE(ofproto_dpif);
 
@@ -221,6 +223,8 @@ static void ct_zone_config_init(struct dpif_backer *backer);
 static void ct_zone_config_uninit(struct dpif_backer *backer);
 static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
 static void ct_zone_limits_commit(struct dpif_backer *backer);
+static bool check_drop_action(struct dpif_backer *backer);
+static bool recheck_support_explicit_drop_action(struct dpif_backer *backer);
 
 static inline struct ofproto_dpif *
 ofproto_dpif_cast(const struct ofproto *ofproto)
@@ -391,6 +395,10 @@ type_run(const char *type)
 udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
 }
 
+if (recheck_support_explicit_drop_action(backer)) {
+backer->need_revalidate = REV_RECONFIGURE;
+}
+
 if (backer->need_revalidate) {
 struct ofproto_dpif *ofproto;
 struct simap_node *node;
@@ -807,6 +815,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
 
 shash_add(&all_dpif_backers, type, backer);
 
+atomic_init(&backer->rt_support.explicit_drop_action, false);
 check_support(backer);
 atomic_count_init(&backer->tnl_count, 0);
 
@@ -855,7 +864,10 @@ ovs_native_tunneling_is_on(struct ofproto_dpif *ofproto)
 bool
 ovs_explicit_drop_action_supported(struct ofproto_dpif *ofproto)
 {
-return ofproto->backer->rt_support.explicit_drop_action;
+bool value;
+atomic_read_relaxed(&ofproto->backer->rt_support.explicit_drop_action,
+&value);
+return value;
 }
 
 bool
@@ -1379,6 +1391,43 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+bool hw_offload;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_ATTR_DROP, XLATE_OK);
+
+supported = dpif_probe_feature(backer->dpif, "drop", &ke

[ovs-dev] [PATCH v9 1/5] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2024-03-07 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  1 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 30 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index e6c53937d8b9..89b0d1d6b4aa 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9489,6 +9489,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index d07241f1e7cd..0f480bec48d0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1289,6 +1289,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index eb03b57c42ec..081e4d43268a 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -837,6 +837,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1227,6 +1228,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 9306c9b4d47a..f4c492f2ae6f 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_names);
+break;
 case OVS_ACTION_ATTR_DROP:
 ds_put_cstr(ds, "drop");
 break;
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..cd65dae7e18a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3135,6 +3135,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 c

[ovs-dev] [PATCH v9 3/5] dpif: Support atomic_bool field type.

2024-03-07 Thread Eric Garver
The next commit will convert a dp feature from bool to atomic_bool. As
such we have to add support to the macros and functions. We must pass by
reference instead of pass by value because all the atomic operations
require a reference.

Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 52 --
 1 file changed, 45 insertions(+), 7 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index d732198de5ea..718cc7bfd254 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -717,6 +717,8 @@ close_dpif_backer(struct dpif_backer *backer, bool del)
 }
 
 static void check_support(struct dpif_backer *backer);
+static void copy_support(struct dpif_backer_support *dst,
+ struct dpif_backer_support *src);
 
 static int
 open_dpif_backer(const char *type, struct dpif_backer **backerp)
@@ -837,7 +839,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
  * 'boottime_support' can be checked to prevent 'support' to be changed
  * beyond the datapath capabilities. In case 'support' is changed by
  * the user, 'boottime_support' can be used to restore it.  */
-backer->bt_support = backer->rt_support;
+copy_support(&backer->bt_support, &backer->rt_support);
 
 return error;
 }
@@ -1611,6 +1613,22 @@ CHECK_FEATURE__(ct_orig_tuple6, ct_orig_tuple6, 
ct_nw_proto, 1, ETH_TYPE_IPV6)
 #undef CHECK_FEATURE
 #undef CHECK_FEATURE__
 
+static void
+copy_support(struct dpif_backer_support *dst, struct dpif_backer_support *src)
+{
+#define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
+if (!strcmp(#TYPE, "atomic_bool")) { \
+bool value; \
+atomic_read_relaxed((atomic_bool *) &src->NAME, &value); \
+atomic_store_relaxed((atomic_bool *) &dst->NAME, value); \
+} else { \
+dst->NAME = src->NAME; \
+}
+
+DPIF_SUPPORT_FIELDS
+#undef DPIF_SUPPORT_FIELD
+}
+
 static void
 check_support(struct dpif_backer *backer)
 {
@@ -6248,20 +6266,30 @@ ofproto_unixctl_dpif_dump_dps(struct unixctl_conn 
*conn, int argc OVS_UNUSED,
 }
 
 static void
-show_dp_feature_bool(struct ds *ds, const char *feature, bool b)
+show_dp_feature_bool(struct ds *ds, const char *feature, const bool *b)
 {
-ds_put_format(ds, "%s: %s\n", feature, b ? "Yes" : "No");
+ds_put_format(ds, "%s: %s\n", feature, *b ? "Yes" : "No");
 }
 
 static void
-show_dp_feature_size_t(struct ds *ds, const char *feature, size_t s)
+show_dp_feature_atomic_bool(struct ds *ds, const char *feature,
+const atomic_bool *b)
 {
-ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, s);
+bool value;
+atomic_read_relaxed(b, &value);
+ds_put_format(ds, "%s: %s\n", feature, value ? "Yes" : "No");
+}
+
+static void
+show_dp_feature_size_t(struct ds *ds, const char *feature, const size_t *s)
+{
+ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, *s);
 }
 
 enum dpif_support_field_type {
 DPIF_SUPPORT_FIELD_bool,
 DPIF_SUPPORT_FIELD_size_t,
+DPIF_SUPPORT_FIELD_atomic_bool,
 };
 
 struct dpif_support_field {
@@ -6278,12 +6306,12 @@ static void
 dpif_show_support(const struct dpif_backer_support *support, struct ds *ds)
 {
 #define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->NAME);
+show_dp_feature_##TYPE (ds, TITLE, &support->NAME);
 DPIF_SUPPORT_FIELDS
 #undef DPIF_SUPPORT_FIELD
 
 #define ODP_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->odp.NAME );
+show_dp_feature_##TYPE (ds, TITLE, &support->odp.NAME );
 ODP_SUPPORT_FIELDS
 #undef ODP_SUPPORT_FIELD
 }
@@ -6302,6 +6330,16 @@ display_support_field(const char *name,
   b ? "true" : "false");
 break;
 }
+case DPIF_SUPPORT_FIELD_atomic_bool: {
+bool v;
+bool b;
+atomic_read_relaxed((atomic_bool *) field->rt_ptr, &v);
+atomic_read_relaxed((atomic_bool *) field->bt_ptr, &b);
+ds_put_format(ds, "%s (%s) : [run time]:%s, [boot time]:%s\n", name,
+  field->title, v ? "true" : "false",
+  b ? "true" : "false");
+break;
+}
 case DPIF_SUPPORT_FIELD_size_t:
 ds_put_format(ds, "%s (%s) : [run time]:%"PRIuSIZE
   ", [boot time]:%"PRIuSIZE"\n", name,
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v9 5/5] tests: system-traffic: Add coverage for drop action.

2024-03-07 Thread Eric Garver
Exercise the drop action in the datapath. This specific tests triggers
an xlate_error.

For the kernel datapath skb drop reasons can then be seen while this
test runs.

 # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
   0.000 ping/1275884 skb:kfree_skb(skbaddr: 0x8acd76546000, \
  location: 0xc0ee3634, protocol: 2048, reason: 196611)

Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 +++
 2 files changed, 35 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 01ebe364ee7c..564bc163945e 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -374,3 +374,7 @@ m4_define([OVS_CHECK_CT_CLEAR],
 # OVS_CHECK_GITHUB_ACTION
 m4_define([OVS_CHECK_GITHUB_ACTION],
 [AT_SKIP_IF([test "$GITHUB_ACTIONS" = "true"])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports drop action" ovs-vswitchd.log])])
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 07d09b912e0b..d7673ecac8c9 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2231,6 +2231,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl
+  strip_recirc | strip_stats | strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v8 3/4] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-03-06 Thread Eric Garver
On Wed, Mar 06, 2024 at 12:34:07PM -0500, Eric Garver wrote:
> Kernel support has been added for this action. As such, we need to probe
> the datapath for support.
> 
> Signed-off-by: Eric Garver 
> ---
>  include/linux/openvswitch.h |  2 +-
>  lib/dpif.c  |  6 ---
>  lib/dpif.h  |  1 -
>  ofproto/ofproto-dpif.c  | 89 +++--
>  ofproto/ofproto-dpif.h  |  4 +-
>  5 files changed, 89 insertions(+), 13 deletions(-)
> 
> diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
> index a265e05ad253..fce6456f47c8 100644
> --- a/include/linux/openvswitch.h
> +++ b/include/linux/openvswitch.h
> @@ -1086,11 +1086,11 @@ enum ovs_action_attr {
>   OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
>   OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
>   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
> + OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
>  
>  #ifndef __KERNEL__
>   OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
>   OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
> - OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
>   OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
>  #endif
>   __OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
> diff --git a/lib/dpif.c b/lib/dpif.c
> index 0f480bec48d0..28fa40879655 100644
> --- a/lib/dpif.c
> +++ b/lib/dpif.c
> @@ -1934,12 +1934,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
>  return dpif_is_netdev(dpif);
>  }
>  
> -bool
> -dpif_supports_explicit_drop_action(const struct dpif *dpif)
> -{
> -return dpif_is_netdev(dpif);
> -}
> -
>  bool
>  dpif_supports_lb_output_action(const struct dpif *dpif)
>  {
> diff --git a/lib/dpif.h b/lib/dpif.h
> index 0f2dc2ef3c55..8dc5da45b3ef 100644
> --- a/lib/dpif.h
> +++ b/lib/dpif.h
> @@ -940,7 +940,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
> odp_port_t port_no,
>  
>  char *dpif_get_dp_version(const struct dpif *);
>  bool dpif_supports_tnl_push_pop(const struct dpif *);
> -bool dpif_supports_explicit_drop_action(const struct dpif *);
>  bool dpif_synced_dp_layers(struct dpif *);
>  
>  /* Log functions. */
> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index b1978e3f2fd5..da83d6196b13 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -72,6 +72,8 @@
>  #include "util.h"
>  #include "uuid.h"
>  #include "vlan-bitmap.h"
> +#include "dpif-netdev.h"
> +#include "netdev-offload.h"
>  
>  VLOG_DEFINE_THIS_MODULE(ofproto_dpif);
>  
> @@ -221,6 +223,8 @@ static void ct_zone_config_init(struct dpif_backer 
> *backer);
>  static void ct_zone_config_uninit(struct dpif_backer *backer);
>  static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
>  static void ct_zone_limits_commit(struct dpif_backer *backer);
> +static bool check_drop_action(struct dpif_backer *backer);
> +static bool recheck_support_explicit_drop_action(struct dpif_backer *backer);
>  
>  static inline struct ofproto_dpif *
>  ofproto_dpif_cast(const struct ofproto *ofproto)
> @@ -391,6 +395,10 @@ type_run(const char *type)
>  udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
>  }
>  
> +if (recheck_support_explicit_drop_action(backer)) {
> +backer->need_revalidate = REV_RECONFIGURE;
> +}
> +
>  if (backer->need_revalidate) {
>  struct ofproto_dpif *ofproto;
>  struct simap_node *node;
> @@ -807,6 +815,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
> **backerp)
>  
>  shash_add(&all_dpif_backers, type, backer);
>  
> +atomic_init(&backer->rt_support.explicit_drop_action, false);
>  check_support(backer);
>  atomic_count_init(&backer->tnl_count, 0);
>  
> @@ -855,7 +864,10 @@ ovs_native_tunneling_is_on(struct ofproto_dpif *ofproto)
>  bool
>  ovs_explicit_drop_action_supported(struct ofproto_dpif *ofproto)
>  {
> -return ofproto->backer->rt_support.explicit_drop_action;
> +bool value;
> +atomic_read_relaxed(&ofproto->backer->rt_support.explicit_drop_action,
> +&value);
> +return value;
>  }
>  
>  bool
> @@ -1379,6 +1391,43 @@ check_ct_timeout_policy(struct dpif_backer *backer)
>  return !error;
>  }
>  
> +/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. 
> */
> +static bool
> +check_drop_action(struct dpif_backer *backer)
> +{
> +struct o

[ovs-dev] [PATCH v8 4/4] tests: system-traffic: Add coverage for drop action.

2024-03-06 Thread Eric Garver
Exercise the drop action in the datapath. This specific tests triggers
an xlate_error.

For the kernel datapath skb drop reasons can then be seen while this
test runs.

 # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
   0.000 ping/1275884 skb:kfree_skb(skbaddr: 0x8acd76546000, \
  location: 0xc0ee3634, protocol: 2048, reason: 196611)

Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 +++
 2 files changed, 35 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 01ebe364ee7c..564bc163945e 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -374,3 +374,7 @@ m4_define([OVS_CHECK_CT_CLEAR],
 # OVS_CHECK_GITHUB_ACTION
 m4_define([OVS_CHECK_GITHUB_ACTION],
 [AT_SKIP_IF([test "$GITHUB_ACTIONS" = "true"])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports drop action" ovs-vswitchd.log])])
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 07d09b912e0b..d7673ecac8c9 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2231,6 +2231,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl
+  strip_recirc | strip_stats | strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v8 2/4] dpif: Support atomic_bool field type.

2024-03-06 Thread Eric Garver
The next commit will convert a dp feature from bool to atomic_bool. As
such we have to add support to the macros and functions. We must pass by
reference instead of pass by value because all the atomic operations
require a reference.

Signed-off-by: Eric Garver 
---
 ofproto/ofproto-dpif.c | 52 --
 1 file changed, 45 insertions(+), 7 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index f59d69c4d1e8..b1978e3f2fd5 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -717,6 +717,8 @@ close_dpif_backer(struct dpif_backer *backer, bool del)
 }
 
 static void check_support(struct dpif_backer *backer);
+static void copy_support(struct dpif_backer_support *dst,
+ struct dpif_backer_support *src);
 
 static int
 open_dpif_backer(const char *type, struct dpif_backer **backerp)
@@ -837,7 +839,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
  * 'boottime_support' can be checked to prevent 'support' to be changed
  * beyond the datapath capabilities. In case 'support' is changed by
  * the user, 'boottime_support' can be used to restore it.  */
-backer->bt_support = backer->rt_support;
+copy_support(&backer->bt_support, &backer->rt_support);
 
 return error;
 }
@@ -1611,6 +1613,22 @@ CHECK_FEATURE__(ct_orig_tuple6, ct_orig_tuple6, 
ct_nw_proto, 1, ETH_TYPE_IPV6)
 #undef CHECK_FEATURE
 #undef CHECK_FEATURE__
 
+static void
+copy_support(struct dpif_backer_support *dst, struct dpif_backer_support *src)
+{
+#define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
+if (!strcmp(#TYPE, "atomic_bool")) { \
+bool value; \
+atomic_read_relaxed(&src->NAME, &value); \
+atomic_store_relaxed(&dst->NAME, value); \
+} else { \
+dst->NAME = src->NAME; \
+}
+
+DPIF_SUPPORT_FIELDS
+#undef DPIF_SUPPORT_FIELD
+}
+
 static void
 check_support(struct dpif_backer *backer)
 {
@@ -6249,20 +6267,30 @@ ofproto_unixctl_dpif_dump_dps(struct unixctl_conn 
*conn, int argc OVS_UNUSED,
 }
 
 static void
-show_dp_feature_bool(struct ds *ds, const char *feature, bool b)
+show_dp_feature_bool(struct ds *ds, const char *feature, const bool *b)
 {
-ds_put_format(ds, "%s: %s\n", feature, b ? "Yes" : "No");
+ds_put_format(ds, "%s: %s\n", feature, *b ? "Yes" : "No");
 }
 
 static void
-show_dp_feature_size_t(struct ds *ds, const char *feature, size_t s)
+show_dp_feature_atomic_bool(struct ds *ds, const char *feature,
+const atomic_bool *b)
 {
-ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, s);
+bool value;
+atomic_read_relaxed(b, &value);
+ds_put_format(ds, "%s: %s\n", feature, value ? "Yes" : "No");
+}
+
+static void
+show_dp_feature_size_t(struct ds *ds, const char *feature, const size_t *s)
+{
+ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, *s);
 }
 
 enum dpif_support_field_type {
 DPIF_SUPPORT_FIELD_bool,
 DPIF_SUPPORT_FIELD_size_t,
+DPIF_SUPPORT_FIELD_atomic_bool,
 };
 
 struct dpif_support_field {
@@ -6279,12 +6307,12 @@ static void
 dpif_show_support(const struct dpif_backer_support *support, struct ds *ds)
 {
 #define DPIF_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->NAME);
+show_dp_feature_##TYPE (ds, TITLE, &support->NAME);
 DPIF_SUPPORT_FIELDS
 #undef DPIF_SUPPORT_FIELD
 
 #define ODP_SUPPORT_FIELD(TYPE, NAME, TITLE) \
-show_dp_feature_##TYPE (ds, TITLE, support->odp.NAME );
+show_dp_feature_##TYPE (ds, TITLE, &support->odp.NAME );
 ODP_SUPPORT_FIELDS
 #undef ODP_SUPPORT_FIELD
 }
@@ -6303,6 +6331,16 @@ display_support_field(const char *name,
   b ? "true" : "false");
 break;
 }
+case DPIF_SUPPORT_FIELD_atomic_bool: {
+bool v;
+bool b;
+atomic_read_relaxed((atomic_bool *) field->rt_ptr, &v);
+atomic_read_relaxed((atomic_bool *) field->bt_ptr, &b);
+ds_put_format(ds, "%s (%s) : [run time]:%s, [boot time]:%s\n", name,
+  field->title, v ? "true" : "false",
+  b ? "true" : "false");
+break;
+}
 case DPIF_SUPPORT_FIELD_size_t:
 ds_put_format(ds, "%s (%s) : [run time]:%"PRIuSIZE
   ", [boot time]:%"PRIuSIZE"\n", name,
-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v8 0/4] dpif: probe support for OVS_ACTION_ATTR_DROP

2024-03-06 Thread Eric Garver
Probe the datapath implementation for support of OVS_ACTION_ATTR_DROP.  Also
add a new test case.

v8:
  - new patch to support atomic_bool dpif field types
  - re-add re-probe of support
  - use atomic_bool type for explicit_drop_action
v7:
  - remove re-probe of support as Ilya is working on a generic solution
v6:
  - improve log if hw-offload enabled
  - re-probe support if hw-offload set true at runtime
v5:
  - combine patches 3 and 4
  - add description to combined patch 3
v4:
  - avoid passing action to datapath if TC offload in use
v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (4):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Support atomic_bool field type.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  tests: system-traffic: Add coverage for drop action.

 include/linux/openvswitch.h   |   3 +-
 lib/dpif-netdev.c |   1 +
 lib/dpif.c|   7 +-
 lib/dpif.h|   1 -
 lib/odp-execute.c |   2 +
 lib/odp-util.c|  23 ++
 ofproto/ofproto-dpif-ipfix.c  |   1 +
 ofproto/ofproto-dpif-sflow.c  |   1 +
 ofproto/ofproto-dpif.c| 141 +++---
 ofproto/ofproto-dpif.h|   4 +-
 tests/system-common-macros.at |   4 +
 tests/system-traffic.at   |  31 
 12 files changed, 199 insertions(+), 20 deletions(-)

-- 
2.43.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v8 1/4] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2024-03-06 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  1 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 30 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index e6c53937d8b9..89b0d1d6b4aa 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9489,6 +9489,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index d07241f1e7cd..0f480bec48d0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1289,6 +1289,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index eb03b57c42ec..081e4d43268a 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -837,6 +837,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1227,6 +1228,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 9306c9b4d47a..f4c492f2ae6f 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_names);
+break;
 case OVS_ACTION_ATTR_DROP:
 ds_put_cstr(ds, "drop");
 break;
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..cd65dae7e18a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3135,6 +3135,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 c

[ovs-dev] [PATCH v8 3/4] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2024-03-06 Thread Eric Garver
Kernel support has been added for this action. As such, we need to probe
the datapath for support.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 ---
 lib/dpif.h  |  1 -
 ofproto/ofproto-dpif.c  | 89 +++--
 ofproto/ofproto-dpif.h  |  4 +-
 5 files changed, 89 insertions(+), 13 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index 0f480bec48d0..28fa40879655 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1934,12 +1934,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 return dpif_is_netdev(dpif);
 }
 
-bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
-{
-return dpif_is_netdev(dpif);
-}
-
 bool
 dpif_supports_lb_output_action(const struct dpif *dpif)
 {
diff --git a/lib/dpif.h b/lib/dpif.h
index 0f2dc2ef3c55..8dc5da45b3ef 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index b1978e3f2fd5..da83d6196b13 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -72,6 +72,8 @@
 #include "util.h"
 #include "uuid.h"
 #include "vlan-bitmap.h"
+#include "dpif-netdev.h"
+#include "netdev-offload.h"
 
 VLOG_DEFINE_THIS_MODULE(ofproto_dpif);
 
@@ -221,6 +223,8 @@ static void ct_zone_config_init(struct dpif_backer *backer);
 static void ct_zone_config_uninit(struct dpif_backer *backer);
 static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
 static void ct_zone_limits_commit(struct dpif_backer *backer);
+static bool check_drop_action(struct dpif_backer *backer);
+static bool recheck_support_explicit_drop_action(struct dpif_backer *backer);
 
 static inline struct ofproto_dpif *
 ofproto_dpif_cast(const struct ofproto *ofproto)
@@ -391,6 +395,10 @@ type_run(const char *type)
 udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
 }
 
+if (recheck_support_explicit_drop_action(backer)) {
+backer->need_revalidate = REV_RECONFIGURE;
+}
+
 if (backer->need_revalidate) {
 struct ofproto_dpif *ofproto;
 struct simap_node *node;
@@ -807,6 +815,7 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
 
 shash_add(&all_dpif_backers, type, backer);
 
+atomic_init(&backer->rt_support.explicit_drop_action, false);
 check_support(backer);
 atomic_count_init(&backer->tnl_count, 0);
 
@@ -855,7 +864,10 @@ ovs_native_tunneling_is_on(struct ofproto_dpif *ofproto)
 bool
 ovs_explicit_drop_action_supported(struct ofproto_dpif *ofproto)
 {
-return ofproto->backer->rt_support.explicit_drop_action;
+bool value;
+atomic_read_relaxed(&ofproto->backer->rt_support.explicit_drop_action,
+&value);
+return value;
 }
 
 bool
@@ -1379,6 +1391,43 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+bool hw_offload;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_ATTR_DROP, XLATE_OK);
+
+supported = dpif_probe_feature(backer->dpif, "drop", &ke

Re: [ovs-dev] [PATCH v7 2/3] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2023-12-15 Thread Eric Garver
On Fri, Dec 15, 2023 at 06:02:21PM +0100, Adrian Moreno wrote:
> 
> 
> On 9/28/23 13:50, Eelco Chaudron wrote:
> > 
> > 
> > On 25 Sep 2023, at 20:04, Eric Garver wrote:
> > 
> > > Kernel support has been added for this action. As such, we need to probe
> > > the datapath for support.
> > > 
> > > Signed-off-by: Eric Garver 
> > 
> > This patch looks fine to me, and I’ll ack it. However, we should not apply 
> > this series until we have a final version of Ilya’s RFC patch applied.
> > 
> > This is the patch I’m referring to:
> > 
> > https://patchwork.ozlabs.org/project/openvswitch/patch/20230908234009.892803-1-i.maxim...@ovn.org/
> > 
> 
> 
> Hi Eric,
> 
> We've further investigated Ilya's RFC and seem some blocking issues. So I'm
> afraid we have to ask you to respin your V6 of this patch addressing Ilya's
> thread-safety problems as well as another concern: making sure re-probing
> does not install a dp flow that affects ongoing traffic.
> 
> More details here:
> https://patchwork.ozlabs.org/project/openvswitch/patch/20230908234009.892803-1-i.maxim...@ovn.org/
> 
> Sorry for delaying this. If you want help, I volunteer.

ACK. I'll investigate in the new year.

Eric.

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v7 3/3] tests: system-traffic: Add coverage for drop action.

2023-09-25 Thread Eric Garver
Exercise the drop action in the datapath. This specific tests triggers
an xlate_error.

For the kernel datapath skb drop reasons can then be seen while this
test runs.

 # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
   0.000 ping/1275884 skb:kfree_skb(skbaddr: 0x8acd76546000, \
  location: 0xc0ee3634, protocol: 2048, reason: 196611)

Acked-by: Simon Horman 
Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 +++
 2 files changed, 35 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 0077a8609c02..afc0df00a329 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -359,3 +359,7 @@ m4_define([OVS_CHECK_IPROUTE_ENCAP],
 # OVS_CHECK_CT_CLEAR()
 m4_define([OVS_CHECK_CT_CLEAR],
 [AT_SKIP_IF([! grep -q "Datapath supports ct_clear action" 
ovs-vswitchd.log])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports drop action" ovs-vswitchd.log])])
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 418cd32fecdc..78a9a1b3f7ec 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2048,6 +2048,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl
+  strip_recirc | strip_stats | strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.41.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v7 1/3] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2023-09-25 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Acked-by: Simon Horman 
Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  1 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 30 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 157694bcf0e7..c5263f1c2664 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9258,6 +9258,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index d07241f1e7cd..0f480bec48d0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1289,6 +1289,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index eb03b57c42ec..081e4d43268a 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -837,6 +837,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1227,6 +1228,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 3eb2c3cb98ca..42dbbb4cb26a 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_names);
+break;
 case OVS_ACTION_ATTR_DROP:
 ds_put_cstr(ds, "drop");
 break;
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..cd65dae7e18a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3135,6 +3135,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_

[ovs-dev] [PATCH v7 2/3] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2023-09-25 Thread Eric Garver
Kernel support has been added for this action. As such, we need to probe
the datapath for support.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 --
 lib/dpif.h  |  1 -
 ofproto/ofproto-dpif.c  | 42 +++--
 4 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index 0f480bec48d0..28fa40879655 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1934,12 +1934,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 return dpif_is_netdev(dpif);
 }
 
-bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
-{
-return dpif_is_netdev(dpif);
-}
-
 bool
 dpif_supports_lb_output_action(const struct dpif *dpif)
 {
diff --git a/lib/dpif.h b/lib/dpif.h
index 0f2dc2ef3c55..8dc5da45b3ef 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index ba5706f6adcc..5707716ae5d1 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -72,6 +72,8 @@
 #include "util.h"
 #include "uuid.h"
 #include "vlan-bitmap.h"
+#include "dpif-netdev.h"
+#include "netdev-offload.h"
 
 VLOG_DEFINE_THIS_MODULE(ofproto_dpif);
 
@@ -1375,6 +1377,43 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+bool hw_offload;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_ATTR_DROP, XLATE_OK);
+
+supported = dpif_probe_feature(backer->dpif, "drop", &key, &actions, NULL);
+
+/* TC does not support offloading this action. */
+hw_offload = netdev_is_flow_api_enabled() && !dpif_is_netdev(backer->dpif);
+
+VLOG_INFO("%s: Datapath %s drop action%s", dpif_name(backer->dpif),
+  (supported) ? "supports" : "does not support",
+  (hw_offload) ? ", but not enabled due to hardware offload being "
+ "enabled" : "");
+
+return supported && !hw_offload;
+}
+
 /* Tests whether 'backer''s datapath supports the all-zero SNAT case. */
 static bool
 dpif_supports_ct_zero_snat(struct dpif_backer *backer)
@@ -1627,8 +1666,7 @@ check_support(struct dpif_backer *backer)
 backer->rt_support.max_hash_alg = check_max_dp_hash_alg(backer);
 backer->rt_support.check_pkt_len = check_check_pkt_len(backer);
 backer->rt_support.ct_timeout = check_ct_timeout_policy(backer);
-backer->rt_support.explicit_drop_action =
-dpif_supports_explicit_drop_action(backer->dpif);
+backer->rt_support.explicit_drop_action = check_drop_action(backer);
 backer->rt_support.lb_output_action =
 dpif_supports_lb_output_action(backer->dpif);
 backer->rt_support.ct_zero_snat = dpif_supports_ct_zero_snat(backer);
-- 
2.41.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v7 0/3] dpif: probe support for OVS_ACTION_ATTR_DROP

2023-09-25 Thread Eric Garver
Probe the datapath implementation for support of OVS_ACTION_ATTR_DROP.
Also add a new test case.

v7:
  - remove re-probe of support as Ilya is working on a generic solution
v6:
  - improve log if hw-offload enabled
  - re-probe support if hw-offload set true at runtime
v5:
  - combine patches 3 and 4
  - add description to combined patch 3
v4:
  - avoid passing action to datapath if TC offload in use
v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (3):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  tests: system-traffic: Add coverage for drop action.

 include/linux/openvswitch.h   |  3 ++-
 lib/dpif-netdev.c |  1 +
 lib/dpif.c|  7 +-
 lib/dpif.h|  1 -
 lib/odp-execute.c |  2 ++
 lib/odp-util.c| 23 +++
 ofproto/ofproto-dpif-ipfix.c  |  1 +
 ofproto/ofproto-dpif-sflow.c  |  1 +
 ofproto/ofproto-dpif.c| 42 +--
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 ++
 11 files changed, 106 insertions(+), 10 deletions(-)

-- 
2.41.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v6 2/3] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2023-09-11 Thread Eric Garver
On Sat, Sep 09, 2023 at 01:41:05AM +0200, Ilya Maximets wrote:
> On 9/1/23 21:42, Eric Garver wrote:
> > Kernel support is being added for this action. As such, we need to probe
> > the datapath for support.
> > 
> > Signed-off-by: Eric Garver 
> > ---
> >  include/linux/openvswitch.h |  2 +-
> >  lib/dpif.c  |  6 -
> >  lib/dpif.h  |  1 -
> >  ofproto/ofproto-dpif.c  | 52 +++--
> >  4 files changed, 51 insertions(+), 10 deletions(-)
> > 
> > diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
> > index a265e05ad253..fce6456f47c8 100644
> > --- a/include/linux/openvswitch.h
> > +++ b/include/linux/openvswitch.h
> > @@ -1086,11 +1086,11 @@ enum ovs_action_attr {
> > OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
> > OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
> > OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
> > +   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
> >  
> >  #ifndef __KERNEL__
> > OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
> > OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
> > -   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
> > OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
> >  #endif
> > __OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
> > diff --git a/lib/dpif.c b/lib/dpif.c
> > index 0f480bec48d0..28fa40879655 100644
> > --- a/lib/dpif.c
> > +++ b/lib/dpif.c
> > @@ -1934,12 +1934,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
> >  return dpif_is_netdev(dpif);
> >  }
> >  
> > -bool
> > -dpif_supports_explicit_drop_action(const struct dpif *dpif)
> > -{
> > -return dpif_is_netdev(dpif);
> > -}
> > -
> >  bool
> >  dpif_supports_lb_output_action(const struct dpif *dpif)
> >  {
> > diff --git a/lib/dpif.h b/lib/dpif.h
> > index 0f2dc2ef3c55..8dc5da45b3ef 100644
> > --- a/lib/dpif.h
> > +++ b/lib/dpif.h
> > @@ -940,7 +940,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
> > odp_port_t port_no,
> >  
> >  char *dpif_get_dp_version(const struct dpif *);
> >  bool dpif_supports_tnl_push_pop(const struct dpif *);
> > -bool dpif_supports_explicit_drop_action(const struct dpif *);
> >  bool dpif_synced_dp_layers(struct dpif *);
> >  
> >  /* Log functions. */
> > diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> > index e22ca757ac35..5ed849e463c2 100644
> > --- a/ofproto/ofproto-dpif.c
> > +++ b/ofproto/ofproto-dpif.c
> > @@ -72,6 +72,8 @@
> >  #include "util.h"
> >  #include "uuid.h"
> >  #include "vlan-bitmap.h"
> > +#include "dpif-netdev.h"
> > +#include "netdev-offload.h"
> >  
> >  VLOG_DEFINE_THIS_MODULE(ofproto_dpif);
> >  
> > @@ -220,6 +222,7 @@ static void ofproto_unixctl_init(void);
> >  static void ct_zone_config_init(struct dpif_backer *backer);
> >  static void ct_zone_config_uninit(struct dpif_backer *backer);
> >  static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
> > +static bool check_drop_action(struct dpif_backer *backer);
> >  
> >  static inline struct ofproto_dpif *
> >  ofproto_dpif_cast(const struct ofproto *ofproto)
> > @@ -390,6 +393,15 @@ type_run(const char *type)
> >  udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
> >  }
> >  
> > +/* For TC, if vswitchd started with other_config:hw-offload set to 
> > "false",
> > + * and the configuration is now "true", then we need to re-probe 
> > datapath
> > + * support for the "drop" action. */
> > +if (backer->rt_support.explicit_drop_action
> > +&& netdev_is_flow_api_enabled() && !dpif_is_netdev(backer->dpif)) {
> > +backer->rt_support.explicit_drop_action = 
> > check_drop_action(backer);
> 
> This seems dangerous to me.  The value is accessed concurrently from
> the other threads, so the update will have to be atomic.
> 
> Also, this check is so specific and re-checks one particular thing.
> Might be hard to maintain.
> 
> OVS requires re-start after enabling HW offload, so the feature
> checking and ll other potential quirks can be taken care of.
> If users really don't want to restart OVS, we can do a soft restart
> by recreating the bridge when the value changes, simil

[ovs-dev] [PATCH v6 2/3] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2023-09-01 Thread Eric Garver
Kernel support is being added for this action. As such, we need to probe
the datapath for support.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 -
 lib/dpif.h  |  1 -
 ofproto/ofproto-dpif.c  | 52 +++--
 4 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index 0f480bec48d0..28fa40879655 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1934,12 +1934,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 return dpif_is_netdev(dpif);
 }
 
-bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
-{
-return dpif_is_netdev(dpif);
-}
-
 bool
 dpif_supports_lb_output_action(const struct dpif *dpif)
 {
diff --git a/lib/dpif.h b/lib/dpif.h
index 0f2dc2ef3c55..8dc5da45b3ef 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index e22ca757ac35..5ed849e463c2 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -72,6 +72,8 @@
 #include "util.h"
 #include "uuid.h"
 #include "vlan-bitmap.h"
+#include "dpif-netdev.h"
+#include "netdev-offload.h"
 
 VLOG_DEFINE_THIS_MODULE(ofproto_dpif);
 
@@ -220,6 +222,7 @@ static void ofproto_unixctl_init(void);
 static void ct_zone_config_init(struct dpif_backer *backer);
 static void ct_zone_config_uninit(struct dpif_backer *backer);
 static void ct_zone_timeout_policy_sweep(struct dpif_backer *backer);
+static bool check_drop_action(struct dpif_backer *backer);
 
 static inline struct ofproto_dpif *
 ofproto_dpif_cast(const struct ofproto *ofproto)
@@ -390,6 +393,15 @@ type_run(const char *type)
 udpif_set_threads(backer->udpif, n_handlers, n_revalidators);
 }
 
+/* For TC, if vswitchd started with other_config:hw-offload set to "false",
+ * and the configuration is now "true", then we need to re-probe datapath
+ * support for the "drop" action. */
+if (backer->rt_support.explicit_drop_action
+&& netdev_is_flow_api_enabled() && !dpif_is_netdev(backer->dpif)) {
+backer->rt_support.explicit_drop_action = check_drop_action(backer);
+backer->need_revalidate = REV_RECONFIGURE;
+}
+
 if (backer->need_revalidate) {
 struct ofproto_dpif *ofproto;
 struct simap_node *node;
@@ -1375,6 +1387,43 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+bool hw_offload;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_ATTR_DROP, XLATE_OK);
+
+supported = dpif_probe_feature(backer->dpif, "drop", &key, &actions, NULL);
+
+/* TC does not support offloading this action. */
+hw_offload = netdev_is_flow_api_enabled() && !dpif_is_netdev(backer->dpif);
+
+VLOG_INFO("%s: Datapath %s drop action%s", dpif_name(backer->dpif),
+  (supported) ? "supports" : "does not support",
+  (hw_offload) ? ", but not enabled due to hardware offload being "
+  

[ovs-dev] [PATCH v6 0/3] dpif: probe support for OVS_ACTION_ATTR_DROP

2023-09-01 Thread Eric Garver
Probe the datapath implementation for support of OVS_ACTION_ATTR_DROP.
Also add a new test case.

I'm not certain about the re-probe. I presume it's a good idea to run
the revalidator as the action is no longer supported by the dpif.

Lastly, I tried to add coverage for the re-probe to the testsuite, but
the testsuite being common to kernel and userspace made that difficult.
If anyone knows a good way to detect in the testsuite whether it's
actively testing kernel or userspace, then I can add it back; maybe wrap
with m4_if().

v6:
  - improve log if hw-offload enabled
  - re-probe support if hw-offload set true at runtime
v5:
  - combine patches 3 and 4
  - add description to combined patch 3
v4:
  - avoid passing action to datapath if TC offload in use
v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (3):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  tests: system-traffic: Add coverage for drop action.

 include/linux/openvswitch.h   |  3 +-
 lib/dpif-netdev.c |  1 +
 lib/dpif.c|  7 +
 lib/dpif.h|  1 -
 lib/odp-execute.c |  2 ++
 lib/odp-util.c| 23 
 ofproto/ofproto-dpif-ipfix.c  |  1 +
 ofproto/ofproto-dpif-sflow.c  |  1 +
 ofproto/ofproto-dpif.c| 52 +--
 tests/system-common-macros.at |  4 +++
 tests/system-traffic.at   | 31 +
 11 files changed, 116 insertions(+), 10 deletions(-)

-- 
2.41.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v6 1/3] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2023-09-01 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Acked-by: Simon Horman 
Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  1 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 30 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 157694bcf0e7..c5263f1c2664 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9258,6 +9258,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index d07241f1e7cd..0f480bec48d0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1289,6 +1289,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index 37f0f717af61..865b6cc0ec1e 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -833,6 +833,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1223,6 +1224,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 3eb2c3cb98ca..42dbbb4cb26a 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_names);
+break;
 case OVS_ACTION_ATTR_DROP:
 ds_put_cstr(ds, "drop");
 break;
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..cd65dae7e18a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3135,6 +3135,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_

[ovs-dev] [PATCH v6 3/3] tests: system-traffic: Add coverage for drop action.

2023-09-01 Thread Eric Garver
Exercise the drop action in the datapath. This specific tests triggers
an xlate_error.

For the kernel datapath skb drop reasons can then be seen while this
test runs.

 # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
   0.000 ping/1275884 skb:kfree_skb(skbaddr: 0x8acd76546000, \
  location: 0xc0ee3634, protocol: 2048, reason: 196611)

Acked-by: Simon Horman 
Acked-by: Eelco Chaudron 
Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 +++
 2 files changed, 35 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 0077a8609c02..afc0df00a329 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -359,3 +359,7 @@ m4_define([OVS_CHECK_IPROUTE_ENCAP],
 # OVS_CHECK_CT_CLEAR()
 m4_define([OVS_CHECK_CT_CLEAR],
 [AT_SKIP_IF([! grep -q "Datapath supports ct_clear action" 
ovs-vswitchd.log])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports drop action" ovs-vswitchd.log])])
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 808c492a225e..a398c17bc16a 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2048,6 +2048,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl
+  strip_recirc | strip_stats | strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.41.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v5 2/3] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2023-08-09 Thread Eric Garver
Kernel support is being added for this action. As such, we need to probe
the datapath for support.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 --
 lib/dpif.h  |  1 -
 ofproto/ofproto-dpif.c  | 41 +++--
 4 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index 0f480bec48d0..28fa40879655 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1934,12 +1934,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 return dpif_is_netdev(dpif);
 }
 
-bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
-{
-return dpif_is_netdev(dpif);
-}
-
 bool
 dpif_supports_lb_output_action(const struct dpif *dpif)
 {
diff --git a/lib/dpif.h b/lib/dpif.h
index 0f2dc2ef3c55..8dc5da45b3ef 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index e22ca757ac35..e4de2becef2e 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -72,6 +72,8 @@
 #include "util.h"
 #include "uuid.h"
 #include "vlan-bitmap.h"
+#include "dpif-netdev.h"
+#include "netdev-offload.h"
 
 VLOG_DEFINE_THIS_MODULE(ofproto_dpif);
 
@@ -1375,6 +1377,42 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+/* TC does not support offloading this action. */
+if (netdev_is_flow_api_enabled() && !dpif_is_netdev(backer->dpif)) {
+return false;
+}
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_ATTR_DROP, XLATE_OK);
+
+supported = dpif_probe_feature(backer->dpif, "drop", &key, &actions, NULL);
+
+VLOG_INFO("%s: Datapath %s drop action",
+  dpif_name(backer->dpif), (supported) ? "supports"
+   : "does not support");
+return supported;
+}
+
 /* Tests whether 'backer''s datapath supports the all-zero SNAT case. */
 static bool
 dpif_supports_ct_zero_snat(struct dpif_backer *backer)
@@ -1627,8 +1665,7 @@ check_support(struct dpif_backer *backer)
 backer->rt_support.max_hash_alg = check_max_dp_hash_alg(backer);
 backer->rt_support.check_pkt_len = check_check_pkt_len(backer);
 backer->rt_support.ct_timeout = check_ct_timeout_policy(backer);
-backer->rt_support.explicit_drop_action =
-dpif_supports_explicit_drop_action(backer->dpif);
+backer->rt_support.explicit_drop_action = check_drop_action(backer);
 backer->rt_support.lb_output_action =
 dpif_supports_lb_output_action(backer->dpif);
 backer->rt_support.ct_zero_snat = dpif_supports_ct_zero_snat(backer);
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v5 0/4] dpif: probe support for OVS_ACTION_ATTR_DROP

2023-08-09 Thread Eric Garver
Probe the datapath implementation for support of OVS_ACTION_ATTR_DROP.
Also add a new test case.

v5:
  - combine patches 3 and 4
  - add description to combined patch 3
v4:
  - avoid passing action to datapath if TC offload in use
v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (3):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  tests: system-traffic: Add coverage for drop action.

 include/linux/openvswitch.h   |  3 ++-
 lib/dpif-netdev.c |  1 +
 lib/dpif.c|  7 +-
 lib/dpif.h|  1 -
 lib/odp-execute.c |  2 ++
 lib/odp-util.c| 23 
 ofproto/ofproto-dpif-ipfix.c  |  1 +
 ofproto/ofproto-dpif-sflow.c  |  1 +
 ofproto/ofproto-dpif.c| 41 +--
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 ++
 11 files changed, 105 insertions(+), 10 deletions(-)

-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v5 1/3] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2023-08-09 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  1 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 30 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 0b623fcea457..4124ce094aba 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9244,6 +9244,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index d07241f1e7cd..0f480bec48d0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1289,6 +1289,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index 37f0f717af61..865b6cc0ec1e 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -833,6 +833,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1223,6 +1224,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 3eb2c3cb98ca..42dbbb4cb26a 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_names);
+break;
 case OVS_ACTION_ATTR_DROP:
 ds_put_cstr(ds, "drop");
 break;
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..cd65dae7e18a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3135,6 +3135,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 c

[ovs-dev] [PATCH v5 3/3] tests: system-traffic: Add coverage for drop action.

2023-08-09 Thread Eric Garver
Exercise the drop action in the datapath. This specific tests triggers
an xlate_error.

For the kernel datapath skb drop reasons can then be seen while this
test runs.

 # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
   0.000 ping/1275884 skb:kfree_skb(skbaddr: 0x8acd76546000, \
  location: 0xc0ee3634, protocol: 2048, reason: 196611)

Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 +++
 2 files changed, 35 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 0077a8609c02..afc0df00a329 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -359,3 +359,7 @@ m4_define([OVS_CHECK_IPROUTE_ENCAP],
 # OVS_CHECK_CT_CLEAR()
 m4_define([OVS_CHECK_CT_CLEAR],
 [AT_SKIP_IF([! grep -q "Datapath supports ct_clear action" 
ovs-vswitchd.log])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports drop action" ovs-vswitchd.log])])
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 945037ec0571..e06c0e316ff4 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2048,6 +2048,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl
+  strip_recirc | strip_stats | strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v4 4/4] tests: system-traffic: Add coverage for drop action.

2023-08-04 Thread Eric Garver
Signed-off-by: Eric Garver 
---
 tests/system-traffic.at | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 945037ec0571..e06c0e316ff4 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2048,6 +2048,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl
+  strip_recirc | strip_stats | strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v4 2/4] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2023-08-04 Thread Eric Garver
Kernel support is being added for this action. As such, we need to probe
the datapath for support.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 --
 lib/dpif.h  |  1 -
 ofproto/ofproto-dpif.c  | 41 +++--
 4 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index aff6ef4ba455..b8a411bf32e8 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1928,12 +1928,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 return dpif_is_netdev(dpif);
 }
 
-bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
-{
-return dpif_is_netdev(dpif);
-}
-
 bool
 dpif_supports_lb_output_action(const struct dpif *dpif)
 {
diff --git a/lib/dpif.h b/lib/dpif.h
index 9e9d0aa1b0a8..44f1d75839c1 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index fad7342b0b02..da120b2f0c0d 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -72,6 +72,8 @@
 #include "util.h"
 #include "uuid.h"
 #include "vlan-bitmap.h"
+#include "dpif-netdev.h"
+#include "netdev-offload.h"
 
 VLOG_DEFINE_THIS_MODULE(ofproto_dpif);
 
@@ -1375,6 +1377,42 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+/* TC does not support offloading this action. */
+if (netdev_is_flow_api_enabled() && !dpif_is_netdev(backer->dpif)) {
+return false;
+}
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_ATTR_DROP, XLATE_OK);
+
+supported = dpif_probe_feature(backer->dpif, "drop", &key, &actions, NULL);
+
+VLOG_INFO("%s: Datapath %s drop action",
+  dpif_name(backer->dpif), (supported) ? "supports"
+   : "does not support");
+return supported;
+}
+
 /* Tests whether 'backer''s datapath supports the all-zero SNAT case. */
 static bool
 dpif_supports_ct_zero_snat(struct dpif_backer *backer)
@@ -1627,8 +1665,7 @@ check_support(struct dpif_backer *backer)
 backer->rt_support.max_hash_alg = check_max_dp_hash_alg(backer);
 backer->rt_support.check_pkt_len = check_check_pkt_len(backer);
 backer->rt_support.ct_timeout = check_ct_timeout_policy(backer);
-backer->rt_support.explicit_drop_action =
-dpif_supports_explicit_drop_action(backer->dpif);
+backer->rt_support.explicit_drop_action = check_drop_action(backer);
 backer->rt_support.lb_output_action =
 dpif_supports_lb_output_action(backer->dpif);
 backer->rt_support.ct_zero_snat = dpif_supports_ct_zero_snat(backer);
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v4 3/4] system-common-macros: Check for drop action in datapath.

2023-08-04 Thread Eric Garver
Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 0077a8609c02..afc0df00a329 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -359,3 +359,7 @@ m4_define([OVS_CHECK_IPROUTE_ENCAP],
 # OVS_CHECK_CT_CLEAR()
 m4_define([OVS_CHECK_CT_CLEAR],
 [AT_SKIP_IF([! grep -q "Datapath supports ct_clear action" 
ovs-vswitchd.log])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports drop action" ovs-vswitchd.log])])
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v4 1/4] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2023-08-04 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  1 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 30 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 0b623fcea457..4124ce094aba 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9244,6 +9244,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index b1cbf39c48d6..aff6ef4ba455 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1283,6 +1283,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index 37f0f717af61..865b6cc0ec1e 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -833,6 +833,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1223,6 +1224,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 3eb2c3cb98ca..42dbbb4cb26a 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_names);
+break;
 case OVS_ACTION_ATTR_DROP:
 ds_put_cstr(ds, "drop");
 break;
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..cd65dae7e18a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3135,6 +3135,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 c

[ovs-dev] [PATCH v4 0/4] dpif: probe support for OVS_ACTION_ATTR_DROP

2023-08-04 Thread Eric Garver
Probe the datapath implementation for support of OVS_ACTION_ATTR_DROP.
Also add a new test case.

v4:
  - avoid passing action to datapath if TC offload in use
v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (4):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  system-common-macros: Check for drop action in datapath.
  tests: system-traffic: Add coverage for drop action.

 include/linux/openvswitch.h   |  3 ++-
 lib/dpif-netdev.c |  1 +
 lib/dpif.c|  7 +-
 lib/dpif.h|  1 -
 lib/odp-execute.c |  2 ++
 lib/odp-util.c| 23 
 ofproto/ofproto-dpif-ipfix.c  |  1 +
 ofproto/ofproto-dpif-sflow.c  |  1 +
 ofproto/ofproto-dpif.c| 41 +--
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 ++
 11 files changed, 105 insertions(+), 10 deletions(-)

-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3 2/4] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2023-08-03 Thread Eric Garver
On Thu, Aug 03, 2023 at 01:43:40PM +0200, Ilya Maximets wrote:
> On 7/28/23 02:04, Eric Garver wrote:
> > Kernel support is being added for this action. As such, we need to probe
> > the datapath for support.
> > 
> > Signed-off-by: Eric Garver 
> 
> Hi, Eric.  Thanks for the update.
> 
> IIRC, there was a discussion that this feature has to be mutually exclusive
> with the TC hardware offload.  Otherwise, we will constantly treat flows
> dumped from TC as invalid.

I think I misunderstood the conversation. I thought it landed on "let's
ignore TC for now", but really it landed on "let's ignore the case of
enabling HW/TC offload at runtime" (since docs say a restart is
required).

I'll work on a v4 then which sets
ofproto->backer->rt_support.explicit_drop_action with regards to TC.

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2 0/4] dpif: probe support for OVS_ACTION_ATTR_DROP

2023-07-27 Thread Eric Garver
copy/paste error in the SUBJECT, but only for the cover letter.

s/v2/v3/

On Thu, Jul 27, 2023 at 08:04:42PM -0400, Eric Garver wrote:
> Probe the datapath implementation for support of OVS_ACTION_ATTR_DROP.
> Also add a new test case.
> 
> v3:
>   - alter test such that it's reliable, different xlate_error
>   - better commit message in patch 2
>   - reordered _DEC_TTL value in switch statements
>   - add format_dec_ttl_action()
> v2:
>   - new patch (1) to fix build (switch cases)
>   - fixed check-system-userspace
> 
> Eric Garver (4):
>   dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
>   dpif: Probe support for OVS_ACTION_ATTR_DROP.
>   system-common-macros: Check for drop action in datapath.
>   tests: system-traffic: Add coverage for drop action.
> 
>  include/linux/openvswitch.h   |  3 ++-
>  lib/dpif-netdev.c |  1 +
>  lib/dpif.c|  7 +--
>  lib/dpif.h|  1 -
>  lib/odp-execute.c |  2 ++
>  lib/odp-util.c| 23 +++
>  ofproto/ofproto-dpif-ipfix.c  |  1 +
>  ofproto/ofproto-dpif-sflow.c  |  1 +
>  ofproto/ofproto-dpif.c| 34 --
>  tests/system-common-macros.at |  4 
>  tests/system-traffic.at   | 31 +++
>  11 files changed, 98 insertions(+), 10 deletions(-)
> 
> -- 
> 2.39.0
> 
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> 

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v3 2/4] dpif: Probe support for OVS_ACTION_ATTR_DROP.

2023-07-27 Thread Eric Garver
Kernel support is being added for this action. As such, we need to probe
the datapath for support.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 --
 lib/dpif.h  |  1 -
 ofproto/ofproto-dpif.c  | 34 --
 4 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index aff6ef4ba455..b8a411bf32e8 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1928,12 +1928,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 return dpif_is_netdev(dpif);
 }
 
-bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
-{
-return dpif_is_netdev(dpif);
-}
-
 bool
 dpif_supports_lb_output_action(const struct dpif *dpif)
 {
diff --git a/lib/dpif.h b/lib/dpif.h
index 9e9d0aa1b0a8..44f1d75839c1 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -940,7 +940,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index fad7342b0b02..c490a3c1da48 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1375,6 +1375,37 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_ATTR_DROP, XLATE_OK);
+
+supported = dpif_probe_feature(backer->dpif, "drop", &key, &actions, NULL);
+
+VLOG_INFO("%s: Datapath %s drop action",
+  dpif_name(backer->dpif), (supported) ? "supports"
+   : "does not support");
+return supported;
+}
+
 /* Tests whether 'backer''s datapath supports the all-zero SNAT case. */
 static bool
 dpif_supports_ct_zero_snat(struct dpif_backer *backer)
@@ -1627,8 +1658,7 @@ check_support(struct dpif_backer *backer)
 backer->rt_support.max_hash_alg = check_max_dp_hash_alg(backer);
 backer->rt_support.check_pkt_len = check_check_pkt_len(backer);
 backer->rt_support.ct_timeout = check_ct_timeout_policy(backer);
-backer->rt_support.explicit_drop_action =
-dpif_supports_explicit_drop_action(backer->dpif);
+backer->rt_support.explicit_drop_action = check_drop_action(backer);
 backer->rt_support.lb_output_action =
 dpif_supports_lb_output_action(backer->dpif);
 backer->rt_support.ct_zero_snat = dpif_supports_ct_zero_snat(backer);
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v3 1/4] dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.

2023-07-27 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  |  1 +
 lib/dpif-netdev.c|  1 +
 lib/dpif.c   |  1 +
 lib/odp-execute.c|  2 ++
 lib/odp-util.c   | 23 +++
 ofproto/ofproto-dpif-ipfix.c |  1 +
 ofproto/ofproto-dpif-sflow.c |  1 +
 7 files changed, 30 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 0b623fcea457..4124ce094aba 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9244,6 +9244,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/dpif.c b/lib/dpif.c
index b1cbf39c48d6..aff6ef4ba455 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1283,6 +1283,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index 37f0f717af61..865b6cc0ec1e 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -833,6 +833,7 @@ requires_datapath_assistance(const struct nlattr *a)
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 return false;
 
@@ -1223,6 +1224,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 3eb2c3cb98ca..42dbbb4cb26a 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -143,6 +143,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_POP_NSH: return 0;
 case OVS_ACTION_ATTR_CHECK_PKT_LEN: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_ADD_MPLS: return sizeof(struct ovs_action_add_mpls);
+case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
@@ -1130,6 +1131,25 @@ format_odp_check_pkt_len_action(struct ds *ds, const 
struct nlattr *attr,
 ds_put_cstr(ds, "))");
 }
 
+static void
+format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
+  const struct hmap *portno_names)
+{
+const struct nlattr *a;
+unsigned int left;
+
+ds_put_cstr(ds,"dec_ttl(le_1(");
+NL_ATTR_FOR_EACH (a, left,
+  nl_attr_get(attr), nl_attr_get_size(attr)) {
+if (nl_attr_type(a) == OVS_ACTION_ATTR_DEC_TTL) {
+   format_odp_actions(ds, nl_attr_get(a),
+  nl_attr_get_size(a), portno_names);
+   break;
+}
+}
+ds_put_format(ds, "))");
+}
+
 static void
 format_odp_action(struct ds *ds, const struct nlattr *a,
   const struct hmap *portno_names)
@@ -1283,6 +1303,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
   ntohs(mpls->mpls_ethertype));
 break;
 }
+case OVS_ACTION_ATTR_DEC_TTL:
+format_dec_ttl_action(ds, a, portno_names);
+break;
 case OVS_ACTION_ATTR_DROP:
 ds_put_cstr(ds, "drop");
 break;
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..cd65dae7e18a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3135,6 +3135,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
+case OVS_ACTION_ATTR_DEC_TTL:
 c

[ovs-dev] [PATCH v3 4/4] tests: system-traffic: Add coverage for drop action.

2023-07-27 Thread Eric Garver
Signed-off-by: Eric Garver 
---
 tests/system-traffic.at | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 945037ec0571..e06c0e316ff4 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2048,6 +2048,37 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+dnl Exceed the max number of resubmits.
+(echo "dl_type=0x806, actions=normal"
+for i in `seq 1 64`; do
+ j=`expr $i + 1`
+ echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
+ done
+ echo "in_port=65, actions=local"
+) > flows.txt
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl Generate some traffic.
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+OVS_WAIT_UNTIL_EQUAL([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | 
dnl
+  sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl
+  strip_recirc | strip_stats | strip_used | sort], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop])
+
+OVS_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v2 0/4] dpif: probe support for OVS_ACTION_ATTR_DROP

2023-07-27 Thread Eric Garver
Probe the datapath implementation for support of OVS_ACTION_ATTR_DROP.
Also add a new test case.

v3:
  - alter test such that it's reliable, different xlate_error
  - better commit message in patch 2
  - reordered _DEC_TTL value in switch statements
  - add format_dec_ttl_action()
v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (4):
  dpif: Stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL.
  dpif: Probe support for OVS_ACTION_ATTR_DROP.
  system-common-macros: Check for drop action in datapath.
  tests: system-traffic: Add coverage for drop action.

 include/linux/openvswitch.h   |  3 ++-
 lib/dpif-netdev.c |  1 +
 lib/dpif.c|  7 +--
 lib/dpif.h|  1 -
 lib/odp-execute.c |  2 ++
 lib/odp-util.c| 23 +++
 ofproto/ofproto-dpif-ipfix.c  |  1 +
 ofproto/ofproto-dpif-sflow.c  |  1 +
 ofproto/ofproto-dpif.c| 34 --
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 31 +++
 11 files changed, 98 insertions(+), 10 deletions(-)

-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v3 3/4] system-common-macros: Check for drop action in datapath.

2023-07-27 Thread Eric Garver
Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 0077a8609c02..afc0df00a329 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -359,3 +359,7 @@ m4_define([OVS_CHECK_IPROUTE_ENCAP],
 # OVS_CHECK_CT_CLEAR()
 m4_define([OVS_CHECK_CT_CLEAR],
 [AT_SKIP_IF([! grep -q "Datapath supports ct_clear action" 
ovs-vswitchd.log])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports drop action" ovs-vswitchd.log])])
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH net-next 2/2] net: openvswitch: add drop action

2023-07-10 Thread Eric Garver
On Mon, Jul 10, 2023 at 06:51:19PM +0200, Ilya Maximets wrote:
> On 7/8/23 00:06, Jakub Kicinski wrote:
> > On Fri, 7 Jul 2023 18:04:36 +0200 Ilya Maximets wrote:
>  That already exists, right? Johannes added it in the last release for 
>  WiFi.  
> >>>
> >>> I'm not sure.  The SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE behaves 
> >>> similarly
> >>> to that on a surface.  However, looking closer, any value that can be 
> >>> passed
> >>> into ieee80211_rx_handlers_result() and ends up in the kfree_skb_reason() 
> >>> is
> >>> kind of defined in net/mac80211/drop.h, unless I'm missing something (very
> >>> possible, because I don't really know wifi code).
> >>>
> >>> The difference, I guess, is that for openvswitch values will be provided 
> >>> by
> >>> the userpsace application via netlink interface.  It'll be just a number 
> >>> not
> >>> defined anywhere in the kernel.  Only the subsystem itself will be defined
> >>> in order to occupy the range.  Garbage in, same garbage out, from the 
> >>> kernel's
> >>> perspective.  
> >>
> >> To be clear, I think, not defining them in this particular case is better.
> >> Definition of every reason that userspace can come up with will add extra
> >> uAPI maintenance cost/issues with no practical benefits.  Values are not
> >> going to be used for anything outside reporting a drop reason and subsystem
> >> offset is not part of uAPI anyway.
> > 
> > Ah, I see. No, please don't stuff user space defined values into 
> > the drop reason. The reasons are for debugging the kernel stack 
> > itself. IOW it'd be abuse not reuse.
> 
> Makes sense.  I wasn't sure that's a good solution from a kernel perspective
> either.  It's better than defining all these reasons, IMO, but it's not good
> enough to be considered acceptable, I agree.
> 
> How about we define just 2 reasons, e.g. OVS_DROP_REASON_EXPLICIT_ACTION and
> OVS_DROP_REASON_EXPLICIT_ACTION_WITH_ERROR (exact names can be different) ?
> One for an explicit drop action with a zero argument and one for an explicit
> drop with non-zero argument.
> 
> The exact reason for the error can be retrieved by other means, i.e by looking
> at the datapath flow dump or OVS logs/traces.
> 
> This way we can give a user who is catching packet drop traces a signal that
> there was something wrong with an OVS flow and they can look up exact details
> from the userspace / flow dump.
> 
> The point being, most of the flows will have a zero as a drop action argument,
> i.e. a regular explicit packet drop.  It will be hard to figure out which flow
> exactly we're hitting without looking at the full flow dump.  And if the value
> is non-zero, then it should be immediately obvious which flow is to blame from
> the dump, as we should not have a lot of such flows.
> 
> This would still allow us to avoid a maintenance burden of defining every 
> case,
> which are fairly meaningless for the kernel itself, while having 99% of the
> information we may need.
> 
> Jakub, do you think this will be acceptable?
> 
> Eric, Adrian, Aaron, do you see any problems with such implementation?

I see no problems. I'm content with this approach.

> P.S. There is a plan to add more drop reasons for other places in openvswitch
>  module to catch more regular types of drops like memory issues or upcall
>  failures.  So, the drop reason subsystem can be extended later.
>  The explicit drop action is a bit of an odd case here.
> 
> Best regards, Ilya Maximets.
> 

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2 4/4] tests: system-traffic: add coverage for drop action

2023-07-07 Thread Eric Garver
On Fri, Jul 07, 2023 at 02:09:49PM +0200, Eelco Chaudron wrote:
> 
> 
> On 7 Jul 2023, at 13:08, Ilya Maximets wrote:
> 
> > On 7/5/23 21:47, Eelco Chaudron wrote:
> >>
> >>
> >> On Wed, Jul 5, 2023 at 6:46 PM Eric Garver  wrote:
> >>
> >> On Wed, Jul 05, 2023 at 04:58:47PM +0200, Eelco Chaudron wrote:
> >> >
> >> >
> >> > On 30 Jun 2023, at 21:05, Eric Garver wrote:
> >> > Hi Eric,
> >> >
> >> > I started reviewing the series, and this test was failing every 
> >> other run for me on ‘check-system-userspace’. I ended up making the 
> >> following additional change:
> >> >
> >> > diff --git a/tests/ofproto-macros.at <http://ofproto-macros.at> 
> >> b/tests/ofproto-macros.at <http://ofproto-macros.at>
> >> > index d2e6ac768..573ecdd0f 100644
> >> > --- a/tests/ofproto-macros.at <http://ofproto-macros.at>
> >> > +++ b/tests/ofproto-macros.at <http://ofproto-macros.at>
> >> > @@ -120,7 +120,7 @@ strip_xids () {
> >> >
> >> >  # Changes all 'used:...' to say 'used:0.0', to make output easier 
> >> to compare.
> >> >  strip_used () {
> >> > -    sed 's/used:[[0-9]]\.[[0-9]]*/used:0.0/'
> >> > +    sed 's/used:\([[0-9]]\.[[0-9]]*s\|never\)/used:0.0s/'
> >> >  }
> >>
> >> In this test case I expect the flow to be used. My local test runs do
> >> not yield "never".
> >>
> >> Maybe we need a "ovs-appctl time/warp 5000" before dumping the flow?
> >> This is used in tests/drop-stats.at <http://drop-stats.at> .
> >>
> >> Tried that but did not work, if you look at the actual number of packets 
> >> received by the flow entry, it varies quite a lot from 0 (only learning) 
> >> to 5 when I run the test multiple times.
> >>
> >> I tried changing the following to generate more traffic:
> >>
> >> -dnl generate some traffic
> >> -NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], 
> >> [ignore])
> >> +dnl Generate some traffic.
> >> +NS_CHECK_EXEC([at_ns0], [ping -q -c 100 -i 0.01 -w 1 10.1.1.2], [1], 
> >> [ignore])
> >>
> >> And then run it 100 times, and the earlier problem did not happen:
> >>
> >>   sudo bash -c 'for i in {1..100}; do make check-system-userspace 
> >> TESTSUITEFLAGS="-k drop -v" || break; echo "EC_DONE: $i"; done'
> >>
> >> However, I have some times it fails with no traffic:
> >>
> >>
> >> --- - 2023-07-05 21:46:59.860127196 +0200
> >> +++ 
> >> /home/echaudron/Documents/review/ovs_eric_DROP/tests/system-userspace-testsuite.dir/at-groups/45/stdout
> >>  2023-07-05 21:46:59.857641231 +0200
> >> @@ -1,2 +1 @@
> >> -recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
> >> bytes:0, used:0.0s, actions:drop
> >>  
> >> Maybe this test needs some more love ;)
> >
> > The test likely needs a revalidator/wait call, since you're
> > checking datapath flows.  Otherwise, it'll be time sensitive.
> > Stats are gathered during revalidation.
> 
> That was might thought initially, and I tried it (no luck), but it’s dp 
> flows, not openflow.

revalidator/wait still fails.

The only thing I've found that makes this stable is the sleep below.

--->8---

diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 50d6c2d05e5d..ab893c5c696b 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2068,6 +2068,9 @@ AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
 
 dnl Generate some traffic.
 NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+dnl sleep to let the flow hit the datapath
+sleep 5
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
 
 AT_CHECK([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | dnl
   sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2 1/4] dpif: stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL

2023-07-06 Thread Eric Garver
On Thu, Jul 06, 2023 at 10:40:18AM +0200, Eelco Chaudron wrote:
> 
> 
> On 30 Jun 2023, at 21:05, Eric Garver wrote:
> 
> > This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
> > action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
> > to make -Werror happy we must add a case to all existing switches.
> >
> > Signed-off-by: Eric Garver 
> > ---
> >  include/linux/openvswitch.h  | 1 +
> >  lib/dpif-netdev.c| 1 +
> >  lib/dpif.c   | 1 +
> >  lib/odp-execute.c| 2 ++
> >  lib/odp-util.c   | 2 ++
> >  ofproto/ofproto-dpif-ipfix.c | 1 +
> >  ofproto/ofproto-dpif-sflow.c | 1 +
> >  7 files changed, 9 insertions(+)
> >
> > diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
> > index e305c331516b..a265e05ad253 100644
> > --- a/include/linux/openvswitch.h
> > +++ b/include/linux/openvswitch.h
> > @@ -1085,6 +1085,7 @@ enum ovs_action_attr {
> > OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
> > OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
> > OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
> > +   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
> >
> >  #ifndef __KERNEL__
> > OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
> > diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> > index abe63412ebfc..565cde5f5010 100644
> > --- a/lib/dpif-netdev.c
> > +++ b/lib/dpif-netdev.c
> > @@ -9193,6 +9193,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
> > *packets_,
> >  case OVS_ACTION_ATTR_POP_NSH:
> >  case OVS_ACTION_ATTR_CT_CLEAR:
> >  case OVS_ACTION_ATTR_CHECK_PKT_LEN:
> > +case OVS_ACTION_ATTR_DEC_TTL:
> >  case OVS_ACTION_ATTR_DROP:
> >  case OVS_ACTION_ATTR_ADD_MPLS:
> 
> nit: I would add it here, to keep it in the same order ad the enum definition.

It can either be before _DROP or after _ADD_MPLS. In either case it's
out of order. :P

[..]

> >  case __OVS_ACTION_ATTR_MAX:
> > diff --git a/lib/odp-execute.c b/lib/odp-execute.c
> > index 37f0f717af61..86f1ccb39bf9 100644
> > --- a/lib/odp-execute.c
> > +++ b/lib/odp-execute.c
> > @@ -837,6 +837,7 @@ requires_datapath_assistance(const struct nlattr *a)
> 
> I would put the below DEC_TTL here, although it’s not used due to design 
> issues, but if it ever would be, it should be here.

ACK.

[..]

> > diff --git a/lib/odp-util.c b/lib/odp-util.c
> > index 2ec889c417e5..e1ca2cd0e02b 100644
> > --- a/lib/odp-util.c
> > +++ b/lib/odp-util.c
> > @@ -146,6 +146,7 @@ odp_action_len(uint16_t type)
> >  case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
> >
> >  case OVS_ACTION_ATTR_UNSPEC:
> > +case OVS_ACTION_ATTR_DEC_TTL:
> 
> This can be ‘case OVS_ACTION_ATTR_DEC_TTL: return ATTR_LEN_VARIABLE;’

ACK.

> >  case __OVS_ACTION_ATTR_MAX:
> >  return ATTR_LEN_INVALID;
> >  }
> > @@ -1287,6 +1288,7 @@ format_odp_action(struct ds *ds, const struct nlattr 
> > *a,
> >  ds_put_cstr(ds, "drop");
> >  break;
> >  case OVS_ACTION_ATTR_UNSPEC:
> > +case OVS_ACTION_ATTR_DEC_TTL:
> 
> I think we should be able to add the format for dec_ttl just in case it gets 
> added through some other means.
> 
> static void
> format_dec_ttl_action(struct ds *ds, const struct nlattr *attr,
>   const struct hmap *portno_names)
> {
> const struct nlattr *a;
> unsigned int left;
> 
> ds_put_cstr(ds,"dec_ttl(le_1(");
> NL_ATTR_FOR_EACH (a, left,
>   nl_attr_get(attr), nl_attr_get_size(attr)) {
> if (nl_attr_type(a) == OVS_DEC_TTL_ATTR_ACTION) {
>format_odp_actions(ds, nl_attr_get(a),
>   nl_attr_get_size(a), portno_names);
>break;
> }
> }
> ds_put_format(ds, "))");
> }

Sure. I guess this will be compile only tested.

[..]

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH net-next 2/2] net: openvswitch: add drop action

2023-07-06 Thread Eric Garver
On Thu, Jul 06, 2023 at 08:54:16AM -0400, Aaron Conole wrote:
> Eric Garver  writes:
> 
> > This adds an explicit drop action. This is used by OVS to drop packets
> > for which it cannot determine what to do. An explicit action in the
> > kernel allows passing the reason _why_ the packet is being dropped. We
> > can then use perf tracing to match on the drop reason.
> >
> > e.g. trace all OVS dropped skbs
> >
> >  # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
> >  [..]
> >  106.023 ping/2465 skb:kfree_skb(skbaddr: 0xa0e8765f2000, \
> >   location:0xc0d9b462, protocol: 2048, reason: 196610)
> >
> > reason: 196610 --> 0x30002 (OVS_XLATE_RECURSION_TOO_DEEP)
> >
> > Signed-off-by: Eric Garver 
> > ---
> >  include/uapi/linux/openvswitch.h|  2 ++
> >  net/openvswitch/actions.c   | 13 +
> >  net/openvswitch/flow_netlink.c  | 12 +++-
> >  .../testing/selftests/net/openvswitch/ovs-dpctl.py  |  3 +++
> >  4 files changed, 29 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/uapi/linux/openvswitch.h 
> > b/include/uapi/linux/openvswitch.h
> > index e94870e77ee9..a967dbca3574 100644
> > --- a/include/uapi/linux/openvswitch.h
> > +++ b/include/uapi/linux/openvswitch.h
> > @@ -965,6 +965,7 @@ struct check_pkt_len_arg {
> >   * start of the packet or at the start of the l3 header depending on the 
> > value
> >   * of l3 tunnel flag in the tun_flags field of OVS_ACTION_ATTR_ADD_MPLS
> >   * argument.
> > + * @OVS_ACTION_ATTR_DROP: Explicit drop action.
> >   *
> >   * Only a single header can be set with a single %OVS_ACTION_ATTR_SET.  
> > Not all
> >   * fields within a header are modifiable, e.g. the IPv4 protocol and 
> > fragment
> > @@ -1002,6 +1003,7 @@ enum ovs_action_attr {
> > OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
> > OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
> > OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
> > +   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
> >  
> > __OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
> >* from userspace. */
> > diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
> > index cab1e02b63e0..4ad9a45dc042 100644
> > --- a/net/openvswitch/actions.c
> > +++ b/net/openvswitch/actions.c
> > @@ -32,6 +32,7 @@
> >  #include "vport.h"
> >  #include "flow_netlink.h"
> >  #include "openvswitch_trace.h"
> > +#include "drop.h"
> >  
> >  struct deferred_action {
> > struct sk_buff *skb;
> > @@ -1477,6 +1478,18 @@ static int do_execute_actions(struct datapath *dp, 
> > struct sk_buff *skb,
> > return dec_ttl_exception_handler(dp, skb,
> >  key, a);
> > break;
> > +
> > +   case OVS_ACTION_ATTR_DROP:
> > +   u32 reason = nla_get_u32(a);
> > +
> > +   reason |= SKB_DROP_REASON_SUBSYS_OPENVSWITCH <<
> > +   SKB_DROP_REASON_SUBSYS_SHIFT;
> > +
> > +   if (reason == OVS_XLATE_OK)
> > +   break;
> > +
> > +   kfree_skb_reason(skb, reason);
> > +   return 0;
> > }
> >  
> > if (unlikely(err)) {
> > diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
> > index 41116361433d..23d39eae9a0d 100644
> > --- a/net/openvswitch/flow_netlink.c
> > +++ b/net/openvswitch/flow_netlink.c
> > @@ -39,6 +39,7 @@
> >  #include 
> >  
> >  #include "flow_netlink.h"
> > +#include "drop.h"
> >  
> >  struct ovs_len_tbl {
> > int len;
> > @@ -61,6 +62,7 @@ static bool actions_may_change_flow(const struct nlattr 
> > *actions)
> > case OVS_ACTION_ATTR_RECIRC:
> > case OVS_ACTION_ATTR_TRUNC:
> > case OVS_ACTION_ATTR_USERSPACE:
> > +   case OVS_ACTION_ATTR_DROP:
> > break;
> >  
> > case OVS_ACTION_ATTR_CT:
> > @@ -2394,7 +2396,7 @@ static void ovs_nla_free_nested_actions(const struct 
> > nlattr *actions, int len)
> > /* Whenever new actions are added, the need to update th

Re: [ovs-dev] [PATCH v2 4/4] tests: system-traffic: add coverage for drop action

2023-07-05 Thread Eric Garver
On Wed, Jul 05, 2023 at 04:58:47PM +0200, Eelco Chaudron wrote:
> 
> 
> On 30 Jun 2023, at 21:05, Eric Garver wrote:
> Hi Eric,
> 
> I started reviewing the series, and this test was failing every other run for 
> me on ‘check-system-userspace’. I ended up making the following additional 
> change:
> 
> diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
> index d2e6ac768..573ecdd0f 100644
> --- a/tests/ofproto-macros.at
> +++ b/tests/ofproto-macros.at
> @@ -120,7 +120,7 @@ strip_xids () {
> 
>  # Changes all 'used:...' to say 'used:0.0', to make output easier to compare.
>  strip_used () {
> -sed 's/used:[[0-9]]\.[[0-9]]*/used:0.0/'
> +sed 's/used:\([[0-9]]\.[[0-9]]*s\|never\)/used:0.0s/'
>  }

In this test case I expect the flow to be used. My local test runs do
not yield "never".

Maybe we need a "ovs-appctl time/warp 5000" before dumping the flow?
This is used in tests/drop-stats.at.

> 
> This is also the reason why the intel tests are failing in patchwork; 
> https://mail.openvswitch.org/pipermail/ovs-build/2023-June/032011.html
> 
> I still need to review the other patches in the series, but some small 
> comments while testing the patch set:
> 
> We are trying to align all commit messages to start with a Capital and end 
> with a dot. So in your case:
> 
> ‘tests: system-traffic: Add coverage for drop action.’

ACK. I'll address this in v3.

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v2 1/4] dpif: stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL

2023-06-30 Thread Eric Garver
This is prep for adding a different OVS_ACTION_ATTR_ enum value. This
action, OVS_ACTION_ATTR_DEC_TTL, is not actually implemented. However,
to make -Werror happy we must add a case to all existing switches.

Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h  | 1 +
 lib/dpif-netdev.c| 1 +
 lib/dpif.c   | 1 +
 lib/odp-execute.c| 2 ++
 lib/odp-util.c   | 2 ++
 ofproto/ofproto-dpif-ipfix.c | 1 +
 ofproto/ofproto-dpif-sflow.c | 1 +
 7 files changed, 9 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..a265e05ad253 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,6 +1085,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index abe63412ebfc..565cde5f5010 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9193,6 +9193,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_POP_NSH:
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
 case __OVS_ACTION_ATTR_MAX:
diff --git a/lib/dpif.c b/lib/dpif.c
index b1cbf39c48d6..d328bf288de0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1281,6 +1281,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet_batch 
*packets_,
 case OVS_ACTION_ATTR_CT_CLEAR:
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
 case __OVS_ACTION_ATTR_MAX:
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index 37f0f717af61..86f1ccb39bf9 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -837,6 +837,7 @@ requires_datapath_assistance(const struct nlattr *a)
 return false;
 
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 OVS_NOT_REACHED();
 }
@@ -1223,6 +1224,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch 
*batch, bool steal,
 case OVS_ACTION_ATTR_RECIRC:
 case OVS_ACTION_ATTR_CT:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 /* The following actions are handled by the scalar implementation. */
 case OVS_ACTION_ATTR_POP_VLAN:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 2ec889c417e5..e1ca2cd0e02b 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -146,6 +146,7 @@ odp_action_len(uint16_t type)
 case OVS_ACTION_ATTR_DROP: return sizeof(uint32_t);
 
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 return ATTR_LEN_INVALID;
 }
@@ -1287,6 +1288,7 @@ format_odp_action(struct ds *ds, const struct nlattr *a,
 ds_put_cstr(ds, "drop");
 break;
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case __OVS_ACTION_ATTR_MAX:
 default:
 format_generic_odp_action(ds, a);
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index e6c2968f7e90..c71880e18122 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -3133,6 +3133,7 @@ dpif_ipfix_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_POP_NSH:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_UNSPEC:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_DROP:
 case OVS_ACTION_ATTR_ADD_MPLS:
 case __OVS_ACTION_ATTR_MAX:
diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c
index a405eb0563fe..f026cf0c815c 100644
--- a/ofproto/ofproto-dpif-sflow.c
+++ b/ofproto/ofproto-dpif-sflow.c
@@ -1228,6 +1228,7 @@ dpif_sflow_read_actions(const struct flow *flow,
 case OVS_ACTION_ATTR_UNSPEC:
 case OVS_ACTION_ATTR_CHECK_PKT_LEN:
 case OVS_ACTION_ATTR_DROP:
+case OVS_ACTION_ATTR_DEC_TTL:
 case OVS_ACTION_ATTR_ADD_MPLS:
 case __OVS_ACTION_ATTR_MAX:
 default:
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v2 4/4] tests: system-traffic: add coverage for drop action

2023-06-30 Thread Eric Garver
Signed-off-by: Eric Garver 
---
 tests/system-traffic.at | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 4c378e1d02b0..31c1ef46d561 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2048,6 +2048,36 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+AT_DATA([flows.txt], [dnl
+table=0, dl_type=0x806, actions=normal
+table=0, in_port=ovs-p0, actions=goto_table:1
+table=1, in_port=ovs-p0, actions=goto_table:2
+table=2, in_port=ovs-p0, actions=resubmit(,1)
+])
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl generate some traffic
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+AT_CHECK([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | dnl
+  sed 's/,packet_type(ns=[[0-9]]*,id=[[0-9]]*),/,/;s/,eth(),/,/;' | dnl
+  strip_recirc | strip_stats | strip_used | sort], [0], [dnl
+recirc_id(),in_port(2),eth_type(0x0800),ipv4(frag=no), packets:0, 
bytes:0, used:0.0s, actions:drop
+])
+
+OVS_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v2 3/4] system-common-macros: check for drop action in datapath

2023-06-30 Thread Eric Garver
Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 0077a8609c02..afc0df00a329 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -359,3 +359,7 @@ m4_define([OVS_CHECK_IPROUTE_ENCAP],
 # OVS_CHECK_CT_CLEAR()
 m4_define([OVS_CHECK_CT_CLEAR],
 [AT_SKIP_IF([! grep -q "Datapath supports ct_clear action" 
ovs-vswitchd.log])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports drop action" ovs-vswitchd.log])])
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v2 0/4] dpif: probe support for OVS_ACTION_ATTR_DROP

2023-06-30 Thread Eric Garver
Probe the datapath implementation for support of OVS_ACTION_ATTR_DROP.
Also add a new test case.

v2:
  - new patch (1) to fix build (switch cases)
  - fixed check-system-userspace

Eric Garver (4):
  dpif: stub out unimplemented action OVS_ACTION_ATTR_DEC_TTL
  dpif: probe support for OVS_ACTION_ATTR_DROP
  system-common-macros: check for drop action in datapath
  tests: system-traffic: add coverage for drop action

 include/linux/openvswitch.h   |  3 ++-
 lib/dpif-netdev.c |  1 +
 lib/dpif.c|  7 +--
 lib/dpif.h|  1 -
 lib/odp-execute.c |  2 ++
 lib/odp-util.c|  2 ++
 ofproto/ofproto-dpif-ipfix.c  |  1 +
 ofproto/ofproto-dpif-sflow.c  |  1 +
 ofproto/ofproto-dpif.c| 34 --
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 30 ++
 11 files changed, 76 insertions(+), 10 deletions(-)

-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v2 2/4] dpif: probe support for OVS_ACTION_ATTR_DROP

2023-06-30 Thread Eric Garver
Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  2 +-
 lib/dpif.c  |  6 --
 lib/dpif.h  |  1 -
 ofproto/ofproto-dpif.c  | 34 --
 4 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index a265e05ad253..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1086,11 +1086,11 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index d328bf288de0..dc02ec912693 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1928,12 +1928,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 return dpif_is_netdev(dpif);
 }
 
-bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
-{
-return dpif_is_netdev(dpif);
-}
-
 bool
 dpif_supports_lb_output_action(const struct dpif *dpif)
 {
diff --git a/lib/dpif.h b/lib/dpif.h
index 129cbf6a1d5f..fc1719f88b4f 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -938,7 +938,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index fad7342b0b02..c490a3c1da48 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1375,6 +1375,37 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_ATTR_DROP, XLATE_OK);
+
+supported = dpif_probe_feature(backer->dpif, "drop", &key, &actions, NULL);
+
+VLOG_INFO("%s: Datapath %s drop action",
+  dpif_name(backer->dpif), (supported) ? "supports"
+   : "does not support");
+return supported;
+}
+
 /* Tests whether 'backer''s datapath supports the all-zero SNAT case. */
 static bool
 dpif_supports_ct_zero_snat(struct dpif_backer *backer)
@@ -1627,8 +1658,7 @@ check_support(struct dpif_backer *backer)
 backer->rt_support.max_hash_alg = check_max_dp_hash_alg(backer);
 backer->rt_support.check_pkt_len = check_check_pkt_len(backer);
 backer->rt_support.ct_timeout = check_ct_timeout_policy(backer);
-backer->rt_support.explicit_drop_action =
-dpif_supports_explicit_drop_action(backer->dpif);
+backer->rt_support.explicit_drop_action = check_drop_action(backer);
 backer->rt_support.lb_output_action =
 dpif_supports_lb_output_action(backer->dpif);
 backer->rt_support.ct_zero_snat = dpif_supports_ct_zero_snat(backer);
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 0/3] dpif: probe support for OVS_ACTION_ATTR_DROP

2023-06-30 Thread Eric Garver
On Fri, Jun 30, 2023 at 08:57:15AM +0200, Eelco Chaudron wrote:
> 
> 
> On 29 Jun 2023, at 22:30, Eric Garver wrote:
> 
> > Probe the datapath implementation for support of OVS_ACTION_ATTR_DROP.
> > Also add a new test case.
> 
> 
> Hi Eric,
> 
> Thanks for the patch, but I get quite some build failures on missing switch 
> cases.
> Can you take a look? If you build with the --enable-Werror configure option 
> you will see them.

Yeah. I added OVS_ACTION_ATTR_DEC_TTL to the enum, but failed to add it
to the switch cases. next-next is closed anyways (doh!) so I'll wait a
couple weeks before I post v2 of this series.

Thanks.
Eric.

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH net-next 2/2] net: openvswitch: add drop action

2023-06-30 Thread Eric Garver
On Fri, Jun 30, 2023 at 11:47:04AM +0200, Simon Horman wrote:
> On Thu, Jun 29, 2023 at 04:30:05PM -0400, Eric Garver wrote:
> > This adds an explicit drop action. This is used by OVS to drop packets
> > for which it cannot determine what to do. An explicit action in the
> > kernel allows passing the reason _why_ the packet is being dropped. We
> > can then use perf tracing to match on the drop reason.
> > 
> > e.g. trace all OVS dropped skbs
> > 
> >  # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
> >  [..]
> >  106.023 ping/2465 skb:kfree_skb(skbaddr: 0xa0e8765f2000, \
> >   location:0xc0d9b462, protocol: 2048, reason: 196610)
> > 
> > reason: 196610 --> 0x30002 (OVS_XLATE_RECURSION_TOO_DEEP)
> > 
> > Signed-off-by: Eric Garver 
> 
> ...
> 
> > --- a/net/openvswitch/actions.c
> > +++ b/net/openvswitch/actions.c
> > @@ -32,6 +32,7 @@
> >  #include "vport.h"
> >  #include "flow_netlink.h"
> >  #include "openvswitch_trace.h"
> > +#include "drop.h"
> >  
> >  struct deferred_action {
> > struct sk_buff *skb;
> > @@ -1477,6 +1478,18 @@ static int do_execute_actions(struct datapath *dp, 
> > struct sk_buff *skb,
> > return dec_ttl_exception_handler(dp, skb,
> >  key, a);
> > break;
> > +
> > +   case OVS_ACTION_ATTR_DROP:
> > +   u32 reason = nla_get_u32(a);
> > +
> > +   reason |= SKB_DROP_REASON_SUBSYS_OPENVSWITCH <<
> > +   SKB_DROP_REASON_SUBSYS_SHIFT;
> > +
> > +   if (reason == OVS_XLATE_OK)
> > +   break;
> > +
> > +   kfree_skb_reason(skb, reason);
> > +   return 0;
> > }
> 
> Hi Eric,
> 
> thanks for your patches. This is an interesting new feature.
> 
> unfortunately clang-16 doesn't seem to like this very much.
> I think that it is due to the declaration of reason not
> being enclosed in a block - { }.
> 
>   net/openvswitch/actions.c:1483:4: error: expected expression
>   u32 reason = nla_get_u32(a);
>   ^
>   net/openvswitch/actions.c:1485:4: error: use of undeclared identifier 
> 'reason'
>   reason |= SKB_DROP_REASON_SUBSYS_OPENVSWITCH <<
>   ^
>   net/openvswitch/actions.c:1488:8: error: use of undeclared identifier 
> 'reason'
>   if (reason == OVS_XLATE_OK)
>   ^
>   net/openvswitch/actions.c:1491:26: error: use of undeclared identifier 
> 'reason'
>   kfree_skb_reason(skb, reason);
> ^
>   4 errors generated.
> 
> 
> net-next is currently closed.
> So please provide a v2 once it reposts, after 10th July.

oof. My bad. I'll fix the clang issue and post v2 in a couple weeks.

Thanks.
Eric.

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 3/3] tests: system-traffic: add coverage for drop action

2023-06-29 Thread Eric Garver
Signed-off-by: Eric Garver 
---
 tests/system-traffic.at | 29 +
 1 file changed, 29 insertions(+)

diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 4c378e1d02b0..3268d319381c 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2048,6 +2048,35 @@ masks-cache:size:256
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([datapath - drop action])
+OVS_TRAFFIC_VSWITCHD_START()
+OVS_CHECK_DROP_ACTION()
+AT_KEYWORDS(drop_action)
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
+ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
+
+AT_DATA([flows.txt], [dnl
+table=0, dl_type=0x806, actions=normal
+table=0, in_port=ovs-p0, actions=goto_table:1
+table=1, in_port=ovs-p0, actions=goto_table:2
+table=2, in_port=ovs-p0, actions=resubmit(,1)
+])
+AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
+
+dnl generate some traffic
+NS_CHECK_EXEC([at_ns0], [ping -q -c 10 -i 0.1 -w 2 10.1.1.2], [1], [ignore])
+
+AT_CHECK([ovs-appctl dpctl/dump-flows | grep "eth_type(0x0800)" | grep 
"actions:drop" | dnl
+  strip_recirc | strip_stats | strip_used | sort], [0], [dnl
+recirc_id(),in_port(2),eth(),eth_type(0x0800),ipv4(frag=no), 
packets:0, bytes:0, used:0.0s, actions:drop
+])
+
+OVS_VSWITCHD_STOP(["/|WARN|/d"])
+AT_CLEANUP
+
 AT_SETUP([datapath - simulated flow action update])
 OVS_TRAFFIC_VSWITCHD_START()
 
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 1/3] dpif: probe support for OVS_ACTION_ATTR_DROP

2023-06-29 Thread Eric Garver
Signed-off-by: Eric Garver 
---
 include/linux/openvswitch.h |  3 ++-
 lib/dpif.c  |  6 --
 lib/dpif.h  |  1 -
 ofproto/ofproto-dpif.c  | 34 --
 4 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index e305c331516b..fce6456f47c8 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -1085,11 +1085,12 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CLONE,/* Nested OVS_CLONE_ATTR_*.  */
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
+   OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
 #ifndef __KERNEL__
OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
OVS_ACTION_ATTR_TUNNEL_POP,/* u32 port number. */
-   OVS_ACTION_ATTR_DROP,  /* u32 xlate_error. */
OVS_ACTION_ATTR_LB_OUTPUT, /* u32 bond-id. */
 #endif
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
diff --git a/lib/dpif.c b/lib/dpif.c
index b1cbf39c48d6..bc7aa774e06d 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1927,12 +1927,6 @@ dpif_supports_tnl_push_pop(const struct dpif *dpif)
 return dpif_is_netdev(dpif);
 }
 
-bool
-dpif_supports_explicit_drop_action(const struct dpif *dpif)
-{
-return dpif_is_netdev(dpif);
-}
-
 bool
 dpif_supports_lb_output_action(const struct dpif *dpif)
 {
diff --git a/lib/dpif.h b/lib/dpif.h
index 129cbf6a1d5f..fc1719f88b4f 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -938,7 +938,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
 
 char *dpif_get_dp_version(const struct dpif *);
 bool dpif_supports_tnl_push_pop(const struct dpif *);
-bool dpif_supports_explicit_drop_action(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
 /* Log functions. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index fad7342b0b02..c490a3c1da48 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1375,6 +1375,37 @@ check_ct_timeout_policy(struct dpif_backer *backer)
 return !error;
 }
 
+/* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
+static bool
+check_drop_action(struct dpif_backer *backer)
+{
+struct odputil_keybuf keybuf;
+uint8_t actbuf[NL_A_U32_SIZE];
+struct ofpbuf actions;
+struct ofpbuf key;
+struct flow flow;
+bool supported;
+
+struct odp_flow_key_parms odp_parms = {
+.flow = &flow,
+.probe = true,
+};
+
+memset(&flow, 0, sizeof flow);
+ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+odp_flow_key_from_flow(&odp_parms, &key);
+
+ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+nl_msg_put_u32(&actions, OVS_ACTION_ATTR_DROP, XLATE_OK);
+
+supported = dpif_probe_feature(backer->dpif, "drop", &key, &actions, NULL);
+
+VLOG_INFO("%s: Datapath %s drop action",
+  dpif_name(backer->dpif), (supported) ? "supports"
+   : "does not support");
+return supported;
+}
+
 /* Tests whether 'backer''s datapath supports the all-zero SNAT case. */
 static bool
 dpif_supports_ct_zero_snat(struct dpif_backer *backer)
@@ -1627,8 +1658,7 @@ check_support(struct dpif_backer *backer)
 backer->rt_support.max_hash_alg = check_max_dp_hash_alg(backer);
 backer->rt_support.check_pkt_len = check_check_pkt_len(backer);
 backer->rt_support.ct_timeout = check_ct_timeout_policy(backer);
-backer->rt_support.explicit_drop_action =
-dpif_supports_explicit_drop_action(backer->dpif);
+backer->rt_support.explicit_drop_action = check_drop_action(backer);
 backer->rt_support.lb_output_action =
 dpif_supports_lb_output_action(backer->dpif);
 backer->rt_support.ct_zero_snat = dpif_supports_ct_zero_snat(backer);
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH net-next 2/2] net: openvswitch: add drop action

2023-06-29 Thread Eric Garver
This adds an explicit drop action. This is used by OVS to drop packets
for which it cannot determine what to do. An explicit action in the
kernel allows passing the reason _why_ the packet is being dropped. We
can then use perf tracing to match on the drop reason.

e.g. trace all OVS dropped skbs

 # perf trace -e skb:kfree_skb --filter="reason >= 0x3"
 [..]
 106.023 ping/2465 skb:kfree_skb(skbaddr: 0xa0e8765f2000, \
  location:0xc0d9b462, protocol: 2048, reason: 196610)

reason: 196610 --> 0x30002 (OVS_XLATE_RECURSION_TOO_DEEP)

Signed-off-by: Eric Garver 
---
 include/uapi/linux/openvswitch.h|  2 ++
 net/openvswitch/actions.c   | 13 +
 net/openvswitch/flow_netlink.c  | 12 +++-
 .../testing/selftests/net/openvswitch/ovs-dpctl.py  |  3 +++
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index e94870e77ee9..a967dbca3574 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -965,6 +965,7 @@ struct check_pkt_len_arg {
  * start of the packet or at the start of the l3 header depending on the value
  * of l3 tunnel flag in the tun_flags field of OVS_ACTION_ATTR_ADD_MPLS
  * argument.
+ * @OVS_ACTION_ATTR_DROP: Explicit drop action.
  *
  * Only a single header can be set with a single %OVS_ACTION_ATTR_SET.  Not all
  * fields within a header are modifiable, e.g. the IPv4 protocol and fragment
@@ -1002,6 +1003,7 @@ enum ovs_action_attr {
OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
OVS_ACTION_ATTR_DEC_TTL,  /* Nested OVS_DEC_TTL_ATTR_*. */
+   OVS_ACTION_ATTR_DROP, /* u32 xlate_error. */
 
__OVS_ACTION_ATTR_MAX,/* Nothing past this will be accepted
   * from userspace. */
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index cab1e02b63e0..4ad9a45dc042 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -32,6 +32,7 @@
 #include "vport.h"
 #include "flow_netlink.h"
 #include "openvswitch_trace.h"
+#include "drop.h"
 
 struct deferred_action {
struct sk_buff *skb;
@@ -1477,6 +1478,18 @@ static int do_execute_actions(struct datapath *dp, 
struct sk_buff *skb,
return dec_ttl_exception_handler(dp, skb,
 key, a);
break;
+
+   case OVS_ACTION_ATTR_DROP:
+   u32 reason = nla_get_u32(a);
+
+   reason |= SKB_DROP_REASON_SUBSYS_OPENVSWITCH <<
+   SKB_DROP_REASON_SUBSYS_SHIFT;
+
+   if (reason == OVS_XLATE_OK)
+   break;
+
+   kfree_skb_reason(skb, reason);
+   return 0;
}
 
if (unlikely(err)) {
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 41116361433d..23d39eae9a0d 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -39,6 +39,7 @@
 #include 
 
 #include "flow_netlink.h"
+#include "drop.h"
 
 struct ovs_len_tbl {
int len;
@@ -61,6 +62,7 @@ static bool actions_may_change_flow(const struct nlattr 
*actions)
case OVS_ACTION_ATTR_RECIRC:
case OVS_ACTION_ATTR_TRUNC:
case OVS_ACTION_ATTR_USERSPACE:
+   case OVS_ACTION_ATTR_DROP:
break;
 
case OVS_ACTION_ATTR_CT:
@@ -2394,7 +2396,7 @@ static void ovs_nla_free_nested_actions(const struct 
nlattr *actions, int len)
/* Whenever new actions are added, the need to update this
 * function should be considered.
 */
-   BUILD_BUG_ON(OVS_ACTION_ATTR_MAX != 23);
+   BUILD_BUG_ON(OVS_ACTION_ATTR_MAX != 24);
 
if (!actions)
return;
@@ -3182,6 +3184,7 @@ static int __ovs_nla_copy_actions(struct net *net, const 
struct nlattr *attr,
[OVS_ACTION_ATTR_CHECK_PKT_LEN] = (u32)-1,
[OVS_ACTION_ATTR_ADD_MPLS] = sizeof(struct 
ovs_action_add_mpls),
[OVS_ACTION_ATTR_DEC_TTL] = (u32)-1,
+   [OVS_ACTION_ATTR_DROP] = sizeof(u32),
};
const struct ovs_action_push_vlan *vlan;
int type = nla_type(a);
@@ -3453,6 +3456,13 @@ static int __ovs_nla_copy_actions(struct net *net, const 
struct nlattr *attr,
skip_copy = true;
break;
 
+   case OVS_ACTION_ATTR_DROP:
+ 

[ovs-dev] [PATCH net-next 0/2] net: openvswitch: add drop action

2023-06-29 Thread Eric Garver
Prior to this series the "drop" action was implicit by an empty set of
actions. This series adds support for an explicit drop action. The
primary motivation is to allow passing xlate_error from userspace such
that xlater_error can be passed to kfree_skb_reason() and therefore
traced.       

Eric Garver (2):
  net: openvswitch: add drop reasons
  net: openvswitch: add drop action

 include/net/dropreason.h  |  6 
 include/uapi/linux/openvswitch.h  |  2 ++
 net/openvswitch/actions.c | 13 +++
 net/openvswitch/datapath.c| 17 ++
 net/openvswitch/drop.h| 34 +++
 net/openvswitch/flow_netlink.c| 12 ++-
 .../selftests/net/openvswitch/ovs-dpctl.py|  3 ++
 7 files changed, 86 insertions(+), 1 deletion(-)
 create mode 100644 net/openvswitch/drop.h

-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 0/3] dpif: probe support for OVS_ACTION_ATTR_DROP

2023-06-29 Thread Eric Garver
Probe the datapath implementation for support of OVS_ACTION_ATTR_DROP.
Also add a new test case.

Eric Garver (3):
  dpif: probe support for OVS_ACTION_ATTR_DROP
  system-common-macros: check for drop action in datapath
  tests: system-traffic: add coverage for drop action

 include/linux/openvswitch.h   |  3 ++-
 lib/dpif.c|  6 --
 lib/dpif.h|  1 -
 ofproto/ofproto-dpif.c| 34 --
 tests/system-common-macros.at |  4 
 tests/system-traffic.at   | 29 +
 6 files changed, 67 insertions(+), 10 deletions(-)

-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH net-next 1/2] net: openvswitch: add drop reasons

2023-06-29 Thread Eric Garver
These are counterparts to userspace's xlate_error values.

Signed-off-by: Eric Garver 
---
 include/net/dropreason.h   |  6 ++
 net/openvswitch/datapath.c | 17 +
 net/openvswitch/drop.h | 34 ++
 3 files changed, 57 insertions(+)
 create mode 100644 net/openvswitch/drop.h

diff --git a/include/net/dropreason.h b/include/net/dropreason.h
index 685fb37df8e8..653675bba758 100644
--- a/include/net/dropreason.h
+++ b/include/net/dropreason.h
@@ -23,6 +23,12 @@ enum skb_drop_reason_subsys {
 */
SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR,
 
+   /**
+* @SKB_DROP_REASON_SUBSYS_OPENVSWITCH: openvswitch drop reasons
+* see net/openvswitch/drop.h
+*/
+   SKB_DROP_REASON_SUBSYS_OPENVSWITCH,
+
/** @SKB_DROP_REASON_SUBSYS_NUM: number of subsystems defined */
SKB_DROP_REASON_SUBSYS_NUM
 };
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index a6d2a0b1aa21..4ebdc52856ab 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -48,6 +48,7 @@
 #include "openvswitch_trace.h"
 #include "vport-internal_dev.h"
 #include "vport-netdev.h"
+#include "drop.h"
 
 unsigned int ovs_net_id __read_mostly;
 
@@ -2702,6 +2703,18 @@ static struct pernet_operations ovs_net_ops = {
.size = sizeof(struct ovs_net),
 };
 
+static const char * const ovs_drop_reasons[] = {
+   [0] = "OVS_XLATE_OK",
+#define S(x) #x,
+   OVS_DROP_REASONS(S)
+#undef S
+};
+
+static struct drop_reason_list drop_reason_list_ovs = {
+   .reasons = ovs_drop_reasons,
+   .n_reasons = ARRAY_SIZE(ovs_drop_reasons),
+};
+
 static int __init dp_init(void)
 {
int err;
@@ -2743,6 +2756,9 @@ static int __init dp_init(void)
if (err < 0)
goto error_unreg_netdev;
 
+   drop_reasons_register_subsys(SKB_DROP_REASON_SUBSYS_OPENVSWITCH,
+&drop_reason_list_ovs);
+
return 0;
 
 error_unreg_netdev:
@@ -2769,6 +2785,7 @@ static void dp_cleanup(void)
ovs_netdev_exit();
unregister_netdevice_notifier(&ovs_dp_device_notifier);
unregister_pernet_device(&ovs_net_ops);
+   drop_reasons_unregister_subsys(SKB_DROP_REASON_SUBSYS_OPENVSWITCH);
rcu_barrier();
ovs_vport_exit();
ovs_flow_exit();
diff --git a/net/openvswitch/drop.h b/net/openvswitch/drop.h
new file mode 100644
index ..787eda0083c1
--- /dev/null
+++ b/net/openvswitch/drop.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * openvswitch drop reason list
+ */
+
+#ifndef OPENVSWITCH_DROP_H
+#define OPENVSWITCH_DROP_H
+#include 
+
+/* these are counterparts to userspace xlate_error */
+#define OVS_DROP_REASONS(R)  \
+   R(OVS_XLATE_BRIDGE_NOT_FOUND)\
+   R(OVS_XLATE_RECURSION_TOO_DEEP)  \
+   R(OVS_XLATE_TOO_MANY_RESUBMITS)  \
+   R(OVS_XLATE_STACK_TOO_DEEP)  \
+   R(OVS_XLATE_NO_RECIRCULATION_CONTEXT)\
+   R(OVS_XLATE_RECIRCULATION_CONFLICT)  \
+   R(OVS_XLATE_TOO_MANY_MPLS_LABELS)\
+   R(OVS_XLATE_INVALID_TUNNEL_METADATA) \
+   R(OVS_XLATE_UNSUPPORTED_PACKET_TYPE) \
+   R(OVS_XLATE_CONGESTION_DROP) \
+   R(OVS_XLATE_FORWARDING_DISABLED) \
+   /* deliberate comment for trailing \ */
+
+enum ovs_drop_reason {
+   OVS_XLATE_OK = SKB_DROP_REASON_SUBSYS_OPENVSWITCH <<
+   SKB_DROP_REASON_SUBSYS_SHIFT,
+#define ENUM(x) x,
+   OVS_DROP_REASONS(ENUM)
+#undef ENUM
+   OVS_XLATE_MAX,
+};
+
+#endif /* OPENVSWITCH_DROP_H */
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 2/3] system-common-macros: check for drop action in datapath

2023-06-29 Thread Eric Garver
Signed-off-by: Eric Garver 
---
 tests/system-common-macros.at | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 0077a8609c02..afc0df00a329 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -359,3 +359,7 @@ m4_define([OVS_CHECK_IPROUTE_ENCAP],
 # OVS_CHECK_CT_CLEAR()
 m4_define([OVS_CHECK_CT_CLEAR],
 [AT_SKIP_IF([! grep -q "Datapath supports ct_clear action" 
ovs-vswitchd.log])])
+
+# OVS_CHECK_DROP_ACTION()
+m4_define([OVS_CHECK_DROP_ACTION],
+[AT_SKIP_IF([! grep -q "Datapath supports drop action" ovs-vswitchd.log])])
-- 
2.39.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3 1/2] Documentation: update IPsec tutorial for F32

2020-10-27 Thread Eric Garver
On Tue, Oct 27, 2020 at 10:45:17AM -0400, Mark Gray wrote:
> F32 requires the "python3-openvswitch" package now. Also, the
> iptables chain "IN_FedoraServer_allow" does not exist on Fedora 32.
> 
> Signed-off-by: Mark Gray 

Thanks.

Acked-by: Eric Garver 

> ---
>  Documentation/tutorials/ipsec.rst | 108 +++---
>  1 file changed, 55 insertions(+), 53 deletions(-)
> 
> diff --git a/Documentation/tutorials/ipsec.rst 
> b/Documentation/tutorials/ipsec.rst
> index b4c3235132bc..ebc0ae429c19 100644
> --- a/Documentation/tutorials/ipsec.rst
> +++ b/Documentation/tutorials/ipsec.rst
> @@ -42,7 +42,7 @@ Installing OVS and IPsec Packages
>  -
>  
>  OVS IPsec has .deb and .rpm packages. You should use the right package
> -based on your Linux distribution. This tutorial uses Ubuntu 16.04 and Fedora 
> 27
> +based on your Linux distribution. This tutorial uses Ubuntu 16.04 and Fedora 
> 32
>  as examples.
>  
>  Ubuntu
> @@ -59,8 +59,8 @@ Ubuntu
>  
>  2. Install the related packages::
>  
> -   $ apt-get install dkms strongswan
> -   $ dpkg -i libopenvswitch_*.deb openvswitch-common_*.deb \
> +   # apt-get install dkms strongswan
> +   # dpkg -i libopenvswitch_*.deb openvswitch-common_*.deb \
>   openvswitch-switch_*.deb openvswitch-datapath-dkms_*.deb \
>   python-openvswitch_*.deb openvswitch-pki_*.deb \
>   openvswitch-ipsec_*.deb
> @@ -71,23 +71,25 @@ Ubuntu
>  Fedora
>  ~~
>  
> -1. Follow :doc:`/intro/install/fedora` to build RPM packages.
> +1. Install the related packages. Fedora 32 does not require installation of
> +   the out-of-tree kernel module::
>  
> -2. Install the related packages::
> +   # dnf install python3-openvswitch libreswan \
> + openvswitch openvswitch-ipsec
> +
> +2. Install firewall rules to allow ESP and IKE traffic::
>  
> -   $ dnf install python2-openvswitch libreswan \
> - "kernel-devel-uname-r == $(uname -r)"
> -   $ rpm -i openvswitch-*.rpm openvswitch-kmod-*.rpm \
> -openvswitch-openvswitch-ipsec-*.rpm
> +   # systemctl start firewalld
> +   # firewall-cmd --add-service ipsec
>  
> -3. Install firewall rules to allow ESP and IKE traffic::
> +   Or to make permanent::
>  
> -   $ iptables -A IN_FedoraServer_allow -p esp -j ACCEPT
> -   $ iptables -A IN_FedoraServer_allow -p udp --dport 500 -j ACCEPT
> +   # systemctl enable firewalld
> +   # firewall-cmd --permanent --add-service ipsec
>  
> -4. Run the openvswitch-ipsec service::
> +3. Run the openvswitch-ipsec service::
>  
> -   $ systemctl start openvswitch-ipsec.service
> +   # systemctl start openvswitch-ipsec.service
>  
> .. note::
>  
> @@ -97,47 +99,47 @@ Fedora
>  Configuring IPsec tunnel
>  
>  
> -Suppose you want to build IPsec tunnel between two hosts. Assume `host_1`'s
> +Suppose you want to build an IPsec tunnel between two hosts. Assume 
> `host_1`'s
>  external IP is 1.1.1.1, and `host_2`'s external IP is 2.2.2.2. Make sure
>  `host_1` and `host_2` can ping each other via these external IPs.
>  
>  0. Set up some variables to make life easier.  On both hosts, set ``ip_1`` 
> and
> ``ip_2`` variables, e.g.::
>  
> - $ ip_1=1.1.1.1
> - $ ip_2=2.2.2.2
> + # ip_1=1.1.1.1
> + # ip_2=2.2.2.2
>  
>  1. Set up OVS bridges in both hosts.
>  
> In `host_1`::
>  
> -   $ ovs-vsctl add-br br-ipsec
> -   $ ip addr add 192.0.0.1/24 dev br-ipsec
> -   $ ip link set br-ipsec up
> +   # ovs-vsctl add-br br-ipsec
> +   # ip addr add 192.0.0.1/24 dev br-ipsec
> +   # ip link set br-ipsec up
>  
> In `host_2`::
>  
> -   $ ovs-vsctl add-br br-ipsec
> -   $ ip addr add 192.0.0.2/24 dev br-ipsec
> -   $ ip link set br-ipsec up
> +   # ovs-vsctl add-br br-ipsec
> +   # ip addr add 192.0.0.2/24 dev br-ipsec
> +   # ip link set br-ipsec up
>  
>  2. Set up IPsec tunnel.
>  
> -   There are three authentication methods. You can choose one to set up your
> -   IPsec tunnel.
> +   There are three authentication methods.  Choose one method to set up your
> +   IPsec tunnel and follow the steps below.
>  
> a) Using pre-shared key:
>  
>In `host_1`::
>  
> -  $ ovs-vsctl add-port br-ipsec tun -- \
> +  # ovs-vsctl add-port br-ipsec tun -- \
>set interface tun type=gre \
>  options:remote_ip=$ip_2 \
>  

  1   2   3   4   >