From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5AA43A0A0C; Sat, 19 Jun 2021 15:56:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D0E6B40E64; Sat, 19 Jun 2021 15:56:51 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2063.outbound.protection.outlook.com [40.107.244.63]) by mails.dpdk.org (Postfix) with ESMTP id 648C540E32; Sat, 19 Jun 2021 15:56:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jTyDyKTy1I57i0Gz2Z5uP8Nr32ZPE8iWeWQBeatvt/fHnj1ZSaZEzedtb6OAv8aOXSH4rtwnlVoV6rbYQeyzW+BqsoIQNWlSe5UOP+NiIQgeXwsHpjkiGgSt5Hqstcs7jMone+r7j1y2m3uBW8zlUULHpdMnq/p03K5YDKZsThrOOZTiKjEP7edo2lXrXuAlXwWrRrcNV50DOQ8lwtD7Ug0L4pHj7zV0K2rrKzds6UYLtPGQT3l4ApZtiyTeeiwRlCffz93fIMuQ/bDazDquwgxre4ypP7GE49L5qJ5AIkIRrejb3q6jIkb635WNt99uiXb0IJ/6IWS5ztOKAonxxQ== 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=XvVxKrc7kgvKJ+LeX44b1uDTzNYO3yIZhdgFbOTMajE=; b=eQrJcMjPhv6Su0RfjpvOeK3SxVWknaXADfml16nXcFWEEn5ccydoEGCj3BMe5oQ0e3EqFSzuGsblJsSJhhsWR3JoJ1V79ajlyWwOiw1viqzbrw5sPqPKzGSEeZSkWaxMV8r0znMm3/FJvPFnWUfHMBnbXetZRvDZ6/HTWqo/Ht+TlM88lWMgXehaZ4iuAOxAt7EMIHB9QddtiMhB6LcyN85k6/amELqAH48iyFgM25OjwxXjZZhDkDwgaTZ0im/A+AP0eqc7iKuSfD6r+0HYErHR5tGLcWyS8qNoXm6V9okWZJkPUckfeBp7yaYD4yC6Xn8QQ3YV9yGp7SC5zuI00A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XvVxKrc7kgvKJ+LeX44b1uDTzNYO3yIZhdgFbOTMajE=; b=Rf4Y1/urWKHi69h952O4OHCw2n56bKnCmjMEt6vCMfstQZtWsZNkrbC1j8ACnXz2gLhp3mKe4pzrmL/Fu3A8l7b1slBpMF36wO9J3QxPIC4m4Xao9Ag/ZipML+Rbug0YkEfIkZmGFFnBWgWQZIQUhb6Qn0SZahIPPUNrIvdHCQZXivyRRdFowcBxcuPoWd5+litrx07hVSuI7SySYWSjKmRZWrvIEgxJv3Ule3N+CAxjx5SbBD4NWBSrGrRc/30asMaBQLonn/PMoKRr/7swXP2/WGS//bqSMaf7zUcpdNGp9Z2uOG1R4bwGjLaUhH/f0qtBKLp0QRG5iTaBfIHTXQ== Received: from BN9PR03CA0554.namprd03.prod.outlook.com (2603:10b6:408:138::19) by MW2PR12MB2524.namprd12.prod.outlook.com (2603:10b6:907:9::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.21; Sat, 19 Jun 2021 13:56:47 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:408:138:cafe::14) by BN9PR03CA0554.outlook.office365.com (2603:10b6:408:138::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.19 via Frontend Transport; Sat, 19 Jun 2021 13:56:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4242.16 via Frontend Transport; Sat, 19 Jun 2021 13:56:47 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 19 Jun 2021 13:56:45 +0000 From: Viacheslav Ovsiienko To: CC: , , Date: Sat, 19 Jun 2021 16:56:28 +0300 Message-ID: <20210619135628.1626-1-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0bd12ca0-ecec-4dfe-009b-08d9332a148d X-MS-TrafficTypeDiagnostic: MW2PR12MB2524: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j8tPD6PlC7atp7/Zz9BHINvdY1P0BZ66bAI4PcbyDiYI7O5BJeonKqjFMo7M5ypbIub93VJui5df2jWFFox+GTONHf2JHEjw0wIyOtC0pX/HwXZQbwBdEnQmo/yMRvcOy5pPh0E7fgU3fXVM1nzgSNwexo0IFRE0O3ZpaVv3uWmNRHhOlaJ4P8xWLZ9H+PeL1zhWn5XU74WmF0zSeqf9pE5Z8MNvc7COjgnGVJnh8fyXgovl65Ak0A/5a+P0u0MgaRl5B2IBPNcNS3FcznPKsnsVzelGOkbjL2KUZwdBJKNUkbFXVlVNpgYMHJ6yfvrnZ6EUWTqLMm22YTSCAlzLWMTH4KN6yd8xVPStLb5VuTx/jwyUNDJnyPm1YHNjmJCmPdNQpgARcbqJkdOqID+yFObItZKFb9DhiV2DgVYYNk8yTM7jAD1p4RLpSIRgGk+BmWHAZd4+aQLfsGLsfUE5gjk6rCN6f9RFgBfoLnwEhTLTH5x29ittgPoJtoVavjNpfc0LAUmNxN5txmHd/io0RRsFTBcQ2zuFQBbhOES+LPATnXsoutXD5w+kwkcUPw5NJ9g4+XNy9nlMMCQkOfN0O4uQQdKfF8DA3AEG9DvcHUvz3AIe7XtpkQMjbQXFriX8oTHu519V4tP6n3aSuXNC5gtSvrtBPIGAxlnYFyh79fc= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(136003)(346002)(376002)(39860400002)(396003)(36840700001)(46966006)(54906003)(316002)(83380400001)(426003)(478600001)(36906005)(336012)(186003)(36860700001)(26005)(6286002)(2616005)(16526019)(7696005)(356005)(4326008)(47076005)(6666004)(7636003)(450100002)(2906002)(82310400003)(5660300002)(82740400003)(8936002)(86362001)(55016002)(8676002)(6916009)(36756003)(1076003)(70586007)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2021 13:56:47.4244 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0bd12ca0-ecec-4dfe-009b-08d9332a148d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2524 Subject: [dpdk-dev] [PATCH] common/mlx5: fix Netlink port name attribute padding X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On some kernels the string attributes within Netlink reply messages might be not padded with zeroes (in cases when string length is aligned with 4-byte boundary). This caused wrong physical port names recognition and mlx5 PMD load failures. Fixes: 30a86157f6d5 ("net/mlx5: support PF representor") Cc: stable@dpdk.org Signed-off-by: Viacheslav Ovsiienko --- drivers/common/mlx5/linux/mlx5_nl.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c index f0d04f9473..3f1912d078 100644 --- a/drivers/common/mlx5/linux/mlx5_nl.c +++ b/drivers/common/mlx5/linux/mlx5_nl.c @@ -33,6 +33,8 @@ #define MLX5_SEND_BUF_SIZE 32768 /* Receive buffer size for the Netlink socket */ #define MLX5_RECV_BUF_SIZE 32768 +/* Maximal physical port name length. */ +#define MLX5_PHYS_PORT_NAME_MAX 128 /** Parameters of VLAN devices created by driver. */ #define MLX5_VMWA_VLAN_DEVICE_PFX "evmlx" @@ -1191,6 +1193,7 @@ mlx5_nl_switch_info_cb(struct nlmsghdr *nh, void *arg) size_t off = NLMSG_LENGTH(sizeof(struct ifinfomsg)); bool switch_id_set = false; bool num_vf_set = false; + int len; if (nh->nlmsg_type != RTM_NEWLINK) goto error; @@ -1206,7 +1209,24 @@ mlx5_nl_switch_info_cb(struct nlmsghdr *nh, void *arg) num_vf_set = true; break; case IFLA_PHYS_PORT_NAME: - mlx5_translate_port_name((char *)payload, &info); + len = RTA_PAYLOAD(ra); + /* Some kernels do not pad attributes with zero. */ + if (len > 0 && len < MLX5_PHYS_PORT_NAME_MAX) { + char name[MLX5_PHYS_PORT_NAME_MAX]; + + /* + * We can't just patch the message with padding + * zero - it might corrupt the following items + * in the message, we have to copy the string + * by attribute length and pad the copied one. + */ + memcpy(name, payload, len); + name[len] = 0; + mlx5_translate_port_name(name, &info); + } else { + info.name_type = + MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN; + } break; case IFLA_PHYS_SWITCH_ID: info.switch_id = 0; -- 2.18.1