Add support for unicast compose_nd_ns that allows the caller to specify if the packet should be created as multicast or unicast to specified address.
Signed-off-by: Ales Musil <[email protected]> --- v2: Reabse on top of latest main. Address Ilya's comments. Note: This is planned to be used by OVN for MAC binding refresh, as that it would be nice if this could be backported. --- lib/packets.c | 12 ++++++++---- lib/packets.h | 4 +++- ofproto/ofproto-dpif-xlate.c | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/packets.c b/lib/packets.c index 998a73afe..493bc3024 100644 --- a/lib/packets.c +++ b/lib/packets.c @@ -1868,17 +1868,21 @@ compose_ipv6(struct dp_packet *packet, uint8_t proto, /* Compose an IPv6 Neighbor Discovery Neighbor Solicitation message. */ void -compose_nd_ns(struct dp_packet *b, const struct eth_addr eth_src, +compose_nd_ns(struct dp_packet *b, bool multicast, + const struct eth_addr eth_src, struct eth_addr eth_dst, const struct in6_addr *ipv6_src, const struct in6_addr *ipv6_dst) { struct in6_addr sn_addr; - struct eth_addr eth_dst; struct ovs_nd_msg *ns; struct ovs_nd_lla_opt *lla_opt; uint32_t icmp_csum; - in6_addr_solicited_node(&sn_addr, ipv6_dst); - ipv6_multicast_to_ethernet(ð_dst, &sn_addr); + if (multicast) { + in6_addr_solicited_node(&sn_addr, ipv6_dst); + ipv6_multicast_to_ethernet(ð_dst, &sn_addr); + } else { + sn_addr = *ipv6_dst; + } eth_compose(b, eth_dst, eth_src, ETH_TYPE_IPV6, IPV6_HEADER_LEN); ns = compose_ipv6(b, IPPROTO_ICMPV6, ipv6_src, &sn_addr, diff --git a/lib/packets.h b/lib/packets.h index 4d680412a..96e98f5fd 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -1673,7 +1673,9 @@ void compose_arp(struct dp_packet *, uint16_t arp_op, const struct eth_addr arp_sha, const struct eth_addr arp_tha, bool broadcast, ovs_be32 arp_spa, ovs_be32 arp_tpa); -void compose_nd_ns(struct dp_packet *, const struct eth_addr eth_src, +void compose_nd_ns(struct dp_packet *, bool multicast, + const struct eth_addr eth_src, + struct eth_addr eth_dst, const struct in6_addr *ipv6_src, const struct in6_addr *ipv6_dst); void compose_nd_na(struct dp_packet *, const struct eth_addr eth_src, diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index c1ba447e9..b9991464a 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -3761,7 +3761,7 @@ tnl_send_nd_request(struct xlate_ctx *ctx, const struct xport *out_dev, struct dp_packet packet; dp_packet_init(&packet, 0); - compose_nd_ns(&packet, eth_src, ipv6_src, ipv6_dst); + compose_nd_ns(&packet, true, eth_src, eth_addr_zero, ipv6_src, ipv6_dst); compose_table_xlate(ctx, out_dev, &packet); dp_packet_uninit(&packet); } -- 2.54.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
