From patchwork Tue Jun 15 14:24:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1492268 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=GuVWd1nE; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G49fB2fRwz9sRN for ; Wed, 16 Jun 2021 00:28:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 19B5560747; Tue, 15 Jun 2021 14:28:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aNtWCBKHFm9H; Tue, 15 Jun 2021 14:28:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 6F8756060C; Tue, 15 Jun 2021 14:28:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 31EE1C000D; Tue, 15 Jun 2021 14:28:12 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 486A7C000B for ; Tue, 15 Jun 2021 14:28:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 35FA0405EC for ; Tue, 15 Jun 2021 14:28:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zLcUjmjaM4Sx for ; Tue, 15 Jun 2021 14:28:09 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by smtp4.osuosl.org (Postfix) with ESMTPS id C1BC140307 for ; Tue, 15 Jun 2021 14:28:08 +0000 (UTC) Received: by mail-lf1-x135.google.com with SMTP id p17so27353469lfc.6 for ; Tue, 15 Jun 2021 07:28:08 -0700 (PDT) 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=PWr9aMrHWg+8dKM0dWUl89HingwtSGlkFv2m60ePfBc=; b=GuVWd1nE73ZsCLWpdolDygTm8pFf5+b9LhyIUqGPusEEQsEACv+n5qFkbemNHxrvNt 4eM6HxiLF6CwOqE9MlHVn5Pg1eKtGgRU7nqGYo0Em3Xy8n6ro1esXsVmdBIyCoSHSGie rWV1G1WY74zB6NrYrvwQgdiy1Idk2CCT1Zic5H8ccDl+jVpG1n9j0Bv6Bzx0kHzaqBfS d9RacdfaQq3LZzYmI+J8sdfKGjbZNPJCBKceKMAAhYtb4BL7K58ef8Prdzxb4sxQS4t/ w3PN/tS2LVaimZ6muC+PujWH5B4Nyt3sAC11RXrGV194LVpWpt+mdkqM5jvRgXV/9pAo mBLw== 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=PWr9aMrHWg+8dKM0dWUl89HingwtSGlkFv2m60ePfBc=; b=geV6/YFiLEJPRQoB0iThrJk+KI0ek/N7Ys8f1N4qhZ/dHOhRVwSnkpdLUkQf5HtGJI yOBxhmEzZ1QVefl8DfqqoRUSNbGwsxP5ddMT+ty+okwe9eXlFtKsdTy1hjSjrIlQk5qc +imDX6sA8uLPhdrifv4g/2pRoGz+4D1O4A7HvynDGOHwUU7FyUsdgnhJkoqcS7XAsxdj P7y+qegmq7E6PKhlyJZCxzrhfE0a5bql75L/2AZoYMDp2CsOUOPflX1vFLTrLtCmaJpT 7WbaMoioK8v+Jdkee1IDJel0uQZ/A/yYVqHb+WlAHR4OKKR6zAK5bthgjDbph5thYHYn YbnQ== X-Gm-Message-State: AOAM5313sYKIoOsGLrgAASwdyPTxgNoZmN6axeHJVYR+wBgE1tTBHfvP bZUWklKvmN1X6IsivwmWp/y4MPyNHeTGuVgP X-Google-Smtp-Source: ABdhPJxcF4XxuERcHotZeUhFQ59mVFHN0t9sLxpo5rKrOJO7Dn3zH86DJYH4pMKlknBlKijpMXtNAw== X-Received: by 2002:ac2:528f:: with SMTP id q15mr16055856lfm.36.1623767286349; Tue, 15 Jun 2021 07:28:06 -0700 (PDT) Received: from Vladislavs-MacBook-Pro.local.ru (109-252-131-42.dynamic.spd-mgts.ru. [109.252.131.42]) by smtp.gmail.com with ESMTPSA id c20sm1819351lfv.291.2021.06.15.07.28.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jun 2021 07:28:05 -0700 (PDT) From: Vladislav Odintsov To: dev@openvswitch.org Date: Tue, 15 Jun 2021 17:24:04 +0300 Message-Id: <20210615142405.20140-1-odivlad@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [PATCH ovn v2] northd: Add support for DHCP Option 12 (Hostname) X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" DHCP option Hostname (opcode 12) can be configured in Logical_Switch_Port as well as in DHCP_Options table's options:hostname column. If both methods of configuration were used, Logical_Switch_Port's setting takes precedence. Signed-off-by: Vladislav Odintsov --- v1 -> v2 * Added support for configuring hostname dhcp 12 option in DHCP_Options. * Updated ovn-nb manpage. --- lib/ovn-l7.h | 1 + northd/ovn-northd.c | 9 +++++++++ ovn-nb.xml | 23 +++++++++++++++++++++++ tests/ovn.at | 3 +++ tests/test-ovn.c | 1 + 5 files changed, 37 insertions(+) diff --git a/lib/ovn-l7.h b/lib/ovn-l7.h index 5e33d619c..9a33f5cda 100644 --- a/lib/ovn-l7.h +++ b/lib/ovn-l7.h @@ -81,6 +81,7 @@ struct gen_opts_map { #define DHCP_OPT_DNS_SERVER DHCP_OPTION("dns_server", 6, "ipv4") #define DHCP_OPT_LOG_SERVER DHCP_OPTION("log_server", 7, "ipv4") #define DHCP_OPT_LPR_SERVER DHCP_OPTION("lpr_server", 9, "ipv4") +#define DHCP_OPT_HOSTNAME DHCP_OPTION("hostname", 12, "str") #define DHCP_OPT_DOMAIN_NAME DHCP_OPTION("domain_name", 15, "str") #define DHCP_OPT_SWAP_SERVER DHCP_OPTION("swap_server", 16, "ipv4") diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index c39d451ec..45486daac 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -4574,6 +4574,14 @@ build_dhcpv4_action(struct ovn_port *op, ovs_be32 offer_ip, REGBIT_DHCP_OPTS_RESULT" = put_dhcp_opts(offerip = " IP_FMT", ", IP_ARGS(offer_ip)); + /* Try to get hostname DHCP option from ovn_port as it can be passed there + * instead of DHCP_Options set. Logical_Switch_Port options:hostname takes + precedence over DHCP_Options options:hostname. */ + const char *hostname = smap_get(&op->nbsp->options, "hostname"); + if (hostname) { + smap_replace(&dhcpv4_options, "hostname", hostname); + } + /* We're not using SMAP_FOR_EACH because we want a consistent order of the * options on different architectures (big or little endian, SSE4.2) */ const struct smap_node **sorted_opts = smap_sort(&dhcpv4_options); @@ -13561,6 +13569,7 @@ static struct gen_opts_map supported_dhcp_opts[] = { DHCP_OPT_BOOTFILE, DHCP_OPT_PATH_PREFIX, DHCP_OPT_TFTP_SERVER_ADDRESS, + DHCP_OPT_HOSTNAME, DHCP_OPT_DOMAIN_NAME, DHCP_OPT_ARP_CACHE_TIMEOUT, DHCP_OPT_TCP_KEEPALIVE_INTERVAL, diff --git a/ovn-nb.xml b/ovn-nb.xml index cf1e3aac4..e107c9035 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -929,6 +929,15 @@ If set, indicates the maximum burst size for data sent from this interface, in bits. + + +

+ If set, indicates the DHCPv4 option "Hostname" (option code 12) + associated for this Logical Switch Port. If DHCPv4 is enabled for + this Logical Switch Port, hostname dhcp option will be included in + DHCP reply. +

+
@@ -3297,6 +3306,20 @@

+ +

+ The DHCPv4 option code for this option is 12. + If set, indicates the DHCPv4 option "Hostname". + Alternatively, this option can be configured in + column in table . + If Hostname option value is set in both conflicting + and + tables, + takes precedence. +

+
+

The DHCPv4 option code for this option is 15. This option diff --git a/tests/ovn.at b/tests/ovn.at index 71d2bab4d..757e15972 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -1345,6 +1345,9 @@ reg2[5] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.254.0,m reg2[5] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.254.0,mtu=1400,domain_name="ovn.org",wpad="https://example.org",bootfile_name="https://127.0.0.1/boot.ipxe",path_prefix="/tftpboot",domain_search_list="ovn.org,abc.ovn.org,def.ovn.org,ovn.test,def.ovn.test,test.org,abc.com"); formats as reg2[5] = put_dhcp_opts(offerip = 10.0.0.4, router = 10.0.0.1, netmask = 255.255.254.0, mtu = 1400, domain_name = "ovn.org", wpad = "https://example.org", bootfile_name = "https://127.0.0.1/boot.ipxe", path_prefix = "/tftpboot", domain_search_list = "ovn.org,abc.ovn.org,def.ovn.org,ovn.test,def.ovn.test,test.org,abc.com"); encodes as controller(userdata=00.00.00.02.00.00.00.00.00.01.de.10.00.00.00.25.0a.00.00.04.43.1b.68.74.74.70.73.3a.2f.2f.31.32.37.2e.30.2e.30.2e.31.2f.62.6f.6f.74.2e.69.70.78.65.03.04.0a.00.00.01.01.04.ff.ff.fe.00.1a.02.05.78.0f.07.6f.76.6e.2e.6f.72.67.fc.13.68.74.74.70.73.3a.2f.2f.65.78.61.6d.70.6c.65.2e.6f.72.67.d2.09.2f.74.66.74.70.62.6f.6f.74.77.35.03.6f.76.6e.03.6f.72.67.00.03.61.62.63.c0.00.03.64.65.66.c0.00.03.6f.76.6e.04.74.65.73.74.00.03.64.65.66.c0.15.04.74.65.73.74.c0.04.03.61.62.63.03.63.6f.6d.00,pause) +reg2[5] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.254.0,mtu=1400,domain_name="ovn.org",hostname="ip-10-0-0-4"); + formats as reg2[5] = put_dhcp_opts(offerip = 10.0.0.4, router = 10.0.0.1, netmask = 255.255.254.0, mtu = 1400, domain_name = "ovn.org", hostname = "ip-10-0-0-4"); + encodes as controller(userdata=00.00.00.02.00.00.00.00.00.01.de.10.00.00.00.25.0a.00.00.04.03.04.0a.00.00.01.01.04.ff.ff.fe.00.1a.02.05.78.0f.07.6f.76.6e.2e.6f.72.67.0c.0b.69.70.2d.31.30.2d.30.2d.30.2d.34,pause) reg1[0..1] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1); Cannot use 2-bit field reg1[0..1] where 1-bit field is required. diff --git a/tests/test-ovn.c b/tests/test-ovn.c index 98cc2c503..a4701b4cb 100644 --- a/tests/test-ovn.c +++ b/tests/test-ovn.c @@ -168,6 +168,7 @@ create_gen_opts(struct hmap *dhcp_opts, struct hmap *dhcpv6_opts, dhcp_opt_add(dhcp_opts, "dns_server", 6, "ipv4"); dhcp_opt_add(dhcp_opts, "log_server", 7, "ipv4"); dhcp_opt_add(dhcp_opts, "lpr_server", 9, "ipv4"); + dhcp_opt_add(dhcp_opts, "hostname", 12, "str"); dhcp_opt_add(dhcp_opts, "domain_name", 15, "str"); dhcp_opt_add(dhcp_opts, "swap_server", 16, "ipv4"); dhcp_opt_add(dhcp_opts, "policy_filter", 21, "ipv4");