diff mbox series

[ovs-dev,v9,02/11] ovs-kmod-ctl: Load kernel module psample

Message ID 20201215033812.145975-3-cmi@nvidia.com
State Changes Requested
Headers show
Series Add offload support for sFlow | expand

Commit Message

Chris Mi Dec. 15, 2020, 3:38 a.m. UTC
Load kernel module psample to receive sampled packets from TC.
Before removing kernel module psample, remove act_sample first.

Signed-off-by: Chris Mi <cmi@nvidia.com>
Reviewed-by: Eli Britstein <elibr@nvidia.com>
---
 utilities/ovs-kmod-ctl.in | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Eelco Chaudron Jan. 12, 2021, 7:34 p.m. UTC | #1
On 15 Dec 2020, at 4:38, Chris Mi wrote:

> Load kernel module psample to receive sampled packets from TC.
> Before removing kernel module psample, remove act_sample first.
>
> Signed-off-by: Chris Mi <cmi@nvidia.com>
> Reviewed-by: Eli Britstein <elibr@nvidia.com>
> ---
>  utilities/ovs-kmod-ctl.in | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/utilities/ovs-kmod-ctl.in b/utilities/ovs-kmod-ctl.in
> index 19f100964..6fa945a83 100644
> --- a/utilities/ovs-kmod-ctl.in
> +++ b/utilities/ovs-kmod-ctl.in
> @@ -28,6 +28,14 @@ for dir in "$sbindir" "$bindir" /sbin /bin 
> /usr/sbin /usr/bin; do
>  done
>
>  insert_mods () {
> +    # Try loading psample kernel module.
> +    modinfo psample > /dev/null 2>&1
> +    if test $? = 0; then
> +        action "Inserting psample module" modprobe psample
> +    else
> +        log_warning_msg "No psample module, can't offload sFlow 
> action"
> +    fi
> +

I don't think we need to load psample here, it will be automatically 
loaded if we add the sample action. Same as for vxlan, gre, etc., etc.

>      # Try loading openvswitch kernel module.
>      action "Inserting openvswitch module" modprobe openvswitch
>  }
> @@ -95,6 +103,12 @@ remove_kmods() {
>      if test -e /sys/module/vxlan; then
>          action "Forcing removal of vxlan module" rmmod vxlan
>      fi
> +    if test -e /sys/module/act_sample; then
> +        action "Forcing removal of act_sample module" rmmod 
> act_sample
> +    fi
> +    if test -e /sys/module/psample; then
> +        action "Forcing removal of psample module" rmmod psample
> +    fi
>  }
>
>  usage () {
> -- 
> 2.26.2
Chris Mi Jan. 13, 2021, 1:37 a.m. UTC | #2
On 1/13/2021 3:34 AM, Eelco Chaudron wrote:
>
>
> On 15 Dec 2020, at 4:38, Chris Mi wrote:
>
>> Load kernel module psample to receive sampled packets from TC.
>> Before removing kernel module psample, remove act_sample first.
>>
>> Signed-off-by: Chris Mi <cmi@nvidia.com>
>> Reviewed-by: Eli Britstein <elibr@nvidia.com>
>> ---
>>  utilities/ovs-kmod-ctl.in | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/utilities/ovs-kmod-ctl.in b/utilities/ovs-kmod-ctl.in
>> index 19f100964..6fa945a83 100644
>> --- a/utilities/ovs-kmod-ctl.in
>> +++ b/utilities/ovs-kmod-ctl.in
>> @@ -28,6 +28,14 @@ for dir in "$sbindir" "$bindir" /sbin /bin 
>> /usr/sbin /usr/bin; do
>>  done
>>
>>  insert_mods () {
>> +    # Try loading psample kernel module.
>> +    modinfo psample > /dev/null 2>&1
>> +    if test $? = 0; then
>> +        action "Inserting psample module" modprobe psample
>> +    else
>> +        log_warning_msg "No psample module, can't offload sFlow action"
>> +    fi
>> +
>
> I don't think we need to load psample here, it will be automatically 
> loaded if we add the sample action. Same as for vxlan, gre, etc., etc.
Actually it's a little different. We need to initialize the psample 
netlink family and multicast group
when starting ovs daemon. If psample module is not loaded, we'll fail to 
initialize them.
>
>>      # Try loading openvswitch kernel module.
>>      action "Inserting openvswitch module" modprobe openvswitch
>>  }
>> @@ -95,6 +103,12 @@ remove_kmods() {
>>      if test -e /sys/module/vxlan; then
>>          action "Forcing removal of vxlan module" rmmod vxlan
>>      fi
>> +    if test -e /sys/module/act_sample; then
>> +        action "Forcing removal of act_sample module" rmmod act_sample
>> +    fi
>> +    if test -e /sys/module/psample; then
>> +        action "Forcing removal of psample module" rmmod psample
>> +    fi
>>  }
>>
>>  usage () {
>> -- 
>> 2.26.2
>
Eelco Chaudron Jan. 13, 2021, 10:29 a.m. UTC | #3
On 13 Jan 2021, at 2:37, Chris Mi wrote:

> On 1/13/2021 3:34 AM, Eelco Chaudron wrote:
>>
>>
>> On 15 Dec 2020, at 4:38, Chris Mi wrote:
>>
>>> Load kernel module psample to receive sampled packets from TC.
>>> Before removing kernel module psample, remove act_sample first.
>>>
>>> Signed-off-by: Chris Mi <cmi@nvidia.com>
>>> Reviewed-by: Eli Britstein <elibr@nvidia.com>
>>> ---
>>>  utilities/ovs-kmod-ctl.in | 14 ++++++++++++++
>>>  1 file changed, 14 insertions(+)
>>>
>>> diff --git a/utilities/ovs-kmod-ctl.in b/utilities/ovs-kmod-ctl.in
>>> index 19f100964..6fa945a83 100644
>>> --- a/utilities/ovs-kmod-ctl.in
>>> +++ b/utilities/ovs-kmod-ctl.in
>>> @@ -28,6 +28,14 @@ for dir in "$sbindir" "$bindir" /sbin /bin 
>>> /usr/sbin /usr/bin; do
>>>  done
>>>
>>>  insert_mods () {
>>> +    # Try loading psample kernel module.
>>> +    modinfo psample > /dev/null 2>&1
>>> +    if test $? = 0; then
>>> +        action "Inserting psample module" modprobe psample
>>> +    else
>>> +        log_warning_msg "No psample module, can't offload 
>>> sFlow action"
>>> +    fi
>>> +
>>
>> I don't think we need to load psample here, it will be automatically 
>> loaded if we add the sample action. Same as for vxlan, gre, etc., 
>> etc.

> Actually it's a little different. We need to initialize the psample 
> netlink family and multicast group
> when starting ovs daemon. If psample module is not loaded, we'll fail 
> to initialize them.

You are right something was wrong with my setup causing it to load 
through a different way…
I did a bit more experimenting, and this patch is needed and looks fine, 
so

Acked-by: Eelco Chaudron <echaudro@redhat.com>
diff mbox series

Patch

diff --git a/utilities/ovs-kmod-ctl.in b/utilities/ovs-kmod-ctl.in
index 19f100964..6fa945a83 100644
--- a/utilities/ovs-kmod-ctl.in
+++ b/utilities/ovs-kmod-ctl.in
@@ -28,6 +28,14 @@  for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
 done
 
 insert_mods () {
+    # Try loading psample kernel module.
+    modinfo psample > /dev/null 2>&1
+    if test $? = 0; then
+        action "Inserting psample module" modprobe psample
+    else
+        log_warning_msg "No psample module, can't offload sFlow action"
+    fi
+
     # Try loading openvswitch kernel module.
     action "Inserting openvswitch module" modprobe openvswitch
 }
@@ -95,6 +103,12 @@  remove_kmods() {
     if test -e /sys/module/vxlan; then
         action "Forcing removal of vxlan module" rmmod vxlan
     fi
+    if test -e /sys/module/act_sample; then
+        action "Forcing removal of act_sample module" rmmod act_sample
+    fi
+    if test -e /sys/module/psample; then
+        action "Forcing removal of psample module" rmmod psample
+    fi
 }
 
 usage () {