Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check 'hostname' instead of 'hostname -s' in sethostname #20404

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tomvil
Copy link

@tomvil tomvil commented Oct 2, 2024

Why I did it

I noticed that /etc/hosts file is getting constantly filled with new records when dhclient is enabled.

root@test:~# cat /etc/hosts | wc -l
246

DHCP is providing FQDN, while we check only against short hostname and this will never match.

root@test:~# hostname
test.lab.com
root@test:~# hostname -s
test

And DHCP offer:

root@test:~# tcpdump -i eth0 -n -vv port 67 or port 68
tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
...
	    Hostname (12), length 30: "test.lab.com"
...

sethostname6 also uses hostname instead of hostname -s

Work item tracking
  • Microsoft ADO (number only):

How I did it

I changed current_host_name variable to be hostname value instead of hostname -s

How to verify it

  • Enable DHCP client on the switch
  • Receive offer with FQDN hostname option
  • Without this fix everytime new entry will be added to /etc/hosts
  • With this fix no new entry will be added

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305
  • 202405

Tested branch (Please provide the tested image version)

202405

Description for the changelog

Change current_host_name value to hostname instead of hostname -s in sethostname file

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@tomvil tomvil requested a review from lguohan as a code owner October 2, 2024 06:49
Copy link

linux-foundation-easycla bot commented Oct 2, 2024

CLA Signed


The committers listed above are authorized under a signed CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant