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 3/7] bonding: arp_ip_target helpers.
Date: Wed, 22 Oct 2025 11:25:30 -0700 [thread overview]
Message-ID: <20251022182721.2567561-4-wilder@us.ibm.com> (raw)
In-Reply-To: <20251022182721.2567561-1-wilder@us.ibm.com>
Adding helpers and defines needed for extending the
arp_ip_target parameters.
Signed-off-by: David Wilder <wilder@us.ibm.com>
---
include/net/bonding.h | 52 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/include/net/bonding.h b/include/net/bonding.h
index 3497e5061f90..0537b92c65eb 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -809,4 +809,56 @@ static inline netdev_tx_t bond_tx_drop(struct net_device *dev, struct sk_buff *s
return NET_XMIT_DROP;
}
+/* Helpers for handling arp_ip_target */
+#define BOND_OPTION_STRING_MAX_SIZE 64
+#define BOND_MAX_VLAN_TAGS 5
+#define BOND_VLAN_PROTO_NONE cpu_to_be16(0xffff)
+
+static inline char *bond_arp_target_to_string(const struct bond_arp_target *target,
+ char *buf, int size)
+{
+ struct bond_vlan_tag *tags = target->tags;
+ int i, num = 0;
+
+ BUILD_BUG_ON(size != BOND_OPTION_STRING_MAX_SIZE);
+
+ if (!(target->flags & BOND_TARGET_USERTAGS)) {
+ num = snprintf(&buf[0], size, "%pI4", &target->target_ip);
+ return buf;
+ }
+
+ num = snprintf(&buf[0], size, "%pI4[", &target->target_ip);
+ if (tags) {
+ for (i = 0; (tags[i].vlan_proto != BOND_VLAN_PROTO_NONE); i++) {
+ if (!tags[i].vlan_id)
+ continue;
+ if (i != 0)
+ num = num + snprintf(&buf[num], size - num, "/");
+ num = num + snprintf(&buf[num], size - num, "%u",
+ tags[i].vlan_id);
+ }
+ }
+ snprintf(&buf[num], size - num, "]");
+ return buf;
+}
+
+static inline void bond_free_vlan_tag(struct bond_arp_target *target)
+{
+ struct bond_vlan_tag *tags = target->tags;
+
+ target->tags = NULL;
+ target->flags = 0;
+ kfree(tags);
+}
+
+static inline void __bond_free_vlan_tags(struct bond_arp_target *targets)
+{
+ int i;
+
+ for (i = 0; i < BOND_MAX_ARP_TARGETS && targets[i].tags; i++)
+ bond_free_vlan_tag(&targets[i]);
+}
+
+#define bond_free_vlan_tags(targets) __bond_free_vlan_tags(targets)
+
#endif /* _NET_BONDING_H */
--
2.50.1
next prev 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 ` David Wilder [this message]
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 ` [PATCH net-next v14 6/7] bonding: Update for extended arp_ip_target format David Wilder
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-4-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