Skip to contentSkip to conversation

image.bbclass: add postprocess func to disable DNS lookups for openssh

PATCH New Stefan Stanacar 1 participant 1 message Mar 31, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 image.bbclass: add postprocess func to disable DNS lookups for openssh

In the default config openssh does reverse DNS resolution, but
if there is no DNS configured on the target (or even worse the DNS server is unreachable) there is a long timeout when connecting over ssh. This is most visible on core-image-sato-sdk builds on AB, where the tests take a long time because each ssh command spends 15 seconds just connecting to the target, disabling the reverse DNS resolution halves the total test time.
This isn't a qemu specific problem however and instead of changing the default config I think it's worth disabling this when debug-tweaks is enabled.

Patch based on a previous version sent by Saul Wold <[email protected]>

[YOCTO #5954]

---
 meta/classes/image.bbclass | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
meta/classes/image.bbclass +9 -1
index 29309f5..846c768 100644
@@ -146,6 +146,8 @@ MACHINE_POSTPROCESS_COMMAND ?= ""
 ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "ssh_allow_empty_password; ", "",d)}'
 # Enable postinst logging if debug-tweaks is enabled
 ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "postinst_enable_logging; ", "",d)}'
+# Disable DNS lookups if debug-tweaks is enabled
+ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "ssh_disable_dns_lookup; ", "",d)}'
 # Write manifest
 IMAGE_MANIFEST = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.manifest"
 ROOTFS_POSTPROCESS_COMMAND =+ "write_image_manifest ; "
@@ -304,6 +306,12 @@ ssh_allow_empty_password () {
 	fi
 }
 
+ssh_disable_dns_lookup () {
+        if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
+            sed -i -e 's:#UseDNS yes:UseDNS no:' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+        fi
+}
+
 # Enable postinst logging if debug-tweaks is enabled
 postinst_enable_logging () {
 	mkdir -p ${IMAGE_ROOTFS}${sysconfdir}/default
@@ -374,7 +382,7 @@ rootfs_sysroot_relativelinks () {
 	sysroot-relativelinks.py ${SDK_OUTPUT}/${SDKTARGETSYSROOT}
 }
 
-EXPORT_FUNCTIONS zap_empty_root_password remove_init_link do_rootfs make_zimage_symlink_relative set_image_autologin rootfs_update_timestamp rootfs_no_x_startup
+EXPORT_FUNCTIONS zap_empty_root_password remove_init_link do_rootfs make_zimage_symlink_relative set_image_autologin rootfs_update_timestamp rootfs_no_x_startup ssh_disable_dns_lookup
 
 do_fetch[noexec] = "1"
 do_unpack[noexec] = "1"
Signature · 1 line
1.9.0