mbox series

[ovs-dev,v27,0/8] Add offload support for sFlow

Message ID 20230601111658.113144-1-cmi@nvidia.com
Headers show
Series Add offload support for sFlow | expand

Message

Chris Mi June 1, 2023, 11:16 a.m. UTC
This patch set adds offload support for sFlow.

Psample is a genetlink channel for packet sampling. TC action act_sample
uses psample to send sampled packets to userspace.

When offloading sample action to TC, userspace creates a unique ID to
map sFlow action and tunnel info and passes this ID to kernel instead
of the sFlow info. psample will send this ID and sampled packet to
userspace. Using the ID, userspace can recover the sFlow info and send
sampled packet to the right sFlow monitoring host.

v2-v1:
- Fix robot errors.
v3-v2:
- Remove Gerrit Change-Id.
- Add patch #9 to fix older kernels build issue.
- Add travis test result.
v4-v3:
- Fix offload issue when sampling rate is 1.
v5-v4:
- Move polling thread from ofproto to netdev-offload-tc.
v6-v5:
- Rebase.
- Add GitHub Actions test result.
v7-v6:
- Remove Gerrit Change-Id.
- Fix "ERROR: Inappropriate spacing around cast"
v8-v7
- Address Eelco Chaudron's comment for patch #11.
v9-v8
- Remove sflow_len from struct dpif_sflow_attr.
- Log a debug message for other userspace actions.
v10-v9
- Address Eelco Chaudron's comments on v9.
v11-v10
- Fix a bracing error.
v12-v11
- Add duplicate sample group id check.
v13-v12
- Remove the psample poll thread from netdev-offload-tc and reuse
  ofproto handler thread according to Ilya's new desgin.
- Add dpif-offload-provider layer according to Eli's suggestion.
v14-v13
- Fix a robot error.
v15-v14
- Address Eelco Chaudron's comments on v14.
v16-v15
- Address Eelco Chaudron's comments on v15.
- Add two test cases.
v17-v16
- Address Eelco Chaudron's comments on v16.
- Move struct dpif_offload_api from struct dpif_class to struct dpif.
v18-v17
- Rename dpif_offload_api to dpif_offload_class.
- Add init and destroy callbacks in dpif_offload_class. They are called
  when registering dpif_offload_class.
v19-18
- Fix a bug that psample_sock is destroyed when last bridge is deleted.
v20-19
- Move buf_stub to struct dpif_offload_sflow avoid garbage values when
  ofproto proceses the sampled packet.
v21-20
- Remove netdev dummy for dpif-offload according to Eelco's comment.
v22-21
- Address Ilya's comments:
 - Remove dpif-offload-provider layer.
 - Remove process_offload_sflow and reuse upcall_receive.
 - Introduce sample id pool.
 - Introduce netdev_offload_recv.
v23-22
- Address Ilya's comments:
 - Add struct flow in struct dpif_upcall.
 - Add handler id in recv() and recv_wait().
 - misc changes.
v24-23
- Fix checkpath and actions errors.
v25-24
- Address Eelco's comments:
 - Add tunnel test.
 - Change sample group id and sample info to 1:1 mapping.
 - Move sample group id from tcf_id to ufid_to_tc_data.
 - misc changes.
v26-25
- Address Eelco's comments:
 - Rename actions to userspace_actions.
 - Add in tunnel test.
v27-26
- Address Eelco's comments:
 - Introduce nullable_xmemdup() and flow_tnl_copy().
 - Improve sgid node locking.
 - Improve comments and documents.
 - Add support for multiple sgids.
 - Improve test cases.
 - misc changes.

Chris Mi (8):
  compat: Add psample and tc sample action defines for older kernels
  ovs-kmod-ctl: Load kernel module psample
  netdev-offload-tc: Introduce group ID management API
  netdev-offload-tc: Add sample offload API for TC
  netdev-offload: Add netdev offload recv and recv_wait APIs
  dpif-netlink: Add netdev offload recv in normal recv upcalls
  netdev-offload-tc: Add offload support for sFlow
  system-offloads-traffic.at: Add sFlow offload test cases

 Documentation/howto/tc-offload.rst |  24 ++
 include/linux/automake.mk          |  10 +-
 include/linux/psample.h            |  62 +++
 include/linux/tc_act/tc_sample.h   |  25 ++
 lib/dpif-netlink.c                 |  41 +-
 lib/dpif.h                         |   6 +-
 lib/flow.h                         |   2 +-
 lib/netdev-offload-provider.h      |  30 ++
 lib/netdev-offload-tc.c            | 602 +++++++++++++++++++++++++++--
 lib/netdev-offload.c               |  41 +-
 lib/netdev-offload.h               |   5 +
 lib/packets.h                      |   2 +-
 lib/tc.c                           |  63 ++-
 lib/tc.h                           |   6 +
 lib/util.c                         |   6 +
 lib/util.h                         |   1 +
 ofproto/ofproto-dpif-upcall.c      |  15 +-
 tests/system-offloads-traffic.at   | 152 ++++++++
 utilities/ovs-kmod-ctl.in          |  14 +
 19 files changed, 1062 insertions(+), 45 deletions(-)
 create mode 100644 include/linux/psample.h
 create mode 100644 include/linux/tc_act/tc_sample.h

Comments

Eelco Chaudron June 16, 2023, 2:24 p.m. UTC | #1
On 1 Jun 2023, at 13:16, Chris Mi wrote:

> This patch set adds offload support for sFlow.
>
> Psample is a genetlink channel for packet sampling. TC action act_sample
> uses psample to send sampled packets to userspace.
>
> When offloading sample action to TC, userspace creates a unique ID to
> map sFlow action and tunnel info and passes this ID to kernel instead
> of the sFlow info. psample will send this ID and sampled packet to
> userspace. Using the ID, userspace can recover the sFlow info and send
> sampled packet to the right sFlow monitoring host.

Hi Chris,

I’m done reviewing the v27. And I have some comments on patches 3, 7, and 8, but to speed things up, I’ve included a full diff of the required changes. If you agree, just apply them and send a v28.

Cheers,

Eelco

> v2-v1:
> - Fix robot errors.
> v3-v2:
> - Remove Gerrit Change-Id.
> - Add patch #9 to fix older kernels build issue.
> - Add travis test result.
> v4-v3:
> - Fix offload issue when sampling rate is 1.
> v5-v4:
> - Move polling thread from ofproto to netdev-offload-tc.
> v6-v5:
> - Rebase.
> - Add GitHub Actions test result.
> v7-v6:
> - Remove Gerrit Change-Id.
> - Fix "ERROR: Inappropriate spacing around cast"
> v8-v7
> - Address Eelco Chaudron's comment for patch #11.
> v9-v8
> - Remove sflow_len from struct dpif_sflow_attr.
> - Log a debug message for other userspace actions.
> v10-v9
> - Address Eelco Chaudron's comments on v9.
> v11-v10
> - Fix a bracing error.
> v12-v11
> - Add duplicate sample group id check.
> v13-v12
> - Remove the psample poll thread from netdev-offload-tc and reuse
>   ofproto handler thread according to Ilya's new desgin.
> - Add dpif-offload-provider layer according to Eli's suggestion.
> v14-v13
> - Fix a robot error.
> v15-v14
> - Address Eelco Chaudron's comments on v14.
> v16-v15
> - Address Eelco Chaudron's comments on v15.
> - Add two test cases.
> v17-v16
> - Address Eelco Chaudron's comments on v16.
> - Move struct dpif_offload_api from struct dpif_class to struct dpif.
> v18-v17
> - Rename dpif_offload_api to dpif_offload_class.
> - Add init and destroy callbacks in dpif_offload_class. They are called
>   when registering dpif_offload_class.
> v19-18
> - Fix a bug that psample_sock is destroyed when last bridge is deleted.
> v20-19
> - Move buf_stub to struct dpif_offload_sflow avoid garbage values when
>   ofproto proceses the sampled packet.
> v21-20
> - Remove netdev dummy for dpif-offload according to Eelco's comment.
> v22-21
> - Address Ilya's comments:
>  - Remove dpif-offload-provider layer.
>  - Remove process_offload_sflow and reuse upcall_receive.
>  - Introduce sample id pool.
>  - Introduce netdev_offload_recv.
> v23-22
> - Address Ilya's comments:
>  - Add struct flow in struct dpif_upcall.
>  - Add handler id in recv() and recv_wait().
>  - misc changes.
> v24-23
> - Fix checkpath and actions errors.
> v25-24
> - Address Eelco's comments:
>  - Add tunnel test.
>  - Change sample group id and sample info to 1:1 mapping.
>  - Move sample group id from tcf_id to ufid_to_tc_data.
>  - misc changes.
> v26-25
> - Address Eelco's comments:
>  - Rename actions to userspace_actions.
>  - Add in tunnel test.
> v27-26
> - Address Eelco's comments:
>  - Introduce nullable_xmemdup() and flow_tnl_copy().
>  - Improve sgid node locking.
>  - Improve comments and documents.
>  - Add support for multiple sgids.
>  - Improve test cases.
>  - misc changes.
>
> Chris Mi (8):
>   compat: Add psample and tc sample action defines for older kernels
>   ovs-kmod-ctl: Load kernel module psample
>   netdev-offload-tc: Introduce group ID management API
>   netdev-offload-tc: Add sample offload API for TC
>   netdev-offload: Add netdev offload recv and recv_wait APIs
>   dpif-netlink: Add netdev offload recv in normal recv upcalls
>   netdev-offload-tc: Add offload support for sFlow
>   system-offloads-traffic.at: Add sFlow offload test cases
>
>  Documentation/howto/tc-offload.rst |  24 ++
>  include/linux/automake.mk          |  10 +-
>  include/linux/psample.h            |  62 +++
>  include/linux/tc_act/tc_sample.h   |  25 ++
>  lib/dpif-netlink.c                 |  41 +-
>  lib/dpif.h                         |   6 +-
>  lib/flow.h                         |   2 +-
>  lib/netdev-offload-provider.h      |  30 ++
>  lib/netdev-offload-tc.c            | 602 +++++++++++++++++++++++++++--
>  lib/netdev-offload.c               |  41 +-
>  lib/netdev-offload.h               |   5 +
>  lib/packets.h                      |   2 +-
>  lib/tc.c                           |  63 ++-
>  lib/tc.h                           |   6 +
>  lib/util.c                         |   6 +
>  lib/util.h                         |   1 +
>  ofproto/ofproto-dpif-upcall.c      |  15 +-
>  tests/system-offloads-traffic.at   | 152 ++++++++
>  utilities/ovs-kmod-ctl.in          |  14 +
>  19 files changed, 1062 insertions(+), 45 deletions(-)
>  create mode 100644 include/linux/psample.h
>  create mode 100644 include/linux/tc_act/tc_sample.h
>
> -- 
> 2.26.3
Chris Mi June 19, 2023, 4:59 a.m. UTC | #2
On 6/16/2023 10:24 PM, Eelco Chaudron wrote:
>
> On 1 Jun 2023, at 13:16, Chris Mi wrote:
>
>> This patch set adds offload support for sFlow.
>>
>> Psample is a genetlink channel for packet sampling. TC action act_sample
>> uses psample to send sampled packets to userspace.
>>
>> When offloading sample action to TC, userspace creates a unique ID to
>> map sFlow action and tunnel info and passes this ID to kernel instead
>> of the sFlow info. psample will send this ID and sampled packet to
>> userspace. Using the ID, userspace can recover the sFlow info and send
>> sampled packet to the right sFlow monitoring host.
> Hi Chris,
>
> I’m done reviewing the v27. And I have some comments on patches 3, 7, and 8, but to speed things up, I’ve included a full diff of the required changes. If you agree, just apply them and send a v28.
Hi Eelco,

All diffs are applied successfully. And 3 test cases passed. Thanks a 
lot. I'll send v28.

Thanks,
Chris
>
> Cheers,
>
> Eelco
>
>> v2-v1:
>> - Fix robot errors.
>> v3-v2:
>> - Remove Gerrit Change-Id.
>> - Add patch #9 to fix older kernels build issue.
>> - Add travis test result.
>> v4-v3:
>> - Fix offload issue when sampling rate is 1.
>> v5-v4:
>> - Move polling thread from ofproto to netdev-offload-tc.
>> v6-v5:
>> - Rebase.
>> - Add GitHub Actions test result.
>> v7-v6:
>> - Remove Gerrit Change-Id.
>> - Fix "ERROR: Inappropriate spacing around cast"
>> v8-v7
>> - Address Eelco Chaudron's comment for patch #11.
>> v9-v8
>> - Remove sflow_len from struct dpif_sflow_attr.
>> - Log a debug message for other userspace actions.
>> v10-v9
>> - Address Eelco Chaudron's comments on v9.
>> v11-v10
>> - Fix a bracing error.
>> v12-v11
>> - Add duplicate sample group id check.
>> v13-v12
>> - Remove the psample poll thread from netdev-offload-tc and reuse
>>    ofproto handler thread according to Ilya's new desgin.
>> - Add dpif-offload-provider layer according to Eli's suggestion.
>> v14-v13
>> - Fix a robot error.
>> v15-v14
>> - Address Eelco Chaudron's comments on v14.
>> v16-v15
>> - Address Eelco Chaudron's comments on v15.
>> - Add two test cases.
>> v17-v16
>> - Address Eelco Chaudron's comments on v16.
>> - Move struct dpif_offload_api from struct dpif_class to struct dpif.
>> v18-v17
>> - Rename dpif_offload_api to dpif_offload_class.
>> - Add init and destroy callbacks in dpif_offload_class. They are called
>>    when registering dpif_offload_class.
>> v19-18
>> - Fix a bug that psample_sock is destroyed when last bridge is deleted.
>> v20-19
>> - Move buf_stub to struct dpif_offload_sflow avoid garbage values when
>>    ofproto proceses the sampled packet.
>> v21-20
>> - Remove netdev dummy for dpif-offload according to Eelco's comment.
>> v22-21
>> - Address Ilya's comments:
>>   - Remove dpif-offload-provider layer.
>>   - Remove process_offload_sflow and reuse upcall_receive.
>>   - Introduce sample id pool.
>>   - Introduce netdev_offload_recv.
>> v23-22
>> - Address Ilya's comments:
>>   - Add struct flow in struct dpif_upcall.
>>   - Add handler id in recv() and recv_wait().
>>   - misc changes.
>> v24-23
>> - Fix checkpath and actions errors.
>> v25-24
>> - Address Eelco's comments:
>>   - Add tunnel test.
>>   - Change sample group id and sample info to 1:1 mapping.
>>   - Move sample group id from tcf_id to ufid_to_tc_data.
>>   - misc changes.
>> v26-25
>> - Address Eelco's comments:
>>   - Rename actions to userspace_actions.
>>   - Add in tunnel test.
>> v27-26
>> - Address Eelco's comments:
>>   - Introduce nullable_xmemdup() and flow_tnl_copy().
>>   - Improve sgid node locking.
>>   - Improve comments and documents.
>>   - Add support for multiple sgids.
>>   - Improve test cases.
>>   - misc changes.
>>
>> Chris Mi (8):
>>    compat: Add psample and tc sample action defines for older kernels
>>    ovs-kmod-ctl: Load kernel module psample
>>    netdev-offload-tc: Introduce group ID management API
>>    netdev-offload-tc: Add sample offload API for TC
>>    netdev-offload: Add netdev offload recv and recv_wait APIs
>>    dpif-netlink: Add netdev offload recv in normal recv upcalls
>>    netdev-offload-tc: Add offload support for sFlow
>>    system-offloads-traffic.at: Add sFlow offload test cases
>>
>>   Documentation/howto/tc-offload.rst |  24 ++
>>   include/linux/automake.mk          |  10 +-
>>   include/linux/psample.h            |  62 +++
>>   include/linux/tc_act/tc_sample.h   |  25 ++
>>   lib/dpif-netlink.c                 |  41 +-
>>   lib/dpif.h                         |   6 +-
>>   lib/flow.h                         |   2 +-
>>   lib/netdev-offload-provider.h      |  30 ++
>>   lib/netdev-offload-tc.c            | 602 +++++++++++++++++++++++++++--
>>   lib/netdev-offload.c               |  41 +-
>>   lib/netdev-offload.h               |   5 +
>>   lib/packets.h                      |   2 +-
>>   lib/tc.c                           |  63 ++-
>>   lib/tc.h                           |   6 +
>>   lib/util.c                         |   6 +
>>   lib/util.h                         |   1 +
>>   ofproto/ofproto-dpif-upcall.c      |  15 +-
>>   tests/system-offloads-traffic.at   | 152 ++++++++
>>   utilities/ovs-kmod-ctl.in          |  14 +
>>   19 files changed, 1062 insertions(+), 45 deletions(-)
>>   create mode 100644 include/linux/psample.h
>>   create mode 100644 include/linux/tc_act/tc_sample.h
>>
>> -- 
>> 2.26.3