From patchwork Thu May 24 04:47:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 919565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40rxj75n0qz9s0q for ; Thu, 24 May 2018 14:48:27 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="MxJojqCV"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="UsKJCHnO"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40rxj742M4zF1Hg for ; Thu, 24 May 2018 14:48:27 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="MxJojqCV"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="UsKJCHnO"; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mendozajonas.com (client-ip=66.111.4.28; helo=out4-smtp.messagingengine.com; envelope-from=sam@mendozajonas.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="MxJojqCV"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="UsKJCHnO"; dkim-atps=neutral Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40rxhY0kzqzF1H5 for ; Thu, 24 May 2018 14:47:56 +1000 (AEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 854F221C2C; Thu, 24 May 2018 00:47:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 24 May 2018 00:47:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= mendozajonas.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=+nXOscsw+1sVHOJi2OoSwVZ4T1AEGdtdkig96VqsDq8=; b=MxJojqCV T8wi2FHucUZad4ZvqAVunAs+5hWwn8MWV2mZeHTNMm7572PhtnS/hsY3qG5PVQoA b9dscFp0uuuwROUM3j7x7bYwVa6S5QDrtXQtscYrpBbjwAYnXPR4YQZcBu+sqGw7 JZLkArZVRMuHo13TlOaHzpnBQkFcKaulvu0h+ldaZV+qnhE4aztiv8ADMhEjmY2e oKOOcn11iSikHtOpHSjLYd0NYVB0DzSA+pZdtq7xBcGgPr98npSjwG2nroC3ypaN ZRqKjcXw52HeJIRB214090oyaq4elm/G/uwdB1M8BHGP4nQT5G50Zoa6Pih18jCM eAJo0NvxF+q1Sg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=+nXOscsw+1sVHOJi2OoSwVZ4T1AEGdtdkig96VqsDq8=; b=UsKJCHnO erxFfQOa2NDHxrPJC+O4lfd98DNjWc4b2achVK9FKU/dKWUXIy63zetMT/0oymAK TzzNcn/0dFYWqhg47bcB9wneG+JQlF11hd2poVtNlqmKXw97oD+5Nc96ZJZb4Clf HXa/7JNL55aSbhYH6NMg8DLBSaw1vSxpmx+abTGm8gfFapRgrR27O4IknorWdZo5 YfdxrUiuYnkwqHyUuSv1oPn3okj80mPvkc+U7V3jKSoYW6DPOjC7R2T2kJU88B1x mkSgS01w2ulN5SG1kOyqYuRC4j9SeguqGAwiWP/U5ghgpzBr/ZGkBCs88eNJVb2g t9HTkK8LBJIfAQ== X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from v4.ozlabs.ibm.com (unknown [122.99.82.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 414B91025E; Thu, 24 May 2018 00:47:53 -0400 (EDT) From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH v2 2/9] discover/sysinfo: Set IPv6 addresses Date: Thu, 24 May 2018 14:47:35 +1000 Message-Id: <20180524044742.25889-3-sam@mendozajonas.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524044742.25889-1-sam@mendozajonas.com> References: <20180524044742.25889-1-sam@mendozajonas.com> X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Mendoza-Jonas MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Signed-off-by: Samuel Mendoza-Jonas --- discover/sysinfo.c | 23 +++++++++++++++++++---- ui/ncurses/nc-sysinfo.c | 3 +++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/discover/sysinfo.c b/discover/sysinfo.c index 74d1eae..b7286f1 100644 --- a/discover/sysinfo.c +++ b/discover/sysinfo.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "discover-server.h" #include "platform.h" @@ -32,7 +33,7 @@ void system_info_set_interface_address(unsigned int hwaddr_size, { struct interface_info *if_info; unsigned int i; - char mac[20]; + char mac[20], **if_addr, *new_addr, *subnet; for (i = 0; i < sysinfo->n_interfaces; i++) { if_info = sysinfo->interfaces[i]; @@ -43,12 +44,26 @@ void system_info_set_interface_address(unsigned int hwaddr_size, if (memcmp(if_info->hwaddr, hwaddr, hwaddr_size)) continue; + /* + * Don't include the subnet from a static config, and check if + * we're updating the IPv4 or IPv6 address. + * */ + if ((subnet = strchr(address, '/'))) + new_addr = talloc_strndup(if_info, address, subnet - address); + else + new_addr = talloc_strdup(if_info, address); + if (addr_scheme(new_addr) == AF_INET) + if_addr = &if_info->address; + else + if_addr = &if_info->address_v6; + /* Found an existing interface. Notify clients if a new address * is set */ - if (!if_info->address || strcmp(if_info->address, address)) { - talloc_free(if_info->address); - if_info->address = talloc_strdup(if_info, address); + if (!*if_addr || strcmp(*if_addr, address)) { + talloc_free(*if_addr); + *if_addr = new_addr; discover_server_notify_system_info(server, sysinfo); + pb_log("ADDR: %s on %s\n", *if_addr, if_info->name); return; } } diff --git a/ui/ncurses/nc-sysinfo.c b/ui/ncurses/nc-sysinfo.c index 8252b45..756f15d 100644 --- a/ui/ncurses/nc-sysinfo.c +++ b/ui/ncurses/nc-sysinfo.c @@ -131,6 +131,9 @@ static void sysinfo_screen_populate(struct sysinfo_screen *screen, line("%s:", info->name); line(_(" MAC: %s"), macbuf); line(_(" IP Address: %s"), info->address ?: _("none")); + if (info->address_v6) + line(_(" IPv6 Address: %s"), + info->address_v6 ?: _("none")); /* TRANSLATORS: these "up" / "down" strings refer to the * link status for a network connection. */ line(_(" link: %s"), info->link ? _("up") : _("down"));