Skip to content

ospfd: remove unnecessary space - #21979

Merged
eqvinox merged 1 commit into
FRRouting:masterfrom
anlancs:fix/ospfd-redundant-white
May 19, 2026
Merged

ospfd: remove unnecessary space#21979
eqvinox merged 1 commit into
FRRouting:masterfrom
anlancs:fix/ospfd-redundant-white

Conversation

@anlancs

@anlancs anlancs commented May 19, 2026

Copy link
Copy Markdown
Contributor

Remove unnecessary spaces in config written with interface_config_auth_str().

Before:

interface enp1s0
 ip ospf authentication  1.2.3.4

After:

interface enp1s0
 ip ospf authentication 1.2.3.4

Also, remove trailing one from "area <> virtual-link <> authentication" in this same way.

Remove unnecessary spaces in config written with `interface_config_auth_str()`.

Before:
```
interface enp1s0
 ip ospf authentication  1.2.3.4
```

After:
```
interface enp1s0
 ip ospf authentication 1.2.3.4
```

Also, remove trailing one from "area <> virtual-link <> authentication"
in this same way.

Signed-off-by: anlan_cs <anlan_cs@126.com>
@greptile-apps

greptile-apps Bot commented May 19, 2026

Copy link
Copy Markdown

Greptile Summary

This PR removes a spurious trailing space in interface_config_auth_str() that was emitted when OSPF simple authentication is configured. The fix applies to both the ip ospf authentication interface config and the area <> virtual-link <> authentication config paths.

  • Root cause: OSPF_AUTH_SIMPLE wrote \" \" into the suffix buffer; since the caller's format string already ends with authentication, this produced a stale trailing space. Setting buf[0] = '\\0' instead yields the correct output.
  • Scope: Single switch-case change in one helper function; both callers guard buf usage behind if (ret), so the empty-string value is safe in all code paths.

Confidence Score: 5/5

Safe to merge β€” the change is a targeted one-line cosmetic fix with no functional side effects.

The fix is minimal and well-scoped: it corrects trailing whitespace in generated OSPF config for simple authentication. Both call sites guard on the return value before using the buffer, so the empty string is handled correctly. No logic is altered beyond the formatting of the emitted config line.

No files require special attention.

Important Files Changed

Filename Overview
ospfd/ospf_vty.c One-line fix in interface_config_auth_str(): replaces snprintf(buf, BUFSIZ, " ") with buf[0] = '\0' for OSPF_AUTH_SIMPLE, eliminating the extra space in generated config output.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[interface_config_auth_str] --> B{params->auth_type}
    B -->|OSPF_AUTH_NOTSET| C[return 0]
    B -->|OSPF_AUTH_NULL| D["buf = ' null'\nreturn 1"]
    B -->|OSPF_AUTH_SIMPLE| E["buf = '' βœ…\nreturn 1"]
    B -->|OSPF_AUTH_CRYPTOGRAPHIC| F["buf = ' message-digest'\nor ' key-chain NAME'\nreturn 1"]
    D --> G[Caller: 'ip ospf authentication null']
    E --> H[Caller: 'ip ospf authentication']
    F --> I[Caller: 'ip ospf authentication message-digest']
Loading

Reviews (1): Last reviewed commit: "ospfd: remove unnecessary space" | Re-trigger Greptile

@donaldsharp

Copy link
Copy Markdown
Member

I'll work on getting this through CI, LGTM

@ton31337

Copy link
Copy Markdown
Member

@Mergifyio backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2

@mergify

mergify Bot commented May 19, 2026

Copy link
Copy Markdown

backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2

βœ… Backports have been created

Details

@riw777 riw777 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@eqvinox
eqvinox merged commit 2c43029 into FRRouting:master May 19, 2026
36 of 37 checks passed
riw777 added a commit that referenced this pull request May 20, 2026
riw777 added a commit that referenced this pull request May 20, 2026
riw777 added a commit that referenced this pull request May 20, 2026
riw777 added a commit that referenced this pull request May 20, 2026
riw777 added a commit that referenced this pull request May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants