lkml.org 
[lkml]   [2022]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 1/3] net:ipv6:Add ndisc_bond_send_na to support sending na by slave directly
From
On 3/10/22 7:49 PM, Sun Shouxin wrote:
> diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
> index fcb288b0ae13..c59a110e9b10 100644
> --- a/net/ipv6/ndisc.c
> +++ b/net/ipv6/ndisc.c
> @@ -572,6 +572,67 @@ void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,
> ndisc_send_skb(skb, daddr, src_addr);
> }
>
> +void ndisc_bond_send_na(struct net_device *dev, const struct in6_addr *daddr,

This ipv6 code, not bond code


> + const struct in6_addr *solicited_addr,
> + bool router, bool solicited, bool override,
> + bool inc_opt, unsigned short vlan_id,
> + const void *mac_dst, const void *mac_src)
> +{
> + struct sk_buff *skb;
> + const struct in6_addr *src_addr;
> + struct nd_msg *msg;
> + struct net *net = dev_net(dev);
> + struct sock *sk = net->ipv6.ndisc_sk;
> + int optlen = 0;
> + int ret;
> +
> + src_addr = solicited_addr;
> + if (!dev->addr_len)
> + inc_opt = false;
> + if (inc_opt)
> + optlen += ndisc_opt_addr_space(dev,
> + NDISC_NEIGHBOUR_ADVERTISEMENT);
> +
> + skb = ndisc_alloc_skb(dev, sizeof(*msg) + optlen);
> + if (!skb)
> + return;
> +
> + msg = skb_put(skb, sizeof(*msg));
> + *msg = (struct nd_msg) {
> + .icmph = {
> + .icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT,
> + .icmp6_router = router,
> + .icmp6_solicited = solicited,
> + .icmp6_override = override,
> + },
> + .target = *solicited_addr,
> + };
> +
> + if (inc_opt)
> + ndisc_fill_addr_option(skb, ND_OPT_TARGET_LL_ADDR,
> + dev->dev_addr,
> + NDISC_NEIGHBOUR_ADVERTISEMENT);
> +
> + if (vlan_id)
> + __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
> + vlan_id);
> +
> + msg->icmph.icmp6_cksum = csum_ipv6_magic(src_addr, daddr, skb->len,
> + IPPROTO_ICMPV6,
> + csum_partial(&msg->icmph,
> + skb->len, 0));
> +
> + ip6_nd_hdr(skb, src_addr, daddr, inet6_sk(sk)->hop_limit, skb->len);
> +
> + skb->protocol = htons(ETH_P_IPV6);
> + skb->dev = dev;
> + if (dev_hard_header(skb, dev, ETH_P_IPV6, mac_dst, mac_src, skb->len) < 0)
> + return;
> +
> + ret = dev_queue_xmit(skb);
> +}
> +EXPORT_SYMBOL(ndisc_bond_send_na);

It would be better to refactor ndisc_send_na and extract what you think
you need into a new helper that gets exported for bond.

\
 
 \ /
  Last update: 2022-03-11 18:00    [W:0.089 / U:0.472 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site