Re: [ovs-dev] [PATCH v1 05/13] vswitchd: Add local sampling to vswitchd schema.
On 7/7/24 22:08, Adrian Moreno wrote: > Add as new column in the Flow_Sample_Collector_Set table named > "local_group_id" which enables this feature. > > Signed-off-by: Adrian Moreno > --- > NEWS | 4 ++ > vswitchd/bridge.c | 78 +++--- > vswitchd/vswitch.ovsschema | 9 - > vswitchd/vswitch.xml | 40 +-- > 4 files changed, 120 insertions(+), 11 deletions(-) > > diff --git a/NEWS b/NEWS > index e0359b759..15faf9fc3 100644 > --- a/NEWS > +++ b/NEWS > @@ -16,6 +16,10 @@ Post-v3.3.0 > per interface 'options:dpdk-lsc-interrupt' to 'false'. > - Python: > * Added custom transaction support to the Idl via add_op(). > + - Local sampling is introduced. It reuses the OpenFlow sample action and > + allows samples to be emitted locally (instead of via IPFIX) in a > + datapath-specific manner. The Linux kernel datapath is the first to > + support this feature by using the new datapath "psample" action. We try to keep doesble spaces between sentences in the NEWS file. > > > v3.3.0 - 16 Feb 2024 > diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c > index 95a65fcdc..b7db681f3 100644 > --- a/vswitchd/bridge.c > +++ b/vswitchd/bridge.c > @@ -288,6 +288,7 @@ static void bridge_configure_mac_table(struct bridge *); > static void bridge_configure_mcast_snooping(struct bridge *); > static void bridge_configure_sflow(struct bridge *, int > *sflow_bridge_number); > static void bridge_configure_ipfix(struct bridge *); > +static void bridge_configure_lsample(struct bridge *); > static void bridge_configure_spanning_tree(struct bridge *); > static void bridge_configure_tables(struct bridge *); > static void bridge_configure_dp_desc(struct bridge *); > @@ -989,6 +990,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch > *ovs_cfg) > bridge_configure_netflow(br); > bridge_configure_sflow(br, _bridge_number); > bridge_configure_ipfix(br); > +bridge_configure_lsample(br); > bridge_configure_spanning_tree(br); > bridge_configure_tables(br); > bridge_configure_dp_desc(br); > @@ -1537,10 +1539,11 @@ ovsrec_ipfix_is_valid(const struct ovsrec_ipfix > *ipfix) > return ipfix && ipfix->n_targets > 0; > } > > -/* Returns whether a Flow_Sample_Collector_Set row is valid. */ > +/* Returns whether a Flow_Sample_Collector_Set row contains a valid IPFIX > + * configuration. */ > static bool > -ovsrec_fscs_is_valid(const struct ovsrec_flow_sample_collector_set *fscs, > - const struct bridge *br) > +ovsrec_fscs_is_valid_ipfix(const struct ovsrec_flow_sample_collector_set > *fscs, > + const struct bridge *br) > { > return ovsrec_ipfix_is_valid(fscs->ipfix) && fscs->bridge == br->cfg; > } > @@ -1558,7 +1561,7 @@ bridge_configure_ipfix(struct bridge *br) > const char *virtual_obs_id; > > OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH(fe_cfg, idl) { > -if (ovsrec_fscs_is_valid(fe_cfg, br)) { > +if (ovsrec_fscs_is_valid_ipfix(fe_cfg, br)) { > n_fe_opts++; > } > } > @@ -1621,7 +1624,7 @@ bridge_configure_ipfix(struct bridge *br) > fe_opts = xcalloc(n_fe_opts, sizeof *fe_opts); > opts = fe_opts; > OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH(fe_cfg, idl) { > -if (ovsrec_fscs_is_valid(fe_cfg, br)) { > +if (ovsrec_fscs_is_valid_ipfix(fe_cfg, br)) { > opts->collector_set_id = fe_cfg->id; > sset_init(>targets); > sset_add_array(>targets, fe_cfg->ipfix->targets, > @@ -1667,6 +1670,71 @@ bridge_configure_ipfix(struct bridge *br) > } > } > > +/* Returns whether a Flow_Sample_Collector_Set row contains a valid local > + * sampling configuration. */ > +static bool > +ovsrec_fscs_is_valid_local(const struct ovsrec_flow_sample_collector_set > *fscs, > + const struct bridge *br) > +{ > +return fscs->local_group_id && fscs->n_local_group_id == 1 && > + fscs->bridge == br->cfg; > +} > + > +/* Set local sample configuration on 'br'. */ > +static void > +bridge_configure_lsample(struct bridge *br) > +{ > +static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); > +const struct ovsrec_flow_sample_collector_set *fscs; > +struct ofproto_lsample_options *opts_array, *opts; > +size_t n_opts = 0; > +int ret; > + > +/* Iterate the Flow_Sample_Collector_Set table twice. > + * First to get the number of valid configuration entries, then to > process > + * each of them and build an array of options. */ > +OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH (fscs, idl) { > +if (ovsrec_fscs_is_valid_local(fscs, br)) { > +n_opts ++; Space is not needed. > +} > +} > + > +if (n_opts == 0) { > +ofproto_set_local_sample(br->ofproto, NULL, 0); > +
Re: [ovs-dev] [PATCH v1 05/13] vswitchd: Add local sampling to vswitchd schema.
On Tue, Jul 09, 2024 at 11:45:35AM GMT, Eelco Chaudron wrote: > On 7 Jul 2024, at 22:08, Adrian Moreno wrote: > > > Add as new column in the Flow_Sample_Collector_Set table named > > "local_group_id" which enables this feature. > > Small nit below, if fixed add my ACK to the next revision. > > //Eelco > > > Signed-off-by: Adrian Moreno > > --- > > NEWS | 4 ++ > > vswitchd/bridge.c | 78 +++--- > > vswitchd/vswitch.ovsschema | 9 - > > vswitchd/vswitch.xml | 40 +-- > > 4 files changed, 120 insertions(+), 11 deletions(-) > > > > diff --git a/NEWS b/NEWS > > index e0359b759..15faf9fc3 100644 > > --- a/NEWS > > +++ b/NEWS > > @@ -16,6 +16,10 @@ Post-v3.3.0 > > per interface 'options:dpdk-lsc-interrupt' to 'false'. > > - Python: > > * Added custom transaction support to the Idl via add_op(). > > + - Local sampling is introduced. It reuses the OpenFlow sample action and > > + allows samples to be emitted locally (instead of via IPFIX) in a > > + datapath-specific manner. The Linux kernel datapath is the first to > > + support this feature by using the new datapath "psample" action. > > > > > > v3.3.0 - 16 Feb 2024 > > diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c > > index 95a65fcdc..b7db681f3 100644 > > --- a/vswitchd/bridge.c > > +++ b/vswitchd/bridge.c > > @@ -288,6 +288,7 @@ static void bridge_configure_mac_table(struct bridge *); > > static void bridge_configure_mcast_snooping(struct bridge *); > > static void bridge_configure_sflow(struct bridge *, int > > *sflow_bridge_number); > > static void bridge_configure_ipfix(struct bridge *); > > +static void bridge_configure_lsample(struct bridge *); > > static void bridge_configure_spanning_tree(struct bridge *); > > static void bridge_configure_tables(struct bridge *); > > static void bridge_configure_dp_desc(struct bridge *); > > @@ -989,6 +990,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch > > *ovs_cfg) > > bridge_configure_netflow(br); > > bridge_configure_sflow(br, _bridge_number); > > bridge_configure_ipfix(br); > > +bridge_configure_lsample(br); > > bridge_configure_spanning_tree(br); > > bridge_configure_tables(br); > > bridge_configure_dp_desc(br); > > @@ -1537,10 +1539,11 @@ ovsrec_ipfix_is_valid(const struct ovsrec_ipfix > > *ipfix) > > return ipfix && ipfix->n_targets > 0; > > } > > > > -/* Returns whether a Flow_Sample_Collector_Set row is valid. */ > > +/* Returns whether a Flow_Sample_Collector_Set row contains a valid IPFIX > > + * configuration. */ > > static bool > > -ovsrec_fscs_is_valid(const struct ovsrec_flow_sample_collector_set *fscs, > > - const struct bridge *br) > > +ovsrec_fscs_is_valid_ipfix(const struct ovsrec_flow_sample_collector_set > > *fscs, > > + const struct bridge *br) > > { > > return ovsrec_ipfix_is_valid(fscs->ipfix) && fscs->bridge == br->cfg; > > } > > @@ -1558,7 +1561,7 @@ bridge_configure_ipfix(struct bridge *br) > > const char *virtual_obs_id; > > > > OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH(fe_cfg, idl) { > > -if (ovsrec_fscs_is_valid(fe_cfg, br)) { > > +if (ovsrec_fscs_is_valid_ipfix(fe_cfg, br)) { > > n_fe_opts++; > > } > > } > > @@ -1621,7 +1624,7 @@ bridge_configure_ipfix(struct bridge *br) > > fe_opts = xcalloc(n_fe_opts, sizeof *fe_opts); > > opts = fe_opts; > > OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH(fe_cfg, idl) { > > -if (ovsrec_fscs_is_valid(fe_cfg, br)) { > > +if (ovsrec_fscs_is_valid_ipfix(fe_cfg, br)) { > > opts->collector_set_id = fe_cfg->id; > > sset_init(>targets); > > sset_add_array(>targets, fe_cfg->ipfix->targets, > > @@ -1667,6 +1670,71 @@ bridge_configure_ipfix(struct bridge *br) > > } > > } > > > > +/* Returns whether a Flow_Sample_Collector_Set row contains a valid local > > + * sampling configuration. */ > > +static bool > > +ovsrec_fscs_is_valid_local(const struct ovsrec_flow_sample_collector_set > > *fscs, > > + const struct bridge *br) > > +{ > > +return fscs->local_group_id && fscs->n_local_group_id == 1 && > > + fscs->bridge == br->cfg; > > +} > > + > > +/* Set local sample configuration on 'br'. */ > > +static void > > +bridge_configure_lsample(struct bridge *br) > > +{ > > +static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); > > +const struct ovsrec_flow_sample_collector_set *fscs; > > +struct ofproto_lsample_options *opts_array, *opts; > > +size_t n_opts = 0; > > +int ret; > > + > > +/* Iterate the Flow_Sample_Collector_Set table twice. > > + * First to get the number of valid configuration entries, then to > > process > > + * each of them and build an array of options.
Re: [ovs-dev] [PATCH v1 05/13] vswitchd: Add local sampling to vswitchd schema.
On 7 Jul 2024, at 22:08, Adrian Moreno wrote: > Add as new column in the Flow_Sample_Collector_Set table named > "local_group_id" which enables this feature. Small nit below, if fixed add my ACK to the next revision. //Eelco > Signed-off-by: Adrian Moreno > --- > NEWS | 4 ++ > vswitchd/bridge.c | 78 +++--- > vswitchd/vswitch.ovsschema | 9 - > vswitchd/vswitch.xml | 40 +-- > 4 files changed, 120 insertions(+), 11 deletions(-) > > diff --git a/NEWS b/NEWS > index e0359b759..15faf9fc3 100644 > --- a/NEWS > +++ b/NEWS > @@ -16,6 +16,10 @@ Post-v3.3.0 > per interface 'options:dpdk-lsc-interrupt' to 'false'. > - Python: > * Added custom transaction support to the Idl via add_op(). > + - Local sampling is introduced. It reuses the OpenFlow sample action and > + allows samples to be emitted locally (instead of via IPFIX) in a > + datapath-specific manner. The Linux kernel datapath is the first to > + support this feature by using the new datapath "psample" action. > > > v3.3.0 - 16 Feb 2024 > diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c > index 95a65fcdc..b7db681f3 100644 > --- a/vswitchd/bridge.c > +++ b/vswitchd/bridge.c > @@ -288,6 +288,7 @@ static void bridge_configure_mac_table(struct bridge *); > static void bridge_configure_mcast_snooping(struct bridge *); > static void bridge_configure_sflow(struct bridge *, int > *sflow_bridge_number); > static void bridge_configure_ipfix(struct bridge *); > +static void bridge_configure_lsample(struct bridge *); > static void bridge_configure_spanning_tree(struct bridge *); > static void bridge_configure_tables(struct bridge *); > static void bridge_configure_dp_desc(struct bridge *); > @@ -989,6 +990,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch > *ovs_cfg) > bridge_configure_netflow(br); > bridge_configure_sflow(br, _bridge_number); > bridge_configure_ipfix(br); > +bridge_configure_lsample(br); > bridge_configure_spanning_tree(br); > bridge_configure_tables(br); > bridge_configure_dp_desc(br); > @@ -1537,10 +1539,11 @@ ovsrec_ipfix_is_valid(const struct ovsrec_ipfix > *ipfix) > return ipfix && ipfix->n_targets > 0; > } > > -/* Returns whether a Flow_Sample_Collector_Set row is valid. */ > +/* Returns whether a Flow_Sample_Collector_Set row contains a valid IPFIX > + * configuration. */ > static bool > -ovsrec_fscs_is_valid(const struct ovsrec_flow_sample_collector_set *fscs, > - const struct bridge *br) > +ovsrec_fscs_is_valid_ipfix(const struct ovsrec_flow_sample_collector_set > *fscs, > + const struct bridge *br) > { > return ovsrec_ipfix_is_valid(fscs->ipfix) && fscs->bridge == br->cfg; > } > @@ -1558,7 +1561,7 @@ bridge_configure_ipfix(struct bridge *br) > const char *virtual_obs_id; > > OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH(fe_cfg, idl) { > -if (ovsrec_fscs_is_valid(fe_cfg, br)) { > +if (ovsrec_fscs_is_valid_ipfix(fe_cfg, br)) { > n_fe_opts++; > } > } > @@ -1621,7 +1624,7 @@ bridge_configure_ipfix(struct bridge *br) > fe_opts = xcalloc(n_fe_opts, sizeof *fe_opts); > opts = fe_opts; > OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH(fe_cfg, idl) { > -if (ovsrec_fscs_is_valid(fe_cfg, br)) { > +if (ovsrec_fscs_is_valid_ipfix(fe_cfg, br)) { > opts->collector_set_id = fe_cfg->id; > sset_init(>targets); > sset_add_array(>targets, fe_cfg->ipfix->targets, > @@ -1667,6 +1670,71 @@ bridge_configure_ipfix(struct bridge *br) > } > } > > +/* Returns whether a Flow_Sample_Collector_Set row contains a valid local > + * sampling configuration. */ > +static bool > +ovsrec_fscs_is_valid_local(const struct ovsrec_flow_sample_collector_set > *fscs, > + const struct bridge *br) > +{ > +return fscs->local_group_id && fscs->n_local_group_id == 1 && > + fscs->bridge == br->cfg; > +} > + > +/* Set local sample configuration on 'br'. */ > +static void > +bridge_configure_lsample(struct bridge *br) > +{ > +static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); > +const struct ovsrec_flow_sample_collector_set *fscs; > +struct ofproto_lsample_options *opts_array, *opts; > +size_t n_opts = 0; > +int ret; > + > +/* Iterate the Flow_Sample_Collector_Set table twice. > + * First to get the number of valid configuration entries, then to > process > + * each of them and build an array of options. */ > +OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH (fscs, idl) { > +if (ovsrec_fscs_is_valid_local(fscs, br)) { > +n_opts ++; > +} > +} > + > +if (n_opts == 0) { > +ofproto_set_local_sample(br->ofproto, NULL, 0); > +return; > +} > + > +
[ovs-dev] [PATCH v1 05/13] vswitchd: Add local sampling to vswitchd schema.
Add as new column in the Flow_Sample_Collector_Set table named "local_group_id" which enables this feature. Signed-off-by: Adrian Moreno --- NEWS | 4 ++ vswitchd/bridge.c | 78 +++--- vswitchd/vswitch.ovsschema | 9 - vswitchd/vswitch.xml | 40 +-- 4 files changed, 120 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index e0359b759..15faf9fc3 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,10 @@ Post-v3.3.0 per interface 'options:dpdk-lsc-interrupt' to 'false'. - Python: * Added custom transaction support to the Idl via add_op(). + - Local sampling is introduced. It reuses the OpenFlow sample action and + allows samples to be emitted locally (instead of via IPFIX) in a + datapath-specific manner. The Linux kernel datapath is the first to + support this feature by using the new datapath "psample" action. v3.3.0 - 16 Feb 2024 diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 95a65fcdc..b7db681f3 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -288,6 +288,7 @@ static void bridge_configure_mac_table(struct bridge *); static void bridge_configure_mcast_snooping(struct bridge *); static void bridge_configure_sflow(struct bridge *, int *sflow_bridge_number); static void bridge_configure_ipfix(struct bridge *); +static void bridge_configure_lsample(struct bridge *); static void bridge_configure_spanning_tree(struct bridge *); static void bridge_configure_tables(struct bridge *); static void bridge_configure_dp_desc(struct bridge *); @@ -989,6 +990,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg) bridge_configure_netflow(br); bridge_configure_sflow(br, _bridge_number); bridge_configure_ipfix(br); +bridge_configure_lsample(br); bridge_configure_spanning_tree(br); bridge_configure_tables(br); bridge_configure_dp_desc(br); @@ -1537,10 +1539,11 @@ ovsrec_ipfix_is_valid(const struct ovsrec_ipfix *ipfix) return ipfix && ipfix->n_targets > 0; } -/* Returns whether a Flow_Sample_Collector_Set row is valid. */ +/* Returns whether a Flow_Sample_Collector_Set row contains a valid IPFIX + * configuration. */ static bool -ovsrec_fscs_is_valid(const struct ovsrec_flow_sample_collector_set *fscs, - const struct bridge *br) +ovsrec_fscs_is_valid_ipfix(const struct ovsrec_flow_sample_collector_set *fscs, + const struct bridge *br) { return ovsrec_ipfix_is_valid(fscs->ipfix) && fscs->bridge == br->cfg; } @@ -1558,7 +1561,7 @@ bridge_configure_ipfix(struct bridge *br) const char *virtual_obs_id; OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH(fe_cfg, idl) { -if (ovsrec_fscs_is_valid(fe_cfg, br)) { +if (ovsrec_fscs_is_valid_ipfix(fe_cfg, br)) { n_fe_opts++; } } @@ -1621,7 +1624,7 @@ bridge_configure_ipfix(struct bridge *br) fe_opts = xcalloc(n_fe_opts, sizeof *fe_opts); opts = fe_opts; OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH(fe_cfg, idl) { -if (ovsrec_fscs_is_valid(fe_cfg, br)) { +if (ovsrec_fscs_is_valid_ipfix(fe_cfg, br)) { opts->collector_set_id = fe_cfg->id; sset_init(>targets); sset_add_array(>targets, fe_cfg->ipfix->targets, @@ -1667,6 +1670,71 @@ bridge_configure_ipfix(struct bridge *br) } } +/* Returns whether a Flow_Sample_Collector_Set row contains a valid local + * sampling configuration. */ +static bool +ovsrec_fscs_is_valid_local(const struct ovsrec_flow_sample_collector_set *fscs, + const struct bridge *br) +{ +return fscs->local_group_id && fscs->n_local_group_id == 1 && + fscs->bridge == br->cfg; +} + +/* Set local sample configuration on 'br'. */ +static void +bridge_configure_lsample(struct bridge *br) +{ +static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); +const struct ovsrec_flow_sample_collector_set *fscs; +struct ofproto_lsample_options *opts_array, *opts; +size_t n_opts = 0; +int ret; + +/* Iterate the Flow_Sample_Collector_Set table twice. + * First to get the number of valid configuration entries, then to process + * each of them and build an array of options. */ +OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH (fscs, idl) { +if (ovsrec_fscs_is_valid_local(fscs, br)) { +n_opts ++; +} +} + +if (n_opts == 0) { +ofproto_set_local_sample(br->ofproto, NULL, 0); +return; +} + +opts_array = xcalloc(n_opts, sizeof *opts_array); +opts = opts_array; + +OVSREC_FLOW_SAMPLE_COLLECTOR_SET_FOR_EACH (fscs, idl) { +if (!ovsrec_fscs_is_valid_local(fscs, br)) { +continue; +} +opts->collector_set_id = fscs->id; +opts->group_id = *fscs->local_group_id; +opts++; +} + +ret