From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22C1D21B9C6 for ; Fri, 27 Jun 2025 20:19:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751055588; cv=none; b=WzhRwQEQz4QZ93O6yhUiND4VmQZJ4CAV08e7V+AhO8hTQN2ZmNB6vVMSnNkHN65oOPLd0PsCnJqcUu3nEi9EnnkYPwIdCBoOcAGB51jwx4YNJaq3S9Lj+HrIA4wPrUKC2ddRHa/HX2i0GSJAEyOXSHwwri0Mb9zxs3Y+Z2ZgWO8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751055588; c=relaxed/simple; bh=+qO/xuOtI273bKL3joeaM7tS4d580sMC4uWzNU3R8Lg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r64WV4JPg0Z/8XCPqKR3/bbP4/wWyAmknTtaYGl8pmc2Ya2VFZI6Sith4yCOQ6fxaIt1UZNPx0VyGL0QbyrVzNQC4/HShxtQKiu6VXZS46d6qjEeSXa5FetxU1I7uP+lMyqqu/lR/shc03hZ87Zbs8cO+qBydUX0xDfmiTeWvNQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=us.ibm.com; spf=none smtp.mailfrom=linux.vnet.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=h0ShnEcY; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=us.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.vnet.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="h0ShnEcY" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 55RIeGEj031124; Fri, 27 Jun 2025 20:19:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=YkboRM2RINc8UxhUg QImppm0zbQKtyM+AgkXz7ZrtNM=; b=h0ShnEcYnBc+hcVFUDgVvHmETkNZ3r60I 95KQc+4oVM83dFOuNKpm+h71dtk6PcVtOT/2H0OTBBTO5hRza3N8hDvFii+15Ez+ WAONufFbxVuTiQZF+KQRocQTl1hPQX67b0VQFfko97sniAW7FDMG6aJA92dqTj9e NlY+wgMgzDqiVadNskRky6MQ8JZxmga2tn7BwMcUoZQ20xOKwEbl0OR54DTWrbUC QmxGv9hW4ECj+om7kASONs4EVva1QH1quwhnMf2+8k9F2t99MAtG1bod1Avlm0bw XSrIkb6n5hGg7UrY9NYXYbN9c1poauq6sFiUBpOfd6/wbCAB03G7w== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 47dk64faak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Jun 2025 20:19:41 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 55RGsjhM002512; Fri, 27 Jun 2025 20:19:41 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 47e8jmnu3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Jun 2025 20:19:41 +0000 Received: from smtpav06.wdc07v.mail.ibm.com (smtpav06.wdc07v.mail.ibm.com [10.39.53.233]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 55RKJd3U24642152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 27 Jun 2025 20:19:39 GMT Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2543958056; Fri, 27 Jun 2025 20:19:39 +0000 (GMT) Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D449B5803F; Fri, 27 Jun 2025 20:19:38 +0000 (GMT) Received: from localhost (unknown [9.61.49.21]) by smtpav06.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 27 Jun 2025 20:19:38 +0000 (GMT) From: David Wilder To: netdev@vger.kernel.org Cc: jv@jvosburgh.net, wilder@us.ibm.com, pradeeps@linux.vnet.ibm.com, pradeep@us.ibm.com, i.maximets@ovn.org, amorenoz@redhat.com, haliu@redhat.com Subject: [PATCH net-next v4 4/7] bonding: Processing extended arp_ip_target from user space. Date: Fri, 27 Jun 2025 13:17:17 -0700 Message-ID: <20250627201914.1791186-5-wilder@us.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250627201914.1791186-1-wilder@us.ibm.com> References: <20250627201914.1791186-1-wilder@us.ibm.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNjI3MDE2NCBTYWx0ZWRfXxAajW39LZgcA fTWScBsHLh59hYP4JmPLe8M39AG/wlTZZgMWfjkJCrkMA0FJETx7gsrQ00WTYVmFUH9NnVmw8+Y zMTMT8SMvCdzQYN1+adK690eBOCi0wkYqrFF8VZO+MBC60mXrQQGFNaCc7/6nXYksf687CnrPtK gUDAm74HaHJbriHDwDVR5sGb152+eAof7ifuzx67GBnTsijMvVOd9rVYofd/KrQCY08jesXOIo+ dW3XhjPobqdGoGIF3lRLgZWPYNSW88qu1L5okCNPaTRr01VCMK/oiTW6rEkDO9vymTCBrCHZV4b rb0FcSWQY0p+dPt8G8zNeDQOxWIvx/OdKem2yPyFZh41k+mCnaqTg1TPBQ0CY9G6zgbE9QcHO25 Kq2saDi41XJU+SGiNO6zBk8VAPtIl6xz4yPfXjba4wYoaWQGQp+VSmnTG0l0hob7OlezbG/M X-Proofpoint-ORIG-GUID: hhfqGh-CNUYQmSknwnF62dImdbrW-qg2 X-Proofpoint-GUID: hhfqGh-CNUYQmSknwnF62dImdbrW-qg2 X-Authority-Analysis: v=2.4 cv=BfvY0qt2 c=1 sm=1 tr=0 ts=685efcde cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=6IFa9wvqVegA:10 a=VnNF1IyMAAAA:8 a=CoZdYgcViVoGV0ZuhukA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-06-27_05,2025-06-27_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 suspectscore=0 adultscore=0 spamscore=0 impostorscore=0 mlxlogscore=811 malwarescore=0 phishscore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2506270164 Changes to bond_netlink and bond_options to process extended format arp_ip_target option sent from user space via the ip command. The extended format adds a list of vlan tags to the ip target address. Signed-off-by: David Wilder --- drivers/net/bonding/bond_netlink.c | 5 +- drivers/net/bonding/bond_options.c | 81 +++++++++++++++++++++--------- 2 files changed, 60 insertions(+), 26 deletions(-) diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index 1a3d17754c0a..23e27530c4d8 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c @@ -292,9 +292,10 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[], if (nla_len(attr) < sizeof(target)) return -EINVAL; - target = nla_get_be32(attr); + bond_opt_initextra(&newval, + (__force void *)nla_data(attr), + nla_len(attr)); - bond_opt_initval(&newval, (__force u64)target); err = __bond_opt_set(bond, BOND_OPT_ARP_TARGETS, &newval, data[IFLA_BOND_ARP_IP_TARGET], diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index e4b7eb376575..6e0611de1087 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -31,8 +31,8 @@ static int bond_option_use_carrier_set(struct bonding *bond, const struct bond_opt_value *newval); static int bond_option_arp_interval_set(struct bonding *bond, const struct bond_opt_value *newval); -static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target); -static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target); +static int bond_option_arp_ip_target_add(struct bonding *bond, struct bond_arp_target target); +static int bond_option_arp_ip_target_rem(struct bonding *bond, struct bond_arp_target target); static int bond_option_arp_ip_targets_set(struct bonding *bond, const struct bond_opt_value *newval); static int bond_option_ns_ip6_targets_set(struct bonding *bond, @@ -1115,7 +1115,7 @@ static int bond_option_arp_interval_set(struct bonding *bond, } static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot, - __be32 target, + struct bond_arp_target target, unsigned long last_rx) { struct bond_arp_target *targets = bond->params.arp_targets; @@ -1125,24 +1125,25 @@ static void _bond_options_arp_ip_target_set(struct bonding *bond, int slot, if (slot >= 0 && slot < BOND_MAX_ARP_TARGETS) { bond_for_each_slave(bond, slave, iter) slave->target_last_arp_rx[slot] = last_rx; - targets[slot].target_ip = target; + memcpy(&targets[slot], &target, sizeof(target)); } } -static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) +static int _bond_option_arp_ip_target_add(struct bonding *bond, struct bond_arp_target target) { struct bond_arp_target *targets = bond->params.arp_targets; + char pbuf[BOND_OPTION_STRING_MAX_SIZE]; int ind; - if (!bond_is_ip_target_ok(target)) { + if (!bond_is_ip_target_ok(target.target_ip)) { netdev_err(bond->dev, "invalid ARP target %pI4 specified for addition\n", - &target); + &target.target_ip); return -EINVAL; } - if (bond_get_targets_ip(targets, target) != -1) { /* dup */ + if (bond_get_targets_ip(targets, target.target_ip) != -1) { /* dup */ netdev_err(bond->dev, "ARP target %pI4 is already present\n", - &target); + &target.target_ip); return -EINVAL; } @@ -1152,43 +1153,44 @@ static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) return -EINVAL; } - netdev_dbg(bond->dev, "Adding ARP target %pI4\n", &target); + netdev_dbg(bond->dev, "Adding ARP target %s\n", + bond_arp_target_to_string(&target, pbuf, sizeof(pbuf))); _bond_options_arp_ip_target_set(bond, ind, target, jiffies); return 0; } -static int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) +static int bond_option_arp_ip_target_add(struct bonding *bond, struct bond_arp_target target) { return _bond_option_arp_ip_target_add(bond, target); } -static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) +static int bond_option_arp_ip_target_rem(struct bonding *bond, struct bond_arp_target target) { struct bond_arp_target *targets = bond->params.arp_targets; + unsigned long *targets_rx; struct list_head *iter; struct slave *slave; - unsigned long *targets_rx; int ind, i; - if (!bond_is_ip_target_ok(target)) { + if (!bond_is_ip_target_ok(target.target_ip)) { netdev_err(bond->dev, "invalid ARP target %pI4 specified for removal\n", - &target); + &target.target_ip); return -EINVAL; } - ind = bond_get_targets_ip(targets, target); + ind = bond_get_targets_ip(targets, target.target_ip); if (ind == -1) { netdev_err(bond->dev, "unable to remove nonexistent ARP target %pI4\n", - &target); + &target.target_ip); return -EINVAL; } if (ind == 0 && !targets[1].target_ip && bond->params.arp_interval) netdev_warn(bond->dev, "Removing last arp target with arp_interval on\n"); - netdev_dbg(bond->dev, "Removing ARP target %pI4\n", &target); + netdev_dbg(bond->dev, "Removing ARP target %pI4\n", &target.target_ip); bond_for_each_slave(bond, slave, iter) { targets_rx = slave->target_last_arp_rx; @@ -1196,30 +1198,45 @@ static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) targets_rx[i] = targets_rx[i+1]; targets_rx[i] = 0; } - for (i = ind; (i < BOND_MAX_ARP_TARGETS - 1) && targets[i + 1].target_ip; i++) - targets[i] = targets[i+1]; + + bond_free_vlan_tag(&targets[ind]); + + for (i = ind; (i < BOND_MAX_ARP_TARGETS - 1) && targets[i + 1].target_ip; i++) { + targets[i].target_ip = targets[i + 1].target_ip; + targets[i].tags = targets[i + 1].tags; + targets[i].flags = targets[i + 1].flags; + } targets[i].target_ip = 0; + targets[i].flags = 0; + targets[i].tags = NULL; return 0; } void bond_option_arp_ip_targets_clear(struct bonding *bond) { + struct bond_arp_target empty_target; int i; + empty_target.target_ip = 0; + empty_target.tags = NULL; + for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) - _bond_options_arp_ip_target_set(bond, i, 0, 0); + _bond_options_arp_ip_target_set(bond, i, empty_target, 0); } static int bond_option_arp_ip_targets_set(struct bonding *bond, const struct bond_opt_value *newval) { + size_t len = (size_t)newval->extra_len; + char *extra = (char *)newval->extra; + struct bond_arp_target target; int ret = -EPERM; - __be32 target; if (newval->string) { + /* Adding or removing arp_ip_target from sysfs */ if (strlen(newval->string) < 1 || - !in4_pton(newval->string + 1, -1, (u8 *)&target, -1, NULL)) { + !in4_pton(newval->string + 1, -1, (u8 *)&target.target_ip, -1, NULL)) { netdev_err(bond->dev, "invalid ARP target specified\n"); return ret; } @@ -1230,7 +1247,23 @@ static int bond_option_arp_ip_targets_set(struct bonding *bond, else netdev_err(bond->dev, "no command found in arp_ip_targets file - use + or -\n"); } else { - target = newval->value; + /* Adding arp_ip_target from netlink. aka: ip command */ + if (len < sizeof(target.target_ip)) { + netdev_err(bond->dev, "invalid ARP target specified\n"); + return ret; + } + memcpy(&target.target_ip, newval->extra, sizeof(__be32)); + len = len - sizeof(target.target_ip); + extra = extra + sizeof(target.target_ip); + + if (len) + target.tags = kmalloc(len, GFP_ATOMIC); + + if (target.tags) { + memcpy(target.tags, extra, len); + target.flags |= BOND_TARGET_USERTAGS; + } + ret = bond_option_arp_ip_target_add(bond, target); } -- 2.43.5