bonding: add IPv6 NS/NA monitor support
Subsystems (5)
v2 cover bonding: add IPv6 NS/NA monitor support
This patch add bond IPv6 NS/NA monitor support. A new option ns_ip6_target is added, which is similar with arp_ip_target. The IPv6 NS/NA monitor will take effect when there is a valid IPv6 address. Both ARP monitor and NS monitor will working at the same time.
A new extra storage field is added to struct bond_opt_value for IPv6 support.
Function bond_handle_vlan() is split from bond_arp_send() for both IPv4/IPv6 usage.
To alloc NS message and send out. ndisc_ns_create() and ndisc_send_skb() are exported.
v1 -> v2:
1. remove sysfs entry[1] and only keep netlink support.
RFC -> v1:
1. define BOND_MAX_ND_TARGETS as BOND_MAX_ARP_TARGETS
2. adjust for reverse xmas tree ordering of local variables
3. remove bond_do_ns_validate()
4. add extra field for bond_opt_value
5. set IS_ENABLED(CONFIG_IPV6) for IPv6 codes
[1] https://lore.kernel.org/netdev/8863.1645071997@famine
Hangbin Liu (5):
ipv6: separate ndisc_ns_create() from ndisc_send_ns()
Bonding: split bond_handle_vlan from bond_arp_send
bonding: add extra field for bond_opt_value
bonding: add new parameter ns_targets
bonding: add new option ns_ip6_target
Documentation/networking/bonding.rst | 11 + drivers/net/bonding/bond_main.c | 295 +++++++++++++++++++++++---- drivers/net/bonding/bond_netlink.c | 59 ++++++ drivers/net/bonding/bond_options.c | 74 ++++++- include/net/bond_options.h | 31 ++- include/net/bonding.h | 26 ++- include/net/ndisc.h | 5 + include/uapi/linux/if_link.h | 1 + net/ipv6/ndisc.c | 49 +++-- tools/include/uapi/linux/if_link.h | 1 + 10 files changed, 481 insertions(+), 71 deletions(-)
Signature · 1 line
2.31.1
PATCH v2 1/5 ipv6: separate ndisc_ns_create() from ndisc_send_ns()
This patch separate NS message allocation steps from ndisc_send_ns(), so it could be used in other places, like bonding, to allocate and send IPv6 NS message.
Also export ndisc_send_skb() and ndisc_ns_create() for later bonding usage.
--- include/net/ndisc.h | 5 +++++ net/ipv6/ndisc.c | 49 +++++++++++++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 17 deletions(-)
include/net/ndisc.h +5 -0
@@ -447,10 +447,15 @@ void ndisc_cleanup(void);int ndisc_rcv (struct sk_buff *skb); +struct sk_buff *ndisc_ns_create (struct net_device *dev,const struct in6_addr *solicit, +const struct in6_addr *saddr,u64 nonce);void ndisc_send_ns (struct net_device *dev,const struct in6_addr *solicit,const struct in6_addr *daddr,const struct in6_addr *saddr,u64 nonce); +void ndisc_send_skb (struct sk_buff *skb,const struct in6_addr *daddr, +const struct in6_addr *saddr); +void ndisc_send_rs (struct net_device *dev,const struct in6_addr *saddr,const struct in6_addr *daddr); void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,
net/ipv6/ndisc.c +32 -17
83 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH v2 2/5 Bonding: split bond_handle_vlan from bond_arp_send
In reply to Hangbin LiuFunction bond_handle_vlan() is split from bond_arp_send() for later IPv6 usage.
--- drivers/net/bonding/bond_main.c | 58 +++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 24 deletions(-)
drivers/net/bonding/bond_main.c +34 -24
@@ -2793,31 +2793,15 @@ static bool bond_has_this_ip(struct bonding *bond, __be32 ip)return ret; } -/* We go to the (large) trouble of VLAN tagging ARP frames because -* switches in VLAN mode (especially if ports are configured as -* "native" to a VLAN) might not pass non-tagged frames. -*/ -static void bond_arp_send (struct slave *slave,int arp_op,__be32 dest_ip, -__be32 src_ip,struct bond_vlan_tag *tags) +static bool bond_handle_vlan (struct slave *slave,struct bond_vlan_tag *tags, +struct sk_buff *skb) { -struct sk_buff *skb; -struct bond_vlan_tag *outer_tag = tags; -struct net_device *slave_dev = slave->dev;struct net_device *bond_dev = slave->bond->dev; - -slave_dbg (bond_dev, slave_dev,"arp %d on slave: dst %pI4 src %pI4\n" , - arp_op, &dest_ip, &src_ip); - - skb =arp_create (arp_op,ETH_P_ARP , dest_ip, slave_dev, src_ip, -NULL , slave_dev->dev_addr,NULL ); - -if (!skb) { -net_err_ratelimited ("ARP packet allocation failed\n" ); -return ; - } +struct net_device *slave_dev = slave->dev; +struct bond_vlan_tag *outer_tag = tags;if (!tags || tags->vlan_proto ==VLAN_N_VID ) - goto xmit; +return true; tags++;
@@ -2834,7 +2818,7 @@ static void bond_arp_send(struct slave *slave, int arp_op, __be32 dest_ip, tags->vlan_id);if (!skb) {net_err_ratelimited ("failed to insert inner VLAN tag\n" ); -return ; +return false; } tags++;
@@ -2847,8 +2831,34 @@ static void bond_arp_send(struct slave *slave, int arp_op, __be32 dest_ip, outer_tag->vlan_id); } -xmit: -arp_xmit (skb); +return true; +} + +/* We go to the (large) trouble of VLAN tagging ARP frames because +* switches in VLAN mode (especially if ports are configured as +* "native" to a VLAN) might not pass non-tagged frames. +*/ +static void bond_arp_send (struct slave *slave,int arp_op,__be32 dest_ip, +__be32 src_ip,struct bond_vlan_tag *tags) +{ +struct net_device *bond_dev = slave->bond->dev; +struct net_device *slave_dev = slave->dev; +struct sk_buff *skb; + +slave_dbg (bond_dev, slave_dev,"arp %d on slave: dst %pI4 src %pI4\n" , + arp_op, &dest_ip, &src_ip); + + skb =arp_create (arp_op,ETH_P_ARP , dest_ip, slave_dev, src_ip, +NULL , slave_dev->dev_addr,NULL ); + +if (!skb) { +net_err_ratelimited ("ARP packet allocation failed\n" ); +return ; + } + +if (bond_handle_vlan (slave, tags, skb)) +arp_xmit (skb); +return ; }/* Validate the device path between the @start_dev and the @end_dev.
Signature · 1 line
2.31.1
PATCH v2 3/5 bonding: add extra field for bond_opt_value
In reply to Hangbin LiuAdding an extra storage field for bond_opt_value so we can set large bytes of data for bonding options in future, e.g. IPv6 address.
Define a new call bond_opt_initextra(). Also change the checking order of __bond_opt_init() and check values first.
--- include/net/bond_options.h | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
include/net/bond_options.h +18 -9
@@ -71,14 +71,18 @@ enum {/* This structure is used for storing option values and for passing option * values when changing an option. The logic when used as an arg is as follows: -* - if string != NULL -> parse it, if the opt is RAW type then return it, else -* return the parse result -* - if string == NULL -> parse value +* - if value != ULLONG_MAX -> parse value +* - if string != NULL -> parse string +* - if the opt is RAW data and length less than maxlen, +* copy the data to extra storage */ + +#define BOND_OPT_EXTRA_MAXLEN 16struct bond_opt_value {char *string;u64 value;u32 flags; +char extra[BOND_OPT_EXTRA_MAXLEN ]; };struct bonding ;
@@ -118,17 +122,22 @@ const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val);* When value is ULLONG_MAX then string will be used. */ static inline void __bond_opt_init (struct bond_opt_value *optval, -char *string,u64 value) +char *string,u64 value, +void *extra,size_t extra_len) {memset (optval,0 ,sizeof (*optval)); optval->value =ULLONG_MAX ; -if (value ==ULLONG_MAX ) - optval->string = string; -else +if (value !=ULLONG_MAX ) optval->value = value; +else if (string) + optval->string = string; +else if (extra_len <=BOND_OPT_EXTRA_MAXLEN ) +memcpy (optval->extra, extra, extra_len); } -#define bond_opt_initval (optval, value) __bond_opt_init(optval, NULL, value) -#define bond_opt_initstr (optval, str) __bond_opt_init(optval, str, ULLONG_MAX) +#define bond_opt_initval (optval, value) __bond_opt_init(optval, NULL, value, NULL, 0) +#define bond_opt_initstr (optval, str) __bond_opt_init(optval, str, ULLONG_MAX, NULL, 0) +#define bond_opt_initextra (optval, extra, extra_len) \ + __bond_opt_init(optval, NULL, ULLONG_MAX, extra, extra_len)void bond_option_arp_ip_targets_clear (struct bonding *bond);
Signature · 1 line
2.31.1
PATCH v2 4/5 bonding: add new parameter ns_targets
In reply to Hangbin LiuAdd a new bonding parameter ns_targets to store IPv6 address. Add required bond_ns_send/rcv functions first before adding IPv6 address option setting.
Add two functions bond_send/rcv_validate so we can send/recv ARP and NS at the same time.
--- drivers/net/bonding/bond_main.c | 237 ++++++++++++++++++++++++++--- drivers/net/bonding/bond_options.c | 2 +- include/net/bonding.h | 19 ++- 3 files changed, 237 insertions(+), 21 deletions(-)
drivers/net/bonding/bond_main.c +218 -19
@@ -88,6 +88,7 @@#if IS_ENABLED (CONFIG_TLS_DEVICE )#include <net/tls.h> #endif +#include <net/ip6_route.h> #include "bonding_priv.h"
@@ -2975,30 +2976,17 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 slave->target_last_arp_rx[i] = jiffies; } -int bond_arp_rcv (const struct sk_buff *skb,struct bonding *bond, -struct slave *slave) +static int bond_arp_rcv (const struct sk_buff *skb,struct bonding *bond, +struct slave *slave) {struct arphdr *arp = (struct arphdr *)skb->data;struct slave *curr_active_slave, *curr_arp_slave;unsigned char *arp_ptr;__be32 sip, tip; -int is_arp = skb->protocol ==__cpu_to_be16 (ETH_P_ARP );unsigned int alen; -if (!slave_do_arp_validate (bond, slave)) { -if ((slave_do_arp_validate_only (bond) && is_arp) || - !slave_do_arp_validate_only (bond)) - slave->last_rx = jiffies; -return RX_HANDLER_ANOTHER ; - }else if (!is_arp) { -return RX_HANDLER_ANOTHER ; - } - alen =arp_hdr_len (bond->dev); -slave_dbg (bond->dev, slave->dev,"%s: skb->dev %s\n" , - __func__, skb->dev->name); -if (alen >skb_headlen (skb)) { arp =kmalloc (alen,GFP_ATOMIC );if (!arp)
@@ -3069,6 +3057,216 @@ int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond,return RX_HANDLER_ANOTHER ; } +#if IS_ENABLED (CONFIG_IPV6 ) +static void bond_ns_send (struct slave *slave,const struct in6_addr *daddr, +const struct in6_addr *saddr,struct bond_vlan_tag *tags) +{ +struct net_device *bond_dev = slave->bond->dev; +struct net_device *slave_dev = slave->dev; +struct in6_addr mcaddr; +struct sk_buff *skb; + +slave_dbg (bond_dev, slave_dev,"NS on slave: dst %pI6c src %pI6c\n" , + daddr, saddr); + + skb =ndisc_ns_create (slave_dev, daddr, saddr,0 ); +if (!skb) { +net_err_ratelimited ("NS packet allocation failed\n" ); +return ; + } + +addrconf_addr_solict_mult (daddr, &mcaddr); +if (bond_handle_vlan (slave, tags, skb)) +ndisc_send_skb (skb, &mcaddr, saddr); +} + +static void bond_ns_send_all (struct bonding *bond,struct slave *slave) +{ +struct in6_addr *targets = bond->params.ns_targets; +struct bond_vlan_tag *tags; +struct dst_entry *dst; +struct in6_addr saddr; +struct flowi6 fl6; +int i; + +for (i =0 ; i <BOND_MAX_NS_TARGETS && !ipv6_addr_any (&targets[i]); i++) { +slave_dbg (bond->dev, slave->dev,"%s: target %pI6c\n" , + __func__, &targets[i]); + tags =NULL ; + +/* Find out through which dev should the packet go */ +memset (&fl6,0 ,sizeof (struct flowi6 )); + fl6.daddr = targets[i]; + fl6.flowi6_oif = bond->dev->ifindex; + + dst =ip6_route_output (dev_net (bond->dev),NULL , &fl6); +if (dst->error) { +dst_release (dst); +/* there's no route to target - try to send arp +* probe to generate any traffic (arp_validate=0) +*/ +if (bond->params.arp_validate) +pr_warn_once ("%s: no route to ns_ip6_target %pI6c and arp_validate is set\n" , + bond->dev->name, + &targets[i]); +bond_ns_send (slave, &targets[i], &in6addr_any, tags); +continue ; + } + +/* bond device itself */ +if (dst->dev == bond->dev) + goto found; + +rcu_read_lock (); + tags =bond_verify_device_path (bond->dev, dst->dev,0 ); +rcu_read_unlock (); + +if (!IS_ERR_OR_NULL (tags)) + goto found; + +/* Not our device - skip */ +slave_dbg (bond->dev, slave->dev,"no path to ns_ip6_target %pI6c via dst->dev %s\n" , + &targets[i], dst->dev ? dst->dev->name :"NULL" ); + +dst_release (dst); +continue ; + +found: +if (!ipv6_dev_get_saddr (dev_net (dst->dev), dst->dev, &targets[i],0 , &saddr)) +bond_ns_send (slave, &targets[i], &saddr, tags); +dst_release (dst); +kfree (tags); + } +} + +static int bond_confirm_addr6 (struct net_device *dev, +struct netdev_nested_priv *priv) +{ +struct in6_addr *addr = (struct in6_addr *)priv->data; + +return ipv6_chk_addr (dev_net (dev), addr, dev,0 ); +} + +static bool bond_has_this_ip6 (struct bonding *bond,struct in6_addr *addr) +{ +struct netdev_nested_priv priv = { + .data = addr, + }; +int ret = false; + +if (bond_confirm_addr6 (bond->dev, &priv)) +return true; + +rcu_read_lock (); +if (netdev_walk_all_upper_dev_rcu (bond->dev, bond_confirm_addr6, &priv)) + ret = true; +rcu_read_unlock (); + +return ret; +} + +static void bond_validate_ns (struct bonding *bond,struct slave *slave, +struct in6_addr *saddr,struct in6_addr *daddr) +{ +int i; + +if (ipv6_addr_any (saddr) || !bond_has_this_ip6 (bond, daddr)) { +slave_dbg (bond->dev, slave->dev,"%s: sip %pI6c tip %pI6c not found\n" , + __func__, saddr, daddr); +return ; + } + + i =bond_get_targets_ip6 (bond->params.ns_targets, saddr); +if (i ==-1 ) { +slave_dbg (bond->dev, slave->dev,"%s: sip %pI6c not found in targets\n" , + __func__, saddr); +return ; + } + slave->last_rx = jiffies; + slave->target_last_arp_rx[i] = jiffies; +} + +static int bond_na_rcv (const struct sk_buff *skb,struct bonding *bond, +struct slave *slave) +{ +struct slave *curr_active_slave, *curr_arp_slave; +struct icmp6hdr *hdr =icmp6_hdr (skb); +struct in6_addr *saddr, *daddr; + +if (skb->pkt_type ==PACKET_OTHERHOST || + skb->pkt_type ==PACKET_LOOPBACK || + hdr->icmp6_type !=NDISC_NEIGHBOUR_ADVERTISEMENT ) + goto out; + + saddr = &ipv6_hdr (skb)->saddr; + daddr = &ipv6_hdr (skb)->daddr; + +slave_dbg (bond->dev, slave->dev,"%s: %s/%d av %d sv %d sip %pI6c tip %pI6c\n" , + __func__, slave->dev->name,bond_slave_state (slave), + bond->params.arp_validate,slave_do_arp_validate (bond, slave), + saddr, daddr); + + curr_active_slave =rcu_dereference (bond->curr_active_slave); + curr_arp_slave =rcu_dereference (bond->current_arp_slave); + +/* We 'trust' the received ARP enough to validate it if: +* see bond_arp_rcv(). +*/ +if (bond_is_active_slave (slave)) +bond_validate_ns (bond, slave, saddr, daddr); +else if (curr_active_slave && +time_after (slave_last_rx (bond, curr_active_slave), + curr_active_slave->last_link_up)) +bond_validate_ns (bond, slave, saddr, daddr); +else if (curr_arp_slave && +bond_time_in_interval (bond, +dev_trans_start (curr_arp_slave->dev),1 )) +bond_validate_ns (bond, slave, saddr, daddr); + +out: +return RX_HANDLER_ANOTHER ; +} +#endif + +int bond_rcv_validate (const struct sk_buff *skb,struct bonding *bond, +struct slave *slave) +{ +#if IS_ENABLED (CONFIG_IPV6 ) +bool is_ipv6 = skb->protocol ==__cpu_to_be16 (ETH_P_IPV6 ); +#endif +bool is_arp = skb->protocol ==__cpu_to_be16 (ETH_P_ARP ); + +slave_dbg (bond->dev, slave->dev,"%s: skb->dev %s\n" , + __func__, skb->dev->name); + +/* Use arp validate logic for both ARP and NS */ +if (!slave_do_arp_validate (bond, slave)) { +if ((slave_do_arp_validate_only (bond) && is_arp) || +#if IS_ENABLED(CONFIG_IPV6) + (slave_do_arp_validate_only (bond) && is_ipv6) || +#endif + !slave_do_arp_validate_only (bond)) + slave->last_rx = jiffies; +return RX_HANDLER_ANOTHER ; + }else if (is_arp) { +return bond_arp_rcv (skb, bond, slave); +#if IS_ENABLED (CONFIG_IPV6 ) + } else if (is_ipv6) { +return bond_na_rcv (skb, bond, slave); +#endif + }else { +return RX_HANDLER_ANOTHER ; + } +} + +static void bond_send_validate (struct bonding *bond,struct slave *slave) +{ +bond_arp_send_all (bond, slave); +#if IS_ENABLED (CONFIG_IPV6 ) +bond_ns_send_all (bond, slave); +#endif +} +/* function to verify if we're in the arp_interval timeslice, returns true if * (last_act - arp_interval) <= jiffies <= (last_act + mod * arp_interval + * arp_interval/2) . the arp_interval/2 is needed for really fast networks.
@@ -3164,7 +3362,7 @@ static void bond_loadbalance_arp_mon(struct bonding *bond)* to be unstable during low/no traffic periods */ if (bond_slave_is_up (slave)) -bond_arp_send_all (bond, slave); +bond_send_validate (bond, slave); }rcu_read_unlock ();
@@ -3378,7 +3576,7 @@ static bool bond_ab_arp_probe(struct bonding *bond) curr_active_slave->dev->name);if (curr_active_slave) { -bond_arp_send_all (bond, curr_active_slave); +bond_send_validate (bond, curr_active_slave);return should_notify_rtnl; }
@@ -3430,7 +3628,7 @@ static bool bond_ab_arp_probe(struct bonding *bond)bond_set_slave_link_state (new_slave,BOND_LINK_BACK ,BOND_SLAVE_NOTIFY_LATER );bond_set_slave_active_flags (new_slave,BOND_SLAVE_NOTIFY_LATER ); -bond_arp_send_all (bond, new_slave); +bond_send_validate (bond, new_slave); new_slave->last_link_up = jiffies;rcu_assign_pointer (bond->current_arp_slave, new_slave);
@@ -3966,7 +4164,7 @@ static int bond_open(struct net_device *bond_dev)if (bond->params.arp_interval) {/* arp interval, in milliseconds. */ queue_delayed_work (bond->wq, &bond->arp_work,0 ); - bond->recv_probe = bond_arp_rcv; + bond->recv_probe = bond_rcv_validate; }if (BOND_MODE (bond) ==BOND_MODE_8023AD ) {
@@ -5947,6 +6145,7 @@ static int bond_check_params(struct bond_params *params)strscpy_pad (params->primary, primary,sizeof (params->primary));memcpy (params->arp_targets, arp_target,sizeof (arp_target)); +memset (params->ns_targets,0 ,sizeof (struct in6_addr ) *BOND_MAX_NS_TARGETS );return 0 ; }
drivers/net/bonding/bond_options.c +1 -1
@@ -1052,7 +1052,7 @@ static int bond_option_arp_interval_set(struct bonding *bond,cancel_delayed_work_sync (&bond->arp_work); }else {/* arp_validate can be set only in active-backup mode */ - bond->recv_probe = bond_arp_rcv; + bond->recv_probe = bond_rcv_validate;cancel_delayed_work_sync (&bond->mii_work);queue_delayed_work (bond->wq, &bond->arp_work,0 ); }
include/net/bonding.h +18 -1
@@ -29,8 +29,11 @@#include <net/bond_3ad.h> #include <net/bond_alb.h> #include <net/bond_options.h> +#include <net/ipv6.h> +#include <net/addrconf.h> #define BOND_MAX_ARP_TARGETS 16 +#define BOND_MAX_NS_TARGETS BOND_MAX_ARP_TARGETS#define BOND_DEFAULT_MIIMON 100
@@ -146,6 +149,7 @@ struct bond_params {struct reciprocal_value reciprocal_packets_per_slave;u16 ad_actor_sys_prio;u16 ad_user_port_key; +struct in6_addr ns_targets[BOND_MAX_NS_TARGETS ];/* 2 bytes of padding : see ether_addr_equal_64bits() */ u8 ad_actor_system[ETH_ALEN +2 ];
@@ -628,7 +632,7 @@ struct bond_net {struct class_attribute class_attr_bonding_masters; }; -int bond_arp_rcv (const struct sk_buff *skb,struct bonding *bond,struct slave *slave); +int bond_rcv_validate (const struct sk_buff *skb,struct bonding *bond,struct slave *slave);netdev_tx_t bond_dev_queue_xmit (struct bonding *bond,struct sk_buff *skb,struct net_device *slave_dev);int bond_create (struct net *net,const char *name);int bond_create_sysfs (struct bond_net *net);
@@ -735,6 +739,19 @@ static inline int bond_get_targets_ip(__be32 *targets, __be32 ip)return -1 ; } +static inline int bond_get_targets_ip6 (struct in6_addr *targets,struct in6_addr *ip) +{ +int i; + +for (i =0 ; i <BOND_MAX_NS_TARGETS ; i++) +if (ipv6_addr_equal (&targets[i], ip)) +return i; +else if (ipv6_addr_any (&targets[i])) +break ; + +return -1 ; +} +/* exported from bond_main.c */ extern unsigned int bond_net_id;
Signature · 1 line
2.31.1
PATCH v2 5/5 bonding: add new option ns_ip6_target
In reply to Hangbin LiuThis patch add a new bonding option ns_ip6_target, which correspond to the arp_ip_target. With this we set IPv6 targets and send IPv6 NS request to determine the health of the link.
For other related options like the validation, we still use arp_validate, and will change to ns_validate later.
Note: the sysfs configuration support was removed based on
https://lore.kernel.org/netdev/8863.1645071997@famine
---
v2: remove sysfs configuration
--- Documentation/networking/bonding.rst | 11 +++++ drivers/net/bonding/bond_netlink.c | 59 +++++++++++++++++++++++ drivers/net/bonding/bond_options.c | 72 ++++++++++++++++++++++++++++ include/net/bond_options.h | 4 ++ include/net/bonding.h | 7 +++ include/uapi/linux/if_link.h | 1 + tools/include/uapi/linux/if_link.h | 1 + 7 files changed, 155 insertions(+)
Documentation/networking/bonding.rst +11 -0
@@ -313,6 +313,17 @@ arp_ip_target maximum number of targets that can be specified is 16. The default value is no IP addresses. +ns_ip6_target + + Specifies the IPv6 addresses to use as IPv6 monitoring peers when + arp_interval is > 0. These are the targets of the NS request + sent to determine the health of the link to the targets. + Specify these values in ffff:ffff::ffff:ffff format. Multiple IPv6 + addresses must be separated by a comma. At least one IPv6 + address must be given for NS/NA monitoring to function. The + maximum number of targets that can be specified is 16. The + default value is no IPv6 addresses. + arp_validate Specifies whether or not ARP probes and replies should be
drivers/net/bonding/bond_netlink.c +59 -0
89 lines not on this page · raw message
drivers/net/bonding/bond_options.c +72 -0
90 lines not on this page · raw message
include/net/bond_options.h +4 -0
@@ -66,6 +66,7 @@ enum {BOND_OPT_PEER_NOTIF_DELAY ,BOND_OPT_LACP_ACTIVE ,BOND_OPT_MISSED_MAX , +BOND_OPT_NS_TARGETS , BOND_OPT_LAST };
@@ -140,5 +141,8 @@ static inline void __bond_opt_init(struct bond_opt_value *optval, __bond_opt_init(optval, NULL, ULLONG_MAX, extra, extra_len)void bond_option_arp_ip_targets_clear (struct bonding *bond); +#if IS_ENABLED (CONFIG_IPV6 ) +void bond_option_ns_ip6_targets_clear (struct bonding *bond); +#endif #endif /* _NET_BOND_OPTIONS_H */
include/net/bonding.h +7 -0
@@ -503,6 +503,13 @@ static inline int bond_is_ip_target_ok(__be32 addr)return !ipv4_is_lbcast (addr) && !ipv4_is_zeronet (addr); } +static inline int bond_is_ip6_target_ok (struct in6_addr *addr) +{ +return !ipv6_addr_any (addr) && + !ipv6_addr_loopback (addr) && + !ipv6_addr_is_multicast (addr); +} +/* Get the oldest arp which we've received on this slave for bond's * arp_targets. */
include/uapi/linux/if_link.h +1 -0
@@ -860,6 +860,7 @@ enum {IFLA_BOND_PEER_NOTIF_DELAY ,IFLA_BOND_AD_LACP_ACTIVE ,IFLA_BOND_MISSED_MAX , +IFLA_BOND_NS_IP6_TARGET , __IFLA_BOND_MAX, };
tools/include/uapi/linux/if_link.h +1 -0
@@ -860,6 +860,7 @@ enum {IFLA_BOND_PEER_NOTIF_DELAY ,IFLA_BOND_AD_LACP_ACTIVE ,IFLA_BOND_MISSED_MAX , +IFLA_BOND_NS_IP6_TARGET , __IFLA_BOND_MAX, };
Signature · 1 line
2.31.1
PATCH v2 1/1 bond: add ns_ip6_target option
In reply to Hangbin LiuSimilar with arp_ip_target, this option add bond IPv6 NS/NA monitor support. When IPv6 target was set, the ARP target will be disabled.
---
v2: define BOND_MAX_NS_TARGETS
--- ip/iplink_bond.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-)
ip/iplink_bond.c +52 -1
@@ -21,6 +21,7 @@#include "json_print.h" #define BOND_MAX_ARP_TARGETS 16 +#define BOND_MAX_NS_TARGETS BOND_MAX_ARP_TARGETSstatic unsigned int xstats_print_attr;static int filter_index;
@@ -136,6 +137,7 @@ static void print_explain(FILE *f)" [ arp_validate ARP_VALIDATE ]\n" " [ arp_all_targets ARP_ALL_TARGETS ]\n" " [ arp_ip_target [ ARP_IP_TARGET, ... ] ]\n" +" [ ns_ip6_target [ NS_IP6_TARGET, ... ] ]\n" " [ primary SLAVE_DEV ]\n" " [ primary_reselect PRIMARY_RESELECT ]\n" " [ fail_over_mac FAIL_OVER_MAC ]\n"
@@ -248,6 +250,25 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,addattr_nest_end (n, nest); }addattr_nest_end (n, nest); + }else if (matches (*argv,"ns_ip6_target" ) ==0 ) { +struct rtattr *nest =addattr_nest (n,1024 , +IFLA_BOND_NS_IP6_TARGET ); +if (NEXT_ARG_OK ()) { +NEXT_ARG (); +char *targets =strdupa (*argv); +char *target =strtok (targets,"," ); +int i; + +for (i =0 ; target && i <BOND_MAX_NS_TARGETS ; i++) { +inet_prefix ip6_addr; + +get_addr (&ip6_addr, target,AF_INET6 ); +addattr_l (n,1024 , i, ip6_addr.data,sizeof (struct in6_addr )); + target =strtok (NULL ,"," ); + } +addattr_nest_end (n, nest); + } +addattr_nest_end (n, nest); }else if (matches (*argv,"arp_validate" ) ==0 ) {NEXT_ARG ();if (get_index (arp_validate_tbl, *argv) <0 )
@@ -404,6 +425,8 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,static void bond_print_opt (struct link_util *lu,FILE *f,struct rtattr *tb[]) { +int i; +if (!tb)return ;
@@ -469,7 +492,6 @@ static void bond_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])if (tb[IFLA_BOND_ARP_IP_TARGET ]) {struct rtattr *iptb[BOND_MAX_ARP_TARGETS +1 ]; -int i;parse_rtattr_nested (iptb,BOND_MAX_ARP_TARGETS , tb[IFLA_BOND_ARP_IP_TARGET ]);
@@ -497,6 +519,35 @@ static void bond_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) } } +if (tb[IFLA_BOND_NS_IP6_TARGET ]) { +struct rtattr *ip6tb[BOND_MAX_NS_TARGETS +1 ]; + +parse_rtattr_nested (ip6tb,BOND_MAX_NS_TARGETS , + tb[IFLA_BOND_NS_IP6_TARGET ]); + +if (ip6tb[0 ]) { +open_json_array (PRINT_JSON ,"ns_ip6_target" ); +print_string (PRINT_FP ,NULL ,"ns_ip6_target " ,NULL ); + } + +for (i =0 ; i <BOND_MAX_NS_TARGETS ; i++) { +if (ip6tb[i]) +print_string (PRINT_ANY , +NULL , +"%s" , +rt_addr_n2a_rta (AF_INET6 , ip6tb[i])); +if (!is_json_context () + && i <BOND_MAX_NS_TARGETS -1 + && ip6tb[i+1 ]) +fprintf (f,"," ); + } + +if (ip6tb[0 ]) { +print_string (PRINT_FP ,NULL ," " ,NULL ); +close_json_array (PRINT_JSON ,NULL ); + } + } +if (tb[IFLA_BOND_ARP_VALIDATE ]) {__u32 arp_v =rta_getattr_u32 (tb[IFLA_BOND_ARP_VALIDATE ]);const char *arp_validate =get_name (arp_validate_tbl, arp_v);
Signature · 1 line
2.31.1
David Ahern
maintainerRe: [PATCHv2 iproute2-next] bond: add ns_ip6_target option
ip/iplink_bond.c static int bond_parse_opt(struct link_util *lu, int argc, char **argv, · line 253
Quoted 12 lines · Hangbin Liu
Similar with
arp_ip_target, this option add bond IPv6 NS/NA monitor support. When IPv6 target was set, the ARP target will be disabled.Signed-off-by Hangbin Liu <[email protected]>---
v2: defineBOND_MAX_NS_TARGETS--- ip/iplink_bond.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-)ip/iplink_bond.c +1
-0+ }else if (matches (*argv,"ns_ip6_target" ) ==0 ) {
changed matches to strcmp and applied.
we are not accepting any more uses of matches.
Re: [PATCHv2 iproute2-next] bond: add ns_ip6_target option
Quoted 12 lines · David Ahern
Quoted 10 lines · Hangbin Liu
Similar with
arp_ip_target, this option add bond IPv6 NS/NA monitor support. When IPv6 target was set, the ARP target will be disabled.Signed-off-by Hangbin Liu <[email protected]>---
v2: defineBOND_MAX_NS_TARGETS--- ip/iplink_bond.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-)
Quoted 5 lines
ip/iplink_bond.c static int bond_parse_opt(struct link_util *lu, int argc, char **argv, · line 253
Quoted 1 line
ip/iplink_bond.c +1
-0+ }else if (matches (*argv,"ns_ip6_target" ) ==0 ) {changed matches to strcmp and applied.
we are not accepting any more uses of matches.
Oh, my bad. I forgot to change match to strcmp when copy/paste the arp_ip_target code...
Hangbin
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 8 lines · On Mon, 21 Feb 2022 13:54:52 +0800 you wrote:
This patch add bond IPv6 NS/NA monitor support. A new option
ns_ip6_targetis added, which is similar witharp_ip_target. The IPv6 NS/NA monitor will take effect when there is a valid IPv6 address. Both ARP monitor and NS monitor will working at the same time.A new extra storage field is added to struct
bond_opt_valuefor IPv6 support.[...]
Here is the summary with links:
- [PATCHv2,net-next,1/5] ipv6: separate ndisc_ns_create() from ndisc_send_ns()
https://git.kernel.org/netdev/net-next/c/696c65444120 - [PATCHv2,net-next,2/5] Bonding: split bond_handle_vlan from bond_arp_send https://git.kernel.org/netdev/net-next/c/1fcd5d448c59 - [PATCHv2,net-next,3/5] bonding: add extra field for bond_opt_value https://git.kernel.org/netdev/net-next/c/841e95641e4c - [PATCHv2,net-next,4/5] bonding: add new parameter ns_targets https://git.kernel.org/netdev/net-next/c/4e24be018eb9 - [PATCHv2,net-next,5/5] bonding: add new option ns_ip6_target https://git.kernel.org/netdev/net-next/c/129e3c1bab24
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html