lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 12 Jun 2023 16:56:17 +0000
From: "Keller, Jacob E" <jacob.e.keller@...el.com>
To: Jakub Kicinski <kuba@...nel.org>, "davem@...emloft.net"
	<davem@...emloft.net>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>, "edumazet@...gle.com"
	<edumazet@...gle.com>, "pabeni@...hat.com" <pabeni@...hat.com>, "Kubalewski,
 Arkadiusz" <arkadiusz.kubalewski@...el.com>
Subject: RE: [PATCH net-next 2/2] tools: ynl-gen: inherit policy in multi-attr



> -----Original Message-----
> From: Jakub Kicinski <kuba@...nel.org>
> Sent: Monday, June 12, 2023 8:59 AM
> To: davem@...emloft.net
> Cc: netdev@...r.kernel.org; edumazet@...gle.com; pabeni@...hat.com;
> Kubalewski, Arkadiusz <arkadiusz.kubalewski@...el.com>; Jakub Kicinski
> <kuba@...nel.org>
> Subject: [PATCH net-next 2/2] tools: ynl-gen: inherit policy in multi-attr
> 
> Instead of reimplementing policies in MutliAttr for every
> underlying type forward the calls to the base type.
> This will be needed for DPLL which uses a multi-attr nest,
> and currently gets an invalid NLA_NEST policy generated.
> 
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>

Reviewed-by: Jacob Keller <Jacob.e.keller@...el.com>

> ---
>  tools/net/ynl/ynl-gen-c.py | 42 ++++++++++++++++++++++----------------
>  1 file changed, 24 insertions(+), 18 deletions(-)
> 
> diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
> index 54777d529f5e..71c5e79e877f 100755
> --- a/tools/net/ynl/ynl-gen-c.py
> +++ b/tools/net/ynl/ynl-gen-c.py
> @@ -462,6 +462,11 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr,
> SpecOperation, SpecEnumSet, S
> 
> 
>  class TypeMultiAttr(Type):
> +    def __init__(self, family, attr_set, attr, value, base_type):
> +        super().__init__(family, attr_set, attr, value)
> +
> +        self.base_type = base_type
> +
>      def is_multi_val(self):
>          return True
> 
> @@ -497,13 +502,11 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr,
> SpecOperation, SpecEnumSet, S
>          else:
>              raise Exception(f"Free of MultiAttr sub-type {self.attr['type']} not
> supported yet")
> 
> +    def _attr_policy(self, policy):
> +        return self.base_type._attr_policy(policy)
> +
>      def _attr_typol(self):
> -        if 'type' not in self.attr or self.attr['type'] == 'nest':
> -            return f'.type = YNL_PT_NEST, .nest = &{self.nested_render_name}_nest, '
> -        elif self.attr['type'] in scalars:
> -            return f".type = YNL_PT_U{self.attr['type'][1:]}, "
> -        else:
> -            raise Exception(f"Sub-type {self.attr['type']} not supported yet")
> +        return self.base_type._attr_typol()
> 
>      def _attr_get(self, ri, var):
>          return f'n_{self.c_name}++;', None, None
> @@ -717,29 +720,32 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr,
> SpecOperation, SpecEnumSet, S
>              self.c_name = ''
> 
>      def new_attr(self, elem, value):
> -        if 'multi-attr' in elem and elem['multi-attr']:
> -            return TypeMultiAttr(self.family, self, elem, value)
> -        elif elem['type'] in scalars:
> -            return TypeScalar(self.family, self, elem, value)
> +        if elem['type'] in scalars:
> +            t = TypeScalar(self.family, self, elem, value)
>          elif elem['type'] == 'unused':
> -            return TypeUnused(self.family, self, elem, value)
> +            t = TypeUnused(self.family, self, elem, value)
>          elif elem['type'] == 'pad':
> -            return TypePad(self.family, self, elem, value)
> +            t = TypePad(self.family, self, elem, value)
>          elif elem['type'] == 'flag':
> -            return TypeFlag(self.family, self, elem, value)
> +            t = TypeFlag(self.family, self, elem, value)
>          elif elem['type'] == 'string':
> -            return TypeString(self.family, self, elem, value)
> +            t = TypeString(self.family, self, elem, value)
>          elif elem['type'] == 'binary':
> -            return TypeBinary(self.family, self, elem, value)
> +            t = TypeBinary(self.family, self, elem, value)
>          elif elem['type'] == 'nest':
> -            return TypeNest(self.family, self, elem, value)
> +            t = TypeNest(self.family, self, elem, value)
>          elif elem['type'] == 'array-nest':
> -            return TypeArrayNest(self.family, self, elem, value)
> +            t = TypeArrayNest(self.family, self, elem, value)
>          elif elem['type'] == 'nest-type-value':
> -            return TypeNestTypeValue(self.family, self, elem, value)
> +            t = TypeNestTypeValue(self.family, self, elem, value)
>          else:
>              raise Exception(f"No typed class for type {elem['type']}")
> 
> +        if 'multi-attr' in elem and elem['multi-attr']:
> +            t = TypeMultiAttr(self.family, self, elem, value, t)
> +
> +        return t
> +
> 
>  class Operation(SpecOperation):
>      def __init__(self, family, yaml, req_value, rsp_value):
> --
> 2.40.1
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ