From patchwork Wed Apr 24 09:56:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Yerramneni X-Patchwork-Id: 1927082 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=QkGca65r; 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=NXLJJ933; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.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 4VPZCG06nrz1yZr for ; Wed, 24 Apr 2024 19:56:58 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 1A5B040825; Wed, 24 Apr 2024 09:56:56 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id cnhjIOTAImqS; Wed, 24 Apr 2024 09:56:52 +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 90ED440791 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=QkGca65r; 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=NXLJJ933 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 90ED440791; Wed, 24 Apr 2024 09:56:52 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6C817C0077; Wed, 24 Apr 2024 09:56:52 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6F675C0037 for ; Wed, 24 Apr 2024 09:56:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id CA57F60BA8 for ; Wed, 24 Apr 2024 09:56:42 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 2ue0gUbu9og8 for ; Wed, 24 Apr 2024 09:56:41 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=148.163.155.12; helo=mx0b-002c1b01.pphosted.com; envelope-from=naveen.yerramneni@nutanix.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org D1E3D60B2C Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=nutanix.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D1E3D60B2C Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=proofpoint20171006 header.b=QkGca65r; dkim=pass (2048-bit key, unprotected) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=selector1 header.b=NXLJJ933 Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) by smtp3.osuosl.org (Postfix) with ESMTPS id D1E3D60B2C for ; Wed, 24 Apr 2024 09:56:40 +0000 (UTC) Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43O0S6NB031071; Wed, 24 Apr 2024 02:56:39 -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=W/pxnzopXuNQrhNqfn8PFntFvb8fUxj7Brq2M6Hy9 fc=; b=QkGca65r3njrVTZsiCphyWx2gn3ducTgCbMCQtSAyl/7pGGIyX+I3DKXk /r/yUTKu2Boip56/p4pdH/4zZEPj8xlaPvoaMxdVLtYl03R1DHcBj/r7XLI9aHxt /Qkt0+xNkqo6jhHGIVeXMUNFx81JQIehleYN9pgtJZb9oKwvgsDCeP4f9xjlIEW8 G5gUO+NyzWne+5cSQN+NKdYct9jYLrxfhdBePBrAv58T2wLkHzaZq+R/dYDw/dqm H9zHEfX3buD/zl92G1PzgU5rbQzmHpuc4JnThK5CW228N0y08ZCpFqJWbMd2ytYC rDtBQ1faLrPAyDobLM/XgWlMMgtQg== Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2041.outbound.protection.outlook.com [104.47.56.41]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3xmd7yfsuc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 Apr 2024 02:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KwNWcynjk+rwQNudoueUK/VzB1pewcfK5vMVmtW9+fhDdvhKeNH9kWlDYBsN/y5K+of1AKlOT2A7CFi8ZEYQ2KknVRqkwFW/4bgYMiPf9WeU5N1chExtX3rN4CsKO4SQ8q2l/ME1/YT8hW+JNRsKR6tq/ptmoCW0Pk7soad78x3vZTdW0b3eIJTBfeVnrbVKYfKW+FIk7nWlmH1bXM8IrCFP7EEHwhm5l860/Ud7fjYqGJjIUIuM3DqaJm9wigfh2LOXb4y++DnK1hyLfWY623CE0aD7DHrdCoaPM34k/nlUZtCWVWMUaKsOuvTE1tj2D+01ZS7qgis0hRkBEs4omQ== 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=W/pxnzopXuNQrhNqfn8PFntFvb8fUxj7Brq2M6Hy9fc=; b=FOHH3qPDi2/PwQrsvQk6/oXOYIy30onP5F2gB+PWk3mUomVfqwfl59aBk0RaDULVyZA69WtEF0uU8z+OVMpK2l7BOoFCpEwuyLv5u+/f9PMnrlVCc224THvRQRP68Nfcd9elTob/+HjO2W90B1/q6E5w7UjyYm4hXCBmSFoL/vEPp5kPJX63opM5AFg7b4eJYl5x8kB/TKhrKRYPhKPrPH5J0Sb5Q5IyeJRPKY+quNqHtRnQ0oPCt1w5QiA3hFnkl+uoafjScU7d0dSbJ5JH8lE9ihzWfRz42uwvITITAUwKxkNkwI1zJilRdc8lGbZcqb5M06YHuQ0/VXL4CPTluw== 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=W/pxnzopXuNQrhNqfn8PFntFvb8fUxj7Brq2M6Hy9fc=; b=NXLJJ933KrOD4FRMLkolhR+d8oCGxyCjMPaCk7CdQkFY6i1zNemU4OR8ucwCv5wtLBWrPQQKdVbK+TAieHsDYWZtxOZ4Z5muO34NOKmkxmSeLaxFMd/2qEgXNh+ih0NOIUjpkhr5ZrdIIYySy8xvEOkIX+iHVxVovMCkoINv+aZUo/UcGo1bKf+5unf7ziuIXvnvXwiCBBw1QEB0x1kKlcxjwBK1YwYzYpGFCNR2mHxfTlEjrObQjxSTVzXWom61c/Nnq8MWtygJunSFgLFnzIJGMLMOGZ0UET9GBg30Y6L0clkgnHAM/bQJdzwZ53LzX8plfW9nmEN1w6qaJwf3Tg== Received: from SJ0PR02MB7808.namprd02.prod.outlook.com (2603:10b6:a03:326::16) by SJ0PR02MB7453.namprd02.prod.outlook.com (2603:10b6:a03:29b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.23; Wed, 24 Apr 2024 09:56:37 +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.7519.021; Wed, 24 Apr 2024 09:56:37 +0000 From: Naveen Yerramneni To: dev@openvswitch.org Date: Wed, 24 Apr 2024 09:56:06 +0000 Message-Id: <20240424095607.129155-3-naveen.yerramneni@nutanix.com> X-Mailer: git-send-email 2.36.6 In-Reply-To: <20240424095607.129155-1-naveen.yerramneni@nutanix.com> References: <20240424095607.129155-1-naveen.yerramneni@nutanix.com> X-ClientProxiedBy: PH8PR21CA0001.namprd21.prod.outlook.com (2603:10b6:510:2ce::25) To SJ0PR02MB7808.namprd02.prod.outlook.com (2603:10b6:a03:326::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR02MB7808:EE_|SJ0PR02MB7453:EE_ X-MS-Office365-Filtering-Correlation-Id: 589697dc-995f-49ed-7c69-08dc6444d4bf x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|366007|52116005|376005|1800799015|38350700005; X-Microsoft-Antispam-Message-Info: FxcrZf6O/y1kP41ZpiU1YpLEIWGF/QfYcG8LsUl6uplJlNt3AnXbPcL5qdXGz6J2FKvlQ/vY6FdvmCU98ovAZp2PrYmu3XHPx+UvfGUT4KROjA7nNvHpQ69Sq3oQJFXXOZvXaV+9CavAGlSCAj7LiVH3cNrxNgJ0VH5MyAV+6Cb86A01ys6ENGLRHiFCxKghQBvOn1oqhp+mA7tpFIpyD7Zx0Xodmwfhu92j9x4nV6zX4Az7+r2XN+se0NvEHKRo7eYQEt+lHH/M/PPVzy952toXkKnN43/lWYpQbztFeoS96WQYTDge8O9dJBay/oNXmdyv9IDL5nrnocG/j+LTkmG43mzUgkJgpVyhYYNRNsDPyzi/lxr4SGrOb90qCH1V53COq0i4VlAVuV2Dv36/8R00DjFd6Mpm9eyXq+orGJh9i29jxKi3SjVVkUKtHb8FlxAKyuArrA/KmePZBzuwZYwe/T0Y4MQOqgnedUIqx7BtQ2oQPM81dyqaJ46rx59upDxku/YNtkojolNUq9gbtq7tFkGo0JsvbqxsXEJV0LPExVpL1SeiwkidPw31DXk2WoxfswQzTWsm0tCSxlu4015Y4WfpZzkeMD8Tz6BsH2vnMzhc++hJ16Vmg8tOn23X8YmY4Kj+sEGYX84nnnb+9xDwF654RjTdrzY2dUYzrQ8VTC+cUNA4dDhM0kjZGd7881VX82/9/UVWdarLdDFPbD7qPKU/6K3Fl/j21I6930bR/KCn82qRKryRGrTWubKzPJuqMWd4ikmDAHJRBqgMyETOQteeCLvDjUbCwzbE0yqYf5I47hKpLqMgezjYBeqabPvt5+v+sj81MkdwaapveIg1q+QIReNMgbX0g2LEK8ZfOyrCaGJrQIw6I3sHCLsMdKTZeaUBal6TntJtnxSGnMu4ryGhKtR5VNPQTIH0ZfVUrXt4MJ9E5WwkTBUgLUeyC9fyUeI9tstSdBb5+KpOZ3Xn2/VETPbipfJpQqRCbSFiOQpt0z8kwZw1P3qk5BKCwx3WFMcROKMR/49b+BrizgrOp3HTNrgbfQjM94WNUbe7HpxhqiH0hQwlj08f40pYlXHW449V1PNgokL2Colc3f8tlpLk7WWbsnVTJ/bcQ/lnmwHa/Ldht7n9q2B7fRm+pmIZ7nW8fwiqiFF0H3DmSxyPWUExffezaC1JGg5+8xg+VZF075qoj33KeWW8QH92A0WucC+WJSkFZ5thfRnat9RwN0VcnDISSTSslbLw7W9CRlKbwW/gKorebpTOb2PI6z06RJw7+fFdTs9VpZxQu0eaZ66kcXxCe3rzYxqo1R5htIOBbjCIVkKX9dZMvcqqOO1KDapHoNSiOMs3G0T2Vg== 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)(376005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h76f5dHzUP86pjfMMSIga3RQ9Zr3ynQctLB1rFpN84+EIPDCamZ+do/NFR3ua8phkOpQVXqroP7ChCmCzw3EHbATUcRN3vw0HFbz4FwbhBw12H4K6zL7RQ9f8zfXQjhIZvyO7Zm+mCKYpCKiE8eCq8fGIaKOyHN2DHQZThJcP0wTxGt0yuNP7Hu+kVtj9OdHqLRnBQAYQD38ox9msKoaGnGsQ+F2H0EkIlw5NFRjbQ1yrqTt2m1sRTXDO8gRtW1aZlYwOGsZaWyiXZQFyV2bp4xGD6VAs5rcDaJyeL32pNI1+WQfLS3zpt3SebSpIeJIHHk0XJxWyp3cViG+N0DdFcZnpdnBj/I3uTqBiSRUmBd0B/M8pD8dAcC1PEHBMWUJJEHDixJHYm1Lat2RcKWA/E0WrpSgnu3xRhC9KVTxxHCciaQ9MkZhozR22fq+exNqF4fq+hcCcCcDt6Q9s+k1RkQHdXf+1kYUtFh/PeFYR4KyXJeqo2bULNc3JXq/AqWwVu/e9RXGSMkAbpMwUkOYVlTxukPi/UiKe8pmR6V4LEwt9uQsdKLM2VsFnRcg0v+LheCt2JVLp2ALsrnRqnzX/d6pdFiUsTGkWeUmUbze552W3sdyCb1364kDeEaMEEMOntXJvNcnIKs2TCBZmubfvqnxKuisc6ftx6y159hxlSyVtCQt29Pev37yZk365dKYuPva7x9rlNuh96o8sGBZu4IoDKSNoShI6qxw3TbmRDcvxwDBgYTcH45bDM9o1WZEh8ekRM0NHfF95ecsddwsaf6B/rMOTkkhp0dUybaX2PXz4VBrfIR5bE1egI1cxMA+BfUUt6M6+Y15jzZcepQ1XWR114hYRw7Ny2X2pc4R5pnKxIQjYjk1TyHdUr7N0TnuN7eSoi48ob0tUr0VGWWERZp4D1cLvkBOfPR+UF7xtfSqSHJduBg3f8b3qbhUbJ+cP+wa8fYvRdCLd1h6P9kvwLghk0SdSNO3IcVTAXAht0eropZHmr3pGQcL5NEI1H+ZEEfzJHNaMOvdFPhGt6Pwp+Dd7yAmYzKYjsvuf/ga9VFCnVkUBwA37sKa4MQMYX94/+n8hrz6l3ZQFeKN438CwPyIFdpxpHpOpV71U8rN1E8saiUWcvSnxbAFpxA602x8TzE1jg7JlvBko+hhNveeSBaYdyUiS1CaRbEB9iIXIItlcJ1JR6fgKz4pVSwXV+0D4MfJ0UhKqy9Xq2I1I/vZyjufeQMY2OYBQPoUzeYRbBJ8aQByOE7fzuvMvh/7929QKAHserGalUZelV26h8xt6+S/18MMgatAyaeHOSh+GlhkG7AY8SzHynYHF5Q28781es9OMm3QbR5Cxkgy+Asu/nvSEQZ+jUqevYUVg+av21lrScAnIeh4OPjRK8wcQjaoBQaLaHiXYh2JPjgNjxqOG4jI20geEJxuP0lqqJO9ZDkYyLUa6biyhy8c3yY3b8vuKsqufE7jIHe5fuYEumWKz232wQId3ImPs18NSQuS7SMoCHwXmWBZsCFveg1v9o3kZVF+v/IlheFNySPK/eEMhdeD57/dQ/PQzAzkBt9nc1fFDZ601EQ6wQLcBEA7rTXVkLo5FDuOujMqLMaLprMC/TtIft0oTGnKuvOp7zXxLS8= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 589697dc-995f-49ed-7c69-08dc6444d4bf X-MS-Exchange-CrossTenant-AuthSource: SJ0PR02MB7808.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2024 09:56:37.1093 (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: qNAA/Que7bTTV+gCWZsnalqNFn2qlUfXjruNsyvKFgYrK+Kn/DPbwo+7KFY6hIfLnuE5Aoo3aFJLtQyK7IYkmKS7ipLXbDj/12dZMzUl6s8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR02MB7453 X-Proofpoint-GUID: Rp-COrbJbigd0sF2B2FDvQDY2tSqC6jC X-Proofpoint-ORIG-GUID: Rp-COrbJbigd0sF2B2FDvQDY2tSqC6jC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-24_07,2024-04-23_02,2023-05-22_02 X-Proofpoint-Spam-Reason: safe Cc: huzaifa.c@nutanix.com Subject: [ovs-dev] [PATCH OVN v6 2/3] controller: 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" Added changes in pinctrl to process DHCP Relay opcodes: - ACTION_OPCODE_DHCP_RELAY_REQ_CHK: For request packets - ACTION_OPCODE_DHCP_RELAY_RESP_CHK: For response packet Signed-off-by: Naveen Yerramneni --- controller/pinctrl.c | 597 ++++++++++++++++++++++++++++++++++++++----- lib/ovn-l7.h | 2 + 2 files changed, 530 insertions(+), 69 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index aa73facbf..50e090cd2 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -1993,6 +1993,515 @@ is_dhcp_flags_broadcast(ovs_be16 flags) return flags & htons(DHCP_BROADCAST_FLAG); } +static const char *dhcp_msg_str[] = { + [0] = "INVALID", + [DHCP_MSG_DISCOVER] = "DISCOVER", + [DHCP_MSG_OFFER] = "OFFER", + [DHCP_MSG_REQUEST] = "REQUEST", + [OVN_DHCP_MSG_DECLINE] = "DECLINE", + [DHCP_MSG_ACK] = "ACK", + [DHCP_MSG_NAK] = "NAK", + [OVN_DHCP_MSG_RELEASE] = "RELEASE", + [OVN_DHCP_MSG_INFORM] = "INFORM" +}; + +static bool +dhcp_relay_is_msg_type_supported(uint8_t msg_type) +{ + return (msg_type >= DHCP_MSG_DISCOVER && msg_type <= OVN_DHCP_MSG_RELEASE); +} + +static const char *dhcp_msg_str_get(uint8_t msg_type) +{ + if (!dhcp_relay_is_msg_type_supported(msg_type)) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "Unknown DHCP msg type: %u", msg_type); + return "UNKNOWN"; + } + return dhcp_msg_str[msg_type]; +} + +static const struct dhcp_header * +dhcp_get_hdr_from_pkt(struct dp_packet *pkt_in, const char **in_dhcp_pptr, + const char *end) +{ + /* Validate the DHCP request packet. + * Format of the DHCP packet is + * ----------------------------------------------------------------------- + *| UDP HEADER | DHCP HEADER | 4 Byte DHCP Cookie | DHCP OPTIONS(var len) | + * ----------------------------------------------------------------------- + */ + + *in_dhcp_pptr = dp_packet_get_udp_payload(pkt_in); + if (*in_dhcp_pptr == NULL) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP: Invalid or incomplete DHCP packet received"); + return NULL; + } + + const struct dhcp_header *dhcp_hdr + = (const struct dhcp_header *) *in_dhcp_pptr; + (*in_dhcp_pptr) += sizeof *dhcp_hdr; + if (*in_dhcp_pptr > end) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP: Invalid or incomplete DHCP packet received, " + "bad data length"); + return NULL; + } + + if (dhcp_hdr->htype != 0x1) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP: Packet is recieved with " + "unsupported hardware type"); + return NULL; + } + + if (dhcp_hdr->hlen != 0x6) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP: Packet is recieved with " + "unsupported hardware length"); + return NULL; + } + + /* DHCP options follow the DHCP header. The first 4 bytes of the DHCP + * options is the DHCP magic cookie followed by the actual DHCP options. + */ + ovs_be32 magic_cookie = htonl(DHCP_MAGIC_COOKIE); + if ((*in_dhcp_pptr) + sizeof magic_cookie > end || + get_unaligned_be32((const void *) (*in_dhcp_pptr)) != magic_cookie) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP: Magic cookie not present in the DHCP packet"); + return NULL; + } + + (*in_dhcp_pptr) += sizeof magic_cookie; + + return dhcp_hdr; +} + +static void +dhcp_parse_options(const char **in_dhcp_pptr, const char *end, + const uint8_t **dhcp_msg_type_pptr, + ovs_be32 *request_ip_ptr, + bool *ipxe_req_ptr, ovs_be32 *server_id_ptr, + ovs_be32 *netmask_ptr, ovs_be32 *router_ip_ptr) +{ + while ((*in_dhcp_pptr) < end) { + const struct dhcp_opt_header *in_dhcp_opt = + (const struct dhcp_opt_header *) *in_dhcp_pptr; + if (in_dhcp_opt->code == DHCP_OPT_END) { + break; + } + if (in_dhcp_opt->code == DHCP_OPT_PAD) { + (*in_dhcp_pptr) += 1; + continue; + } + (*in_dhcp_pptr) += sizeof *in_dhcp_opt; + if ((*in_dhcp_pptr) > end) { + break; + } + (*in_dhcp_pptr) += in_dhcp_opt->len; + if ((*in_dhcp_pptr) > end) { + break; + } + + switch (in_dhcp_opt->code) { + case DHCP_OPT_MSG_TYPE: + if (dhcp_msg_type_pptr && in_dhcp_opt->len == 1) { + *dhcp_msg_type_pptr = DHCP_OPT_PAYLOAD(in_dhcp_opt); + } + break; + case DHCP_OPT_REQ_IP: + if (request_ip_ptr && in_dhcp_opt->len == 4) { + *request_ip_ptr = get_unaligned_be32( + DHCP_OPT_PAYLOAD(in_dhcp_opt)); + } + break; + case OVN_DHCP_OPT_CODE_SERVER_ID: + if (server_id_ptr && in_dhcp_opt->len == 4) { + *server_id_ptr = get_unaligned_be32( + DHCP_OPT_PAYLOAD(in_dhcp_opt)); + } + break; + case OVN_DHCP_OPT_CODE_NETMASK: + if (netmask_ptr && in_dhcp_opt->len == 4) { + *netmask_ptr = get_unaligned_be32( + DHCP_OPT_PAYLOAD(in_dhcp_opt)); + } + break; + case OVN_DHCP_OPT_CODE_ROUTER_IP: + if (router_ip_ptr && in_dhcp_opt->len == 4) { + *router_ip_ptr = get_unaligned_be32( + DHCP_OPT_PAYLOAD(in_dhcp_opt)); + } + break; + case DHCP_OPT_ETHERBOOT: + if (ipxe_req_ptr) { + *ipxe_req_ptr = true; + } + break; + default: + break; + } + } +} + +/* Called with in the pinctrl_handler thread context. */ +static void +pinctrl_handle_dhcp_relay_req_chk( + struct rconn *swconn, + struct dp_packet *pkt_in, struct ofputil_packet_in *pin, + struct ofpbuf *userdata, + struct ofpbuf *continuation) +{ + enum ofp_version version = rconn_get_version(swconn); + enum ofputil_protocol proto = ofputil_protocol_from_ofp_version(version); + struct dp_packet *pkt_out_ptr = NULL; + uint32_t success = 0; + + /* Parse result field. */ + const struct mf_field *f; + enum ofperr ofperr = nx_pull_header(userdata, NULL, &f, NULL); + if (ofperr) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_REQ_CHK: bad result OXM (%s)", + ofperr_to_string(ofperr)); + goto exit; + } + ovs_be32 *ofsp = ofpbuf_try_pull(userdata, sizeof *ofsp); + /* Check that the result is valid and writable. */ + struct mf_subfield dst = { .field = f, .ofs = ntohl(*ofsp), .n_bits = 1 }; + ofperr = mf_check_dst(&dst, NULL); + if (ofperr) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_REQ_CHK: bad result bit (%s)", + ofperr_to_string(ofperr)); + goto exit; + } + + /* Parse relay IP and server IP. */ + ovs_be32 *relay_ip = ofpbuf_try_pull(userdata, sizeof *relay_ip); + ovs_be32 *server_ip = ofpbuf_try_pull(userdata, sizeof *server_ip); + if (!relay_ip || !server_ip) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_REQ_CHK: relay ip or server ip " + "not present in the userdata"); + goto exit; + } + + size_t in_l4_size = dp_packet_l4_size(pkt_in); + const char *end = (char *) dp_packet_l4(pkt_in) + in_l4_size; + const char *in_dhcp_ptr = NULL; + const struct dhcp_header *in_dhcp_data + = dhcp_get_hdr_from_pkt(pkt_in, &in_dhcp_ptr, end); + + if (!in_dhcp_data) { + goto exit; + } + ovs_assert(in_dhcp_ptr); + + if (in_dhcp_data->op != DHCP_OP_REQUEST) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_REQ_CHK: invalid opcode in the " + "DHCP packet: %d", in_dhcp_data->op); + goto exit; + } + + if (in_dhcp_data->giaddr) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_REQ_CHK: giaddr is already set"); + goto exit; + } + + const uint8_t *in_dhcp_msg_type = NULL; + ovs_be32 request_ip = in_dhcp_data->ciaddr; + + dhcp_parse_options(&in_dhcp_ptr, end, + &in_dhcp_msg_type, &request_ip, NULL, NULL, NULL, NULL); + + /* Check whether the DHCP Message Type (opt 53) is present or not */ + if (!in_dhcp_msg_type) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_REQ_CHK: missing message type"); + goto exit; + } + + /* Relay the DHCP request packet */ + uint16_t new_l4_size = in_l4_size; + size_t new_packet_size = pkt_in->l4_ofs + new_l4_size; + + struct dp_packet pkt_out; + dp_packet_init(&pkt_out, new_packet_size); + dp_packet_clear(&pkt_out); + dp_packet_prealloc_tailroom(&pkt_out, new_packet_size); + pkt_out_ptr = &pkt_out; + + /* Copy the L2 and L3 headers from the pkt_in as they would remain same*/ + dp_packet_put( + &pkt_out, dp_packet_pull(pkt_in, pkt_in->l4_ofs), pkt_in->l4_ofs); + + pkt_out.l2_5_ofs = pkt_in->l2_5_ofs; + pkt_out.l2_pad_size = pkt_in->l2_pad_size; + pkt_out.l3_ofs = pkt_in->l3_ofs; + pkt_out.l4_ofs = pkt_in->l4_ofs; + + struct udp_header *udp = dp_packet_put( + &pkt_out, dp_packet_pull(pkt_in, UDP_HEADER_LEN), UDP_HEADER_LEN); + + struct dhcp_header *dhcp_data = dp_packet_put(&pkt_out, + dp_packet_pull(pkt_in, new_l4_size - UDP_HEADER_LEN), + new_l4_size - UDP_HEADER_LEN); + + uint8_t hops = dhcp_data->hops + 1; + if (udp->udp_csum) { + udp->udp_csum = recalc_csum16(udp->udp_csum, + htons((uint16_t) dhcp_data->hops), htons((uint16_t) hops)); + } + dhcp_data->hops = hops; + + dhcp_data->giaddr = *relay_ip; + if (udp->udp_csum) { + udp->udp_csum = recalc_csum32(udp->udp_csum, + 0, dhcp_data->giaddr); + } + pin->packet = dp_packet_data(&pkt_out); + pin->packet_len = dp_packet_size(&pkt_out); + + /* Log the DHCP message. */ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(20, 40); + VLOG_INFO_RL(&rl, "DHCP_RELAY_REQ_CHK:: MSG_TYPE:%s MAC:"ETH_ADDR_FMT + " XID:%u" + " REQ_IP:"IP_FMT + " GIADDR:"IP_FMT + " SERVER_ADDR:"IP_FMT, + dhcp_msg_str_get(*in_dhcp_msg_type), + ETH_ADDR_BYTES_ARGS(dhcp_data->chaddr), ntohl(dhcp_data->xid), + IP_ARGS(request_ip), IP_ARGS(dhcp_data->giaddr), + IP_ARGS(*server_ip)); + success = 1; +exit: + if (!ofperr) { + union mf_subvalue sv; + sv.u8_val = success; + mf_write_subfield(&dst, &sv, &pin->flow_metadata); + } + queue_msg(swconn, ofputil_encode_resume(pin, continuation, proto)); + if (pkt_out_ptr) { + dp_packet_uninit(pkt_out_ptr); + } +} + +/* Called with in the pinctrl_handler thread context. */ +static void +pinctrl_handle_dhcp_relay_resp_chk( + struct rconn *swconn, + struct dp_packet *pkt_in, struct ofputil_packet_in *pin, + struct ofpbuf *userdata, + struct ofpbuf *continuation) +{ + enum ofp_version version = rconn_get_version(swconn); + enum ofputil_protocol proto = ofputil_protocol_from_ofp_version(version); + struct dp_packet *pkt_out_ptr = NULL; + uint32_t success = 0; + + /* Parse result field. */ + const struct mf_field *f; + enum ofperr ofperr = nx_pull_header(userdata, NULL, &f, NULL); + if (ofperr) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_RESP_CHK: bad result OXM (%s)", + ofperr_to_string(ofperr)); + goto exit; + } + ovs_be32 *ofsp = ofpbuf_try_pull(userdata, sizeof *ofsp); + /* Check that the result is valid and writable. */ + struct mf_subfield dst = { .field = f, .ofs = ntohl(*ofsp), .n_bits = 1 }; + ofperr = mf_check_dst(&dst, NULL); + if (ofperr) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_RESP_CHK: bad result bit (%s)", + ofperr_to_string(ofperr)); + goto exit; + } + + /* Parse relay IP and server IP. */ + ovs_be32 *relay_ip = ofpbuf_try_pull(userdata, sizeof *relay_ip); + ovs_be32 *server_ip = ofpbuf_try_pull(userdata, sizeof *server_ip); + if (!relay_ip || !server_ip) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_RESP_CHK: relay ip or server ip " + "not present in the userdata"); + goto exit; + } + + size_t in_l4_size = dp_packet_l4_size(pkt_in); + const char *end = (char *) dp_packet_l4(pkt_in) + in_l4_size; + const char *in_dhcp_ptr = NULL; + const struct dhcp_header *in_dhcp_data + = dhcp_get_hdr_from_pkt(pkt_in, &in_dhcp_ptr, end); + + if (!in_dhcp_data) { + goto exit; + } + ovs_assert(in_dhcp_ptr); + + if (in_dhcp_data->op != DHCP_OP_REPLY) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_RESP_CHK: invalid opcode " + "in the packet: %d", in_dhcp_data->op); + goto exit; + } + + if (!in_dhcp_data->giaddr) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_RESP_CHK: giaddr is " + "not set in request"); + goto exit; + } + + ovs_be32 giaddr = in_dhcp_data->giaddr; + ovs_be32 yiaddr = in_dhcp_data->yiaddr; + ovs_be32 server_id = 0, netmask = 0, router_ip = 0; + const uint8_t *in_dhcp_msg_type = NULL; + + dhcp_parse_options(&in_dhcp_ptr, end, + &in_dhcp_msg_type, NULL, NULL, &server_id, &netmask, &router_ip); + + /* Check whether the DHCP Message Type (opt 53) is present or not */ + if (!in_dhcp_msg_type) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_RESP: missing message type"); + goto exit; + } + + if (!server_id) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_RESP: missing server identifier"); + goto exit; + } + + if (server_id != *server_ip) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_RESP: server identifier mismatch"); + goto exit; + } + + if (giaddr != *relay_ip) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "DHCP_RELAY_RESP: giaddr mismatch"); + goto exit; + } + + if (*in_dhcp_msg_type == DHCP_MSG_OFFER || + *in_dhcp_msg_type == DHCP_MSG_ACK) { + if ((yiaddr & netmask) != (giaddr & netmask)) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_INFO_RL(&rl, "DHCP_RELAY_RESP_CHK:: Allocated ip adress and" + " giaddr are not in same subnet." + " MSG_TYPE:%s MAC:"ETH_ADDR_FMT + " XID:%u" + " YIADDR:"IP_FMT + " GIADDR:"IP_FMT + " SERVER_ADDR:"IP_FMT, + dhcp_msg_str_get(*in_dhcp_msg_type), + ETH_ADDR_BYTES_ARGS(in_dhcp_data->chaddr), + ntohl(in_dhcp_data->xid), + IP_ARGS(yiaddr), + IP_ARGS(giaddr), IP_ARGS(server_id)); + goto exit; + } + + if (router_ip && router_ip != giaddr) { + /* Log the default gateway mismatch and + * continue with rest of the processing */ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_INFO_RL(&rl, "DHCP_RELAY_RESP_CHK::" + " Router ip adress and giaddr are not same." + " MSG_TYPE:%s MAC:"ETH_ADDR_FMT + " XID:%u" + " YIADDR:"IP_FMT + " GIADDR:"IP_FMT + " SERVER_ADDR:"IP_FMT, + dhcp_msg_str_get(*in_dhcp_msg_type), + ETH_ADDR_BYTES_ARGS(in_dhcp_data->chaddr), + ntohl(in_dhcp_data->xid), + IP_ARGS(yiaddr), + IP_ARGS(giaddr), IP_ARGS(server_id)); + } + } + + /* Update destination MAC & IP so that the packet is forward to the + * right destination node. + */ + uint16_t new_l4_size = in_l4_size; + size_t new_packet_size = pkt_in->l4_ofs + new_l4_size; + + struct dp_packet pkt_out; + dp_packet_init(&pkt_out, new_packet_size); + dp_packet_clear(&pkt_out); + dp_packet_prealloc_tailroom(&pkt_out, new_packet_size); + pkt_out_ptr = &pkt_out; + + /* Copy the L2 and L3 headers from the pkt_in as they would remain same*/ + struct eth_header *eth = dp_packet_put( + &pkt_out, dp_packet_pull(pkt_in, pkt_in->l4_ofs), pkt_in->l4_ofs); + + pkt_out.l2_5_ofs = pkt_in->l2_5_ofs; + pkt_out.l2_pad_size = pkt_in->l2_pad_size; + pkt_out.l3_ofs = pkt_in->l3_ofs; + pkt_out.l4_ofs = pkt_in->l4_ofs; + + struct udp_header *udp = dp_packet_put( + &pkt_out, dp_packet_pull(pkt_in, UDP_HEADER_LEN), UDP_HEADER_LEN); + + struct dhcp_header *dhcp_data = dp_packet_put( + &pkt_out, dp_packet_pull(pkt_in, new_l4_size - UDP_HEADER_LEN), + new_l4_size - UDP_HEADER_LEN); + memcpy(ð->eth_dst, dhcp_data->chaddr, sizeof(eth->eth_dst)); + + /* Send a broadcast IP frame when BROADCAST flag is set. */ + struct ip_header *out_ip = dp_packet_l3(&pkt_out); + ovs_be32 ip_dst; + ovs_be32 ip_dst_orig = get_16aligned_be32(&out_ip->ip_dst); + if (!is_dhcp_flags_broadcast(dhcp_data->flags)) { + ip_dst = dhcp_data->yiaddr; + } else { + ip_dst = htonl(0xffffffff); + } + put_16aligned_be32(&out_ip->ip_dst, ip_dst); + out_ip->ip_csum = recalc_csum32(out_ip->ip_csum, + ip_dst_orig, ip_dst); + if (udp->udp_csum) { + udp->udp_csum = recalc_csum32(udp->udp_csum, + ip_dst_orig, ip_dst); + } + pin->packet = dp_packet_data(&pkt_out); + pin->packet_len = dp_packet_size(&pkt_out); + + /* Log the DHCP message. */ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(20, 40); + VLOG_INFO_RL(&rl, "DHCP_RELAY_RESP_CHK:: MSG_TYPE:%s MAC:"ETH_ADDR_FMT + " XID:%u" + " YIADDR:"IP_FMT + " GIADDR:"IP_FMT + " SERVER_ADDR:"IP_FMT, + dhcp_msg_str_get(*in_dhcp_msg_type), + ETH_ADDR_BYTES_ARGS(dhcp_data->chaddr), ntohl(dhcp_data->xid), + IP_ARGS(yiaddr), + IP_ARGS(giaddr), IP_ARGS(server_id)); + success = 1; +exit: + if (!ofperr) { + union mf_subvalue sv; + sv.u8_val = success; + mf_write_subfield(&dst, &sv, &pin->flow_metadata); + } + queue_msg(swconn, ofputil_encode_resume(pin, continuation, proto)); + if (pkt_out_ptr) { + dp_packet_uninit(pkt_out_ptr); + } +} + /* Called with in the pinctrl_handler thread context. */ static void pinctrl_handle_put_dhcp_opts( @@ -2040,30 +2549,16 @@ pinctrl_handle_put_dhcp_opts( goto exit; } - /* Validate the DHCP request packet. - * Format of the DHCP packet is - * ------------------------------------------------------------------------ - *| UDP HEADER | DHCP HEADER | 4 Byte DHCP Cookie | DHCP OPTIONS(var len)| - * ------------------------------------------------------------------------ - */ - const char *end = (char *)dp_packet_l4(pkt_in) + dp_packet_l4_size(pkt_in); - const char *in_dhcp_ptr = dp_packet_get_udp_payload(pkt_in); - if (!in_dhcp_ptr) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - VLOG_WARN_RL(&rl, "Invalid or incomplete DHCP packet received"); - goto exit; - } - + const char *in_dhcp_ptr = NULL; const struct dhcp_header *in_dhcp_data - = (const struct dhcp_header *) in_dhcp_ptr; - in_dhcp_ptr += sizeof *in_dhcp_data; - if (in_dhcp_ptr > end) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - VLOG_WARN_RL(&rl, "Invalid or incomplete DHCP packet received, " - "bad data length"); + = dhcp_get_hdr_from_pkt(pkt_in, &in_dhcp_ptr, end); + + if (!in_dhcp_data) { goto exit; } + ovs_assert(in_dhcp_ptr); + if (in_dhcp_data->op != DHCP_OP_REQUEST) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); VLOG_WARN_RL(&rl, "Invalid opcode in the DHCP packet: %d", @@ -2071,58 +2566,11 @@ pinctrl_handle_put_dhcp_opts( goto exit; } - /* DHCP options follow the DHCP header. The first 4 bytes of the DHCP - * options is the DHCP magic cookie followed by the actual DHCP options. - */ - ovs_be32 magic_cookie = htonl(DHCP_MAGIC_COOKIE); - if (in_dhcp_ptr + sizeof magic_cookie > end || - get_unaligned_be32((const void *) in_dhcp_ptr) != magic_cookie) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - VLOG_WARN_RL(&rl, "DHCP magic cookie not present in the DHCP packet"); - goto exit; - } - in_dhcp_ptr += sizeof magic_cookie; - bool ipxe_req = false; const uint8_t *in_dhcp_msg_type = NULL; ovs_be32 request_ip = in_dhcp_data->ciaddr; - while (in_dhcp_ptr < end) { - const struct dhcp_opt_header *in_dhcp_opt = - (const struct dhcp_opt_header *)in_dhcp_ptr; - if (in_dhcp_opt->code == DHCP_OPT_END) { - break; - } - if (in_dhcp_opt->code == DHCP_OPT_PAD) { - in_dhcp_ptr += 1; - continue; - } - in_dhcp_ptr += sizeof *in_dhcp_opt; - if (in_dhcp_ptr > end) { - break; - } - in_dhcp_ptr += in_dhcp_opt->len; - if (in_dhcp_ptr > end) { - break; - } - - switch (in_dhcp_opt->code) { - case DHCP_OPT_MSG_TYPE: - if (in_dhcp_opt->len == 1) { - in_dhcp_msg_type = DHCP_OPT_PAYLOAD(in_dhcp_opt); - } - break; - case DHCP_OPT_REQ_IP: - if (in_dhcp_opt->len == 4) { - request_ip = get_unaligned_be32(DHCP_OPT_PAYLOAD(in_dhcp_opt)); - } - break; - case DHCP_OPT_ETHERBOOT: - ipxe_req = true; - break; - default: - break; - } - } + dhcp_parse_options(&in_dhcp_ptr, end, + &in_dhcp_msg_type, &request_ip, &ipxe_req, NULL, NULL, NULL); /* Check that the DHCP Message Type (opt 53) is present or not with * valid values - DHCP_MSG_DISCOVER or DHCP_MSG_REQUEST. @@ -2329,6 +2777,7 @@ pinctrl_handle_put_dhcp_opts( dhcp_data->yiaddr = 0; } + ovs_be32 magic_cookie = htonl(DHCP_MAGIC_COOKIE); dp_packet_put(&pkt_out, &magic_cookie, sizeof(ovs_be32)); uint16_t out_dhcp_opts_size = 12; @@ -3298,6 +3747,16 @@ process_packet_in(struct rconn *swconn, const struct ofp_header *msg) ovs_mutex_unlock(&pinctrl_mutex); break; + case ACTION_OPCODE_DHCP_RELAY_REQ_CHK: + pinctrl_handle_dhcp_relay_req_chk(swconn, &packet, &pin, + &userdata, &continuation); + break; + + case ACTION_OPCODE_DHCP_RELAY_RESP_CHK: + pinctrl_handle_dhcp_relay_resp_chk(swconn, &packet, &pin, + &userdata, &continuation); + break; + case ACTION_OPCODE_PUT_DHCP_OPTS: pinctrl_handle_put_dhcp_opts(swconn, &packet, &pin, &headers, &userdata, &continuation); diff --git a/lib/ovn-l7.h b/lib/ovn-l7.h index f4a30cc00..7f5673b12 100644 --- a/lib/ovn-l7.h +++ b/lib/ovn-l7.h @@ -68,7 +68,9 @@ struct gen_opts_map { * OVN_DHCP_OPT_CODE_. */ #define OVN_DHCP_OPT_CODE_NETMASK 1 +#define OVN_DHCP_OPT_CODE_ROUTER_IP 3 #define OVN_DHCP_OPT_CODE_LEASE_TIME 51 +#define OVN_DHCP_OPT_CODE_SERVER_ID 54 #define OVN_DHCP_OPT_CODE_T1 58 #define OVN_DHCP_OPT_CODE_T2 59