Skip to content

Commit ec8c257

Browse files
ordexkuba-moo
authored andcommitted
ynl: ensure exact-len value is resolved
For type String and Binary we are currently usinig the exact-len limit value as is without attempting any name resolution. However, the spec may specify the name of a constant rather than an actual value, which would result in using the constant name as is and thus break the policy. Ensure the limit value is passed to get_limit(), which will always attempt resolving the name before printing the policy rule. Signed-off-by: Antonio Quartulli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e5a2802 commit ec8c257

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/net/ynl/ynl-gen-c.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def _attr_typol(self):
413413

414414
def _attr_policy(self, policy):
415415
if 'exact-len' in self.checks:
416-
mem = 'NLA_POLICY_EXACT_LEN(' + str(self.checks['exact-len']) + ')'
416+
mem = 'NLA_POLICY_EXACT_LEN(' + str(self.get_limit('exact-len')) + ')'
417417
else:
418418
mem = '{ .type = ' + policy
419419
if 'max-len' in self.checks:
@@ -465,7 +465,7 @@ def _attr_typol(self):
465465

466466
def _attr_policy(self, policy):
467467
if 'exact-len' in self.checks:
468-
mem = 'NLA_POLICY_EXACT_LEN(' + str(self.checks['exact-len']) + ')'
468+
mem = 'NLA_POLICY_EXACT_LEN(' + str(self.get_limit('exact-len')) + ')'
469469
else:
470470
mem = '{ '
471471
if len(self.checks) == 1 and 'min-len' in self.checks:

0 commit comments

Comments
 (0)