Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2101493

Summary: keepalived doesn't correctly handle variable substitution in conditional lines
Product: Red Hat Enterprise Linux 9 Reporter: Phil Randal <phil.randal>
Component: keepalivedAssignee: Ryan O'Hara <rohara>
Status: CLOSED ERRATA QA Contact: Juraj Hrdlica <jhrdlica>
Severity: low Docs Contact:
Priority: unspecified    
Version: 9.0CC: bperkins, cfeist, cluster-maint, jhrdlica
Target Milestone: rcKeywords: Triaged
Target Release: 9.2Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: keepalived-2.2.4-4.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 07:46:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Phil Randal 2022-06-27 15:34:41 UTC
Description of problem:

man keepalived.conf clearly states

"
           $IF_MAIN=@main
           $IF_MAIN priority 240

           will produce:
               priority 240
               if the config_id is main and nothing if the config_id is not main,
               although why anyone would want to use this rather than simply the
               following is not known (but still possible):
                   @main priority 240

"

Yet this does not work correctly under all circumstances.

Version-Release number of selected component (if applicable):

2.2.4 (also affects 2.1.5)

How reproducible:

Consistently reproducible on RHEL 8.6 and 9.0

Steps to Reproduce:
1.

set the following in keepalived.conf

$PRI=@my-server-id

$PRI priority 240

on expansion will produce garbled output


Actual results:

journalctl -xe shows in the log:

Unknown keyword 'priorixxxx' where xxxx is trailing part of host name.

Expected results:

For priority to be set

Additional info:

The reason is that after the variable value substitution, the line-length is not recalculated.

Fix is to apply the following patch

I've recalculated the buffer length at the head of the loop for obvious correctness and resilience in the case of future code changes

--- a/lib/parser.c 2022-06-27 08:58:01.163365991 +0100
+++ b/lib/parser.c 2022-06-27 09:05:08.456532867 +0100
@@ -2735,7 +2735,8 @@

                do {
                        recheck = false;
-                       if (buf[0] == '@') {
+                       len = strlen(buf);
+                       if (buf[0] == '@') {
                                /* If the line starts '@', check the following word matches the system id.
                                   @^ reverses the sense of the match */
                                if (buf[1] == '^') {

Comment 1 Phil Randal 2022-06-27 15:41:23 UTC
Also raised as an issue against keeplived on Github:

https://github.com/acassen/keepalived/issues/2148

Comment 2 Ryan O'Hara 2022-07-07 14:41:10 UTC
It appears the updated patch is here:

https://github.com/acassen/keepalived/commit/2a7950a375458d588b0252d4b6d63b3680bf9f1b

Comment 10 Juraj Hrdlica 2023-02-27 13:26:37 UTC
Tested for keepalived-2.2.4-6.el9.x86_64

keepalived.conf:
vrrp_instance VI_1 {
    $PRI=@my-server-id
    $PRI priority 240
    ...

Running journalctl does not show any errors.
Keepalived parses conf file properly and works as expected.

Comment 13 errata-xmlrpc 2023-05-09 07:46:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (keepalived bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2335