From patchwork Thu Jun 11 20:44:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Sharma X-Patchwork-Id: 1307813 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=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nutanix.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=proofpoint20171006 header.b=SDeectZ0; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49jbS23nbxz9sRN for ; Fri, 12 Jun 2020 06:44:00 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E310520511; Thu, 11 Jun 2020 20:43:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XWJfjSnqRjqp; Thu, 11 Jun 2020 20:43:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id A5AD8204D0; Thu, 11 Jun 2020 20:43:48 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 86B08C0178; Thu, 11 Jun 2020 20:43:48 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 102C8C016F for ; Thu, 11 Jun 2020 20:43:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id EB4928968E for ; Thu, 11 Jun 2020 20:43:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 21BY5el6bkyC for ; Thu, 11 Jun 2020 20:43:46 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx0a-002c1b01.pphosted.com (mx0a-002c1b01.pphosted.com [148.163.151.68]) by hemlock.osuosl.org (Postfix) with ESMTPS id 740A98968D for ; Thu, 11 Jun 2020 20:43:46 +0000 (UTC) Received: from pps.filterd (m0127839.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05BKdEE7030355 for ; Thu, 11 Jun 2020 13:43:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=proofpoint20171006; bh=BQ6IDG7DOFouQhYpMHU6vPTPn1Mii0IQfyPcBSuiLsI=; b=SDeectZ0G6shjIj2JAZhGykh6cZehvQVxTUtXWGi3Deqpo9sVtVZ7FgN4kLuzDvHz7Wm Pzwrr8SYHi+KGa9MV9nvu3CvHoIJMYlvtVKz8tvDvJ4MIfr+ubu6qfyyUBrWv7Qor6BK d284gm+fH6hMvszaNcaHLn0AafryXgp5pVhzBCzkY5dWhC4+a32c8QvIBhz9LGCfvYeY mzE0lzEMBcdmUHyFIlZyqgpmdQ0qswDOM/XXC/g8zLfsPRgBd3is4NkTMbvNU3krqJfY PofufqOX9wI7DYfgyE92hKK82YbNAzSoFtHoXD/zpjcsOoBjI30TB4S8hl6QZA36rMSl nQ== Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by mx0a-002c1b01.pphosted.com with ESMTP id 31ga7jn0aa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 Jun 2020 13:43:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JQkBVv2iKBv5prT32Lt1HjRaBo/pixo/dCkiuMXEQvD5cOSLHKa+PEbMF59/ReBg5Q397p6z3rnqjpo+XBNfzYo7znKVcKNtCGvG0nQC+lJl3HTc5KmLhuD8rBVAD2uwBY0j037bSmO8oHcOqG0mueyZNG65edJrcuhUmU2tlXUdv/v/A85B8jC3N71VFYStbNBfQn8VhJh5bJaofkPcuTmDddu2OAjfQybZI2e2yjMmhuUHRs1kyKTj5OZou2iPR8bz9YN/ZUTufPt/5VinWXl9QCt1bfUjKvOlAh1fXbFNzamEuwvl/6xEmlNNyJbZTWX1vV8weQaVJfolM87xtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BQ6IDG7DOFouQhYpMHU6vPTPn1Mii0IQfyPcBSuiLsI=; b=iyfRE0R0/hgcGidApxA9vu9TuwSgq6LlARHB2CBq+pVyeUp9p9IZJEIScgmDmtD27fjypElp/MvT37jRGYkEkzQ0e9AAD1hJt8nD0M+sonqZEGBk5v+lpzF1lgpNPmwgA182GVyFTp5BrhWBOHBHLKj+aQLJYSyhp6qr5Ec2CJNmQEyTs6aO000Fr4qOLzMcwV28I5JSdMZw1t1ZAx2WCCR5qkRyT6mFR4Ip4Ypj+uk+f7M22hDaMWlU1wcSIMm5fkDSCnBgagJBnQPJybtLsOqnrF+UwQpmKmHlxuVQILXjx5gqIk2ZUJGGLsYSwEElpZhYWMH31Z16Xfd+QIwxoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Authentication-Results: openvswitch.org; dkim=none (message not signed) header.d=none;openvswitch.org; dmarc=none action=none header.from=nutanix.com; Received: from BL0PR02MB3714.namprd02.prod.outlook.com (2603:10b6:207:44::16) by BL0PR02MB3873.namprd02.prod.outlook.com (2603:10b6:207:49::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.22; Thu, 11 Jun 2020 20:43:42 +0000 Received: from BL0PR02MB3714.namprd02.prod.outlook.com ([fe80::445e:7f74:952e:2ccb]) by BL0PR02MB3714.namprd02.prod.outlook.com ([fe80::445e:7f74:952e:2ccb%5]) with mapi id 15.20.3088.022; Thu, 11 Jun 2020 20:43:42 +0000 From: Ankur Sharma To: ovs-dev@openvswitch.org Date: Thu, 11 Jun 2020 13:44:40 -0700 Message-Id: <1591908281-42017-1-git-send-email-svc.mail.git@nutanix.com> X-Mailer: git-send-email 1.8.3.1 X-ClientProxiedBy: BYAPR01CA0034.prod.exchangelabs.com (2603:10b6:a02:80::47) To BL0PR02MB3714.namprd02.prod.outlook.com (2603:10b6:207:44::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from northd.localdomain (192.146.154.98) by BYAPR01CA0034.prod.exchangelabs.com (2603:10b6:a02:80::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Thu, 11 Jun 2020 20:43:41 +0000 X-Mailer: git-send-email 1.8.3.1 X-Originating-IP: [192.146.154.98] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ba12dd6d-4b55-4be5-befb-08d80e482078 X-MS-TrafficTypeDiagnostic: BL0PR02MB3873: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-Forefront-PRVS: 0431F981D8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NhtVH8pxf7cAt2BpKPsSG381q8AGNMMX4ou9+2ws/TC0vh36lhg9hAaMLQa5IBNtKydplSMJVXPJgMc06GZ7djHXWpQ40kLJ9Hamqhna48/h6Gb4MnUr5oVZ6OkmsdHePtf/qAzSE7qlMGsInENPQD+kySrYF9VFXFo+SBkJy+vSO6Qqnsyu7HuJ3rRz/rVBMkR5oQ+SZTvum/DU62p5+ybBYyDUZrt/kd7bUKr+/47RrDer3RjIzUKB/RIRBMR8kaZ9pjr1caDEYv8KFjQQi+ojdkGMAT5QWwm5uX+D3jdOdrKkSwFVOXvGZ/QxU007GJyUUe74COiiOVhu3ljYPg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR02MB3714.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(136003)(396003)(366004)(39860400002)(346002)(376002)(5660300002)(66556008)(66476007)(30864003)(66574014)(86362001)(2906002)(66946007)(6486002)(478600001)(16526019)(6512007)(316002)(8676002)(36756003)(186003)(8936002)(26005)(956004)(4326008)(54906003)(6506007)(83380400001)(2616005)(107886003)(6916009)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: TlBlzcKG0lGkoajeF8u9kU5dPEm24vukVQgu+W0WNWdpGMJ6tE/x0rwr5f0spCZBa5sPVL2fGsA1ZkJm92f4/mqKDJLxBoGm22graQDyN7eoWTC0N72AoAINBTXgJQKbyMA/pr1+Z+F4RhhPFQOXE7SenDx4d2j396bE8qGw76s61RScpyC4fdXP5x996BfvokpLwYo2UByvah9U7NpfS5kVnqc6jfBJ6lK4YPsZXBZ2p0KWv7mOcfsSyRmRf+LKBMnWhUn9h4lXZN5wu+nt4uOHvV5WHMEix/SCBxUijkASLCq4OLRlFrftITgwIuBkqHq+i2N1X37i3I/+pQGiUcg4KlckMr5WxPer30rWEwfK7DN2g6ZI3MedPtMRl3Maqaqpshgj0xLWkLj4pk6BNw4psKG5jCxdqUrrweIi+jAyNxhFo3CBg3QziYzw2Zf95A6SclSpB9uUpjGag0HEp6+vJnFd7aSXk1HZ5/Mchiw= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba12dd6d-4b55-4be5-befb-08d80e482078 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2020 20:43:42.2001 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ICT52v21EGWDrNngdcRIWx78rC8qHpxjG7EPm97z6dbc75grZQbvgG78wNqbOkh6Jns0toN32f6BvVGYz4L/46jpO25y+tP7Vye4urdeNmc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR02MB3873 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-11_20:2020-06-11, 2020-06-11 signatures=0 X-Proofpoint-Spam-Reason: safe Cc: Dhathri Purohith , Dhathri Purohith Subject: [ovs-dev] [PATCH v5 1/2 ovn] Fix the data type for DHCP option tftp_server (66) 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" From: Dhathri Purohith From: Dhathri Purohith Currently, DHCP option is of type ipv4. But, according to RFC 2132, option 66 can be a hostname i.e, we should also accept string type. In order to be backward compatible, a new type called "host_id" is introduced, which accepts both ipv4 address and string. Type for DHCP option 66 is changed to "host_id" instead of ipv4. OVN northd code that updates the OVN southbound database is enhanced to consider the change in the type and code for DHCP option, so that the change in datatype is reflected. Signed-off-by: Dhathri Purohith Signed-off-by: Ankur Sharma --- lib/actions.c | 12 ++++++++++ lib/ovn-l7.h | 2 +- northd/ovn-northd.c | 7 +++++- ovn-nb.xml | 18 +++++++++----- ovn-sb.ovsschema | 7 +++--- ovn-sb.xml | 13 ++++++++++ tests/ovn.at | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/test-ovn.c | 2 +- 8 files changed, 117 insertions(+), 12 deletions(-) diff --git a/lib/actions.c b/lib/actions.c index c506151..f21be6d 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -1978,6 +1978,10 @@ parse_gen_opt(struct action_context *ctx, struct ovnact_gen_option *o, return; } + if (!strcmp(o->option->type, "host_id")) { + return; + } + if (!strcmp(o->option->type, "str")) { if (o->value.type != EXPR_C_STRING) { lexer_error(ctx->lexer, "%s option %s requires string value.", @@ -2305,6 +2309,14 @@ encode_put_dhcpv4_option(const struct ovnact_gen_option *o, } else if (!strcmp(o->option->type, "str")) { opt_header[1] = strlen(c->string); ofpbuf_put(ofpacts, c->string, opt_header[1]); + } else if (!strcmp(o->option->type, "host_id")) { + if (o->value.type == EXPR_C_STRING) { + opt_header[1] = strlen(c->string); + ofpbuf_put(ofpacts, c->string, opt_header[1]); + } else { + opt_header[1] = sizeof(ovs_be32); + ofpbuf_put(ofpacts, &c->value.ipv4, sizeof(ovs_be32)); + } } } diff --git a/lib/ovn-l7.h b/lib/ovn-l7.h index cc63d82..38555db 100644 --- a/lib/ovn-l7.h +++ b/lib/ovn-l7.h @@ -57,7 +57,7 @@ struct gen_opts_map { #define DHCP_OPT_NIS_SERVER DHCP_OPTION("nis_server", 41, "ipv4") #define DHCP_OPT_NTP_SERVER DHCP_OPTION("ntp_server", 42, "ipv4") #define DHCP_OPT_SERVER_ID DHCP_OPTION("server_id", 54, "ipv4") -#define DHCP_OPT_TFTP_SERVER DHCP_OPTION("tftp_server", 66, "ipv4") +#define DHCP_OPT_TFTP_SERVER DHCP_OPTION("tftp_server", 66, "host_id") #define DHCP_OPT_CLASSLESS_STATIC_ROUTE \ DHCP_OPTION("classless_static_route", 121, "static_routes") diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index eb78f31..ef08414 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -11360,7 +11360,12 @@ check_and_add_supported_dhcp_opts_to_sb_db(struct northd_context *ctx) struct gen_opts_map *dhcp_opt = dhcp_opts_find(&dhcp_opts_to_add, opt_row->name); if (dhcp_opt) { - hmap_remove(&dhcp_opts_to_add, &dhcp_opt->hmap_node); + if (!strcmp(dhcp_opt->type, opt_row->type) && + dhcp_opt->code == opt_row->code) { + hmap_remove(&dhcp_opts_to_add, &dhcp_opt->hmap_node); + } else { + sbrec_dhcp_options_delete(opt_row); + } } else { sbrec_dhcp_options_delete(opt_row); } diff --git a/ovn-nb.xml b/ovn-nb.xml index acf5648..54f5301 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -2790,12 +2790,6 @@

- -

- The DHCPv4 option code for this option is 66. -

-
-

The DHCPv4 option code for this option is 121. @@ -2944,6 +2938,18 @@

+ + +

+ These options accept either an IPv4 address or a string value. +

+ + +

+ The DHCPv4 option code for this option is 66. +

+
+
diff --git a/ovn-sb.ovsschema b/ovn-sb.ovsschema index c196dda..2ec729b 100644 --- a/ovn-sb.ovsschema +++ b/ovn-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Southbound", - "version": "2.8.0", - "cksum": "1643994484 21853", + "version": "2.8.1", + "cksum": "236203406 21905", "tables": { "SB_Global": { "columns": { @@ -217,7 +217,8 @@ "type": {"key": { "type": "string", "enum": ["set", ["bool", "uint8", "uint16", "uint32", - "ipv4", "static_routes", "str"]]}}}}, + "ipv4", "static_routes", "str", + "host_id"]]}}}}, "isRoot": true}, "DHCPv6_Options": { "columns": { diff --git a/ovn-sb.xml b/ovn-sb.xml index 15204a8..208fb93 100644 --- a/ovn-sb.xml +++ b/ovn-sb.xml @@ -3219,6 +3219,19 @@ tcp.flags = RST; Example. "name=host_name", "code=12", "type=str".

+ +
value: host_id
+
+

+ This indicates that the value of the DHCP option is a host_id. + It can either be a host_name or an IP address. +

+ +

+ Example. "name=tftp_server", "code=66", "type=host_id". +

+
+ diff --git a/tests/ovn.at b/tests/ovn.at index 8743e0e..d3b35ac 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -1212,6 +1212,12 @@ reg2[5] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.254.0,m reg0[15] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.255.0,mtu=1400,ip_forward_enable=1,default_ttl=121,dns_server={8.8.8.8,7.7.7.7},classless_static_route={30.0.0.0/24,10.0.0.4,40.0.0.0/16,10.0.0.6,0.0.0.0/0,10.0.0.1},ethernet_encap=1,router_discovery=0,tftp_server_address={10.0.0.4,10.0.0.5},arp_cache_timeout=10,tcp_keepalive_interval=10); formats as reg0[15] = put_dhcp_opts(offerip = 10.0.0.4, router = 10.0.0.1, netmask = 255.255.255.0, mtu = 1400, ip_forward_enable = 1, default_ttl = 121, dns_server = {8.8.8.8, 7.7.7.7}, classless_static_route = {30.0.0.0/24, 10.0.0.4, 40.0.0.0/16, 10.0.0.6, 0.0.0.0/0, 10.0.0.1}, ethernet_encap = 1, router_discovery = 0, tftp_server_address = {10.0.0.4, 10.0.0.5}, arp_cache_timeout = 10, tcp_keepalive_interval = 10); encodes as controller(userdata=00.00.00.02.00.00.00.00.00.01.de.10.00.00.00.6f.0a.00.00.04.03.04.0a.00.00.01.01.04.ff.ff.ff.00.1a.02.05.78.13.01.01.17.01.79.06.08.08.08.08.08.07.07.07.07.79.14.18.1e.00.00.0a.00.00.04.10.28.00.0a.00.00.06.00.0a.00.00.01.24.01.01.1f.01.00.96.08.0a.00.00.04.0a.00.00.05.23.04.00.00.00.0a.26.04.00.00.00.0a,pause) +reg0[15] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.255.0,mtu=1400,ip_forward_enable=1,default_ttl=121,dns_server={8.8.8.8,7.7.7.7},classless_static_route={30.0.0.0/24,10.0.0.4,40.0.0.0/16,10.0.0.6,0.0.0.0/0,10.0.0.1},ethernet_encap=1,router_discovery=0,tftp_server=10.0.0.10); + formats as reg0[15] = put_dhcp_opts(offerip = 10.0.0.4, router = 10.0.0.1, netmask = 255.255.255.0, mtu = 1400, ip_forward_enable = 1, default_ttl = 121, dns_server = {8.8.8.8, 7.7.7.7}, classless_static_route = {30.0.0.0/24, 10.0.0.4, 40.0.0.0/16, 10.0.0.6, 0.0.0.0/0, 10.0.0.1}, ethernet_encap = 1, router_discovery = 0, tftp_server = 10.0.0.10); + encodes as controller(userdata=00.00.00.02.00.00.00.00.00.01.de.10.00.00.00.6f.0a.00.00.04.03.04.0a.00.00.01.01.04.ff.ff.ff.00.1a.02.05.78.13.01.01.17.01.79.06.08.08.08.08.08.07.07.07.07.79.14.18.1e.00.00.0a.00.00.04.10.28.00.0a.00.00.06.00.0a.00.00.01.24.01.01.1f.01.00.42.04.0a.00.00.0a,pause) +reg0[15] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.255.0,mtu=1400,ip_forward_enable=1,default_ttl=121,dns_server={8.8.8.8,7.7.7.7},classless_static_route={30.0.0.0/24,10.0.0.4,40.0.0.0/16,10.0.0.6,0.0.0.0/0,10.0.0.1},ethernet_encap=1,router_discovery=0,tftp_server="tftp_server_test"); + formats as reg0[15] = put_dhcp_opts(offerip = 10.0.0.4, router = 10.0.0.1, netmask = 255.255.255.0, mtu = 1400, ip_forward_enable = 1, default_ttl = 121, dns_server = {8.8.8.8, 7.7.7.7}, classless_static_route = {30.0.0.0/24, 10.0.0.4, 40.0.0.0/16, 10.0.0.6, 0.0.0.0/0, 10.0.0.1}, ethernet_encap = 1, router_discovery = 0, tftp_server = "tftp_server_test"); + encodes as controller(userdata=00.00.00.02.00.00.00.00.00.01.de.10.00.00.00.6f.0a.00.00.04.03.04.0a.00.00.01.01.04.ff.ff.ff.00.1a.02.05.78.13.01.01.17.01.79.06.08.08.08.08.08.07.07.07.07.79.14.18.1e.00.00.0a.00.00.04.10.28.00.0a.00.00.06.00.0a.00.00.01.24.01.01.1f.01.00.42.10.74.66.74.70.5f.73.65.72.76.65.72.5f.74.65.73.74,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. @@ -5546,6 +5552,68 @@ AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) cat 1.expected | cut -c 53- > expout AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout]) +reset_pcap_file hv1-vif1 hv1/vif1 +reset_pcap_file hv1-vif2 hv1/vif2 +rm -f 1.expected +rm -f 2.expected + +# Set tftp server option (IPv4 address) for ls1 +echo "------ Set tftp server (IPv4 address) --------" +ovn-nbctl dhcp-options-set-options $d1 server_id=10.0.0.1 \ +server_mac=ff:10:00:00:00:01 lease_time=3600 router=10.0.0.1 \ +tftp_server=10.10.10.10 +echo "----------------------------------------------" + +# Send DHCPREQUEST in the SELECTING/INIT-REBOOT state with the offered IP +# address in the Requested IP Address option. +offer_ip=`ip_to_hex 10 0 0 6` +server_ip=`ip_to_hex 10 0 0 1` +ciaddr=`ip_to_hex 0 0 0 0` +request_ip=$offer_ip +expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a00000142040a0a0a0a +test_dhcp 2 f00000000002 03 0 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 05 $expected_dhcp_opts + +# NXT_RESUMEs should be 10. +OVS_WAIT_UNTIL([test 10 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) + +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +cat 2.expected | cut -c -48 > expout +AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) +# Skipping the IPv4 checksum. +cat 2.expected | cut -c 53- > expout +AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) + +reset_pcap_file hv1-vif1 hv1/vif1 +reset_pcap_file hv1-vif2 hv1/vif2 +rm -f 1.expected +rm -f 2.expected + +# Set tftp server option (Hostname) for ls1 +echo "------ Set tftp server (hostname) --------" +ovn-nbctl dhcp-options-set-options $d1 server_id=10.0.0.1 \ +server_mac=ff:10:00:00:00:01 lease_time=3600 router=10.0.0.1 \ +tftp_server=\"test_tftp_server\" +echo "------------------------------------------" + +# Send DHCPREQUEST in the SELECTING/INIT-REBOOT state with the offered IP +# address in the Requested IP Address option. +offer_ip=`ip_to_hex 10 0 0 6` +server_ip=`ip_to_hex 10 0 0 1` +ciaddr=`ip_to_hex 0 0 0 0` +request_ip=$offer_ip +expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a0000014210746573745f746674705f736572766572 +test_dhcp 2 f00000000002 03 0 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 05 $expected_dhcp_opts + +# NXT_RESUMEs should be 11. +OVS_WAIT_UNTIL([test 11 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) + +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +cat 2.expected | cut -c -48 > expout +AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) +# Skipping the IPv4 checksum. +cat 2.expected | cut -c 53- > expout +AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) + OVN_CLEANUP([hv1]) AT_CLEANUP diff --git a/tests/test-ovn.c b/tests/test-ovn.c index a77d2f1..4391694 100644 --- a/tests/test-ovn.c +++ b/tests/test-ovn.c @@ -174,7 +174,7 @@ create_gen_opts(struct hmap *dhcp_opts, struct hmap *dhcpv6_opts, dhcp_opt_add(dhcp_opts, "nis_server", 41, "ipv4"); dhcp_opt_add(dhcp_opts, "ntp_server", 42, "ipv4"); dhcp_opt_add(dhcp_opts, "server_id", 54, "ipv4"); - dhcp_opt_add(dhcp_opts, "tftp_server", 66, "ipv4"); + dhcp_opt_add(dhcp_opts, "tftp_server", 66, "host_id"); dhcp_opt_add(dhcp_opts, "classless_static_route", 121, "static_routes"); dhcp_opt_add(dhcp_opts, "ip_forward_enable", 19, "bool"); dhcp_opt_add(dhcp_opts, "router_discovery", 31, "bool"); From patchwork Thu Jun 11 20:44:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Sharma X-Patchwork-Id: 1307815 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=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nutanix.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=proofpoint20171006 header.b=UaxuSUTU; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49jbSL3jM2z9sRN for ; Fri, 12 Jun 2020 06:44:18 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 8311F26B1E; Thu, 11 Jun 2020 20:44:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3JRBzk+PypJo; Thu, 11 Jun 2020 20:43:55 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id BAAD2267EB; Thu, 11 Jun 2020 20:43:53 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 93C2EC0178; Thu, 11 Jun 2020 20:43:53 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7C573C016F for ; Thu, 11 Jun 2020 20:43:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6B251896A9 for ; Thu, 11 Jun 2020 20:43:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2avDstg0BMJv for ; Thu, 11 Jun 2020 20:43:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx0a-002c1b01.pphosted.com (mx0a-002c1b01.pphosted.com [148.163.151.68]) by hemlock.osuosl.org (Postfix) with ESMTPS id 3F9FC89699 for ; Thu, 11 Jun 2020 20:43:49 +0000 (UTC) Received: from pps.filterd (m0127839.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05BKdGTb030397 for ; Thu, 11 Jun 2020 13:43:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=proofpoint20171006; bh=62IEbMfHec/ZI1nWAeuP36qPOFcdL8OiPgfoiOyP9Rw=; b=UaxuSUTUKeYoeS6BHkVfOCZULiaVe0+RvBW+9crD7yckqwjcQrb6JFrjrZvQC1nQ3cyX 15LyBfsqHohPFcajjp0NZjoQqByoS7Wi3aE8kd1qdUvkg6ECBGQRHyJa9GqhYBuCZtIT /iVqBq5SX9H3zBq9PmHfOCrMLf49w+UK0auUqd0OJA2eU49eIi7IgF9FTj1K8f7W3WQZ MGub7MsOdE9A4oSTuDniVz96w0Eb9vP6J6jpwC2MuxrTk9FSOoD6Wkpn3ooq19RfmFeO wB4/9veSJjNU2y4kttwX5ojy2C3cPltvoWTItfwZYbbnbnNuJC/Omn/mQ/r9K1SkOrJP Eg== Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by mx0a-002c1b01.pphosted.com with ESMTP id 31ga7jn0ak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 Jun 2020 13:43:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B3Wb9ED4iqvH6uwNXFqa6frqGFAxC7i6Y//JO1ioBb42OpOh/BQPSoIegrztdIe7+vwFM8CI7JveZ7YFf4RvdcNpmsKczo3c6i4lDnYBZ9fm3sAIGmuyXaWxByuKITHD8sXjq6n9VU99zy95CIT+PgQR4IExY3BB0UjirBI2KOrAdNb3buwqqZILY6UNOVXdr+gTPuwDc9G2Rc/9agnbInO72hV+72jEl60rSM42dFlm5AH59fHwsv8gnoHsoCB9I+mmzxVwgDZv/0+hK9MpchguMrFi2X7lIKReLhtSKsbViVZEirM8mu1HqloXVccTtH7zwReqclpeBchz3Jh3tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=62IEbMfHec/ZI1nWAeuP36qPOFcdL8OiPgfoiOyP9Rw=; b=c7QdZ3808X3BlQGKUSoqZWfbZGZSkxk20GnCyoioh7AHagrUDwajGvbzqh7frz37ivsyC9MLrwJUmTRk24kZju4ECmhVFXkOh4h58Idcj6nNeI5ZSsndVVr+aQSavbUnKAbXBr1BmxCE8aPQB+5Nv3aSAme3DROyrayEeo71YvvZeJZmE5pT6j5SRmUEe8bpy0cHCoHUmPvWMyrM28ur2zZRuTxmzQipXAwJUqfLCAXbL2gweXm0dD+Iedf+cxMfjcmN2oL6sEit9Ae1vDEf+enH6XZSUwgH26G0ixZWKpPLtYI2Ouhyh+vjAcJI5nKXLw99jeNZ1gldv66Rcb1Yow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Authentication-Results: openvswitch.org; dkim=none (message not signed) header.d=none;openvswitch.org; dmarc=none action=none header.from=nutanix.com; Received: from BL0PR02MB3714.namprd02.prod.outlook.com (2603:10b6:207:44::16) by BL0PR02MB3873.namprd02.prod.outlook.com (2603:10b6:207:49::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.22; Thu, 11 Jun 2020 20:43:44 +0000 Received: from BL0PR02MB3714.namprd02.prod.outlook.com ([fe80::445e:7f74:952e:2ccb]) by BL0PR02MB3714.namprd02.prod.outlook.com ([fe80::445e:7f74:952e:2ccb%5]) with mapi id 15.20.3088.022; Thu, 11 Jun 2020 20:43:44 +0000 From: Ankur Sharma To: ovs-dev@openvswitch.org Date: Thu, 11 Jun 2020 13:44:41 -0700 Message-Id: <1591908281-42017-2-git-send-email-svc.mail.git@nutanix.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591908281-42017-1-git-send-email-svc.mail.git@nutanix.com> References: <1591908281-42017-1-git-send-email-svc.mail.git@nutanix.com> X-ClientProxiedBy: BYAPR01CA0034.prod.exchangelabs.com (2603:10b6:a02:80::47) To BL0PR02MB3714.namprd02.prod.outlook.com (2603:10b6:207:44::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from northd.localdomain (192.146.154.98) by BYAPR01CA0034.prod.exchangelabs.com (2603:10b6:a02:80::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Thu, 11 Jun 2020 20:43:43 +0000 X-Mailer: git-send-email 1.8.3.1 X-Originating-IP: [192.146.154.98] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70f27d02-4764-4c97-b34b-08d80e482205 X-MS-TrafficTypeDiagnostic: BL0PR02MB3873: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Oob-TLC-OOBClassifiers: OLM:1923; X-Forefront-PRVS: 0431F981D8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o5WeYHcX31sy1Nq2XuI8TEq+uoE4Tk9gGz4nYKxZtxIQt+vsghjGJc+a8HU59yb8k3zNW99S2cBub9hLqOzxQCNrFWPxtEn5gTW5bV9s/JUE+0nwNYbvhx5IgTDSaWq5U1snof0SrnVy8wUmui8Q5YPdWZLX9tWcKPy1vQI14SsvpYgPqVlpUnB5QTlIRqMovmi8nx08VZ/UPBnAgT4cJ2r1yWGh0ElZZGHN+FDisV/8pPcdttnBHmuJuAJBKW8uAHvx3uAraWNdFg1M2W5i7Rlzs5XJ2s68/evxSmr6388kvwHKUhAwjk7Mky82/4aKr1rq6O9cVYFOgLNorYCbBFCcPh4ZaXaau1eCJaAQR0oKwogQZ37tl9MouIVXMApCxCGRB6qJ7pWlyDjU+iMrvA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR02MB3714.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(6019001)(136003)(396003)(366004)(39860400002)(346002)(376002)(5660300002)(83080400001)(66556008)(66476007)(30864003)(66574014)(86362001)(2906002)(66946007)(6486002)(478600001)(16526019)(6512007)(316002)(8676002)(36756003)(186003)(8936002)(26005)(956004)(4326008)(54906003)(6506007)(83380400001)(2616005)(107886003)(6916009)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: sEfDMTZ0KFk5h42y6Ddfkdf4PfHxrHCd2/Ymoz65urcV7sxjfgU8vMor+8keJl/SeqkRXVXPmvPx8+a9salvK5Q0OmisNCRu8GMlhx0dvs9wm+nrvg6J+HDlHjwfXfdB3+NlNDwYCV9huArR9BFqXTVOfNNZQul61SMY1Mkf4MvPEC1tUd6Khci9Phyx4OrDh0N8/ZyXzteEC3c5fAt1o6Sd3NtLUN/x0q5IGC2ox6UUuhAivBSfZqrgFnOqyxlz+G8N2Vhj8ujLgCaOGRbqauXX1b4hL+sUr7du3xSVrMUy/G7jhtBF75PUWR0+DHZzX2mCNBwDETvMscbr3oOST0dBACUcV/e9r5bveSUEan/UXNwD+wvWKbLHABmaCTMCFsJbePRttptrXrDL/jHFzpK2/+utV9sMaWr3642dQT9Bgji4viTC6M70iqXFGKzGoWqBSnCE2YZnuOV2QhwddY3IIec/Eo17P7PonxTPX2w= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70f27d02-4764-4c97-b34b-08d80e482205 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2020 20:43:44.6636 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MQP6UAwHewRztHK/eUKzha4QZ27wNz7KsXlSzzndnni4qCNoCaI2gPyXZnFiTtejfdAQIfR8jKuECzq2sRTSv6OQl5O/vOfSg16zeOpaOy0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR02MB3873 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-11_20:2020-06-11, 2020-06-11 signatures=0 X-Proofpoint-Spam-Reason: safe Cc: Dhathri Purohith , Dhathri Purohith Subject: [ovs-dev] [PATCH v5 2/2 ovn] Add support for DHCP domain search option (119) 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" From: Dhathri Purohith From: Dhathri Purohith Domain search list is encoded according to the specifications in RFC 1035, section 4.1.4. Signed-off-by: Dhathri Purohith Signed-off-by: Ankur Sharma Signed-off-by: Dhathri Purohith > Signed-off-by: Ankur Sharma > Signed-off-by: Dhathri Purohith >> Signed-off-by: Ankur Sharma >> --- lib/actions.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++- lib/ovn-l7.h | 3 ++ northd/ovn-northd.c | 1 + ovn-nb.xml | 15 +++++++++- ovn-sb.ovsschema | 6 ++-- ovn-sb.xml | 11 +++++++ tests/ovn.at | 36 ++++++++++++++++++++++ tests/test-ovn.c | 1 + 8 files changed, 154 insertions(+), 5 deletions(-) diff --git a/lib/actions.c b/lib/actions.c index f21be6d..24c9043 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -1982,7 +1982,8 @@ parse_gen_opt(struct action_context *ctx, struct ovnact_gen_option *o, return; } - if (!strcmp(o->option->type, "str")) { + if (!strcmp(o->option->type, "str") || + !strcmp(o->option->type, "domains")) { if (o->value.type != EXPR_C_STRING) { lexer_error(ctx->lexer, "%s option %s requires string value.", opts_type, o->option->name); @@ -2317,6 +2318,89 @@ encode_put_dhcpv4_option(const struct ovnact_gen_option *o, opt_header[1] = sizeof(ovs_be32); ofpbuf_put(ofpacts, &c->value.ipv4, sizeof(ovs_be32)); } + } else if (!strcmp(o->option->type, "domains")) { + /* Please refer to RFC 1035, section 4.1.4 for the format of encoding + * domain names. Below is an example for encoding a search list + * consisting of the "abc.com" and "xyz.abc.com". + * + * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + * |119|14 | 3 |'a'|'b'|'c'| 3 |'c'|'o'|'m'| 0 |'x'|'y'|'z'|xC0|x00| + * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + * + * The encoding of "abc.com" ends with 0 to mark the end of the + * domain name as required by RFC 1035. + * + * The encoding of "xyz" (for "xyz.abc.com") ends with the two-octet + * compression pointer C000 (hex), which points to offset 0 where + * another validly encoded domain name can be found to complete + * the name ("abc.com"). + * + * Encoding adds 2 bytes (one for length and one for delimiter) for + * every domain name that is unique. If all the domain names are unique + * (which probably never happens in real world), then encoded string + * could be longer than the original string. Just to be on the safer + * side, allocate the (approx.) worst case length here. + */ + uint8_t *dns_encoded = xzalloc(2 * strlen(c->string)); + uint16_t encode_offset = 0; + struct shash label_offset_map; + shash_init(&label_offset_map); + char *domain_list = xstrdup(c->string), *dom_ptr = NULL; + for (char *domain = strtok_r(domain_list, ",", &dom_ptr); + domain != NULL; + domain = strtok_r(NULL, ",", &dom_ptr)) { + if (strlen(domain) > DOMAIN_NAME_MAX_LEN) { + VLOG_WARN("Domain names longer than 255 characters are not" + "supported"); + goto out; + } + char *label_ptr = NULL, *label; + for (label = strtok_r(domain, ".", &label_ptr); + label != NULL; + label = strtok_r(NULL, ".", &label_ptr)) { + /* Check if we have already encoded this label. If yes, + * fill in the reference and break. */ + uint16_t *get_offset; + get_offset = shash_find_data(&label_offset_map, label); + if (get_offset != NULL) { + ovs_be16 temp = htons(0xc000) | htons(*get_offset); + memcpy(dns_encoded + encode_offset, &temp, + sizeof(temp)); + encode_offset += sizeof(temp); + break; + } else { + /* The label was not encoded before, encode it now and add + * the offset to the label_offset_map. */ + uint16_t *set_offset = xzalloc(sizeof(uint16_t)); + memcpy(set_offset, &encode_offset, sizeof(uint16_t)); + shash_add_once(&label_offset_map, label, set_offset); + + uint8_t len = strlen(label); + memcpy(dns_encoded + encode_offset, &len, sizeof(uint8_t)); + encode_offset += sizeof(uint8_t); + memcpy(dns_encoded + encode_offset, label, len); + encode_offset += len; + } + } + /* Add the end marker (0 byte) to determine the end of the + * domain. */ + if (label == NULL) { + uint8_t end = 0; + memcpy(dns_encoded + encode_offset, &end, sizeof(uint8_t)); + encode_offset += sizeof(uint8_t); + } + } + opt_header[1] = encode_offset; + ofpbuf_put(ofpacts, dns_encoded, encode_offset); + + out: + free(domain_list); + free(dns_encoded); + struct shash_node *node, *next; + SHASH_FOR_EACH_SAFE (node, next, &label_offset_map) { + shash_delete(&label_offset_map, node); + } + shash_destroy(&label_offset_map); } } diff --git a/lib/ovn-l7.h b/lib/ovn-l7.h index 38555db..f34bc0d 100644 --- a/lib/ovn-l7.h +++ b/lib/ovn-l7.h @@ -34,6 +34,7 @@ struct gen_opts_map { size_t code; }; +#define DOMAIN_NAME_MAX_LEN 255 #define DHCP_BROADCAST_FLAG 0x8000 #define DHCP_OPTION(NAME, CODE, TYPE) \ @@ -81,6 +82,8 @@ struct gen_opts_map { #define DHCP_OPT_PATH_PREFIX DHCP_OPTION("path_prefix", 210, "str") #define DHCP_OPT_TFTP_SERVER_ADDRESS \ DHCP_OPTION("tftp_server_address", 150, "ipv4") +#define DHCP_OPT_DOMAIN_SEARCH_LIST \ + DHCP_OPTION("domain_search_list", 119, "domains") #define DHCP_OPT_ARP_CACHE_TIMEOUT \ DHCP_OPTION("arp_cache_timeout", 35, "uint32") diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index ef08414..4ec2034 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -11336,6 +11336,7 @@ static struct gen_opts_map supported_dhcp_opts[] = { DHCP_OPT_DOMAIN_NAME, DHCP_OPT_ARP_CACHE_TIMEOUT, DHCP_OPT_TCP_KEEPALIVE_INTERVAL, + DHCP_OPT_DOMAIN_SEARCH_LIST, }; static struct gen_opts_map supported_dhcpv6_opts[] = { diff --git a/ovn-nb.xml b/ovn-nb.xml index 54f5301..80e843c 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -2939,7 +2939,7 @@
- +

These options accept either an IPv4 address or a string value.

@@ -2950,6 +2950,19 @@

+ + +

+ These options accept string value which is a comma separated + list of domain names. The domain names are encoded based on RFC 1035. +

+ + +

+ The DHCPv4 option code for this option is 119. +

+
+
diff --git a/ovn-sb.ovsschema b/ovn-sb.ovsschema index 2ec729b..99c5de8 100644 --- a/ovn-sb.ovsschema +++ b/ovn-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Southbound", - "version": "2.8.1", - "cksum": "236203406 21905", + "version": "2.8.2", + "cksum": "464326363 21916", "tables": { "SB_Global": { "columns": { @@ -218,7 +218,7 @@ "type": "string", "enum": ["set", ["bool", "uint8", "uint16", "uint32", "ipv4", "static_routes", "str", - "host_id"]]}}}}, + "host_id", "domains"]]}}}}, "isRoot": true}, "DHCPv6_Options": { "columns": { diff --git a/ovn-sb.xml b/ovn-sb.xml index 208fb93..a6da80b 100644 --- a/ovn-sb.xml +++ b/ovn-sb.xml @@ -3232,6 +3232,17 @@ tcp.flags = RST;

+
value: domains
+
+

+ This indicates that the value of the DHCP option is a domain name + or a comma separated list of domain names. +

+ +

+ Example. "name=domain_search_list", "code=119", "type=domains". +

+
diff --git a/tests/ovn.at b/tests/ovn.at index d3b35ac..341641b 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -1218,6 +1218,9 @@ reg0[15] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.255.0, reg0[15] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.255.0,mtu=1400,ip_forward_enable=1,default_ttl=121,dns_server={8.8.8.8,7.7.7.7},classless_static_route={30.0.0.0/24,10.0.0.4,40.0.0.0/16,10.0.0.6,0.0.0.0/0,10.0.0.1},ethernet_encap=1,router_discovery=0,tftp_server="tftp_server_test"); formats as reg0[15] = put_dhcp_opts(offerip = 10.0.0.4, router = 10.0.0.1, netmask = 255.255.255.0, mtu = 1400, ip_forward_enable = 1, default_ttl = 121, dns_server = {8.8.8.8, 7.7.7.7}, classless_static_route = {30.0.0.0/24, 10.0.0.4, 40.0.0.0/16, 10.0.0.6, 0.0.0.0/0, 10.0.0.1}, ethernet_encap = 1, router_discovery = 0, tftp_server = "tftp_server_test"); encodes as controller(userdata=00.00.00.02.00.00.00.00.00.01.de.10.00.00.00.6f.0a.00.00.04.03.04.0a.00.00.01.01.04.ff.ff.ff.00.1a.02.05.78.13.01.01.17.01.79.06.08.08.08.08.08.07.07.07.07.79.14.18.1e.00.00.0a.00.00.04.10.28.00.0a.00.00.06.00.0a.00.00.01.24.01.01.1f.01.00.42.10.74.66.74.70.5f.73.65.72.76.65.72.5f.74.65.73.74,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",wpad="https://example.org",bootfile_name="https://127.0.0.1/boot.ipxe",path_prefix="/tftpboot",domain_search_list="ovn.org,abc.ovn.org"); + 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"); + 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.fc.13.68.74.74.70.73.3a.2f.2f.65.78.61.6d.70.6c.65.2e.6f.72.67.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.d2.09.2f.74.66.74.70.62.6f.6f.74.77.0f.03.6f.76.6e.03.6f.72.67.00.03.61.62.63.c0.00,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. @@ -1235,6 +1238,8 @@ reg1[0] = put_dhcp_opts(offerip="xyzzy"); DHCPv4 option offerip requires numeric value. reg1[0] = put_dhcp_opts(offerip=1.2.3.4, domain_name=1.2.3.4); DHCPv4 option domain_name requires string value. +reg1[0] = put_dhcp_opts(offerip=1.2.3.4, domain_search_list=1.2.3.4); + DHCPv4 option domain_search_list requires string value. # nd_ns nd_ns { nd.target = xxreg0; output; }; @@ -5614,6 +5619,37 @@ AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) cat 2.expected | cut -c 53- > expout AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) +reset_pcap_file hv1-vif1 hv1/vif1 +reset_pcap_file hv1-vif2 hv1/vif2 +rm -f 1.expected +rm -f 2.expected + +# Set domain search list option for ls1 +echo "------ Set domain search list --------" +ovn-nbctl dhcp-options-set-options $d1 server_id=10.0.0.1 \ +server_mac=ff:10:00:00:00:01 lease_time=3600 router=10.0.0.1 \ +domain_search_list=\"test1.com,test2.com\" +echo "------------------------------------------" + +# Send DHCPREQUEST in the SELECTING/INIT-REBOOT state with the offered IP +# address in the Requested IP Address option. +offer_ip=`ip_to_hex 10 0 0 6` +server_ip=`ip_to_hex 10 0 0 1` +ciaddr=`ip_to_hex 0 0 0 0` +request_ip=$offer_ip +expected_dhcp_opts=771305746573743103636f6d00057465737432c006330400000e100104ffffff0003040a00000136040a000001 +test_dhcp 2 f00000000002 03 0 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 05 $expected_dhcp_opts + +# NXT_RESUMEs should be 12. +OVS_WAIT_UNTIL([test 12 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) + +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +cat 2.expected | cut -c -48 > expout +AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) +# Skipping the IPv4 checksum. +cat 2.expected | cut -c 53- > expout +AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout]) + OVN_CLEANUP([hv1]) AT_CLEANUP diff --git a/tests/test-ovn.c b/tests/test-ovn.c index 4391694..b43f67f 100644 --- a/tests/test-ovn.c +++ b/tests/test-ovn.c @@ -189,6 +189,7 @@ create_gen_opts(struct hmap *dhcp_opts, struct hmap *dhcpv6_opts, dhcp_opt_add(dhcp_opts, "tftp_server_address", 150, "ipv4"); dhcp_opt_add(dhcp_opts, "arp_cache_timeout", 35, "uint32"); dhcp_opt_add(dhcp_opts, "tcp_keepalive_interval", 38, "uint32"); + dhcp_opt_add(dhcp_opts, "domain_search_list", 119, "domains"); /* DHCPv6 options. */ hmap_init(dhcpv6_opts);