Issue
What were you trying to do that didn't work?
When configuring tftp socket to bind on an IPv4 address and IPv6 is disabled through sysctl settings, the following error message is seen:
[...] in.tftpd[11511]: cannot setsockopt IPV6_RECVPKTINFO Protocol not available
This is harmless but annoying.
Digging into the code, it looks like to me the code is broken:
95 static union sock_addr from;
:
356 int main(int argc, char **argv)
357 {
:
894
fromlen = sizeof(from);
895
n = myrecvfrom(fd, buf, sizeof(buf), 0,
896
(struct sockaddr *)&from, &fromlen, &myaddr);
:
---
117 int
118 myrecvfrom(int s, void *buf, int len, unsigned int flags,
119
struct sockaddr *from, socklen_t * fromlen,
120
union sock_addr *myaddr)
121 {
:
162 #ifdef HAVE_IPV6
163 #ifdef IPV6_RECVPKTINFO
164
if (from->sa_family == AF_INET6 || !from->sa_family)
165
if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on)) == -1)
166
syslog(LOG_ERR, "cannot setsockopt IPV6_RECVPKTINFO %m");
167 #endif
168 #endif
Here above the myrecvfrom() function is always called with from->sa_family being 0 because it's zero-initialized memory (line 95) which never got modified at the time the function gets called (line 895 in main() function).
Please provide the package NVR for which bug is seen:
tftp-server-5.2-37.el9.x86_64
How reproducible:
Always
Steps to reproduce
Disable IPv6 in /etc/sysctl.conf and reboot
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Collect system's IPv4 address
Edit tftp.socket to bind to IPv4 address
# systemctl edit tftp.socket --full
[...]
ListenDatagram=192.168.122.157:69
[...]
Connect to tftp
# ncat -u 192.168.122.157 69
foo
Expected results
No error message in the journal
Actual results
Error message:
[...] in.tftpd[11511]: cannot setsockopt IPV6_RECVPKTINFO Protocol not available