]> xenbits.xensource.com Git - unikraft/libs/lwip.git/commitdiff
Set system hostname when initializing interface
authorAndrei Tatar <andrei@unikraft.io>
Fri, 2 Feb 2024 15:48:35 +0000 (16:48 +0100)
committerSimon Kuenzer <simon@unikraft.io>
Fri, 9 Feb 2024 20:08:03 +0000 (21:08 +0100)
This change makes lwip set the system hostname to the one it receives
during initialization, using the `sethostname` library call.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #49

uknetdev.c

index 67a63bf5ea749babcb4c26a1be1101fa831b1352..32c6d83906590ebffe1e18476b2ddada22ee4882 100644 (file)
@@ -34,6 +34,7 @@
 #include <uk/config.h>
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 
 #include <uk/alloc.h>
 #include <uk/print.h>
@@ -699,8 +700,12 @@ struct netif *uknetdev_addif(struct uk_netdev *n
                return NULL;
        }
 
-       if (hostname)
+       if (hostname) {
                netif_set_hostname(nf, hostname);
+#if CONFIG_LIBPOSIX_SYSINFO
+               sethostname(hostname, strlen(hostname));
+#endif /* CONFIG_LIBPOSIX_SYSINFO */
+       }
 
        return ret;
 }