Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: David Wilder <wilder@us.ibm.com>
To: netdev@vger.kernel.org
Cc: jv@jvosburgh.net, wilder@us.ibm.com, pradeep@us.ibm.com,
	i.maximets@ovn.org, amorenoz@redhat.com, haliu@redhat.com,
	stephen@networkplumber.org, horms@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, andrew+netdev@lunn.ch, edumazet@google.com,
	razor@blackwall.org, shuah@kernel.org, corbet@lwn.net,
	linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org
Subject: [PATCH net-next v14 6/7] bonding: Update for extended arp_ip_target format.
Date: Wed, 22 Oct 2025 11:25:33 -0700	[thread overview]
Message-ID: <20251022182721.2567561-7-wilder@us.ibm.com> (raw)
In-Reply-To: <20251022182721.2567561-1-wilder@us.ibm.com>

Updated bond_fill_info() to support extended arp_ip_target format.

Forward and backward compatibility between the kernel and iproute2 is
preserved.

Signed-off-by: David Wilder <wilder@us.ibm.com>
---
 drivers/net/bonding/bond_netlink.c | 34 ++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 15782745fa4d..ba6a48901255 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -16,6 +16,11 @@
 #include <net/bonding.h>
 #include <net/ipv6.h>
 
+struct bond_arp_ip_target_payload {
+	__be32 addr;
+	struct bond_vlan_tag vlans[BOND_MAX_VLAN_TAGS + 1];
+} __packed;
+
 static size_t bond_get_slave_size(const struct net_device *bond_dev,
 				  const struct net_device *slave_dev)
 {
@@ -626,7 +631,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)
 		nla_total_size(sizeof(u32)) +	/* IFLA_BOND_ARP_INTERVAL */
 						/* IFLA_BOND_ARP_IP_TARGET */
 		nla_total_size(sizeof(struct nlattr)) +
-		nla_total_size(sizeof(u32)) * BOND_MAX_ARP_TARGETS +
+		nla_total_size(sizeof(struct bond_arp_ip_target_payload)) * BOND_MAX_ARP_TARGETS +
 		nla_total_size(sizeof(u32)) +	/* IFLA_BOND_ARP_VALIDATE */
 		nla_total_size(sizeof(u32)) +	/* IFLA_BOND_ARP_ALL_TARGETS */
 		nla_total_size(sizeof(u32)) +	/* IFLA_BOND_PRIMARY */
@@ -678,6 +683,7 @@ static int bond_fill_info(struct sk_buff *skb,
 			  const struct net_device *bond_dev)
 {
 	struct bonding *bond = netdev_priv(bond_dev);
+	struct bond_arp_target *arptargets;
 	unsigned int packets_per_slave;
 	int ifindex, i, targets_added;
 	struct nlattr *targets;
@@ -716,12 +722,28 @@ static int bond_fill_info(struct sk_buff *skb,
 		goto nla_put_failure;
 
 	targets_added = 0;
-	for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) {
-		if (bond->params.arp_targets[i].target_ip) {
-			if (nla_put_be32(skb, i, bond->params.arp_targets[i].target_ip))
-				goto nla_put_failure;
-			targets_added = 1;
+
+	arptargets = bond->params.arp_targets;
+	for (i = 0; i < BOND_MAX_ARP_TARGETS && arptargets[i].target_ip ; i++) {
+		struct bond_arp_ip_target_payload data = {};
+		int level, size;
+
+		data.addr = arptargets[i].target_ip;
+		size = sizeof(__be32);
+		targets_added = 1;
+
+		if (arptargets[i].flags & BOND_TARGET_USERTAGS) {
+			for (level = 0; level < BOND_MAX_VLAN_TAGS + 1 ; level++) {
+				data.vlans[level].vlan_proto = arptargets[i].tags[level].vlan_proto;
+				data.vlans[level].vlan_id = arptargets[i].tags[level].vlan_id;
+				size = size + sizeof(struct bond_vlan_tag);
+				if (arptargets[i].tags[level].vlan_proto == BOND_VLAN_PROTO_NONE)
+					break;
+			}
 		}
+
+		if (nla_put(skb, i, size, &data))
+			goto nla_put_failure;
 	}
 
 	if (targets_added)
-- 
2.50.1


  parent reply	other threads:[~2025-10-22 18:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22 18:25 [PATCH net-next v14 0/7] bonding: Extend arp_ip_target format to allow for a list of vlan tags David Wilder
2025-10-22 18:25 ` [PATCH net-next v14 1/7] bonding: Adding struct bond_arp_target David Wilder
2025-10-22 18:25 ` [PATCH net-next v14 2/7] bonding: Adding extra_len field to struct bond_opt_value David Wilder
2025-10-22 18:25 ` [PATCH net-next v14 3/7] bonding: arp_ip_target helpers David Wilder
2025-10-22 18:25 ` [PATCH net-next v14 4/7] bonding: Processing extended arp_ip_target from user space David Wilder
2025-10-22 18:25 ` [PATCH net-next v14 5/7] bonding: Update to bond_arp_send_all() to use supplied vlan tags David Wilder
2025-10-22 18:25 ` David Wilder [this message]
2025-10-22 18:25 ` [PATCH net-next v14 7/7] bonding: Selftest and documentation for the arp_ip_target parameter David Wilder
2025-10-23  0:50 ` [PATCH net-next v14 0/7] bonding: Extend arp_ip_target format to allow for a list of vlan tags Jakub Kicinski
2025-10-25  3:44   ` Jay Vosburgh
2025-11-12  6:44   ` Hangbin Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251022182721.2567561-7-wilder@us.ibm.com \
    --to=wilder@us.ibm.com \
    --cc=amorenoz@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=edumazet@google.com \
    --cc=haliu@redhat.com \
    --cc=horms@kernel.org \
    --cc=i.maximets@ovn.org \
    --cc=jv@jvosburgh.net \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pradeep@us.ibm.com \
    --cc=razor@blackwall.org \
    --cc=shuah@kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox