From patchwork Tue Dec 4 01:41:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 1007392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WUhCxLF+"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4384NF73d8z9s3l for ; Tue, 4 Dec 2018 12:41:49 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5CBEFB4C; Tue, 4 Dec 2018 01:41:46 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 05100B49 for ; Tue, 4 Dec 2018 01:41:45 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id AAB48826 for ; Tue, 4 Dec 2018 01:41:44 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id 64so7327027pfr.9 for ; Mon, 03 Dec 2018 17:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Qh5N/RZfU2ZZWWPH9DUbRVtwEUzSj6ZaevT7XPjzBos=; b=WUhCxLF+KhVR/1vULIDgYzbZIw72730gJ0jgCEaWavzbO0pgPzgNzs2ZLk9ugHaIM+ E5vzRAI5UQJSX2qs231RHJ8P8V67TjZT2lXWFe7IwlOSGlpy7ZOc8/gKNGflnGUPrjuw hG8UIBjBRyjlVPGOBZbanyi/DeH6sfk+hCpEBiis9dLf7fCehoLourkd2DjaOtXRkLFo 6meX9NWwxaB95CAI1LRAmyQ5nIlvLuNZxpSqBaaenUx5nZAVwnZBYhAV81HwNl0X9SW4 yKJGq7+Kl5f8eVZ71utq1h8z3tVlDWC3sfzV2rxOWyN/izMhvrp99s+J2FbUjFbms4Ag kZ+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Qh5N/RZfU2ZZWWPH9DUbRVtwEUzSj6ZaevT7XPjzBos=; b=MH7OXnzYJk+5gL7S6Oux1XabwTULoYwHATY+H+b/nPV1Mx4l9Uq9g4FLzg+OVrpkmv niyi+R4dNup4ScZc+heObVvIKAy9yvDaCRLeoeBeuMx8mcMGmxymFgtL4WaHsEY33lC2 2NYr6alYW/6n3DFh2PHjFUd2LDolmpfMqE6RKN8cvgNPEGSochTUWwwjyU2IXnTKJa1A M3JNFzKA7gge9kbySoodEwPu6bbdwH8UMwo2TUlMQzwBZv7XS7zIsjTT2r+fv3Eq3uOg 5uLoKuFwGFQ692un/IaBWD04Vy+lgXMHOBkQhc0LKO1kxNWsEgBYv6nvtgb5LouGnajm PkyA== X-Gm-Message-State: AA+aEWZZXYsLgK4db7javn11U8+HldWAos5S4H0Fq745p4beNySuQv20 CGpr1pCQFEWQidbopH9/sOU= X-Google-Smtp-Source: AFSGD/XP75EZGOUKrArWJhfP+tZoo6z5CTt6s3TzTZyLUv0FaAyEDx7RVulwm4RU4d1/L6zJ5JyLMA== X-Received: by 2002:a62:5fc4:: with SMTP id t187mr18292584pfb.66.1543887704192; Mon, 03 Dec 2018 17:41:44 -0800 (PST) Received: from titan.localdomain.hq.cloud.yunionyun.com ([104.238.138.31]) by smtp.gmail.com with ESMTPSA id q195sm15773795pgq.7.2018.12.03.17.41.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 17:41:42 -0800 (PST) From: Yousong Zhou X-Google-Original-From: Yousong Zhou To: blp@ovn.org Date: Tue, 4 Dec 2018 01:41:26 +0000 Message-Id: <20181204014126.29006-1-zhouyousong@yunionyun.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: ovs-dev@openvswitch.org Subject: [ovs-dev] [PATCH v2] ovs-ctl: fallback to "uname -n" for fetching hostname X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Yousong Zhou The command "hostname" is not available in OpenWrt by default. Strace result of hostname-3.13 on centos7 shows that bare "hostname" command calls uname() to fetch node name. Signed-off-by: Yousong Zhou --- v2 <- v1: fallback to "uname -n" when FULL_HOSTNAME=yes. Suggested by blp utilities/ovs-ctl.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index e42f0f1e6..c92b270b9 100644 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -38,9 +38,10 @@ insert_mod_if_required () { set_hostname () { # 'hostname -f' needs network connectivity to work. So we should # call this only after ovs-vswitchd is running. - hn="$(hostname -f)" - if test X$FULL_HOSTNAME = Xno; then - hn="$(hostname)" + if test X$FULL_HOSTNAME = Xyes; then + hn="$(hostname -f)" || hn="$(uname -n)" + else + hn="$(uname -n)" fi ovs_vsctl set Open_vSwitch . external-ids:hostname="$hn" }