From patchwork Tue Jul 27 13:44:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 486702 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp231802jas; Tue, 27 Jul 2021 06:46:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwroW7YxWnRVT40WcW0zEY+QDxFunn5N2DKTnj1dmkshicLZUhFBlFEf6sKUTDGArcqlJYu X-Received: by 2002:a05:6402:207b:: with SMTP id bd27mr27326702edb.195.1627393585773; Tue, 27 Jul 2021 06:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627393585; cv=none; d=google.com; s=arc-20160816; b=SsxZ6o5jZCAQhwoNk14e1/2+fx25oRGQtu2ntItFgeYFsm1agUS8pof7HUCUl9KwLq 3sR3pHddJ2QvOqAc5m0lhMIure4D6lfvswW5HuhTnDbprskCSAgXiBoAuny7IWYcqV9c fEnkaqQ2srf0lHAv9UxYEi+RCL2WlB7x8k8MO/wHtN6A0JXgxD8fsfYZWkZdUPfwYTCY AV8H2Bs3uqO9G8B0UoxA33js11VJ2kTtmT3xDcPrs2AEXTjn1oMyM+Dg2sVvniTgV+Kf fn1SR8DuEfO3nwwmtiKmDlY2nSk7pJE44oAmD7Ki5C5sYlqulcMzo4fvgy4HaqhG0FtC pnTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zDMWSkRn6xTtwPB/h0cCFiJ/WF548VcXxdxmd7928T4=; b=DQCu1F3oaTGpfENbpAkXEUJbQn34xeAK3uu5LipUPJlQcMigVuOQXQTvkM/5rON3qk 9k9eT1hvToi7OHskqsagMV/POko5r/3tCxAdvUHKGPc3hawtmHp2F+QRXs/ViqFY44ev CoOUvIsTLgWKrxbYoH2lLG5MdsA5ECp6ZiTXbas2Vu906XehD2/46JVPcnzw3USFyTK4 uCp3DRSEpPTi8JxKTOTbGn5vs0nYy+s46cojQb8aHAiSl5r8ZadL2BmIZ8M+XrjLAB8x gE21SrK4vX08p+gLgoz6pMcqcPJYwKRxZeU3Ayh5HK1lciLXFrWhTxFK8w878eky5G7e Axzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bVjxPzTp; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hc43si3594933ejc.1.2021.07.27.06.46.25; Tue, 27 Jul 2021 06:46:25 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bVjxPzTp; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236928AbhG0NqV (ORCPT + 8 others); Tue, 27 Jul 2021 09:46:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:46386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236802AbhG0NqN (ORCPT ); Tue, 27 Jul 2021 09:46:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 20E7D61A80; Tue, 27 Jul 2021 13:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627393573; bh=jEGLRjSxSpreeMNYZWv9qGfyBSmCVqlGarHcGd930ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bVjxPzTpAMjvPH3OFSezDbICzfAIAhhjkOcOHrx9bDsc2c2xmbr6NZZIikLy4JrdI aaM6z7FZ72cAdIcgSw1378/Fxs1Ay+pC4l4MqBulc6Wp5A/10aMXjzoTLDMv7X/7VH VqxEhB3dUHAZ1T3qixsz9JDO8br7HevBN2hyM5eEL7T6kGkQfP2xtvWrKhUitXc3mG hKq2A4KbVmr6PrV47yq3Mj4xlnG/FrBBihxsQ2EtYZUz9yUVDkWKbBoHJ3KsrqNyUu 0VN7ZG50a5M8w7MEam8iOtYkhCcBpI4xsEe8qrMVWjvqYXh2hdNdQMx19FzGcPkpak 0HqmtD8g5rgOg== From: Arnd Bergmann To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Arnd Bergmann , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek Subject: [PATCH net-next v3 08/31] bonding: use siocdevprivate Date: Tue, 27 Jul 2021 15:44:54 +0200 Message-Id: <20210727134517.1384504-9-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210727134517.1384504-1-arnd@kernel.org> References: <20210727134517.1384504-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann The bonding driver supports two command codes for each operation: one in the SIOCDEVPRIVATE range and another one with the same definition but a unique command code. Only the second set currently works in compat mode, as the ifr_data expansion overwrites part of the ifr_slave field. Move the private ones into ndo_siocdevprivate and change the implementation to call the other function. This makes both version work correctly. Cc: Jay Vosburgh Cc: Veaceslav Falico Cc: Andy Gospodarek Signed-off-by: Arnd Bergmann --- drivers/net/bonding/bond_main.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) -- 2.29.2 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 31730efa7538..96864183f92e 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -4000,7 +4000,6 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd } return 0; - case BOND_INFO_QUERY_OLD: case SIOCBONDINFOQUERY: u_binfo = (struct ifbond __user *)ifr->ifr_data; @@ -4012,7 +4011,6 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd return -EFAULT; return 0; - case BOND_SLAVE_INFO_QUERY_OLD: case SIOCBONDSLAVEINFOQUERY: u_sinfo = (struct ifslave __user *)ifr->ifr_data; @@ -4042,19 +4040,15 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd return -ENODEV; switch (cmd) { - case BOND_ENSLAVE_OLD: case SIOCBONDENSLAVE: res = bond_enslave(bond_dev, slave_dev, NULL); break; - case BOND_RELEASE_OLD: case SIOCBONDRELEASE: res = bond_release(bond_dev, slave_dev); break; - case BOND_SETHWADDR_OLD: case SIOCBONDSETHWADDR: res = bond_set_dev_addr(bond_dev, slave_dev); break; - case BOND_CHANGE_ACTIVE_OLD: case SIOCBONDCHANGEACTIVE: bond_opt_initstr(&newval, slave_dev->name); res = __bond_opt_set_notify(bond, BOND_OPT_ACTIVE_SLAVE, @@ -4067,6 +4061,29 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd return res; } +static int bond_siocdevprivate(struct net_device *bond_dev, struct ifreq *ifr, + void __user *data, int cmd) +{ + struct ifreq ifrdata = { .ifr_data = data }; + + switch (cmd) { + case BOND_INFO_QUERY_OLD: + return bond_do_ioctl(bond_dev, &ifrdata, SIOCBONDINFOQUERY); + case BOND_SLAVE_INFO_QUERY_OLD: + return bond_do_ioctl(bond_dev, &ifrdata, SIOCBONDSLAVEINFOQUERY); + case BOND_ENSLAVE_OLD: + return bond_do_ioctl(bond_dev, ifr, SIOCBONDENSLAVE); + case BOND_RELEASE_OLD: + return bond_do_ioctl(bond_dev, ifr, SIOCBONDRELEASE); + case BOND_SETHWADDR_OLD: + return bond_do_ioctl(bond_dev, ifr, SIOCBONDSETHWADDR); + case BOND_CHANGE_ACTIVE_OLD: + return bond_do_ioctl(bond_dev, ifr, SIOCBONDCHANGEACTIVE); + } + + return -EOPNOTSUPP; +} + static void bond_change_rx_flags(struct net_device *bond_dev, int change) { struct bonding *bond = netdev_priv(bond_dev); @@ -4956,6 +4973,7 @@ static const struct net_device_ops bond_netdev_ops = { .ndo_select_queue = bond_select_queue, .ndo_get_stats64 = bond_get_stats, .ndo_do_ioctl = bond_do_ioctl, + .ndo_siocdevprivate = bond_siocdevprivate, .ndo_change_rx_flags = bond_change_rx_flags, .ndo_set_rx_mode = bond_set_rx_mode, .ndo_change_mtu = bond_change_mtu,