All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/8] net: openvswitch: Add sample multicasting.
@ 2024-04-24 13:50 Adrian Moreno
  2024-04-24 13:50 ` [PATCH net-next 1/8] net: netlink: export genl private pointer getters Adrian Moreno
                   ` (7 more replies)
  0 siblings, 8 replies; 26+ messages in thread
From: Adrian Moreno @ 2024-04-24 13:50 UTC (permalink / raw)
  To: netdev
  Cc: aconole, echaudro, horms, i.maximets, Adrian Moreno, dev,
	linux-kernel, linux-kselftest

** Background **
Currently, OVS supports several packet sampling mechanisms (sFlow,
per-bridge IPFIX, per-flow IPFIX). These end up being translated into a
userspace action that needs to be handled by ovs-vswitchd's handler
threads only to be forwarded to some third party application that
will somehow process the sample and provide observability on the
datapath.

A particularly interesting use-case is controller-driven
per-flow IPFIX sampling where the OpenFlow controller can add metadata
to samples (via two 32bit integers) and this metadata is then available
to the sample-collecting system for correlation.

** Problem **
The fact that sampled traffic share netlink sockets and handler thread
time with upcalls, apart from being a performance bottleneck in the
sample extraction itself, can severely compromise the datapath,
yielding this solution unfit for highly loaded production systems.

Users are left with little options other than guessing what sampling
rate will be OK for their traffic pattern and system load and dealing
with the lost accuracy.

Looking at available infrastructure, an obvious candidated would be
to use psample. However, it's current state does not help with the
use-case at stake because sampled packets do not contain user-defined
metadata.

** Proposal **
This series is an attempt to fix this situation by extending the
existing psample infrastructure to carry a variable length
user-defined cookie.

The main existing user of psample is tc's act_sample. It is also
xtended to forward the action's cookie to psample.

Finally, OVS sample action is extended with a couple of attributes
(OVS_SAMPLE_ATTR_PSAMPLE_{GROUP,COOKIE}) that contain a 32 group_id
and a variable length cookie. When provided, OVS sends the packet
to psample for observability.

In order to make it easier for users to receive samples coming from
a specific source, group_id filtering is added to psample as well
as a tracepoint for troubleshooting.

--
rfc_v2 -> v1:
- Accomodate Ilya's comments.
- Split OVS's attribute in two attributes and simplify internal
handling of psample arguments.
- Extend psample and tc with a user-defined cookie.
- Add a tracepoint to psample to facilitate troubleshooting.

rfc_v1 -> rfc_v2:
- Use psample instead of a new OVS-only multicast group.
- Extend psample and tc with a user-defined cookie.

Adrian Moreno (8):
  net: netlink: export genl private pointer getters
  net: psample: add multicast filtering on group_id
  net: psample: add user cookie
  net: psample: add tracepoint
  net: sched: act_sample: add action cookie to sample
  net:openvswitch: add psample support
  selftests: openvswitch: add sample action.
  selftests: openvswitch: add psample test

 Documentation/netlink/specs/ovs_flow.yaml     |   6 +
 include/net/psample.h                         |   2 +
 include/uapi/linux/openvswitch.h              |  49 ++++-
 include/uapi/linux/psample.h                  |   2 +
 net/netlink/genetlink.c                       |   2 +
 net/openvswitch/actions.c                     |  51 ++++-
 net/openvswitch/flow_netlink.c                |  80 +++++--
 net/psample/psample.c                         | 131 ++++++++++-
 net/psample/trace.h                           |  62 ++++++
 net/sched/act_sample.c                        |  12 +
 .../selftests/net/openvswitch/openvswitch.sh  |  97 +++++++-
 .../selftests/net/openvswitch/ovs-dpctl.py    | 207 +++++++++++++++++-
 12 files changed, 655 insertions(+), 46 deletions(-)
 create mode 100644 net/psample/trace.h

-- 
2.44.0


^ permalink raw reply	[flat|nested] 26+ messages in thread
* Re: [PATCH net-next 6/8] net:openvswitch: add psample support
@ 2024-04-29 22:46 kernel test robot
  0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2024-04-29 22:46 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20240424135109.3524355-7-amorenoz@redhat.com>
References: <20240424135109.3524355-7-amorenoz@redhat.com>
TO: Adrian Moreno <amorenoz@redhat.com>
TO: netdev@vger.kernel.org
CC: aconole@redhat.com
CC: echaudro@redhat.com
CC: horms@kernel.org
CC: i.maximets@ovn.org
CC: Adrian Moreno <amorenoz@redhat.com>
CC: Eric Dumazet <edumazet@google.com>
CC: Jakub Kicinski <kuba@kernel.org>
CC: Paolo Abeni <pabeni@redhat.com>
CC: Pravin B Shelar <pshelar@ovn.org>
CC: Donald Hunter <donald.hunter@gmail.com>
CC: linux-kernel@vger.kernel.org
CC: dev@openvswitch.org

Hi Adrian,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Adrian-Moreno/net-netlink-export-genl-private-pointer-getters/20240424-215821
base:   net-next/main
patch link:    https://lore.kernel.org/r/20240424135109.3524355-7-amorenoz%40redhat.com
patch subject: [PATCH net-next 6/8] net:openvswitch: add psample support
:::::: branch date: 5 days ago
:::::: commit date: 5 days ago
config: i386-randconfig-141-20240430 (https://download.01.org/0day-ci/archive/20240430/202404300611.kJOZL2KI-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202404300611.kJOZL2KI-lkp@intel.com/

New smatch warnings:
net/openvswitch/actions.c:1097 sample() error: uninitialized symbol 'ret'.
net/openvswitch/flow_netlink.c:2599 validate_and_copy_sample() warn: possible spectre second half.  'group'
net/openvswitch/flow_netlink.c:2603 validate_and_copy_sample() warn: possible spectre second half.  'cookie'

Old smatch warnings:
net/openvswitch/flow_netlink.c:507 __parse_flow_nlattrs() warn: potential spectre issue 'ovs_key_lens' [r] (local cap)
net/openvswitch/flow_netlink.c:516 __parse_flow_nlattrs() warn: potential spectre issue 'a' [w] (local cap)
net/openvswitch/flow_netlink.c:614 vxlan_tun_opt_from_nlattr() warn: potential spectre issue 'ovs_vxlan_ext_key_lens' [w] (local cap)
net/openvswitch/flow_netlink.c:697 ip_tun_from_nlattr() warn: potential spectre issue 'ovs_tunnel_key_lens' [w] (local cap)
net/openvswitch/flow_netlink.c:1206 metadata_from_nlattrs() warn: 'in_port' 4294967295 can't fit into 65535 'match->mask->key.phy.in_port'
net/openvswitch/flow_netlink.c:1427 nsh_key_put_from_nlattr() warn: potential spectre issue 'ovs_nsh_key_attr_lens' [w] (local cap)
net/openvswitch/flow_netlink.c:1781 nlattr_set() warn: potential spectre issue 'tbl' [w]
net/openvswitch/flow_netlink.c:2585 validate_and_copy_sample() warn: potential spectre issue 'attrs' [w] (local cap)
net/openvswitch/flow_netlink.c:2591 validate_and_copy_sample() warn: possible spectre second half.  'probability'
net/openvswitch/flow_netlink.c:2595 validate_and_copy_sample() warn: possible spectre second half.  'actions'
net/openvswitch/flow_netlink.c:2685 validate_and_copy_dec_ttl() warn: potential spectre issue 'attrs' [w] (local cap)
net/openvswitch/flow_netlink.c:2694 validate_and_copy_dec_ttl() warn: possible spectre second half.  'actions'
net/openvswitch/flow_netlink.c:2927 validate_set() warn: potential spectre issue 'ovs_key_lens' [w] (local cap)

vim +/ret +1097 net/openvswitch/actions.c

ccc0b9e4657efd Adrian Moreno      2024-04-24  1056  
798c166173ffb5 andy zhou          2017-03-20  1057  /* When 'last' is true, sample() should always consume the 'skb'.
798c166173ffb5 andy zhou          2017-03-20  1058   * Otherwise, sample() should keep 'skb' intact regardless what
798c166173ffb5 andy zhou          2017-03-20  1059   * actions are executed within sample().
798c166173ffb5 andy zhou          2017-03-20  1060   */
ccb1352e76cff0 Jesse Gross        2011-10-25  1061  static int sample(struct datapath *dp, struct sk_buff *skb,
ccea74457bbdaf Neil McKee         2015-05-26  1062  		  struct sw_flow_key *key, const struct nlattr *attr,
798c166173ffb5 andy zhou          2017-03-20  1063  		  bool last)
ccb1352e76cff0 Jesse Gross        2011-10-25  1064  {
ccc0b9e4657efd Adrian Moreno      2024-04-24  1065  	const struct sample_arg *arg;
798c166173ffb5 andy zhou          2017-03-20  1066  	struct nlattr *sample_arg;
798c166173ffb5 andy zhou          2017-03-20  1067  	int rem = nla_len(attr);
ccc0b9e4657efd Adrian Moreno      2024-04-24  1068  	struct nlattr *actions;
bef7f7567a104a andy zhou          2017-03-20  1069  	bool clone_flow_key;
ccc0b9e4657efd Adrian Moreno      2024-04-24  1070  	int ret;
ccb1352e76cff0 Jesse Gross        2011-10-25  1071  
798c166173ffb5 andy zhou          2017-03-20  1072  	/* The first action is always 'OVS_SAMPLE_ATTR_ARG'. */
798c166173ffb5 andy zhou          2017-03-20  1073  	sample_arg = nla_data(attr);
798c166173ffb5 andy zhou          2017-03-20  1074  	arg = nla_data(sample_arg);
798c166173ffb5 andy zhou          2017-03-20  1075  	actions = nla_next(sample_arg, &rem);
e05176a3283822 Wenyu Zhang        2015-08-05  1076  
798c166173ffb5 andy zhou          2017-03-20  1077  	if ((arg->probability != U32_MAX) &&
a251c17aa558d8 Jason A. Donenfeld 2022-10-05  1078  	    (!arg->probability || get_random_u32() > arg->probability)) {
798c166173ffb5 andy zhou          2017-03-20  1079  		if (last)
9d802da40b7c82 Adrian Moreno      2023-08-11  1080  			ovs_kfree_skb_reason(skb, OVS_DROP_LAST_ACTION);
ccb1352e76cff0 Jesse Gross        2011-10-25  1081  		return 0;
ccb1352e76cff0 Jesse Gross        2011-10-25  1082  	}
651887b0c22cff Simon Horman       2014-07-21  1083  
ccc0b9e4657efd Adrian Moreno      2024-04-24  1084  	if (arg->flags & OVS_SAMPLE_ARG_FLAG_PSAMPLE) {
ccc0b9e4657efd Adrian Moreno      2024-04-24  1085  		ret = ovs_psample_packet(dp, key, arg, skb);
ccc0b9e4657efd Adrian Moreno      2024-04-24  1086  		if (ret)
ccc0b9e4657efd Adrian Moreno      2024-04-24  1087  			return ret;
ccc0b9e4657efd Adrian Moreno      2024-04-24  1088  	}
ccc0b9e4657efd Adrian Moreno      2024-04-24  1089  
ccc0b9e4657efd Adrian Moreno      2024-04-24  1090  	if (nla_ok(actions, rem)) {
ccc0b9e4657efd Adrian Moreno      2024-04-24  1091  		clone_flow_key = !(arg->flags & OVS_SAMPLE_ARG_FLAG_EXEC);
ccc0b9e4657efd Adrian Moreno      2024-04-24  1092  		ret = clone_execute(dp, skb, key, 0, actions, rem, last,
bef7f7567a104a andy zhou          2017-03-20  1093  				    clone_flow_key);
ccc0b9e4657efd Adrian Moreno      2024-04-24  1094  	} else if (last) {
ccc0b9e4657efd Adrian Moreno      2024-04-24  1095  		ovs_kfree_skb_reason(skb, OVS_DROP_LAST_ACTION);
ccc0b9e4657efd Adrian Moreno      2024-04-24  1096  	}
ccc0b9e4657efd Adrian Moreno      2024-04-24 @1097  	return ret;
971427f353f3c4 Andy Zhou          2014-09-15  1098  }
971427f353f3c4 Andy Zhou          2014-09-15  1099  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2024-05-08 15:25 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-24 13:50 [PATCH net-next 0/8] net: openvswitch: Add sample multicasting Adrian Moreno
2024-04-24 13:50 ` [PATCH net-next 1/8] net: netlink: export genl private pointer getters Adrian Moreno
2024-04-24 13:50 ` [PATCH net-next 2/8] net: psample: add multicast filtering on group_id Adrian Moreno
2024-04-24 14:54   ` Jiri Pirko
2024-04-25  7:23     ` Adrian Moreno
2024-04-24 13:50 ` [PATCH net-next 3/8] net: psample: add user cookie Adrian Moreno
2024-04-25  7:32   ` Ido Schimmel
2024-04-25  8:09     ` Adrian Moreno
2024-04-24 13:50 ` [PATCH net-next 4/8] net: psample: add tracepoint Adrian Moreno
2024-04-25  7:18   ` Ido Schimmel
2024-04-25  8:06     ` Adrian Moreno
2024-04-25 15:25       ` Ido Schimmel
2024-04-29  5:33         ` Adrian Moreno
2024-04-30 12:53           ` Ido Schimmel
2024-04-24 13:50 ` [PATCH net-next 5/8] net: sched: act_sample: add action cookie to sample Adrian Moreno
2024-04-25  7:39   ` Ido Schimmel
2024-04-25 21:43   ` Jamal Hadi Salim
2024-04-24 13:50 ` [PATCH net-next 6/8] net:openvswitch: add psample support Adrian Moreno
2024-04-30  7:29   ` Dan Carpenter
2024-05-03  9:43   ` Eelco Chaudron
2024-05-07 14:18     ` Adrian Moreno
2024-05-08  9:48       ` Eelco Chaudron
2024-05-08 15:25       ` Aaron Conole
2024-04-24 13:50 ` [PATCH net-next 7/8] selftests: openvswitch: add sample action Adrian Moreno
2024-04-24 13:50 ` [PATCH net-next 8/8] selftests: openvswitch: add psample test Adrian Moreno
  -- strict thread matches above, loose matches on Subject: below --
2024-04-29 22:46 [PATCH net-next 6/8] net:openvswitch: add psample support kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.