Upstream commit:
    commit 8039371847174ff37dc3d02e83cd789dbb6140b0
    Author: Michael Weiß <[email protected]>
    Date:   Fri Sep 23 15:38:19 2022 +0200

    net: openvswitch: allow metering in non-initial user namespace

    The Netlink interface for metering was restricted to global CAP_NET_ADMIN
    by using GENL_ADMIN_PERM. To allow metring in a non-inital user namespace,
    e.g., a container, this is changed to GENL_UNS_ADMIN_PERM.

    Signed-off-by: Michael Weiß <[email protected]>
    Signed-off-by: Paolo Abeni <[email protected]>

Signed-off-by: Michael Weiß <[email protected]>
---
 datapath/meter.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/datapath/meter.c b/datapath/meter.c
index 92c9c3671..000c794f6 100644
--- a/datapath/meter.c
+++ b/datapath/meter.c
@@ -218,7 +218,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
                        return ERR_PTR(-EINVAL);
 
        /* Allocate and set up the meter before locking anything. */
-       meter = kzalloc(struct_size(meter, bands, n_bands), GFP_KERNEL);
+       meter = kzalloc(struct_size(meter, bands, n_bands), GFP_KERNEL_ACCOUNT);
        if (!meter)
                return ERR_PTR(-ENOMEM);
 
@@ -553,9 +553,9 @@ static struct genl_ops dp_meter_genl_ops[] = {
 #ifdef HAVE_GENL_VALIDATE_FLAGS
                .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
-               .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN
-                                          *  privilege.
-                                          */
+               .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN
+                                              *  privilege.
+                                              */
 #ifdef HAVE_GENL_OPS_POLICY
                .policy = meter_policy,
 #endif
@@ -575,9 +575,9 @@ static struct genl_ops dp_meter_genl_ops[] = {
 #ifdef HAVE_GENL_VALIDATE_FLAGS
                .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
 #endif
-               .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN
-                                          *  privilege.
-                                          */
+               .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN
+                                              *  privilege.
+                                              */
 #ifdef HAVE_GENL_OPS_POLICY
                .policy = meter_policy,
 #endif
-- 
2.30.2

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to