From patchwork Wed Mar 20 14:39:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Yerramneni X-Patchwork-Id: 1914129 X-Patchwork-Delegate: nusiddiq@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=0P1YpO+0; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=selector1 header.b=IwDBRs4l; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0B8d1Hgtz23r9 for ; Thu, 21 Mar 2024 01:40:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 028B54095D; Wed, 20 Mar 2024 14:40:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org 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 X_XfnMYk04ve; Wed, 20 Mar 2024 14:40:26 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 36ABC408F0 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=proofpoint20171006 header.b=0P1YpO+0; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=selector1 header.b=IwDBRs4l Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 36ABC408F0; Wed, 20 Mar 2024 14:40:26 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0E064C0072; Wed, 20 Mar 2024 14:40:26 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 30A3CC0072 for ; Wed, 20 Mar 2024 14:40:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 9D62A4159C for ; Wed, 20 Mar 2024 14:40:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mThO8dD0hbPX for ; Wed, 20 Mar 2024 14:40:22 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=148.163.151.68; helo=mx0a-002c1b01.pphosted.com; envelope-from=naveen.yerramneni@nutanix.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 354F041590 Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=nutanix.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 354F041590 Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=proofpoint20171006 header.b=0P1YpO+0; dkim=pass (2048-bit key, unprotected) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=selector1 header.b=IwDBRs4l Received: from mx0a-002c1b01.pphosted.com (mx0a-002c1b01.pphosted.com [148.163.151.68]) by smtp2.osuosl.org (Postfix) with ESMTPS id 354F041590 for ; Wed, 20 Mar 2024 14:40:22 +0000 (UTC) Received: from pps.filterd (m0127838.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42KAj7o9028455; Wed, 20 Mar 2024 07:40:21 -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-transfer-encoding:content-type:mime-version; s= proofpoint20171006; bh=sqwsLdm9PETkKIR2dhyIe83UlfSvv27sv1padO1Wx vE=; b=0P1YpO+0fvcp+RqneQ/5X6feGSxK+x9gd/kiOZDzKLrk0vvf3H/qmadYN HfUMD2txpmaeGzVI9GOT8LtV15G9zguJClHIwWHOxQpfYUF3jQrZvAh4Ce6ZzXEh c6DdXLB828DUwJo61Sl0neEJ2H5FSnGbsP4OufHDzGpugKf1hxlshx2uoFlHoNNA g1RxURr7zpaIkGFjlcvTCPxjD38dOEotFUEQtzWz2GnR3PFHT/z+LPExPwR98DGQ D17f21+c0H6R3jWntwOxxkpKGDIhQmN8H+brs8XtBHVYTcNyEdwEjjrAMw1DzWY2 +9Er4uc7aaIErCYYEH7lNUjBl1u3g== Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3wyhqmstxu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 07:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X27Xyt4k0PJQRu10AB2cCm77P9drTpNTT74FYvKCpmSJlhA1NNf0lT2joDmeagqVv6/bbgUA2wzkC5+e61vQOZ0WLTrHXOx6MA7w9j4RCvuIf2NT0FIYaZWB5JTB49Vd92axp1iA9BVA1W9DtM9b4y6PAFfWtT5TNGVRGHhMkYJHG7elflg/+ALNBLx5q312lZU0PZSOClC1HpTiw0IL4ui+yY7VR/Zy7gNbWYN4IQ3rVrdA0IAA6vTng5aZdwBJw7YzcOny5TYR+7aw9WRTdP15uEdttdj9NgsY2HNGFoVjHPCqvZY3jySS+/bIDUxXs5SXFFj24wdJ2S8+ldTHpg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sqwsLdm9PETkKIR2dhyIe83UlfSvv27sv1padO1WxvE=; b=c7v8XjUqBU1W0njICagycZZTfjOrdHq86xONHyxeX3GvJxcDKJLUfrrBhFbkEWR5+JDjVkNtAs4wVa8OYerwt5Z5Km94fs46uY7v2MmvSGaqxzjEdcpxKHPaHFfr4haW3cZhCbU5rOj/nkeYSVxBvamN/2fwzN9zeB009Mk4t3ymHGqdg38WyHyZEyMNuKud5UiHXcjDUrbxbvPgSSDRC6DodStYi3lvf/rFu36iSxcauZSAtkX4B+grplq7TDV8cYmJvL2Tfjxbcnb8L3w1a6ept+in8XK3UYWsK2LQ8MwvYIaiwv64oAjOkKcsmzsDXczAfaAeaaVfnNGUt5HYag== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sqwsLdm9PETkKIR2dhyIe83UlfSvv27sv1padO1WxvE=; b=IwDBRs4lc18ifd9sPlgJkCTGRrwbmzqUi05VC9yiZK0SZCHG3p/NF91x97v2AVFIFglZHbHVIfIjTy2Zvo/MslUOikzDfdiu23lsqQKkwBoqQQFVt67ItYJsZqxJhRN+FV9tZag4yIbR6EbBof7MwWhNLFl1VqySUrSWqyJvIXUGYB4quBf1PE44D6ELzRKyGIkGUZU+DFgZxvbYXYzfEggLKNq8EMs0Z2F4gK4XIBwUhDONr8cdQ50EPD8s7TJncTEs7VYxO5du8Saz7jZ7u6l8j4WIFz/BEO3zsXXbO9pPekeyuhWM944mpVFcbJziGuZMXVJQqZImB4PboUlZGQ== Received: from SJ0PR02MB7808.namprd02.prod.outlook.com (2603:10b6:a03:326::16) by SJ2PR02MB9705.namprd02.prod.outlook.com (2603:10b6:a03:53d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.31; Wed, 20 Mar 2024 14:40:19 +0000 Received: from SJ0PR02MB7808.namprd02.prod.outlook.com ([fe80::d95e:4ad8:aa24:7c4]) by SJ0PR02MB7808.namprd02.prod.outlook.com ([fe80::d95e:4ad8:aa24:7c4%3]) with mapi id 15.20.7386.025; Wed, 20 Mar 2024 14:40:19 +0000 From: Naveen Yerramneni To: dev@openvswitch.org Date: Wed, 20 Mar 2024 14:39:55 +0000 Message-Id: <20240320143958.39052-2-naveen.yerramneni@nutanix.com> X-Mailer: git-send-email 2.36.6 In-Reply-To: <20240320143958.39052-1-naveen.yerramneni@nutanix.com> References: <20240320143958.39052-1-naveen.yerramneni@nutanix.com> X-ClientProxiedBy: PH8PR15CA0005.namprd15.prod.outlook.com (2603:10b6:510:2d2::12) To SJ0PR02MB7808.namprd02.prod.outlook.com (2603:10b6:a03:326::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR02MB7808:EE_|SJ2PR02MB9705:EE_ X-MS-Office365-Filtering-Correlation-Id: 2402ad92-65bf-479a-9661-08dc48ebaa6d x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yTQyxeGoykrr5fRABevmP/DGBXROL19xgcZspqVLRRxHOwoCeRQHIlPq2I7B8Ow7kW5+72swplrsK7zg2At+En41/EqAj0y8MD6awnU2FV5CqNRSbQzMFXKmdAWdp5Nh2Iuh9qAi6kXHlm0Q5T16Fs9embPWCMC3JfoPa1+lA82NdoAGuEzqdkclEUJkdX/i82/OwDxRR4L5j+K9agl4sSqXHmZmWEK3Tm1BreUP+X+p+3MITSPdTIxjoMuW4NyLZQmN2Gkbkgi5xPnYwpm1uz+HrN1235XjVXzOAWK97AXXWYCN/BJTM2t072qxIe5hL9eBO2ihYPd2teFyy9DWLAfi/qh94Ti0tt4DdaBApkh2109nD0dtiAYqhaHx4vFFQXjV5WsJMY6N0HXw25+CXtpx0OVw/ocfHsRF1U8ChQ3dym7njuVQ2U5v+CqEF/MK7bWFMr3wOa7/6zkt3Ygt+t7N3lS4Ic5JrWh/bb96AEH4fWCAqDZKpi8xvESzPnThUJ1j75ueUaBdDVzAQXlfBrd1d8bAfH4lFPdARHbkbbPft1XpTmvvzdCJnWV1IfqnkEMFJpJbyoE7AWKGgqAN8d/7I20ecuITn8+/lmxBCDkXlyp39eTWUZ1yaeuN1uPo50/RnSSFaSwyJYEv19JN5qJzZUh1LZj0voNWE4EVPPFp7KHmq9YgUmDpyuJ8prKS2nD3/bZ+TpyL5682C9FewpOd23ukxZWWH/uGgaRvEp8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR02MB7808.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(52116005)(1800799015)(376005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: df2NoZWFIFs89Rk3cXImjPJShwdYQaxl0RdWB9QZe8UFwoHbEzXVN00eg2JB5nIV2tElaekq9DxA6XmoFyJPMN0A1rug86uZLdOlb3w6ByhpgS5LTYFIflvC3i0AtW7jxVaAg4eI1ogoJfZ6v2egHuo+p46QaD8NFHKUHKF4XhfeLjGz3jIRP8vSazb5W5lgLHkj6y2OUpEHMy9WnE+ZdRbKv2pEFNly32580CoWfGvy/lswR6zaJ6IcuwixudN46VCX3y/2zp+uSQQYdaDGJCTUejneXi3aipEZaJ8JTHeOmT7R7ZHLMk/t3yUEcb3o0kvsDAdZi94MRk9nxDnGtmlIT5IHH/WpnRP4fNTFkctlw7vqeCOD1n0+Baqov9VEX+vNG0e0iHAKCMHsqIS4b6gXDv53zAhvOSLQdCzvJoMNw7JCKCs7S+1DTwEaZNiXFYcQDWPAdEkPd3z9tpws4toLT2yHmvWhatSYsKvqNLgLAndgN8bTEVSrA9fTwxTQbG+s36abMqb4TvTDhqPeUursg+qlsmFwrLnn5IzSVpsU6zKNYFV8tmcVkyE4vyuMPPErbIt/Rkd1KJGPlLT1D1BBt9SpXa8TeuRGyEBzaZR+hBl1riGpsldzUX06LQnO0b10l7EhijLa5YnHSb2NGDZABJKy/dYO6GWkvh1KYT6HpmhyrCBYZ65a2enpNwtYBZKJajowu3n2CABxJD54trLA6zPA+R0w0OtbzKZSAGtuDLXZ7otZ1OiG+L3VV6MCj/aWX+8L5KdDAFUHlBiqjHv1Qdwe8ISnQVoThzHu1BXwpVn1yDs3df2tj6w9pn3NQAi4On2Yd68C1Z1ftui0wJbUVKQfI8mIsCNc/GY1dEtTPxaclFsbcQEQyRGPp+RtMyJh7peigLaSsrGToKVu/EkkzVttbxGm5P7A5Biv8g9wENIjmPX+IpR6Ekppx/gEzVNytor7fu67yz9OR37kyd9k65Mwx2H/5cKQNHrugXL9Cf6RySKQyG9SbADpPfKzZ1IUVGOzFFZ4ZV0wedsHTAsAtEfe8sH9AcNHNLrDqD2OxWGzFmWy+3aZXlf43W8EIduERwz2BkA7LkGDlSvwclTJ2421PICZRA5/TFXNKUj4Jnf1GJwhrSw6vQVydkbgH7bsJUJVJ2xDOgqibACAqhicXhP68KY5CgUPZmN6EEIT1KJF4e5DuJNO02F+qpBLntV6ACvNFeEiQZnVeCaVIVPhdQrOf58nzOiq4ICEMnueVS73bM8NdzoNzx0Pi3MTFYFIPq0crA2eDNK66TYzeHFHuBc5o2OtSwGFuoCS60t2IN+/Al/kwO2JlAWUmUY1b39dhJn1hSw1tyBJ8PNtt6josLEVboYwfc3T2dvtvYt3S5uLRvov1102+0No2nSpQjIgoYedTpLEOdkxsG+5O/sQjh4+IZdNAngoe8jDSufOkAY+QrFS9zo8zez2keIicVI1GXpBMvjSp5roizmuChQJ7D4f4tA9zKlT/RwchLc3LcfhOX2Ml7ZKzlW+i0VsJdZQbXzQubXRblP0Sg+6T2d8iD5LXBunj2FWIZnevECXOI3RrVvMrtlrLF6zNhPk4AXuNWuQzqoHrBST5WX1QsykCy2f4q1cDfXwmP/OGxs= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2402ad92-65bf-479a-9661-08dc48ebaa6d X-MS-Exchange-CrossTenant-AuthSource: SJ0PR02MB7808.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2024 14:40:19.5316 (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: l53vXbWfTGjh9P0lJr0BWshqgSKz6jM3qO98ql7LFlDeZkHxpSIH1Gc2nWRe4YJxUASXj/vj3ifLPFgiM2mV9biANbJX2eZCyt+taJQeyEI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR02MB9705 X-Proofpoint-ORIG-GUID: Mg8QyPkFOi0YnpqRe-Hf3ezcQy6N5eOy X-Proofpoint-GUID: Mg8QyPkFOi0YnpqRe-Hf3ezcQy6N5eOy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-20_10,2024-03-18_03,2023-05-22_02 X-Proofpoint-Spam-Reason: safe Cc: huzaifa.c@nutanix.com Subject: [ovs-dev] [PATCH OVN v5 1/4] actions: DHCP Relay Agent support for overlay IPv4 subnets. 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" NEW OVN ACTIONS --------------- 1. dhcp_relay_req_chk(, ) - This action executes on the source node on which the DHCP request originated. - This action relays the DHCP request coming from client to the server. Relay-ip is used to update GIADDR in the DHCP header. 2. dhcp_relay_resp_chk(, ) - This action executes on the first node (RC node) which processes the DHCP response from the server. - This action updates the destination MAC and destination IP so that the response can be forwarded to the appropriate node from which request was originated. - Relay-ip, server-ip are used to validate GIADDR and SERVER ID in the DHCP payload. Signed-off-by: Naveen Yerramneni --- include/ovn/actions.h | 27 ++++++++ lib/actions.c | 149 ++++++++++++++++++++++++++++++++++++++++++ utilities/ovn-trace.c | 67 +++++++++++++++++++ 3 files changed, 243 insertions(+) diff --git a/include/ovn/actions.h b/include/ovn/actions.h index dcacbb1ff..8d0c6b9fa 100644 --- a/include/ovn/actions.h +++ b/include/ovn/actions.h @@ -96,6 +96,8 @@ struct collector_set_ids; OVNACT(LOOKUP_ND_IP, ovnact_lookup_mac_bind_ip) \ OVNACT(PUT_DHCPV4_OPTS, ovnact_put_opts) \ OVNACT(PUT_DHCPV6_OPTS, ovnact_put_opts) \ + OVNACT(DHCPV4_RELAY_REQ_CHK, ovnact_dhcp_relay) \ + OVNACT(DHCPV4_RELAY_RESP_CHK, ovnact_dhcp_relay) \ OVNACT(SET_QUEUE, ovnact_set_queue) \ OVNACT(DNS_LOOKUP, ovnact_result) \ OVNACT(LOG, ovnact_log) \ @@ -396,6 +398,15 @@ struct ovnact_put_opts { size_t n_options; }; +/* OVNACT_DHCP_RELAY. */ +struct ovnact_dhcp_relay { + struct ovnact ovnact; + int family; + struct expr_field dst; /* 1-bit destination field. */ + ovs_be32 relay_ipv4; + ovs_be32 server_ipv4; +}; + /* Valid arguments to SET_QUEUE action. * * QDISC_MIN_QUEUE_ID is the default queue, so user-defined queues should @@ -772,6 +783,22 @@ enum action_opcode { /* multicast group split buffer action. */ ACTION_OPCODE_MG_SPLIT_BUF, + + /* "dhcp_relay_req_chk(relay_ip, server_ip)". + * + * Arguments follow the action_header, in this format: + * - The 32-bit DHCP relay IP. + * - The 32-bit DHCP server IP. + */ + ACTION_OPCODE_DHCP_RELAY_REQ_CHK, + + /* "dhcp_relay_resp_chk(relay_ip, server_ip)". + * + * Arguments follow the action_header, in this format: + * - The 32-bit DHCP relay IP. + * - The 32-bit DHCP server IP. + */ + ACTION_OPCODE_DHCP_RELAY_RESP_CHK, }; /* Header. */ diff --git a/lib/actions.c b/lib/actions.c index 71615fc53..d4f4ec2d0 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -2706,6 +2706,149 @@ ovnact_controller_event_free(struct ovnact_controller_event *event) free_gen_options(event->options, event->n_options); } +static void +format_DHCPV4_RELAY_REQ_CHK(const struct ovnact_dhcp_relay *dhcp_relay, + struct ds *s) +{ + expr_field_format(&dhcp_relay->dst, s); + ds_put_format(s, " = dhcp_relay_req_chk("IP_FMT", "IP_FMT");", + IP_ARGS(dhcp_relay->relay_ipv4), + IP_ARGS(dhcp_relay->server_ipv4)); +} + +static void +parse_dhcp_relay_req_chk(struct action_context *ctx, + const struct expr_field *dst, + struct ovnact_dhcp_relay *dhcp_relay) +{ + /* Skip dhcp_relay_req_chk( */ + lexer_force_match(ctx->lexer, LEX_T_LPAREN); + + /* Validate that the destination is a 1-bit, modifiable field. */ + char *error = expr_type_check(dst, 1, true, ctx->scope); + if (error) { + lexer_error(ctx->lexer, "%s", error); + free(error); + return; + } + dhcp_relay->dst = *dst; + + /* Parse relay ip and server ip. */ + if (ctx->lexer->token.format == LEX_F_IPV4) { + dhcp_relay->family = AF_INET; + dhcp_relay->relay_ipv4 = ctx->lexer->token.value.ipv4; + lexer_get(ctx->lexer); + lexer_match(ctx->lexer, LEX_T_COMMA); + if (ctx->lexer->token.format == LEX_F_IPV4) { + dhcp_relay->family = AF_INET; + dhcp_relay->server_ipv4 = ctx->lexer->token.value.ipv4; + lexer_get(ctx->lexer); + } else { + lexer_syntax_error(ctx->lexer, "expecting IPv4 dhcp server ip"); + return; + } + } else { + lexer_syntax_error(ctx->lexer, "expecting IPv4 dhcp relay " + "and server ips"); + return; + } + lexer_force_match(ctx->lexer, LEX_T_RPAREN); +} + +static void +encode_DHCPV4_RELAY_REQ_CHK(const struct ovnact_dhcp_relay *dhcp_relay, + const struct ovnact_encode_params *ep, + struct ofpbuf *ofpacts) +{ + struct mf_subfield dst = expr_resolve_field(&dhcp_relay->dst); + size_t oc_offset = encode_start_controller_op( + ACTION_OPCODE_DHCP_RELAY_REQ_CHK, + true, ep->ctrl_meter_id, + ofpacts); + nx_put_header(ofpacts, dst.field->id, OFP15_VERSION, false); + ovs_be32 ofs = htonl(dst.ofs); + ofpbuf_put(ofpacts, &ofs, sizeof ofs); + ofpbuf_put(ofpacts, &dhcp_relay->relay_ipv4, + sizeof(dhcp_relay->relay_ipv4)); + ofpbuf_put(ofpacts, &dhcp_relay->server_ipv4, + sizeof(dhcp_relay->server_ipv4)); + encode_finish_controller_op(oc_offset, ofpacts); +} + +static void +format_DHCPV4_RELAY_RESP_CHK(const struct ovnact_dhcp_relay *dhcp_relay, + struct ds *s) +{ + expr_field_format(&dhcp_relay->dst, s); + ds_put_format(s, " = dhcp_relay_resp_chk("IP_FMT", "IP_FMT");", + IP_ARGS(dhcp_relay->relay_ipv4), + IP_ARGS(dhcp_relay->server_ipv4)); +} + +static void +parse_dhcp_relay_resp_chk(struct action_context *ctx, + const struct expr_field *dst, + struct ovnact_dhcp_relay *dhcp_relay) +{ + /* Skip dhcp_relay_resp_chk( */ + lexer_force_match(ctx->lexer, LEX_T_LPAREN); + + /* Validate that the destination is a 1-bit, modifiable field. */ + char *error = expr_type_check(dst, 1, true, ctx->scope); + if (error) { + lexer_error(ctx->lexer, "%s", error); + free(error); + return; + } + dhcp_relay->dst = *dst; + + /* Parse relay ip and server ip. */ + if (ctx->lexer->token.format == LEX_F_IPV4) { + dhcp_relay->family = AF_INET; + dhcp_relay->relay_ipv4 = ctx->lexer->token.value.ipv4; + lexer_get(ctx->lexer); + lexer_match(ctx->lexer, LEX_T_COMMA); + if (ctx->lexer->token.format == LEX_F_IPV4) { + dhcp_relay->family = AF_INET; + dhcp_relay->server_ipv4 = ctx->lexer->token.value.ipv4; + lexer_get(ctx->lexer); + } else { + lexer_syntax_error(ctx->lexer, "expecting IPv4 dhcp server ip"); + return; + } + } else { + lexer_syntax_error(ctx->lexer, "expecting IPv4 dhcp relay and " + "server ips"); + return; + } + lexer_force_match(ctx->lexer, LEX_T_RPAREN); +} + +static void +encode_DHCPV4_RELAY_RESP_CHK(const struct ovnact_dhcp_relay *dhcp_relay, + const struct ovnact_encode_params *ep, + struct ofpbuf *ofpacts) +{ + struct mf_subfield dst = expr_resolve_field(&dhcp_relay->dst); + size_t oc_offset = encode_start_controller_op( + ACTION_OPCODE_DHCP_RELAY_RESP_CHK, + true, ep->ctrl_meter_id, + ofpacts); + nx_put_header(ofpacts, dst.field->id, OFP15_VERSION, false); + ovs_be32 ofs = htonl(dst.ofs); + ofpbuf_put(ofpacts, &ofs, sizeof ofs); + ofpbuf_put(ofpacts, &dhcp_relay->relay_ipv4, + sizeof(dhcp_relay->relay_ipv4)); + ofpbuf_put(ofpacts, &dhcp_relay->server_ipv4, + sizeof(dhcp_relay->server_ipv4)); + encode_finish_controller_op(oc_offset, ofpacts); +} + +static void ovnact_dhcp_relay_free( + struct ovnact_dhcp_relay *dhcp_relay OVS_UNUSED) +{ +} + static void parse_put_opts(struct action_context *ctx, const struct expr_field *dst, struct ovnact_put_opts *po, const struct hmap *gen_opts, @@ -5406,6 +5549,12 @@ parse_set_action(struct action_context *ctx) lexer_lookahead(ctx->lexer) == LEX_T_LPAREN) { parse_chk_lb_aff(ctx, &lhs, ovnact_put_CHK_LB_AFF(ctx->ovnacts)); + } else if (lexer_match_id(ctx->lexer, "dhcp_relay_req_chk")) { + parse_dhcp_relay_req_chk(ctx, &lhs, + ovnact_put_DHCPV4_RELAY_REQ_CHK(ctx->ovnacts)); + } else if (lexer_match_id(ctx->lexer, "dhcp_relay_resp_chk")) { + parse_dhcp_relay_resp_chk(ctx, &lhs, + ovnact_put_DHCPV4_RELAY_RESP_CHK(ctx->ovnacts)); } else { parse_assignment_action(ctx, false, &lhs); } diff --git a/utilities/ovn-trace.c b/utilities/ovn-trace.c index e0f1c3ec9..dd7016fc3 100644 --- a/utilities/ovn-trace.c +++ b/utilities/ovn-trace.c @@ -2329,6 +2329,63 @@ execute_put_dhcp_opts(const struct ovnact_put_opts *pdo, execute_put_opts(pdo, name, uflow, super); } +static void +execute_dhcpv4_relay_req_chk(const struct ovnact_dhcp_relay *dr, + struct flow *uflow, struct ovs_list *super) +{ + ovntrace_node_append( + super, OVNTRACE_NODE_ERROR, + "/* We assume that this packet is DHCPDISCOVER or DHCPREQUEST. */"); + + struct ds s = DS_EMPTY_INITIALIZER; + struct mf_subfield dst = expr_resolve_field(&dr->dst); + if (!mf_is_register(dst.field->id)) { + /* Format assignment. */ + ds_clear(&s); + expr_field_format(&dr->dst, &s); + ovntrace_node_append(super, OVNTRACE_NODE_MODIFY, + "%s = 1", ds_cstr(&s)); + } + ds_destroy(&s); + + struct mf_subfield sf = expr_resolve_field(&dr->dst); + union mf_subvalue sv = { .u8_val = 1 }; + mf_write_subfield_flow(&sf, &sv, uflow); +} + +static void +execute_dhcpv4_relay_resp_chk(const struct ovnact_dhcp_relay *dr, + struct flow *uflow, struct ovs_list *super) +{ + ovntrace_node_append( + super, OVNTRACE_NODE_ERROR, + "/* We assume that this packet is DHCPOFFER or DHCPACK and " + "DHCP broadcast flag is set. Dest IP is set to broadcast. " + "Dest MAC is set to broadcast but in real network this is unicast " + "which is extracted from DHCP header. */"); + + /* Assume DHCP broadcast flag is set */ + uflow->nw_dst = htonl(0xFFFFFFFF); + /* Dest MAC is set to broadcast but in real network this is unicast */ + struct eth_addr bcast_mac = { .ea = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}}; + uflow->dl_dst = bcast_mac; + + struct ds s = DS_EMPTY_INITIALIZER; + struct mf_subfield dst = expr_resolve_field(&dr->dst); + if (!mf_is_register(dst.field->id)) { + /* Format assignment. */ + ds_clear(&s); + expr_field_format(&dr->dst, &s); + ovntrace_node_append(super, OVNTRACE_NODE_MODIFY, + "%s = 1", ds_cstr(&s)); + } + ds_destroy(&s); + + struct mf_subfield sf = expr_resolve_field(&dr->dst); + union mf_subvalue sv = { .u8_val = 1 }; + mf_write_subfield_flow(&sf, &sv, uflow); +} + static void execute_put_nd_ra_opts(const struct ovnact_put_opts *pdo, const char *name, struct flow *uflow, @@ -3216,6 +3273,16 @@ trace_actions(const struct ovnact *ovnacts, size_t ovnacts_len, "put_dhcpv6_opts", uflow, super); break; + case OVNACT_DHCPV4_RELAY_REQ_CHK: + execute_dhcpv4_relay_req_chk(ovnact_get_DHCPV4_RELAY_REQ_CHK(a), + uflow, super); + break; + + case OVNACT_DHCPV4_RELAY_RESP_CHK: + execute_dhcpv4_relay_resp_chk(ovnact_get_DHCPV4_RELAY_RESP_CHK(a), + uflow, super); + break; + case OVNACT_PUT_ND_RA_OPTS: execute_put_nd_ra_opts(ovnact_get_PUT_DHCPV6_OPTS(a), "put_nd_ra_opts", uflow, super);